diff -r 000000000000 -r 6474c204b198 dom/mobilemessage/src/MobileMessageService.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dom/mobilemessage/src/MobileMessageService.cpp Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,139 @@ +/* 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 "MobileMessageThread.h" +#include "MobileMessageService.h" +#include "SmsSegmentInfo.h" + +namespace mozilla { +namespace dom { +namespace mobilemessage { + +NS_IMPL_ISUPPORTS(MobileMessageService, nsIMobileMessageService) + +/* static */ StaticRefPtr MobileMessageService::sSingleton; + +/* static */ already_AddRefed +MobileMessageService::GetInstance() +{ + if (!sSingleton) { + sSingleton = new MobileMessageService(); + ClearOnShutdown(&sSingleton); + } + + nsRefPtr service = sSingleton.get(); + return service.forget(); +} + +NS_IMETHODIMP +MobileMessageService::CreateSmsMessage(int32_t aId, + uint64_t aThreadId, + const nsAString& aIccId, + const nsAString& aDelivery, + const nsAString& aDeliveryStatus, + const nsAString& aSender, + const nsAString& aReceiver, + const nsAString& aBody, + const nsAString& aMessageClass, + uint64_t aTimestamp, + uint64_t aSentTimestamp, + uint64_t aDeliveryTimestamp, + bool aRead, + JSContext* aCx, + nsIDOMMozSmsMessage** aMessage) +{ + return SmsMessage::Create(aId, + aThreadId, + aIccId, + aDelivery, + aDeliveryStatus, + aSender, + aReceiver, + aBody, + aMessageClass, + aTimestamp, + aSentTimestamp, + aDeliveryTimestamp, + aRead, + aCx, + aMessage); +} + +NS_IMETHODIMP +MobileMessageService::CreateMmsMessage(int32_t aId, + uint64_t aThreadId, + const nsAString& aIccId, + const nsAString& aDelivery, + JS::Handle aDeliveryInfo, + const nsAString& aSender, + JS::Handle aReceivers, + uint64_t aTimestamp, + uint64_t aSentTimestamp, + bool aRead, + const nsAString& aSubject, + const nsAString& aSmil, + JS::Handle aAttachments, + uint64_t aExpiryDate, + bool aReadReportRequested, + JSContext* aCx, + nsIDOMMozMmsMessage** aMessage) +{ + return MmsMessage::Create(aId, + aThreadId, + aIccId, + aDelivery, + aDeliveryInfo, + aSender, + aReceivers, + aTimestamp, + aSentTimestamp, + aRead, + aSubject, + aSmil, + aAttachments, + aExpiryDate, + aReadReportRequested, + aCx, + aMessage); +} + +NS_IMETHODIMP +MobileMessageService::CreateSmsSegmentInfo(int32_t aSegments, + int32_t aCharsPerSegment, + int32_t aCharsAvailableInLastSegment, + nsIDOMMozSmsSegmentInfo** aSegmentInfo) +{ + nsCOMPtr info = + new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment); + info.forget(aSegmentInfo); + return NS_OK; +} + +NS_IMETHODIMP +MobileMessageService::CreateThread(uint64_t aId, + JS::Handle aParticipants, + uint64_t aTimestamp, + const nsAString& aLastMessageSubject, + const nsAString& aBody, + uint64_t aUnreadCount, + const nsAString& aLastMessageType, + JSContext* aCx, + nsIDOMMozMobileMessageThread** aThread) +{ + return MobileMessageThread::Create(aId, + aParticipants, + aTimestamp, + aLastMessageSubject, + aBody, + aUnreadCount, + aLastMessageType, + aCx, + aThread); +} + +} // namespace mobilemessage +} // namespace dom +} // namespace mozilla