mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Bug 844431 - B2G MMS: provide nsIDOMMobileMessageManager interface (with sendMMS() first) (part 4-2, nsIMmsService.send()). r=vicamo a=leo+
This commit is contained in:
parent
ba17b276e6
commit
b6c241f1ba
@ -3,9 +3,12 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
interface nsIMobileMessageCallback;
|
||||
interface nsIDOMBlob;
|
||||
|
||||
[scriptable, uuid(217ddd76-75db-4210-955d-8806cd8d87f9)]
|
||||
[scriptable, uuid(3ec33286-8559-11e2-9f38-e76b58650568)]
|
||||
interface nsIMmsService : nsISupports
|
||||
{
|
||||
boolean hasSupport();
|
||||
void send(in jsval parameters /* MmsParameters */,
|
||||
in nsIMobileMessageCallback request);
|
||||
};
|
||||
|
@ -66,6 +66,10 @@ XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageDatabaseService",
|
||||
"@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1",
|
||||
"nsIRilMobileMessageDatabaseService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageService",
|
||||
"@mozilla.org/mobilemessage/mobilemessageservice;1",
|
||||
"nsIMobileMessageService");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "MMS", function () {
|
||||
let MMS = {};
|
||||
Cu.import("resource://gre/modules/MmsPduHelper.jsm", MMS);
|
||||
@ -1099,10 +1103,160 @@ MmsService.prototype = {
|
||||
debug("handleDeliveryIndication: got delivery report for " + messageId);
|
||||
},
|
||||
|
||||
createSavableFromParams: function createSavableFromParams(aParams) {
|
||||
debug("createSavableFromParams: aParams: " + JSON.stringify(aParams));
|
||||
let message = {};
|
||||
|
||||
// |message.headers|
|
||||
let headers = message["headers"] = {};
|
||||
let receivers = aParams.receivers;
|
||||
if (receivers.length != 0) {
|
||||
let headersTo = headers["to"] = [];
|
||||
for (let i = 0; i < receivers.length; i++) {
|
||||
headersTo.push({"address": receivers[i], "type": "PLMN"});
|
||||
}
|
||||
}
|
||||
if (aParams.subject) {
|
||||
headers["subject"] = aParams.subject;
|
||||
}
|
||||
|
||||
// |message.parts|
|
||||
let attachments = aParams.attachments;
|
||||
if (attachments.length != 0 || aParams.smil) {
|
||||
let parts = message["parts"] = [];
|
||||
|
||||
// Set the SMIL part if needed.
|
||||
if (aParams.smil) {
|
||||
let part = {
|
||||
"headers": {
|
||||
"content-type": {
|
||||
"media": "application/smil",
|
||||
},
|
||||
},
|
||||
"content": aParams.smil
|
||||
};
|
||||
parts.push(part);
|
||||
}
|
||||
|
||||
// Set other parts for attachments if needed.
|
||||
for (let i = 0; i < attachments.length; i++) {
|
||||
let attachment = attachments[i];
|
||||
let content = attachment.content;
|
||||
let part = {
|
||||
"headers": {
|
||||
"content-type": {
|
||||
"media": content.type
|
||||
},
|
||||
"content-length": content.size,
|
||||
"content-location": attachment.location,
|
||||
"content-id": attachment.id
|
||||
},
|
||||
"content": content
|
||||
};
|
||||
parts.push(part);
|
||||
}
|
||||
}
|
||||
|
||||
// The following attributes are needed for saving message into DB.
|
||||
message["type"] = "mms";
|
||||
message["deliveryStatusRequested"] = true;
|
||||
message["timestamp"] = Date.now();
|
||||
message["receivers"] = receivers;
|
||||
|
||||
debug("createSavableFromParams: message: " + JSON.stringify(message));
|
||||
return message;
|
||||
},
|
||||
|
||||
createMmsMessageFromRecord: function createMmsMessageFromRecord(aRecord) {
|
||||
debug("createMmsMessageFromRecord: aRecord: " + JSON.stringify(aRecord));
|
||||
|
||||
let headers = aRecord["headers"];
|
||||
let subject = headers["subject"];
|
||||
if (subject == undefined) {
|
||||
subject = "";
|
||||
}
|
||||
let smil = "";
|
||||
let attachments = [];
|
||||
let parts = aRecord.parts;
|
||||
if (parts) {
|
||||
for (let i = 0; i < parts.length; i++) {
|
||||
let part = parts[i];
|
||||
let partHeaders = part["headers"];
|
||||
let partContent = part["content"];
|
||||
// Don't need to make the SMIL part if it's present.
|
||||
if (partHeaders["content-type"]["media"] == "application/smil") {
|
||||
smil = part.content;
|
||||
continue;
|
||||
}
|
||||
attachments.push({
|
||||
"id": partHeaders["content-id"],
|
||||
"location": partHeaders["content-location"],
|
||||
"content": partContent
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
debug("createMmsMessageFromRecord: attachments: " + JSON.stringify(attachments));
|
||||
return gMobileMessageService.createMmsMessage(aRecord.id,
|
||||
aRecord.delivery,
|
||||
aRecord.deliveryStatus,
|
||||
aRecord.sender,
|
||||
aRecord.receivers,
|
||||
aRecord.timestamp,
|
||||
aRecord.read,
|
||||
subject,
|
||||
smil,
|
||||
attachments);
|
||||
},
|
||||
|
||||
// nsIMmsService
|
||||
|
||||
hasSupport: function hasSupport() {
|
||||
return true;
|
||||
send: function send(aParams, aRequest) {
|
||||
debug("send: aParams: " + JSON.stringify(aParams));
|
||||
if (aParams.receivers.length == 0) {
|
||||
aRequest.notifySendMmsMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
let self = this;
|
||||
|
||||
let sendTransactionCb = function sendTransactionCb(aIsSentSuccess, aMmsMessage) {
|
||||
debug("sendTransactionCb: aIsSentSuccess: " + aIsSentSuccess);
|
||||
gMobileMessageDatabaseService
|
||||
.setMessageDelivery(aMmsMessage.id,
|
||||
null,
|
||||
aIsSentSuccess ? "sent" : "error",
|
||||
aIsSentSuccess ? null : "error",
|
||||
function notifySetDeliveryResult(setDeliveryRv, record) {
|
||||
debug("Marking the delivery state/staus is done. Notify sent or failed.");
|
||||
if (!aIsSentSuccess) {
|
||||
aRequest.notifySendMessageFailed(Ci.nsIMobileMessageCallback.INTERNAL_ERROR);
|
||||
return;
|
||||
}
|
||||
aRequest.notifyMessageSent(aMmsMessage);
|
||||
});
|
||||
};
|
||||
|
||||
let savableMessage = this.createSavableFromParams(aParams);
|
||||
gMobileMessageDatabaseService
|
||||
.saveSendingMessage(savableMessage,
|
||||
function notifySendingResult(sendingRv, sendingRecord) {
|
||||
debug("Saving sending message is done. Start to send.");
|
||||
let mmsMessage = self.createMmsMessageFromRecord(sendingRecord);
|
||||
let sendTransaction;
|
||||
try {
|
||||
sendTransaction = new SendTransaction(sendingRecord);
|
||||
} catch (e) {
|
||||
debug("Fail to create a SendTransaction instance.");
|
||||
sendTransactionCb(false, mmsMessage);
|
||||
return;
|
||||
}
|
||||
sendTransaction.run(function callback(aMmsStatus, aMsg) {
|
||||
let isSentSuccess = (aMmsStatus == MMS.MMS_PDU_ERROR_OK);
|
||||
debug("The returned status of sendTransaction.run(): " + aMmsStatus);
|
||||
sendTransactionCb(isSentSuccess, mmsMessage);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
// nsIWapPushApplication
|
||||
|
@ -17,6 +17,7 @@ XPIDL_SOURCES += [
|
||||
'nsIDOMSmsSegmentInfo.idl',
|
||||
'nsIMobileMessageCallback.idl',
|
||||
'nsIMobileMessageDatabaseService.idl',
|
||||
'nsIMobileMessageService.idl',
|
||||
'nsISmsService.idl',
|
||||
]
|
||||
|
||||
|
@ -9,6 +9,14 @@ interface nsIDOMMozSmsRequest;
|
||||
interface nsIDOMMozSmsFilter;
|
||||
interface nsIDOMMozSmsSegmentInfo;
|
||||
|
||||
dictionary MmsParameters
|
||||
{
|
||||
jsval receivers; // DOMString[]
|
||||
DOMString? subject;
|
||||
DOMString? smil;
|
||||
jsval attachments; // MmsAttachment[]
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(228508d0-7fe4-11e2-a028-83810f98f20b)]
|
||||
interface nsIDOMMozMobileMessageManager : nsIDOMEventTarget
|
||||
{
|
||||
|
45
dom/mobilemessage/interfaces/nsIMobileMessageService.idl
Normal file
45
dom/mobilemessage/interfaces/nsIMobileMessageService.idl
Normal file
@ -0,0 +1,45 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 "nsISupports.idl"
|
||||
|
||||
interface nsIDOMMozSmsMessage;
|
||||
interface nsIDOMMozMmsMessage;
|
||||
interface nsIDOMMozSmsSegmentInfo;
|
||||
|
||||
%{C++
|
||||
#define MOBILE_MESSAGE_SERVICE_CID { 0x829c1dd6, 0x0466, 0x4591, { 0x83, 0x6f, 0xb8, 0xf6, 0xfd, 0x1f, 0x7b, 0xa5 } }
|
||||
#define MOBILE_MESSAGE_SERVICE_CONTRACTID "@mozilla.org/mobilemessage/mobilemessageservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(4cbc9594-84c3-11e2-a274-ebada93fa6cd)]
|
||||
interface nsIMobileMessageService : nsISupports
|
||||
{
|
||||
[implicit_jscontext]
|
||||
nsIDOMMozSmsMessage createSmsMessage(in long id,
|
||||
in DOMString delivery,
|
||||
in DOMString deliveryStatus,
|
||||
in DOMString sender,
|
||||
in DOMString receiver,
|
||||
in DOMString body,
|
||||
in DOMString messageClass,
|
||||
in jsval timestamp,
|
||||
in bool read);
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIDOMMozMmsMessage createMmsMessage(in long id,
|
||||
in DOMString state,
|
||||
in jsval deliveryStatus,
|
||||
in DOMString sender,
|
||||
in jsval receivers,
|
||||
in jsval timestamp,
|
||||
in boolean read,
|
||||
in DOMString subject,
|
||||
in DOMString smil,
|
||||
in jsval attachments);
|
||||
|
||||
nsIDOMMozSmsSegmentInfo createSmsSegmentInfo(in long segments,
|
||||
in long charsPerSegment,
|
||||
in long charsAvailableInLastSegment);
|
||||
};
|
@ -13,7 +13,7 @@ interface nsIMobileMessageCallback;
|
||||
#define SMS_SERVICE_CONTRACTID "@mozilla.org/sms/smsservice;1"
|
||||
%}
|
||||
|
||||
[scriptable, builtinclass, uuid(5d066568-86d2-11e2-a0d0-7351fb5ae50a)]
|
||||
[scriptable, builtinclass, uuid(c4b2ed2a-8714-11e2-bd2b-13f1a0759342)]
|
||||
interface nsISmsService : nsISupports
|
||||
{
|
||||
boolean hasSupport();
|
||||
@ -23,19 +23,4 @@ interface nsISmsService : nsISupports
|
||||
void send(in DOMString number,
|
||||
in DOMString message,
|
||||
in nsIMobileMessageCallback request);
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIDOMMozSmsMessage createSmsMessage(in long id,
|
||||
in DOMString delivery,
|
||||
in DOMString deliveryStatus,
|
||||
in DOMString sender,
|
||||
in DOMString receiver,
|
||||
in DOMString body,
|
||||
in DOMString messageClass,
|
||||
in jsval timestamp,
|
||||
in bool read);
|
||||
|
||||
nsIDOMMozSmsSegmentInfo createSmsSegmentInfo(in long segments,
|
||||
in long charsPerSegment,
|
||||
in long charsAvailableInLastSegment);
|
||||
};
|
||||
|
@ -47,6 +47,7 @@ EXPORTS_mozilla/dom = \
|
||||
EXPORTS_mozilla/dom/mobilemessage = \
|
||||
SmsChild.h \
|
||||
SmsParent.h \
|
||||
MobileMessageService.h \
|
||||
SmsServicesFactory.h \
|
||||
Constants.h \
|
||||
Types.h \
|
||||
@ -57,6 +58,7 @@ CPPSRCS = \
|
||||
SmsManager.cpp \
|
||||
MobileMessageManager.cpp \
|
||||
SmsService.cpp \
|
||||
MobileMessageService.cpp \
|
||||
SmsIPCService.cpp \
|
||||
SmsServicesFactory.cpp \
|
||||
SmsParent.cpp \
|
||||
|
99
dom/mobilemessage/src/MobileMessageService.cpp
Normal file
99
dom/mobilemessage/src/MobileMessageService.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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 "MmsMessage.h"
|
||||
#include "MobileMessageService.h"
|
||||
#include "SmsSegmentInfo.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
NS_IMPL_ISUPPORTS1(MobileMessageService, nsIMobileMessageService)
|
||||
|
||||
/* static */ StaticRefPtr<MobileMessageService> MobileMessageService::sSingleton;
|
||||
|
||||
/* static */ already_AddRefed<MobileMessageService>
|
||||
MobileMessageService::GetInstance()
|
||||
{
|
||||
if (!sSingleton) {
|
||||
sSingleton = new MobileMessageService();
|
||||
ClearOnShutdown(&sSingleton);
|
||||
}
|
||||
|
||||
nsRefPtr<MobileMessageService> service = sSingleton.get();
|
||||
return service.forget();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageService::CreateSmsMessage(int32_t aId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const jsval& aTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
{
|
||||
return SmsMessage::Create(aId,
|
||||
aDelivery,
|
||||
aDeliveryStatus,
|
||||
aSender,
|
||||
aReceiver,
|
||||
aBody,
|
||||
aMessageClass,
|
||||
aTimestamp,
|
||||
aRead,
|
||||
aCx,
|
||||
aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageService::CreateMmsMessage(int32_t aId,
|
||||
const nsAString& aState,
|
||||
const JS::Value& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const JS::Value& aReceivers,
|
||||
const JS::Value& aTimestamp,
|
||||
bool aRead,
|
||||
const nsAString& aSubject,
|
||||
const nsAString& aSmil,
|
||||
const JS::Value& aAttachments,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozMmsMessage** aMessage)
|
||||
{
|
||||
return MmsMessage::Create(aId,
|
||||
aState,
|
||||
aDeliveryStatus,
|
||||
aSender,
|
||||
aReceivers,
|
||||
aTimestamp,
|
||||
aRead,
|
||||
aSubject,
|
||||
aSmil,
|
||||
aAttachments,
|
||||
aCx,
|
||||
aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
MobileMessageService::CreateSmsSegmentInfo(int32_t aSegments,
|
||||
int32_t aCharsPerSegment,
|
||||
int32_t aCharsAvailableInLastSegment,
|
||||
nsIDOMMozSmsSegmentInfo** aSegmentInfo)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsSegmentInfo> info =
|
||||
new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment);
|
||||
info.forget(aSegmentInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
33
dom/mobilemessage/src/MobileMessageService.h
Normal file
33
dom/mobilemessage/src/MobileMessageService.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_mobilemessage_MobileMessageService_h
|
||||
#define mozilla_dom_mobilemessage_MobileMessageService_h
|
||||
|
||||
#include "nsIMobileMessageService.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
namespace mobilemessage {
|
||||
|
||||
class MobileMessageService MOZ_FINAL : public nsIMobileMessageService
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMOBILEMESSAGESERVICE
|
||||
|
||||
static already_AddRefed<MobileMessageService> GetInstance();
|
||||
|
||||
private:
|
||||
static StaticRefPtr<MobileMessageService> sSingleton;
|
||||
|
||||
};
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_mobilemessage_MobileMessageService_h
|
@ -51,37 +51,6 @@ SmsService::Send(const nsAString& aNumber, const nsAString& aMessage,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsService::CreateSmsMessage(int32_t aId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const jsval& aTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
{
|
||||
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
|
||||
aSender, aReceiver,
|
||||
aBody, aMessageClass, aTimestamp, aRead,
|
||||
aCx, aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsService::CreateSmsSegmentInfo(int32_t aSegments,
|
||||
int32_t aCharsPerSegment,
|
||||
int32_t aCharsAvailableInLastSegment,
|
||||
nsIDOMMozSmsSegmentInfo** aSegmentInfo)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsSegmentInfo> info =
|
||||
new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment);
|
||||
info.forget(aSegmentInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -38,37 +38,6 @@ SmsService::Send(const nsAString& aNumber,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsService::CreateSmsMessage(int32_t aId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const jsval& aTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
{
|
||||
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
|
||||
aSender, aReceiver,
|
||||
aBody, aMessageClass, aTimestamp, aRead,
|
||||
aCx, aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsService::CreateSmsSegmentInfo(int32_t aSegments,
|
||||
int32_t aCharsPerSegment,
|
||||
int32_t aCharsAvailableInLastSegment,
|
||||
nsIDOMMozSmsSegmentInfo** aSegmentInfo)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsSegmentInfo> info =
|
||||
new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment);
|
||||
info.forget(aSegmentInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -79,37 +79,6 @@ SmsIPCService::Send(const nsAString& aNumber,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsIPCService::CreateSmsMessage(int32_t aId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const jsval& aTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
{
|
||||
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
|
||||
aSender, aReceiver,
|
||||
aBody, aMessageClass, aTimestamp, aRead,
|
||||
aCx, aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsIPCService::CreateSmsSegmentInfo(int32_t aSegments,
|
||||
int32_t aCharsPerSegment,
|
||||
int32_t aCharsAvailableInLastSegment,
|
||||
nsIDOMMozSmsSegmentInfo** aSegmentInfo)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsSegmentInfo> info =
|
||||
new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment);
|
||||
info.forget(aSegmentInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Implementation of nsIMobileMessageDatabaseService.
|
||||
*/
|
||||
|
@ -46,9 +46,9 @@ const READ_WRITE = "readwrite";
|
||||
const PREV = "prev";
|
||||
const NEXT = "next";
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
|
||||
"@mozilla.org/sms/smsservice;1",
|
||||
"nsISmsService");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageService",
|
||||
"@mozilla.org/mobilemessage/mobilemessageservice;1",
|
||||
"nsIMobileMessageService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gIDBManager",
|
||||
"@mozilla.org/dom/indexeddb/manager;1",
|
||||
@ -562,15 +562,15 @@ MobileMessageDatabaseService.prototype = {
|
||||
if (DEBUG) {
|
||||
debug("createSmsMessageFromRecord: " + JSON.stringify(aMessageRecord));
|
||||
}
|
||||
return gSmsService.createSmsMessage(aMessageRecord.id,
|
||||
aMessageRecord.delivery,
|
||||
aMessageRecord.deliveryStatus,
|
||||
aMessageRecord.sender,
|
||||
aMessageRecord.receiver,
|
||||
aMessageRecord.body,
|
||||
aMessageRecord.messageClass,
|
||||
aMessageRecord.timestamp,
|
||||
aMessageRecord.read);
|
||||
return gMobileMessageService.createSmsMessage(aMessageRecord.id,
|
||||
aMessageRecord.delivery,
|
||||
aMessageRecord.deliveryStatus,
|
||||
aMessageRecord.sender,
|
||||
aMessageRecord.receiver,
|
||||
aMessageRecord.body,
|
||||
aMessageRecord.messageClass,
|
||||
aMessageRecord.timestamp,
|
||||
aMessageRecord.read);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -48,37 +48,6 @@ SmsService::Send(const nsAString& aNumber,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsService::CreateSmsMessage(int32_t aId,
|
||||
const nsAString& aDelivery,
|
||||
const nsAString& aDeliveryStatus,
|
||||
const nsAString& aSender,
|
||||
const nsAString& aReceiver,
|
||||
const nsAString& aBody,
|
||||
const nsAString& aMessageClass,
|
||||
const jsval& aTimestamp,
|
||||
const bool aRead,
|
||||
JSContext* aCx,
|
||||
nsIDOMMozSmsMessage** aMessage)
|
||||
{
|
||||
return SmsMessage::Create(aId, aDelivery, aDeliveryStatus,
|
||||
aSender, aReceiver,
|
||||
aBody, aMessageClass, aTimestamp, aRead,
|
||||
aCx, aMessage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SmsService::CreateSmsSegmentInfo(int32_t aSegments,
|
||||
int32_t aCharsPerSegment,
|
||||
int32_t aCharsAvailableInLastSegment,
|
||||
nsIDOMMozSmsSegmentInfo** aSegmentInfo)
|
||||
{
|
||||
nsCOMPtr<nsIDOMMozSmsSegmentInfo> info =
|
||||
new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment);
|
||||
info.forget(aSegmentInfo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
} // namespace mobilemessage
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
@ -18,10 +18,10 @@ function do_check_throws(f, result, stack) {
|
||||
do_throw("expected result " + result + ", none thrown", stack);
|
||||
}
|
||||
|
||||
let gSmsService = Cc["@mozilla.org/sms/smsservice;1"]
|
||||
.getService(Ci.nsISmsService);
|
||||
let gMobileMessageService = Cc["@mozilla.org/mobilemessage/mobilemessageservice;1"]
|
||||
.getService(Ci.nsIMobileMessageService);
|
||||
function newMessage() {
|
||||
return gSmsService.createSmsMessage.apply(gSmsService, arguments);
|
||||
return gMobileMessageService.createSmsMessage.apply(gMobileMessageService, arguments);
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
|
@ -118,9 +118,9 @@ XPCOMUtils.defineLazyServiceGetter(this, "gPowerManagerService",
|
||||
"@mozilla.org/power/powermanagerservice;1",
|
||||
"nsIPowerManagerService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gSmsService",
|
||||
"@mozilla.org/sms/smsservice;1",
|
||||
"nsISmsService");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageService",
|
||||
"@mozilla.org/mobilemessage/mobilemessageservice;1",
|
||||
"nsIMobileMessageService");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "gMobileMessageDatabaseService",
|
||||
"@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1",
|
||||
@ -1486,15 +1486,15 @@ RadioInterfaceLayer.prototype = {
|
||||
},
|
||||
|
||||
createSmsMessageFromRecord: function createSmsMessageFromRecord(aRecord) {
|
||||
return gSmsService.createSmsMessage(aRecord.id,
|
||||
aRecord.delivery,
|
||||
aRecord.deliveryStatus,
|
||||
aRecord.sender,
|
||||
aRecord.receiver,
|
||||
aRecord.body,
|
||||
aRecord.messageClass,
|
||||
aRecord.timestamp,
|
||||
aRecord.read);
|
||||
return gMobileMessageService.createSmsMessage(aRecord.id,
|
||||
aRecord.delivery,
|
||||
aRecord.deliveryStatus,
|
||||
aRecord.sender,
|
||||
aRecord.receiver,
|
||||
aRecord.body,
|
||||
aRecord.messageClass,
|
||||
aRecord.timestamp,
|
||||
aRecord.read);
|
||||
},
|
||||
|
||||
portAddressedSmsApps: null,
|
||||
@ -2657,9 +2657,9 @@ RadioInterfaceLayer.prototype = {
|
||||
charsInLastSegment /= 2;
|
||||
}
|
||||
|
||||
let result = gSmsService.createSmsSegmentInfo(options.segmentMaxSeq,
|
||||
options.segmentChars,
|
||||
options.segmentChars - charsInLastSegment);
|
||||
let result = gMobileMessageService.createSmsSegmentInfo(options.segmentMaxSeq,
|
||||
options.segmentChars,
|
||||
options.segmentChars - charsInLastSegment);
|
||||
return result;
|
||||
},
|
||||
|
||||
|
@ -21,7 +21,8 @@ dictionaries = [
|
||||
[ 'CameraPictureOptions', 'nsIDOMCameraManager.idl' ],
|
||||
[ 'CameraRecordingOptions', 'nsIDOMCameraManager.idl' ],
|
||||
[ 'SmsThreadListItem', 'nsIMobileMessageCallback.idl' ],
|
||||
[ 'MmsAttachment', 'nsIDOMMozMmsMessage.idl' ]
|
||||
[ 'MmsAttachment', 'nsIDOMMozMmsMessage.idl' ],
|
||||
[ 'MmsParameters', 'nsIDOMMobileMessageManager.idl' ]
|
||||
]
|
||||
|
||||
# include file names
|
||||
|
@ -219,7 +219,9 @@ static void Shutdown();
|
||||
#include "nsDeviceSensors.h"
|
||||
#include "nsCSPService.h"
|
||||
#include "nsISmsService.h"
|
||||
#include "nsIMobileMessageService.h"
|
||||
#include "nsIMobileMessageDatabaseService.h"
|
||||
#include "mozilla/dom/mobilemessage/MobileMessageService.h"
|
||||
#include "mozilla/dom/mobilemessage/SmsServicesFactory.h"
|
||||
#include "nsIPowerManagerService.h"
|
||||
#include "nsIAlarmHalService.h"
|
||||
@ -302,8 +304,12 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsHapticFeedback)
|
||||
#endif
|
||||
#endif
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ThirdPartyUtil, Init)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISmsService, SmsServicesFactory::CreateSmsService)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileMessageDatabaseService, SmsServicesFactory::CreateMobileMessageDatabaseService)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISmsService,
|
||||
SmsServicesFactory::CreateSmsService)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileMessageService,
|
||||
MobileMessageService::GetInstance)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIMobileMessageDatabaseService,
|
||||
SmsServicesFactory::CreateMobileMessageDatabaseService)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIPowerManagerService,
|
||||
PowerManagerService::GetInstance)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIAlarmHalService,
|
||||
@ -822,6 +828,7 @@ NS_DEFINE_NAMED_CID(NS_HAPTICFEEDBACK_CID);
|
||||
#endif
|
||||
#endif
|
||||
NS_DEFINE_NAMED_CID(SMS_SERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_SERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(MOBILE_MESSAGE_DATABASE_SERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_POWERMANAGERSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(OSFILECONSTANTSSERVICE_CID);
|
||||
@ -1100,6 +1107,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
|
||||
{ &kTHIRDPARTYUTIL_CID, false, NULL, ThirdPartyUtilConstructor },
|
||||
{ &kNS_STRUCTUREDCLONECONTAINER_CID, false, NULL, nsStructuredCloneContainerConstructor },
|
||||
{ &kSMS_SERVICE_CID, false, NULL, nsISmsServiceConstructor },
|
||||
{ &kMOBILE_MESSAGE_SERVICE_CID, false, NULL, nsIMobileMessageServiceConstructor },
|
||||
{ &kMOBILE_MESSAGE_DATABASE_SERVICE_CID, false, NULL, nsIMobileMessageDatabaseServiceConstructor },
|
||||
{ &kNS_POWERMANAGERSERVICE_CID, false, NULL, nsIPowerManagerServiceConstructor },
|
||||
{ &kOSFILECONSTANTSSERVICE_CID, true, NULL, OSFileConstantsServiceConstructor },
|
||||
@ -1242,6 +1250,7 @@ static const mozilla::Module::ContractIDEntry kLayoutContracts[] = {
|
||||
{ THIRDPARTYUTIL_CONTRACTID, &kTHIRDPARTYUTIL_CID },
|
||||
{ NS_STRUCTUREDCLONECONTAINER_CONTRACTID, &kNS_STRUCTUREDCLONECONTAINER_CID },
|
||||
{ SMS_SERVICE_CONTRACTID, &kSMS_SERVICE_CID },
|
||||
{ MOBILE_MESSAGE_SERVICE_CONTRACTID, &kMOBILE_MESSAGE_SERVICE_CID },
|
||||
{ MOBILE_MESSAGE_DATABASE_SERVICE_CONTRACTID, &kMOBILE_MESSAGE_DATABASE_SERVICE_CID },
|
||||
{ POWERMANAGERSERVICE_CONTRACTID, &kNS_POWERMANAGERSERVICE_CID },
|
||||
{ OSFILECONSTANTSSERVICE_CONTRACTID, &kOSFILECONSTANTSSERVICE_CID },
|
||||
|
Loading…
Reference in New Issue
Block a user