michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "SmsMessage.h" michael@0: #include "MmsMessage.h" michael@0: #include "MobileMessageThread.h" michael@0: #include "MobileMessageService.h" michael@0: #include "SmsSegmentInfo.h" michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: namespace mobilemessage { michael@0: michael@0: NS_IMPL_ISUPPORTS(MobileMessageService, nsIMobileMessageService) michael@0: michael@0: /* static */ StaticRefPtr MobileMessageService::sSingleton; michael@0: michael@0: /* static */ already_AddRefed michael@0: MobileMessageService::GetInstance() michael@0: { michael@0: if (!sSingleton) { michael@0: sSingleton = new MobileMessageService(); michael@0: ClearOnShutdown(&sSingleton); michael@0: } michael@0: michael@0: nsRefPtr service = sSingleton.get(); michael@0: return service.forget(); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileMessageService::CreateSmsMessage(int32_t aId, michael@0: uint64_t aThreadId, michael@0: const nsAString& aIccId, michael@0: const nsAString& aDelivery, michael@0: const nsAString& aDeliveryStatus, michael@0: const nsAString& aSender, michael@0: const nsAString& aReceiver, michael@0: const nsAString& aBody, michael@0: const nsAString& aMessageClass, michael@0: uint64_t aTimestamp, michael@0: uint64_t aSentTimestamp, michael@0: uint64_t aDeliveryTimestamp, michael@0: bool aRead, michael@0: JSContext* aCx, michael@0: nsIDOMMozSmsMessage** aMessage) michael@0: { michael@0: return SmsMessage::Create(aId, michael@0: aThreadId, michael@0: aIccId, michael@0: aDelivery, michael@0: aDeliveryStatus, michael@0: aSender, michael@0: aReceiver, michael@0: aBody, michael@0: aMessageClass, michael@0: aTimestamp, michael@0: aSentTimestamp, michael@0: aDeliveryTimestamp, michael@0: aRead, michael@0: aCx, michael@0: aMessage); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileMessageService::CreateMmsMessage(int32_t aId, michael@0: uint64_t aThreadId, michael@0: const nsAString& aIccId, michael@0: const nsAString& aDelivery, michael@0: JS::Handle aDeliveryInfo, michael@0: const nsAString& aSender, michael@0: JS::Handle aReceivers, michael@0: uint64_t aTimestamp, michael@0: uint64_t aSentTimestamp, michael@0: bool aRead, michael@0: const nsAString& aSubject, michael@0: const nsAString& aSmil, michael@0: JS::Handle aAttachments, michael@0: uint64_t aExpiryDate, michael@0: bool aReadReportRequested, michael@0: JSContext* aCx, michael@0: nsIDOMMozMmsMessage** aMessage) michael@0: { michael@0: return MmsMessage::Create(aId, michael@0: aThreadId, michael@0: aIccId, michael@0: aDelivery, michael@0: aDeliveryInfo, michael@0: aSender, michael@0: aReceivers, michael@0: aTimestamp, michael@0: aSentTimestamp, michael@0: aRead, michael@0: aSubject, michael@0: aSmil, michael@0: aAttachments, michael@0: aExpiryDate, michael@0: aReadReportRequested, michael@0: aCx, michael@0: aMessage); michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileMessageService::CreateSmsSegmentInfo(int32_t aSegments, michael@0: int32_t aCharsPerSegment, michael@0: int32_t aCharsAvailableInLastSegment, michael@0: nsIDOMMozSmsSegmentInfo** aSegmentInfo) michael@0: { michael@0: nsCOMPtr info = michael@0: new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment); michael@0: info.forget(aSegmentInfo); michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: MobileMessageService::CreateThread(uint64_t aId, michael@0: JS::Handle aParticipants, michael@0: uint64_t aTimestamp, michael@0: const nsAString& aLastMessageSubject, michael@0: const nsAString& aBody, michael@0: uint64_t aUnreadCount, michael@0: const nsAString& aLastMessageType, michael@0: JSContext* aCx, michael@0: nsIDOMMozMobileMessageThread** aThread) michael@0: { michael@0: return MobileMessageThread::Create(aId, michael@0: aParticipants, michael@0: aTimestamp, michael@0: aLastMessageSubject, michael@0: aBody, michael@0: aUnreadCount, michael@0: aLastMessageType, michael@0: aCx, michael@0: aThread); michael@0: } michael@0: michael@0: } // namespace mobilemessage michael@0: } // namespace dom michael@0: } // namespace mozilla