зеркало из https://github.com/mozilla/gecko-dev.git
Bug 859764 - Part 4: Implementation Change in Different Backend. r=echen
This commit is contained in:
Родитель
23a373fd02
Коммит
2e3d3848e7
|
@ -10,8 +10,8 @@
|
|||
#include "mozilla/dom/mobilemessage/SmsParent.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsTypes.h"
|
||||
#include "mozilla/dom/mobilemessage/Types.h"
|
||||
#include "mozilla/dom/MobileMessageThread.h"
|
||||
#include "mozilla/dom/SmsMessage.h"
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "nsIObserverService.h"
|
||||
|
@ -51,7 +51,7 @@ SmsManager::NotifySmsReceived(jni::String::Param aSender,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> domMessage = new SmsMessage(message);
|
||||
nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
|
||||
obs->NotifyObservers(domMessage, kSmsReceivedObserverTopic, nullptr);
|
||||
});
|
||||
NS_DispatchToMainThread(runnable);
|
||||
|
@ -92,7 +92,7 @@ SmsManager::NotifySmsSent(int32_t aId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> domMessage = new SmsMessage(message);
|
||||
nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
|
||||
obs->NotifyObservers(domMessage, kSmsSentObserverTopic, nullptr);
|
||||
|
||||
nsCOMPtr<nsIMobileMessageCallback> request =
|
||||
|
@ -137,7 +137,7 @@ SmsManager::NotifySmsDelivery(int32_t aId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> domMessage = new SmsMessage(message);
|
||||
nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
|
||||
const char* topic = (message.deliveryStatus() == eDeliveryStatus_Success)
|
||||
? kSmsDeliverySuccessObserverTopic
|
||||
: kSmsDeliveryErrorObserverTopic;
|
||||
|
@ -201,7 +201,7 @@ SmsManager::NotifyGetSms(int32_t aId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> domMessage = new SmsMessage(message);
|
||||
nsCOMPtr<nsISmsMessage> domMessage = new SmsMessageInternal(message);
|
||||
request->NotifyMessageGot(domMessage);
|
||||
});
|
||||
NS_DispatchToMainThread(runnable);
|
||||
|
@ -313,10 +313,10 @@ SmsManager::NotifyThreadCursorResult(int64_t aId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMArray<nsIDOMMozMobileMessageThread> arr;
|
||||
arr.AppendElement(new MobileMessageThread(thread));
|
||||
nsCOMArray<nsIMobileMessageThread> arr;
|
||||
arr.AppendElement(new MobileMessageThreadInternal(thread));
|
||||
|
||||
nsIDOMMozMobileMessageThread** elements;
|
||||
nsIMobileMessageThread** elements;
|
||||
int32_t size;
|
||||
size = arr.Forget(&elements);
|
||||
|
||||
|
@ -365,10 +365,10 @@ SmsManager::NotifyMessageCursorResult(int32_t aMessageId,
|
|||
return;
|
||||
}
|
||||
|
||||
nsCOMArray<nsIDOMMozSmsMessage> arr;
|
||||
arr.AppendElement(new SmsMessage(message));
|
||||
nsCOMArray<nsISmsMessage> arr;
|
||||
arr.AppendElement(new SmsMessageInternal(message));
|
||||
|
||||
nsIDOMMozSmsMessage** elements;
|
||||
nsISmsMessage** elements;
|
||||
int32_t size;
|
||||
size = arr.Forget(&elements);
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SmsMessage.h"
|
||||
#include "SmsService.h"
|
||||
#include "AndroidBridge.h"
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.importGlobalProperties(['Blob']);
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/PhoneNumberUtils.jsm");
|
||||
|
@ -1294,7 +1295,7 @@ SendTransaction.prototype = Object.create(CancellableTransaction.prototype, {
|
|||
|
||||
let numPartsToLoad = parts.length;
|
||||
parts.forEach((aPart) => {
|
||||
if (!(aPart.content instanceof Ci.nsIDOMBlob)) {
|
||||
if (!(aPart.content instanceof Blob)) {
|
||||
numPartsToLoad--;
|
||||
if (!numPartsToLoad) {
|
||||
callbackIfValid();
|
||||
|
@ -1683,7 +1684,7 @@ MmsService.prototype = {
|
|||
* A callback function that takes two arguments: one for X-Mms-Status,
|
||||
* the other parsed MMS message.
|
||||
* @param aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
retrieveMessage: function(aMmsConnection, aContentLocation, aCallback,
|
||||
aDomMessage) {
|
||||
|
@ -1703,7 +1704,7 @@ MmsService.prototype = {
|
|||
* @param aName
|
||||
* The system message name.
|
||||
* @param aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
broadcastMmsSystemMessage: function(aName, aDomMessage) {
|
||||
if (DEBUG) debug("Broadcasting the MMS system message: " + aName);
|
||||
|
@ -1742,7 +1743,7 @@ MmsService.prototype = {
|
|||
* an MMS is sent.
|
||||
*
|
||||
* @params aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
broadcastSentMessageEvent: function(aDomMessage) {
|
||||
// Broadcasting a 'sms-sent' system message to open apps.
|
||||
|
@ -1757,7 +1758,7 @@ MmsService.prototype = {
|
|||
* an MMS is failed to send.
|
||||
*
|
||||
* @params aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
broadcastSentFailureMessageEvent: function(aDomMessage) {
|
||||
// Broadcasting a 'sms-sent' system message to open apps.
|
||||
|
@ -1772,7 +1773,7 @@ MmsService.prototype = {
|
|||
* an MMS is received.
|
||||
*
|
||||
* @params aDomMessage
|
||||
* The nsIDOMMozMmsMessage object.
|
||||
* The nsIMmsMessage object.
|
||||
*/
|
||||
broadcastReceivedMessageEvent: function(aDomMessage) {
|
||||
// Broadcasting a 'sms-received' system message to open apps.
|
||||
|
@ -1822,8 +1823,13 @@ MmsService.prototype = {
|
|||
null,
|
||||
DELIVERY_STATUS_ERROR,
|
||||
null,
|
||||
(rv, domMessage) =>
|
||||
this.broadcastReceivedMessageEvent(domMessage));
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
this.broadcastReceivedMessageEvent(mmsMessage);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1831,8 +1837,13 @@ MmsService.prototype = {
|
|||
retrievedMessage,
|
||||
savableMessage);
|
||||
gMobileMessageDatabaseService.saveReceivedMessage(savableMessage,
|
||||
(rv, domMessage) => {
|
||||
let success = Components.isSuccessCode(rv);
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
let success = Components.isSuccessCode(aRv);
|
||||
|
||||
// Cite 6.2.1 "Transaction Flow" in OMA-TS-MMS_ENC-V1_3-20110913-A:
|
||||
// The M-NotifyResp.ind response PDU SHALL provide a message retrieval
|
||||
|
@ -1851,11 +1862,11 @@ MmsService.prototype = {
|
|||
// At this point we could send a message to content to notify the user
|
||||
// that storing an incoming MMS failed, most likely due to a full disk.
|
||||
// The end user has to retrieve the MMS again.
|
||||
if (DEBUG) debug("Could not store MMS , error code " + rv);
|
||||
if (DEBUG) debug("Could not store MMS , error code " + aRv);
|
||||
return;
|
||||
}
|
||||
|
||||
this.broadcastReceivedMessageEvent(domMessage);
|
||||
this.broadcastReceivedMessageEvent(mmsMessage);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -1968,12 +1979,17 @@ MmsService.prototype = {
|
|||
|
||||
gMobileMessageDatabaseService
|
||||
.saveReceivedMessage(savableMessage,
|
||||
(aRv, aDomMessage) =>
|
||||
this.saveReceivedMessageCallback(mmsConnection,
|
||||
retrievalMode,
|
||||
savableMessage,
|
||||
aRv,
|
||||
aDomMessage));
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
this.saveReceivedMessageCallback(mmsConnection,
|
||||
retrievalMode,
|
||||
savableMessage,
|
||||
aRv,
|
||||
mmsMessage);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -2024,24 +2040,30 @@ MmsService.prototype = {
|
|||
.setMessageDeliveryStatusByEnvelopeId(envelopeId, address, deliveryStatus,
|
||||
(aRv, aDomMessage) => {
|
||||
if (DEBUG) debug("Marking the delivery status is done.");
|
||||
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
|
||||
let topic;
|
||||
if (mmsStatus === MMS.MMS_PDU_STATUS_RETRIEVED) {
|
||||
topic = kSmsDeliverySuccessObserverTopic;
|
||||
// Broadcasting a 'sms-delivery-success' system message to open apps.
|
||||
this.broadcastMmsSystemMessage(topic, aDomMessage);
|
||||
this.broadcastMmsSystemMessage(topic, mmsMessage);
|
||||
} else if (mmsStatus === MMS.MMS_PDU_STATUS_REJECTED) {
|
||||
topic = kSmsDeliveryErrorObserverTopic;
|
||||
// Broadcasting a 'sms-delivery-error' system message to open apps.
|
||||
this.broadcastMmsSystemMessage(topic, aDomMessage);
|
||||
this.broadcastMmsSystemMessage(topic, mmsMessage);
|
||||
} else {
|
||||
if (DEBUG) debug("Needn't fire event for this MMS status. Returning.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Notifying observers the delivery status is updated.
|
||||
Services.obs.notifyObservers(aDomMessage, topic, null);
|
||||
Services.obs.notifyObservers(mmsMessage, topic, null);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -2073,6 +2095,11 @@ MmsService.prototype = {
|
|||
gMobileMessageDatabaseService
|
||||
.setMessageReadStatusByEnvelopeId(envelopeId, address, readStatus,
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Failed to update read status: " + aRv);
|
||||
return;
|
||||
|
@ -2084,13 +2111,13 @@ MmsService.prototype = {
|
|||
topic = kSmsReadSuccessObserverTopic;
|
||||
|
||||
// Broadcasting a 'sms-read-success' system message to open apps.
|
||||
this.broadcastMmsSystemMessage(topic, aDomMessage);
|
||||
this.broadcastMmsSystemMessage(topic, mmsMessage);
|
||||
} else {
|
||||
topic = kSmsReadErrorObserverTopic;
|
||||
}
|
||||
|
||||
// Notifying observers the read status is updated.
|
||||
Services.obs.notifyObservers(aDomMessage, topic, null);
|
||||
Services.obs.notifyObservers(mmsMessage, topic, null);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -2305,21 +2332,27 @@ MmsService.prototype = {
|
|||
aEnvelopeId,
|
||||
(aRv, aDomMessage) => {
|
||||
if (DEBUG) debug("Marking the delivery state/staus is done. Notify sent or failed.");
|
||||
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
if (!isSentSuccess) {
|
||||
if (DEBUG) debug("Sending MMS failed.");
|
||||
aRequest.notifySendMessageFailed(aErrorCode, aDomMessage);
|
||||
this.broadcastSentFailureMessageEvent(aDomMessage);
|
||||
aRequest.notifySendMessageFailed(aErrorCode, mmsMessage);
|
||||
this.broadcastSentFailureMessageEvent(mmsMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) debug("Sending MMS succeeded.");
|
||||
|
||||
// Notifying observers the MMS message is sent.
|
||||
this.broadcastSentMessageEvent(aDomMessage);
|
||||
this.broadcastSentMessageEvent(mmsMessage);
|
||||
|
||||
// Return the request after sending the MMS message successfully.
|
||||
aRequest.notifyMessageSent(aDomMessage);
|
||||
aRequest.notifyMessageSent(mmsMessage);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -2331,29 +2364,34 @@ MmsService.prototype = {
|
|||
gMobileMessageDatabaseService
|
||||
.saveSendingMessage(savableMessage,
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Error! Fail to save sending message! rv = " + aRv);
|
||||
aRequest.notifySendMessageFailed(
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(aRv),
|
||||
aDomMessage);
|
||||
this.broadcastSentFailureMessageEvent(aDomMessage);
|
||||
mmsMessage);
|
||||
this.broadcastSentFailureMessageEvent(mmsMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DEBUG) debug("Saving sending message is done. Start to send.");
|
||||
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsSendingObserverTopic, null);
|
||||
Services.obs.notifyObservers(mmsMessage, kSmsSendingObserverTopic, null);
|
||||
|
||||
if (errorCode !== Ci.nsIMobileMessageCallback.SUCCESS_NO_ERROR) {
|
||||
if (DEBUG) debug("Error! The params for sending MMS are invalid.");
|
||||
sendTransactionCb(aDomMessage, errorCode, null);
|
||||
sendTransactionCb(mmsMessage, errorCode, null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Check radio state in prior to default service Id.
|
||||
if (getRadioDisabledState()) {
|
||||
if (DEBUG) debug("Error! Radio is disabled when sending MMS.");
|
||||
sendTransactionCb(aDomMessage,
|
||||
sendTransactionCb(mmsMessage,
|
||||
Ci.nsIMobileMessageCallback.RADIO_DISABLED_ERROR,
|
||||
null);
|
||||
return;
|
||||
|
@ -2364,7 +2402,7 @@ MmsService.prototype = {
|
|||
// SIM. Users have to manually swith the default SIM before sending.
|
||||
if (mmsConnection.serviceId != this.mmsDefaultServiceId) {
|
||||
if (DEBUG) debug("RIL service is not active to send MMS.");
|
||||
sendTransactionCb(aDomMessage,
|
||||
sendTransactionCb(mmsMessage,
|
||||
Ci.nsIMobileMessageCallback.NON_ACTIVE_SIM_CARD_ERROR,
|
||||
null);
|
||||
return;
|
||||
|
@ -2374,11 +2412,11 @@ MmsService.prototype = {
|
|||
let sendTransaction;
|
||||
try {
|
||||
sendTransaction =
|
||||
new SendTransaction(mmsConnection, aDomMessage.id, savableMessage,
|
||||
new SendTransaction(mmsConnection, mmsMessage.id, savableMessage,
|
||||
savableMessage["deliveryStatusRequested"]);
|
||||
} catch (e) {
|
||||
if (DEBUG) debug("Exception: fail to create a SendTransaction instance.");
|
||||
sendTransactionCb(aDomMessage,
|
||||
sendTransactionCb(mmsMessage,
|
||||
Ci.nsIMobileMessageCallback.INTERNAL_ERROR, null);
|
||||
return;
|
||||
}
|
||||
|
@ -2400,7 +2438,7 @@ MmsService.prototype = {
|
|||
}
|
||||
let envelopeId =
|
||||
aMsg && aMsg.headers && aMsg.headers["message-id"] || null;
|
||||
sendTransactionCb(aDomMessage, errorCode, envelopeId);
|
||||
sendTransactionCb(mmsMessage, errorCode, envelopeId);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
@ -2409,6 +2447,11 @@ MmsService.prototype = {
|
|||
if (DEBUG) debug("Retrieving message with ID " + aMessageId);
|
||||
gMobileMessageDatabaseService
|
||||
.getMessageRecordById(aMessageId, (aRv, aMessageRecord, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Function getMessageRecordById() return error: " + aRv);
|
||||
aRequest.notifyGetMessageFailed(
|
||||
|
@ -2546,23 +2589,28 @@ MmsService.prototype = {
|
|||
aMessageRecord);
|
||||
|
||||
gMobileMessageDatabaseService.saveReceivedMessage(aMessageRecord,
|
||||
(rv, domMessage) => {
|
||||
let success = Components.isSuccessCode(rv);
|
||||
(aRv, aDomMessage) => {
|
||||
let mmsMessage = null;
|
||||
try {
|
||||
mmsMessage = aDomMessage.QueryInterface(Ci.nsIMmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
let success = Components.isSuccessCode(aRv);
|
||||
if (!success) {
|
||||
// At this point we could send a message to content to
|
||||
// notify the user that storing an incoming MMS failed, most
|
||||
// likely due to a full disk.
|
||||
if (DEBUG) debug("Could not store MMS, error code " + rv);
|
||||
if (DEBUG) debug("Could not store MMS, error code " + aRv);
|
||||
aRequest.notifyGetMessageFailed(
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(rv));
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(aRv));
|
||||
return;
|
||||
}
|
||||
|
||||
// Notifying observers a new MMS message is retrieved.
|
||||
this.broadcastReceivedMessageEvent(domMessage);
|
||||
this.broadcastReceivedMessageEvent(mmsMessage);
|
||||
|
||||
// Return the request after retrieving the MMS message successfully.
|
||||
aRequest.notifyMessageGot(domMessage);
|
||||
aRequest.notifyMessageGot(mmsMessage);
|
||||
|
||||
// Cite 6.3.1 "Transaction Flow" in OMA-TS-MMS_ENC-V1_3-20110913-A:
|
||||
// If an acknowledgement is requested, the MMS Client SHALL respond
|
||||
|
@ -2596,7 +2644,7 @@ MmsService.prototype = {
|
|||
url,
|
||||
(aMmsStatus, aRetrievedMsg) =>
|
||||
responseNotify(aMmsStatus, aRetrievedMsg),
|
||||
aDomMessage);
|
||||
mmsMessage);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
|
|
@ -2065,13 +2065,13 @@ MobileMessageDB.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Generate a <code>nsIDOMMozSmsMessage</code> or
|
||||
* <code>nsIDOMMozMmsMessage</code> instance from a stored message record.
|
||||
* Generate a <code>nsISmsMessage</code> or
|
||||
* <code>nsIMmsMessage</code> instance from a stored message record.
|
||||
*
|
||||
* @function MobileMessageDB.createDomMessageFromRecord
|
||||
* @param {MobileMessageDB.MessageRecord} aMessageRecord
|
||||
* The stored message record.
|
||||
* @return {nsIDOMMozSmsMessage|nsIDOMMozMmsMessage}
|
||||
* @return {nsISmsMessage|nsIMmsMessage}
|
||||
*/
|
||||
createDomMessageFromRecord: function(aMessageRecord) {
|
||||
if (DEBUG) {
|
||||
|
@ -2580,7 +2580,7 @@ MobileMessageDB.prototype = {
|
|||
* @callback MobileMessageDB.TransactionResultCallback
|
||||
* @param {number} aErrorCode
|
||||
* The error code on failure, or <code>NS_OK</code> on success.
|
||||
* @param {nsIDOMMozSmsMessage|nsIDOMMozMmsMessage} aDomMessage
|
||||
* @param {nsISmsMessage|nsIMmsMessage} aDomMessage
|
||||
* The DOM message instance of the transaction result.
|
||||
*/
|
||||
|
||||
|
@ -3592,7 +3592,7 @@ MobileMessageDB.prototype = {
|
|||
* The error code on failure, or <code>NS_OK</code> on success.
|
||||
* @param {MobileMessageDB.MessageRecord} aMessageRecord
|
||||
* The stored message record.
|
||||
* @param {nsIDOMMozSmsMessage|nsIDOMMozMmsMessage} aDomMessage
|
||||
* @param {nsISmsMessage|nsIMmsMessage} aDomMessage
|
||||
* The DOM message instance of the message record.
|
||||
*/
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ SmsService.prototype = {
|
|||
|
||||
_notifySendingError: function(aErrorCode, aSendingMessage, aSilent, aRequest) {
|
||||
if (aSilent || aErrorCode === Ci.nsIMobileMessageCallback.NOT_FOUND_ERROR) {
|
||||
// There is no way to modify nsIDOMMozSmsMessage attributes as they
|
||||
// There is no way to modify nsISmsMessage attributes as they
|
||||
// are read only so we just create a new sms instance to send along
|
||||
// with the notification.
|
||||
aRequest.notifySendMessageFailed(aErrorCode,
|
||||
|
@ -322,11 +322,15 @@ SmsService.prototype = {
|
|||
RIL.GECKO_SMS_DELIVERY_STATUS_ERROR,
|
||||
null,
|
||||
(aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
this._broadcastSmsSystemMessage(
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT_FAILED, aDomMessage);
|
||||
aRequest.notifySendMessageFailed(aErrorCode, aDomMessage);
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsFailedObserverTopic, null);
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT_FAILED, smsMessage);
|
||||
aRequest.notifySendMessageFailed(aErrorCode, smsMessage);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsFailedObserverTopic, null);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -396,7 +400,7 @@ SmsService.prototype = {
|
|||
// Message was sent to SMSC.
|
||||
if (!aResponse.deliveryStatus) {
|
||||
if (aSilent) {
|
||||
// There is no way to modify nsIDOMMozSmsMessage attributes as they
|
||||
// There is no way to modify nsISmsMessage attributes as they
|
||||
// are read only so we just create a new sms instance to send along
|
||||
// with the notification.
|
||||
aRequest.notifyMessageSent(
|
||||
|
@ -424,17 +428,21 @@ SmsService.prototype = {
|
|||
sentMessage.deliveryStatus,
|
||||
null,
|
||||
(aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
|
||||
if (requestStatusReport) {
|
||||
// Update the sentMessage and wait for the status report.
|
||||
sentMessage = aDomMessage;
|
||||
sentMessage = smsMessage;
|
||||
}
|
||||
|
||||
this._broadcastSmsSystemMessage(
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT, aDomMessage);
|
||||
aRequest.notifyMessageSent(aDomMessage);
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsSentObserverTopic, null);
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT, smsMessage);
|
||||
aRequest.notifyMessageSent(smsMessage);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsSentObserverTopic, null);
|
||||
});
|
||||
|
||||
// Keep this callback if we have status report waiting.
|
||||
|
@ -450,6 +458,10 @@ SmsService.prototype = {
|
|||
aResponse.deliveryStatus,
|
||||
null,
|
||||
(aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
// TODO bug 832140 handle !Components.isSuccessCode(aRv)
|
||||
|
||||
let [topic, notificationType] =
|
||||
|
@ -461,10 +473,10 @@ SmsService.prototype = {
|
|||
|
||||
// Broadcasting a "sms-delivery-success/sms-delivery-error" system
|
||||
// message to open apps.
|
||||
this._broadcastSmsSystemMessage(notificationType, aDomMessage);
|
||||
this._broadcastSmsSystemMessage(notificationType, smsMessage);
|
||||
|
||||
// Notifying observers the delivery status is updated.
|
||||
Services.obs.notifyObservers(aDomMessage, topic, null);
|
||||
Services.obs.notifyObservers(smsMessage, topic, null);
|
||||
});
|
||||
|
||||
// Send transaction has ended completely.
|
||||
|
@ -479,7 +491,7 @@ SmsService.prototype = {
|
|||
* @param aNotificationType
|
||||
* Ci.nsISmsMessenger.NOTIFICATION_TYPE_*.
|
||||
* @param aDomMessage
|
||||
* The nsIDOMMozSmsMessage object.
|
||||
* The nsISmsMessage object.
|
||||
*/
|
||||
_broadcastSmsSystemMessage: function(aNotificationType, aDomMessage) {
|
||||
if (DEBUG) debug("Broadcasting the SMS system message: " + aNotificationType);
|
||||
|
@ -799,6 +811,10 @@ SmsService.prototype = {
|
|||
}
|
||||
|
||||
let notifyReceived = (aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
let success = Components.isSuccessCode(aRv);
|
||||
|
||||
this._sendAckSms(aRv, aMessage, aServiceId);
|
||||
|
@ -813,8 +829,8 @@ SmsService.prototype = {
|
|||
}
|
||||
|
||||
this._broadcastSmsSystemMessage(
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_RECEIVED, aDomMessage);
|
||||
Services.obs.notifyObservers(aDomMessage, kSmsReceivedObserverTopic, null);
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_RECEIVED, smsMessage);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsReceivedObserverTopic, null);
|
||||
};
|
||||
|
||||
if (aMessage.messageClass != RIL.GECKO_SMS_MESSAGE_CLASSES[RIL.PDU_DCS_MSG_CLASS_0]) {
|
||||
|
@ -960,20 +976,25 @@ SmsService.prototype = {
|
|||
iccId: this._getIccId(aServiceId)
|
||||
};
|
||||
|
||||
let saveSendingMessageCallback = (aRv, aSendingMessage) => {
|
||||
let saveSendingMessageCallback = (aRv, aDomMessage) => {
|
||||
let smsMessage = null;
|
||||
try {
|
||||
smsMessage = aDomMessage.QueryInterface(Ci.nsISmsMessage);
|
||||
} catch (e) {}
|
||||
|
||||
if (!Components.isSuccessCode(aRv)) {
|
||||
if (DEBUG) debug("Error! Fail to save sending message! aRv = " + aRv);
|
||||
this._broadcastSmsSystemMessage(
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT_FAILED, aSendingMessage);
|
||||
Ci.nsISmsMessenger.NOTIFICATION_TYPE_SENT_FAILED, smsMessage);
|
||||
aRequest.notifySendMessageFailed(
|
||||
gMobileMessageDatabaseService.translateCrErrorToMessageCallbackError(aRv),
|
||||
aSendingMessage);
|
||||
Services.obs.notifyObservers(aSendingMessage, kSmsFailedObserverTopic, null);
|
||||
smsMessage);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsFailedObserverTopic, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aSilent) {
|
||||
Services.obs.notifyObservers(aSendingMessage, kSmsSendingObserverTopic, null);
|
||||
Services.obs.notifyObservers(smsMessage, kSmsSendingObserverTopic, null);
|
||||
}
|
||||
|
||||
let connection =
|
||||
|
@ -994,11 +1015,11 @@ SmsService.prototype = {
|
|||
errorCode = Ci.nsIMobileMessageCallback.NO_SIM_CARD_ERROR;
|
||||
}
|
||||
if (errorCode) {
|
||||
this._notifySendingError(errorCode, aSendingMessage, aSilent, aRequest);
|
||||
this._notifySendingError(errorCode, smsMessage, aSilent, aRequest);
|
||||
return;
|
||||
}
|
||||
|
||||
this._scheduleSending(aServiceId, aSendingMessage, aSilent, options,
|
||||
this._scheduleSending(aServiceId, smsMessage, aSilent, options,
|
||||
aRequest);
|
||||
}; // End of |saveSendingMessageCallback|.
|
||||
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SmsChild.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "MmsMessage.h"
|
||||
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "DeletedMessageInfo.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
#include "mozilla/dom/mobilemessage/Constants.h" // For MessageType
|
||||
#include "MobileMessageThread.h"
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "MainThreadUtils.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -28,10 +29,10 @@ CreateMessageFromMessageData(const MobileMessageData& aData)
|
|||
|
||||
switch(aData.type()) {
|
||||
case MobileMessageData::TMmsMessageData:
|
||||
message = new MmsMessage(aData.get_MmsMessageData());
|
||||
message = new MmsMessageInternal(aData.get_MmsMessageData());
|
||||
break;
|
||||
case MobileMessageData::TSmsMessageData:
|
||||
message = new SmsMessage(aData.get_SmsMessageData());
|
||||
message = new SmsMessageInternal(aData.get_SmsMessageData());
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH("Unexpected type of MobileMessageData");
|
||||
|
@ -376,7 +377,8 @@ MobileMessageCursorChild::DoNotifyResult(const nsTArray<ThreadData>& aDataArray)
|
|||
NS_ENSURE_TRUE_VOID(threads.SetCapacity(length, fallible));
|
||||
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
nsCOMPtr<nsISupports> thread = new MobileMessageThread(aDataArray[i]);
|
||||
nsCOMPtr<nsISupports> thread =
|
||||
new MobileMessageThreadInternal(aDataArray[i]);
|
||||
NS_ENSURE_TRUE_VOID(threads.AppendElement(thread, fallible));
|
||||
NS_ENSURE_TRUE_VOID(autoArray.AppendElement(thread.get(), fallible));
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "SmsIPCService.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsChild.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "mozilla/dom/MozMobileMessageManagerBinding.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
|
|
|
@ -5,17 +5,18 @@
|
|||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "SmsParent.h"
|
||||
|
||||
#include "nsISmsService.h"
|
||||
#include "nsIMmsService.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "mozilla/Services.h"
|
||||
#include "nsIDOMMozSmsMessage.h"
|
||||
#include "nsIDOMMozMmsMessage.h"
|
||||
#include "nsISmsMessage.h"
|
||||
#include "nsIMmsMessage.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "SmsMessage.h"
|
||||
#include "MmsMessage.h"
|
||||
#include "SmsMessageInternal.h"
|
||||
#include "MmsMessageInternal.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "MobileMessageThread.h"
|
||||
#include "MobileMessageThreadInternal.h"
|
||||
#include "mozilla/dom/ipc/BlobParent.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/File.h"
|
||||
|
@ -144,23 +145,23 @@ GetMobileMessageDataFromMessage(ContentParent* aParent,
|
|||
return false;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> mmsMsg = do_QueryInterface(aMsg);
|
||||
nsCOMPtr<nsIMmsMessage> mmsMsg = do_QueryInterface(aMsg);
|
||||
if (mmsMsg) {
|
||||
if (!aParent) {
|
||||
NS_ERROR("Invalid ContentParent to convert MMS Message!");
|
||||
return false;
|
||||
}
|
||||
MmsMessageData data;
|
||||
if (!static_cast<MmsMessage*>(mmsMsg.get())->GetData(aParent, data)) {
|
||||
if (!static_cast<MmsMessageInternal*>(mmsMsg.get())->GetData(aParent, data)) {
|
||||
return false;
|
||||
}
|
||||
aData = data;
|
||||
return true;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aMsg);
|
||||
nsCOMPtr<nsISmsMessage> smsMsg = do_QueryInterface(aMsg);
|
||||
if (smsMsg) {
|
||||
aData = static_cast<SmsMessage*>(smsMsg.get())->GetData();
|
||||
aData = static_cast<SmsMessageInternal*>(smsMsg.get())->GetData();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
}
|
||||
|
||||
if (!strcmp(aTopic, kSilentSmsReceivedObserverTopic)) {
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> smsMsg = do_QueryInterface(aSubject);
|
||||
nsCOMPtr<nsISmsMessage> smsMsg = do_QueryInterface(aSubject);
|
||||
if (!smsMsg) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -308,7 +309,7 @@ SmsParent::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
}
|
||||
|
||||
MobileMessageData msgData =
|
||||
static_cast<SmsMessage*>(smsMsg.get())->GetData();
|
||||
static_cast<SmsMessageInternal*>(smsMsg.get())->GetData();
|
||||
Unused << SendNotifyReceivedSilentMessage(msgData);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -906,18 +907,18 @@ MobileMessageCursorParent::NotifyCursorResult(nsISupports** aResults,
|
|||
// error here to avoid sending a message to the dead process.
|
||||
NS_ENSURE_TRUE(mContinueCallback, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsIDOMMozMobileMessageThread> iThread =
|
||||
nsCOMPtr<nsIMobileMessageThread> iThread =
|
||||
do_QueryInterface(aResults[0]);
|
||||
if (iThread) {
|
||||
nsTArray<ThreadData> threads;
|
||||
|
||||
for (uint32_t i = 0; i < aSize; i++) {
|
||||
nsCOMPtr<nsIDOMMozMobileMessageThread> iThread =
|
||||
nsCOMPtr<nsIMobileMessageThread> iThread =
|
||||
do_QueryInterface(aResults[i]);
|
||||
NS_ENSURE_TRUE(iThread, NS_ERROR_FAILURE);
|
||||
|
||||
MobileMessageThread* thread =
|
||||
static_cast<MobileMessageThread*>(iThread.get());
|
||||
MobileMessageThreadInternal* thread =
|
||||
static_cast<MobileMessageThreadInternal*>(iThread.get());
|
||||
threads.AppendElement(thread->GetData());
|
||||
}
|
||||
|
||||
|
@ -928,18 +929,20 @@ MobileMessageCursorParent::NotifyCursorResult(nsISupports** aResults,
|
|||
ContentParent* parent = static_cast<ContentParent*>(Manager()->Manager());
|
||||
nsTArray<MobileMessageData> messages;
|
||||
for (uint32_t i = 0; i < aSize; i++) {
|
||||
nsCOMPtr<nsIDOMMozSmsMessage> iSms = do_QueryInterface(aResults[i]);
|
||||
if (iSms) {
|
||||
SmsMessage* sms = static_cast<SmsMessage*>(iSms.get());
|
||||
messages.AppendElement(sms->GetData());
|
||||
nsCOMPtr<nsISmsMessage> sms = do_QueryInterface(aResults[i]);
|
||||
if (sms) {
|
||||
messages.AppendElement(
|
||||
static_cast<SmsMessageInternal*>(sms.get())->GetData());
|
||||
continue;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMMozMmsMessage> iMms = do_QueryInterface(aResults[i]);
|
||||
if (iMms) {
|
||||
MmsMessage* mms = static_cast<MmsMessage*>(iMms.get());
|
||||
nsCOMPtr<nsIMmsMessage> mms = do_QueryInterface(aResults[i]);
|
||||
if (mms) {
|
||||
MmsMessageData mmsData;
|
||||
NS_ENSURE_TRUE(mms->GetData(parent, mmsData), NS_ERROR_FAILURE);
|
||||
NS_ENSURE_TRUE(
|
||||
static_cast<MmsMessageInternal*>(mms.get())->GetData(parent, mmsData),
|
||||
NS_ERROR_FAILURE
|
||||
);
|
||||
messages.AppendElement(mmsData);
|
||||
continue;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче