2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using System.Collections.Generic;
20 namespace Tizen.Messaging.Messages
23 /// This class represents multimedia messages.
25 public class MmsMessage : Message
27 private IList<MessagesAttachment> _attachment = new List<MessagesAttachment>();
30 /// Creates a multimedia message.
32 public MmsMessage() : base(MessageType.Mms)
36 internal MmsMessage(IntPtr messageHandle) : base(messageHandle)
42 /// The subject of the multimedia message.
48 string subject = null;
49 int ret = Interop.Messages.GetSubject(_messageHandle, out subject);
50 if (ret != (int)MessagesError.None)
52 Log.Error(Globals.LogTag, "Failed to get subject, Error - " + (MessagesError)ret);
59 int ret = Interop.Messages.SetSubject(_messageHandle, value);
60 if (ret != (int)MessagesError.None)
62 Log.Error(Globals.LogTag, "Failed to set subject, Error - " + (MessagesError)ret);
63 MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
69 /// The collection of normal message recipients.
71 public ICollection<MessagesAddress> To
80 /// The collection of CC (carbon copy) message recipients.
82 public ICollection<MessagesAddress> Cc
91 /// The collection of BCC (blind carbon copy) message recipients.
93 public ICollection<MessagesAddress> Bcc
102 /// The list of attachment files.
104 public IList<MessagesAttachment> Attachments
112 internal void SetAttachments()
114 foreach (var it in _attachment)
120 private void AddAttachment(MessagesAttachment attach)
122 int ret = Interop.Messages.AddAttachment(_messageHandle, (int)attach.Type, attach.FilePath);
123 if (ret != (int)MessagesError.None)
125 Log.Error(Globals.LogTag, "Failed to add attachment, Error - " + (MessagesError)ret);
126 MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
130 private void GetAllAttachments()
134 int ret = Interop.Messages.GetAttachmentCount(_messageHandle, out count);
135 if (ret != (int)MessagesError.None)
137 Log.Error(Globals.LogTag, "Failed to get attachment count, Error - " + (MessagesError)ret);
138 MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
143 var attachmentList = new List<MessagesAttachment>();
145 for (int i = 0; i < count; i++)
147 ret = Interop.Messages.GetAttachment(_messageHandle, i, out type, out path);
148 if (ret != (int)MessagesError.None)
150 Log.Error(Globals.LogTag, "Failed to get attachment, Error - " + (MessagesError)ret);
151 MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
154 var attachmentItem = new MessagesAttachment((MediaType)type, path);
155 attachmentList.Add(attachmentItem);
158 _attachment = attachmentList;