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 /// <since_tizen> 3 </since_tizen>
26 public class MmsMessage : Message
28 private IList<MessagesAttachment> _attachment = new List<MessagesAttachment>();
31 /// Creates a multimedia message.
33 /// <since_tizen> 3 </since_tizen>
34 public MmsMessage() : base(MessageType.Mms)
38 internal MmsMessage(IntPtr messageHandle) : base(messageHandle)
44 /// The subject of the multimedia message.
46 /// <since_tizen> 3 </since_tizen>
51 string subject = null;
52 int ret = Interop.Messages.GetSubject(_messageHandle, out subject);
53 if (ret != (int)MessagesError.None)
55 Log.Error(Globals.LogTag, "Failed to get subject, Error - " + (MessagesError)ret);
62 int ret = Interop.Messages.SetSubject(_messageHandle, value);
63 if (ret != (int)MessagesError.None)
65 Log.Error(Globals.LogTag, "Failed to set subject, Error - " + (MessagesError)ret);
66 MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
72 /// The collection of normal message recipients.
74 /// <since_tizen> 3 </since_tizen>
75 public ICollection<MessagesAddress> To
84 /// The collection of CC (carbon copy) message recipients.
86 /// <since_tizen> 3 </since_tizen>
87 public ICollection<MessagesAddress> Cc
96 /// The collection of BCC (blind carbon copy) message recipients.
98 /// <since_tizen> 3 </since_tizen>
99 public ICollection<MessagesAddress> Bcc
108 /// The list of attachment files.
110 /// <since_tizen> 3 </since_tizen>
111 public IList<MessagesAttachment> Attachments
119 internal void SetAttachments()
121 foreach (var it in _attachment)
127 private void AddAttachment(MessagesAttachment attach)
129 int ret = Interop.Messages.AddAttachment(_messageHandle, (int)attach.Type, attach.FilePath);
130 if (ret != (int)MessagesError.None)
132 Log.Error(Globals.LogTag, "Failed to add attachment, Error - " + (MessagesError)ret);
133 MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
137 private void GetAllAttachments()
141 int ret = Interop.Messages.GetAttachmentCount(_messageHandle, out count);
142 if (ret != (int)MessagesError.None)
144 Log.Error(Globals.LogTag, "Failed to get attachment count, Error - " + (MessagesError)ret);
145 MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
150 var attachmentList = new List<MessagesAttachment>();
152 for (int i = 0; i < count; i++)
154 ret = Interop.Messages.GetAttachment(_messageHandle, i, out type, out path);
155 if (ret != (int)MessagesError.None)
157 Log.Error(Globals.LogTag, "Failed to get attachment, Error - " + (MessagesError)ret);
158 MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
161 var attachmentItem = new MessagesAttachment((MediaType)type, path);
162 attachmentList.Add(attachmentItem);
165 _attachment = attachmentList;