1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/mobilemessage/src/MobileMessageService.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,139 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#include "SmsMessage.h" 1.9 +#include "MmsMessage.h" 1.10 +#include "MobileMessageThread.h" 1.11 +#include "MobileMessageService.h" 1.12 +#include "SmsSegmentInfo.h" 1.13 + 1.14 +namespace mozilla { 1.15 +namespace dom { 1.16 +namespace mobilemessage { 1.17 + 1.18 +NS_IMPL_ISUPPORTS(MobileMessageService, nsIMobileMessageService) 1.19 + 1.20 +/* static */ StaticRefPtr<MobileMessageService> MobileMessageService::sSingleton; 1.21 + 1.22 +/* static */ already_AddRefed<MobileMessageService> 1.23 +MobileMessageService::GetInstance() 1.24 +{ 1.25 + if (!sSingleton) { 1.26 + sSingleton = new MobileMessageService(); 1.27 + ClearOnShutdown(&sSingleton); 1.28 + } 1.29 + 1.30 + nsRefPtr<MobileMessageService> service = sSingleton.get(); 1.31 + return service.forget(); 1.32 +} 1.33 + 1.34 +NS_IMETHODIMP 1.35 +MobileMessageService::CreateSmsMessage(int32_t aId, 1.36 + uint64_t aThreadId, 1.37 + const nsAString& aIccId, 1.38 + const nsAString& aDelivery, 1.39 + const nsAString& aDeliveryStatus, 1.40 + const nsAString& aSender, 1.41 + const nsAString& aReceiver, 1.42 + const nsAString& aBody, 1.43 + const nsAString& aMessageClass, 1.44 + uint64_t aTimestamp, 1.45 + uint64_t aSentTimestamp, 1.46 + uint64_t aDeliveryTimestamp, 1.47 + bool aRead, 1.48 + JSContext* aCx, 1.49 + nsIDOMMozSmsMessage** aMessage) 1.50 +{ 1.51 + return SmsMessage::Create(aId, 1.52 + aThreadId, 1.53 + aIccId, 1.54 + aDelivery, 1.55 + aDeliveryStatus, 1.56 + aSender, 1.57 + aReceiver, 1.58 + aBody, 1.59 + aMessageClass, 1.60 + aTimestamp, 1.61 + aSentTimestamp, 1.62 + aDeliveryTimestamp, 1.63 + aRead, 1.64 + aCx, 1.65 + aMessage); 1.66 +} 1.67 + 1.68 +NS_IMETHODIMP 1.69 +MobileMessageService::CreateMmsMessage(int32_t aId, 1.70 + uint64_t aThreadId, 1.71 + const nsAString& aIccId, 1.72 + const nsAString& aDelivery, 1.73 + JS::Handle<JS::Value> aDeliveryInfo, 1.74 + const nsAString& aSender, 1.75 + JS::Handle<JS::Value> aReceivers, 1.76 + uint64_t aTimestamp, 1.77 + uint64_t aSentTimestamp, 1.78 + bool aRead, 1.79 + const nsAString& aSubject, 1.80 + const nsAString& aSmil, 1.81 + JS::Handle<JS::Value> aAttachments, 1.82 + uint64_t aExpiryDate, 1.83 + bool aReadReportRequested, 1.84 + JSContext* aCx, 1.85 + nsIDOMMozMmsMessage** aMessage) 1.86 +{ 1.87 + return MmsMessage::Create(aId, 1.88 + aThreadId, 1.89 + aIccId, 1.90 + aDelivery, 1.91 + aDeliveryInfo, 1.92 + aSender, 1.93 + aReceivers, 1.94 + aTimestamp, 1.95 + aSentTimestamp, 1.96 + aRead, 1.97 + aSubject, 1.98 + aSmil, 1.99 + aAttachments, 1.100 + aExpiryDate, 1.101 + aReadReportRequested, 1.102 + aCx, 1.103 + aMessage); 1.104 +} 1.105 + 1.106 +NS_IMETHODIMP 1.107 +MobileMessageService::CreateSmsSegmentInfo(int32_t aSegments, 1.108 + int32_t aCharsPerSegment, 1.109 + int32_t aCharsAvailableInLastSegment, 1.110 + nsIDOMMozSmsSegmentInfo** aSegmentInfo) 1.111 +{ 1.112 + nsCOMPtr<nsIDOMMozSmsSegmentInfo> info = 1.113 + new SmsSegmentInfo(aSegments, aCharsPerSegment, aCharsAvailableInLastSegment); 1.114 + info.forget(aSegmentInfo); 1.115 + return NS_OK; 1.116 +} 1.117 + 1.118 +NS_IMETHODIMP 1.119 +MobileMessageService::CreateThread(uint64_t aId, 1.120 + JS::Handle<JS::Value> aParticipants, 1.121 + uint64_t aTimestamp, 1.122 + const nsAString& aLastMessageSubject, 1.123 + const nsAString& aBody, 1.124 + uint64_t aUnreadCount, 1.125 + const nsAString& aLastMessageType, 1.126 + JSContext* aCx, 1.127 + nsIDOMMozMobileMessageThread** aThread) 1.128 +{ 1.129 + return MobileMessageThread::Create(aId, 1.130 + aParticipants, 1.131 + aTimestamp, 1.132 + aLastMessageSubject, 1.133 + aBody, 1.134 + aUnreadCount, 1.135 + aLastMessageType, 1.136 + aCx, 1.137 + aThread); 1.138 +} 1.139 + 1.140 +} // namespace mobilemessage 1.141 +} // namespace dom 1.142 +} // namespace mozilla