Merge remote-tracking branch 'messaging/tizen'
authorWonYoung Choi <wy80.choi@samsung.com>
Thu, 10 Aug 2017 01:04:19 +0000 (10:04 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Thu, 10 Aug 2017 01:04:19 +0000 (10:04 +0900)
Change-Id: I78d17674dad1b96e1d92d371af6b0c686fbd6964

27 files changed:
src/Tizen.Messaging/Interop/Interop.Email.cs [new file with mode: 0755]
src/Tizen.Messaging/Interop/Interop.Libraries.cs [new file with mode: 0644]
src/Tizen.Messaging/Interop/Interop.Messages.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Email/EmailAttachment.cs [new file with mode: 0644]
src/Tizen.Messaging/Tizen.Messaging.Email/EmailEnumerations.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Email/EmailErrorFactory.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Email/EmailMessage.cs [new file with mode: 0644]
src/Tizen.Messaging/Tizen.Messaging.Email/EmailRecipient.cs [new file with mode: 0644]
src/Tizen.Messaging/Tizen.Messaging.Email/EmailSender.cs [new file with mode: 0644]
src/Tizen.Messaging/Tizen.Messaging.Email/NamespaceDoc.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/CBMessage.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/Message.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessageReceivedEventArgs.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAddress.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAttachment.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEnumerations.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesErrorFactory.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEvent.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManager.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManagerImpl.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesSearchFilter.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/MmsMessage.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/NamespaceDoc.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/PushMessage.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.Messages/SmsMessage.cs [new file with mode: 0755]
src/Tizen.Messaging/Tizen.Messaging.csproj [new file with mode: 0644]
src/Tizen.Messaging/Tizen.Messaging.snk [new file with mode: 0755]

diff --git a/src/Tizen.Messaging/Interop/Interop.Email.cs b/src/Tizen.Messaging/Interop/Interop.Email.cs
new file mode 100755 (executable)
index 0000000..28601a9
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal enum EmailRecipientType
+    {
+        To = 1,
+        Cc = 2,
+        Bcc = 3
+    }
+
+    internal static partial class Email
+    {
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void EmailSentCallback(IntPtr handle, int result, IntPtr userData);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_create_message")]
+        internal static extern int CreateEmail(out IntPtr EmailHandle);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_destroy_message")]
+        internal static extern int DestroyEmail(IntPtr EmailHandle);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_set_subject")]
+        internal static extern int SetSubject(IntPtr EmailHandle, string text);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_set_body")]
+        internal static extern int SetBody(IntPtr EmailHandle, string text);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_add_recipient")]
+        internal static extern int AddRecipient(IntPtr EmailHandle, int type, string text);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_remove_all_recipients")]
+        internal static extern int RemoveRecipient(IntPtr EmailHandle);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_add_attach")]
+        internal static extern int AddAttachment(IntPtr EmailHandle, string text);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_remove_all_attachments")]
+        internal static extern int RemoveAttachments(IntPtr EmailHandle);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_save_message")]
+        internal static extern int SaveEmail(IntPtr EmailHandle);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_send_message")]
+        internal static extern int SendEmail(IntPtr EmailHandle, bool SaveToSentBox);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_set_message_sent_cb")]
+        internal static extern int SetCb(IntPtr EmailHandle, EmailSentCallback Cb, IntPtr UserData);
+
+        [DllImport(Libraries.Email, EntryPoint = "email_unset_message_sent_cb")]
+        internal static extern int UnsetCb(IntPtr EmailHandle);
+    }
+}
diff --git a/src/Tizen.Messaging/Interop/Interop.Libraries.cs b/src/Tizen.Messaging/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..64170be
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+    internal static partial class Libraries
+    {
+        public const string Messages = "libcapi-messaging-messages.so.0";
+        public const string Email = "libcapi-messaging-email.so.0";
+    }
+}
diff --git a/src/Tizen.Messaging/Interop/Interop.Messages.cs b/src/Tizen.Messaging/Interop/Interop.Messages.cs
new file mode 100755 (executable)
index 0000000..7697262
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class Messages
+    {
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void MessageIncomingCallback(IntPtr messageHandle, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate void MessageSentCallback(int result, IntPtr userData);
+
+        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+        internal delegate bool MessageSearchCallback(IntPtr messageHandle, int index, int resultCount, int totalCount, IntPtr userData);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_open_service")]
+        internal static extern int OpenService(out IntPtr serviceHandle);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_close_service")]
+        internal static extern int CloseService(IntPtr serviceHandle);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_create_message")]
+        internal static extern int CreateMessage(int type, out IntPtr messageHandle);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_destroy_message")]
+        internal static extern int DestroyMessage(IntPtr messageHandle);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_message_id")]
+        internal static extern int GetMessageId(IntPtr messageHandle, out int messageId);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_set_sim_id")]
+        internal static extern int SetSimId(IntPtr messageHandle, int simId);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_sim_id")]
+        internal static extern int GetSimId(IntPtr messageHandle, out int simId);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_set_mbox_type")]
+        internal static extern int SetMboxType(IntPtr messageHandle, int mboxType);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_mbox_type")]
+        internal static extern int GetMboxType(IntPtr messageHandle, out int mboxType);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_message_port")]
+        internal static extern int GetMessagePort(IntPtr messageHandle, out int messagePort);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_message_type")]
+        internal static extern int GetMessageType(IntPtr messageHandle, out int messageType);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_set_text")]
+        internal static extern int SetText(IntPtr messageHandle, string text);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_text")]
+        internal static extern int GetText(IntPtr messageHandle, out string text);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_set_time")]
+        internal static extern int SetTime(IntPtr messageHandle, int time);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_time")]
+        internal static extern int GetTime(IntPtr messageHandle, out int time);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_mms_set_subject")]
+        internal static extern int SetSubject(IntPtr messageHandle, string subject);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_mms_get_subject")]
+        internal static extern int GetSubject(IntPtr messageHandle, out string subject);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_add_address")]
+        internal static extern int AddAddress(IntPtr messageHandle, string address, int type);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_address_count")]
+        internal static extern int GetAddressCount(IntPtr messageHandle, out int count);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_get_address")]
+        internal static extern int GetAddress(IntPtr messageHandle, int index, out string address, out int type);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_remove_all_addresses")]
+        internal static extern int RemoveAllAddress(IntPtr messageHandle);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_mms_add_attachment")]
+        internal static extern int AddAttachment(IntPtr messageHandle, int type, string path);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_mms_get_attachment_count")]
+        internal static extern int GetAttachmentCount(IntPtr messageHandle, out int count);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_mms_get_attachment")]
+        internal static extern int GetAttachment(IntPtr messageHandle, int index, out int type, out string path);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_mms_remove_all_attachments")]
+        internal static extern int RemoveAllAttachment(IntPtr messageHandle);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_set_message_incoming_cb")]
+        internal static extern int SetMessageIncomingCb(IntPtr serviceHandle, MessageIncomingCallback cb, IntPtr userData);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_unset_message_incoming_cb")]
+        internal static extern int UnsetMessageIncomingCb(IntPtr serviceHandle);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_send_message")]
+        internal static extern int SendMessage(IntPtr serviceHandle, IntPtr messageHandle, bool saveToSentbox, MessageSentCallback cb, IntPtr userData);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_search_message_by_id")]
+        internal static extern int GetMessageById(IntPtr serviceHandle, int msgId, out IntPtr messageHandle);
+
+        [DllImport(Libraries.Messages, EntryPoint = "messages_foreach_message")]
+        internal static extern int SearchMessage(IntPtr serviceHandle, int mbox, int messageType, string textKeyword, string addressKeyword, int offset, int limit, MessageSearchCallback cb, IntPtr userData);
+
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailAttachment.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailAttachment.cs
new file mode 100644 (file)
index 0000000..5f8028a
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Messaging.Email
+{
+    /// <summary>
+    /// Represents an email attachment
+    /// </summary>
+    public class EmailAttachment
+    {
+        /// <summary>
+        /// The absolute full path of the file to be attached
+        /// </summary>
+        public string FilePath { get; set; }
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        public EmailAttachment()
+        {
+
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailEnumerations.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailEnumerations.cs
new file mode 100755 (executable)
index 0000000..fdeaa37
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+namespace Tizen.Messaging.Email
+{
+    /// <summary>
+    /// Result of sending the email
+    /// </summary>
+    public enum EmailSendResult
+    {
+        /// <summary>
+        /// Failed to send the message
+        /// </summary>
+        Failure = -1,
+
+        /// <summary>
+        /// email sent successfully
+        /// </summary>
+        Success = 0
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailErrorFactory.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailErrorFactory.cs
new file mode 100755 (executable)
index 0000000..90dbe54
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.IO;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Messaging.Email
+{
+    internal enum EmailError
+    {
+        None = ErrorCode.None,
+        OutOfMemory = ErrorCode.OutOfMemory,
+        InvalidParameter = ErrorCode.InvalidParameter,
+        ServerNotReady = -0x01710000 | 0x501,
+        CommunicationWithServerFailed = -0x01710000 | 0x502,
+        OutOfRange = -0x01710000 | 0x503,
+        SendingFailed = -0x01710000 | 0x504,
+        OperationFailed = -0x01710000 | 0x505,
+        NoSimCard = -0x01710000 | 0x506,
+        NoData = -0x01710000 | 0x507,
+        PermissionDenied = ErrorCode.PermissionDenied,
+        NotSupported = ErrorCode.NotSupported
+    }
+
+    internal static class EmailErrorFactory
+    {
+        internal const string LogTag = "Tizen.Messaging.Email";
+
+        internal static Exception GetException(int err)
+        {
+            EmailError error = (EmailError)err;
+            if (error == EmailError.OutOfMemory)
+            {
+                return new OutOfMemoryException("Out of memory");
+            }
+            else if (error == EmailError.InvalidParameter)
+            {
+                return new ArgumentException("Invalid parameter");
+            }
+            else if (error == EmailError.ServerNotReady)
+            {
+                return new IOException("Server not ready yet"); ;
+            }
+            else if (error == EmailError.NoData)
+            {
+                return new InvalidDataException("No data found");
+            }
+            else if (error == EmailError.CommunicationWithServerFailed)
+            {
+                return new TimeoutException("timed out");
+            }
+            else if (error == EmailError.PermissionDenied)
+            {
+                return new UnauthorizedAccessException("Permission denied");
+            }
+            else if (error == EmailError.NotSupported)
+            {
+                return new NotSupportedException("Not supported");
+            }
+            else if (error == EmailError.OutOfRange)
+            {
+                return new IndexOutOfRangeException("Out of range");
+            }
+            else if (error == EmailError.SendingFailed)
+            {
+                return new Exception("Sending failed");
+            }
+            else if (error == EmailError.OperationFailed)
+            {
+                return new InvalidOperationException("operation failed");
+            }
+            else if (error == EmailError.NoSimCard)
+            {
+                return new Exception("No sim card found");
+            }
+            else
+            {
+                return new Exception("System operation");
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailMessage.cs
new file mode 100644 (file)
index 0000000..f7756c9
--- /dev/null
@@ -0,0 +1,229 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace Tizen.Messaging.Email
+{
+    /// <summary>
+    /// The class contains Messaging API to support sending email messages.
+    /// </summary>
+    public class EmailMessage : IDisposable
+    {
+        internal IntPtr _emailHandle = IntPtr.Zero;
+        private bool _disposed = false;
+        private String _subject;
+        private String _body;
+        private IList<EmailAttachment> _attachments = new List<EmailAttachment>();
+        private ICollection<EmailRecipient> _to = new Collection<EmailRecipient>();
+        private ICollection<EmailRecipient> _cc = new Collection<EmailRecipient>();
+        private ICollection<EmailRecipient> _bcc = new Collection<EmailRecipient>();
+
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        public EmailMessage()
+        {
+            int ret = Interop.Email.CreateEmail(out _emailHandle);
+            if (ret != (int)EmailError.None)
+            {
+                Log.Error(EmailErrorFactory.LogTag, "Failed to create message handle, Error code: " + (EmailError)ret);
+                throw EmailErrorFactory.GetException(ret);
+            }
+        }
+
+        /// <summary>
+        /// Subject of the email message
+        /// </summary>
+        public string Subject
+        {
+            set
+            {
+                _subject = value;
+                int ret = Interop.Email.SetSubject(_emailHandle, _subject);
+                if (ret != (int)EmailError.None)
+                {
+                    Log.Error(EmailErrorFactory.LogTag, "Failed to set subject, Error code: " + (EmailError)ret);
+                    throw EmailErrorFactory.GetException(ret);
+                }
+            }
+            get
+            {
+                return _subject;
+            }
+
+        }
+
+        /// <summary>
+        /// Body of the email message
+        /// </summary>
+        public string Body
+        {
+            set
+            {
+                _body = value;
+                int ret = Interop.Email.SetBody(_emailHandle, _body);
+                if (ret != (int)EmailError.None)
+                {
+                    Log.Error(EmailErrorFactory.LogTag, "Failed to set body, Error code: " + (EmailError)ret);
+                    throw EmailErrorFactory.GetException(ret);
+                }
+            }
+            get
+            {
+                return _body;
+            }
+        }
+
+        /// <summary>
+        /// List of file attachments
+        /// </summary>
+        public IList<EmailAttachment> Attachments
+        {
+            get
+            {
+                return _attachments;
+            }
+        }
+
+        /// <summary>
+        /// Collection of normal email recipients
+        /// </summary>
+        /// <remarks>
+        /// Email address should be in standard format (as described in Internet standards RFC 5321 and RFC 5322).
+        /// </remarks>
+        public ICollection<EmailRecipient> To
+        {
+            get
+            {
+                return _to;
+            }
+        }
+
+        /// <summary>
+        /// Collection of CC(carbon copy) email recipients
+        /// </summary>
+        /// <remarks>
+        /// Email address should be in standard format (as described in Internet standards RFC 5321 and RFC 5322).
+        /// </remarks>
+        public ICollection<EmailRecipient> Cc
+        {
+            get
+            {
+                return _cc;
+            }
+        }
+
+        /// <summary>
+        /// Collection of BCC(blind carbon copy) email recipients
+        /// </summary>
+        /// <remarks>
+        /// Email address should be in standard format (as described in Internet standards RFC 5321 and RFC 5322).
+        /// </remarks>
+        public ICollection<EmailRecipient> Bcc
+        {
+            get
+            {
+                return _bcc;
+            }
+        }
+
+
+        internal void Save()
+        {
+            int ret;
+            FillHandle();
+
+            ret = Interop.Email.SaveEmail(_emailHandle);
+            if (ret != (int)EmailError.None)
+            {
+                Log.Error(EmailErrorFactory.LogTag, "Failed to save email, Error code: " + (EmailError)ret);
+                throw EmailErrorFactory.GetException(ret);
+            }
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        protected virtual void Dispose(bool disposing)
+        {
+            if (_disposed)
+                return;
+
+            if (disposing)
+            {
+
+            }
+
+            if (_emailHandle != IntPtr.Zero)
+            {
+                Interop.Email.DestroyEmail(_emailHandle);
+                _emailHandle = IntPtr.Zero;
+            }
+            _disposed = true;
+        }
+
+        internal void FillHandle()
+        {
+            int ret = (int)EmailError.None;
+            foreach (EmailAttachment it in Attachments)
+            {
+                Console.WriteLine(it.FilePath);
+                ret = Interop.Email.AddAttachment(_emailHandle, it.FilePath);
+                if (ret != (int)EmailError.None)
+                {
+                    Log.Error(EmailErrorFactory.LogTag, "Failed to add attachment, Error code: " + (EmailError)ret);
+                    throw EmailErrorFactory.GetException(ret);
+                }
+            }
+
+            foreach (EmailRecipient it in To)
+            {
+                ret = Interop.Email.AddRecipient(_emailHandle, (int)Interop.EmailRecipientType.To, it.Address);
+                if (ret != (int)EmailError.None)
+                {
+                    Log.Error(EmailErrorFactory.LogTag, "Failed to add recipients, Error code: " + (EmailError)ret);
+                    throw EmailErrorFactory.GetException(ret);
+                }
+            }
+
+            foreach (EmailRecipient it in Cc)
+            {
+                ret = Interop.Email.AddRecipient(_emailHandle, (int)Interop.EmailRecipientType.Cc, it.Address);
+                if (ret != (int)EmailError.None)
+                {
+                    Log.Error(EmailErrorFactory.LogTag, "Failed to add recipients, Error code: " + (EmailError)ret);
+                    throw EmailErrorFactory.GetException(ret);
+                }
+            }
+
+            foreach (EmailRecipient it in Bcc)
+            {
+                ret = Interop.Email.AddRecipient(_emailHandle, (int)Interop.EmailRecipientType.Bcc, it.Address);
+                if (ret != (int)EmailError.None)
+                {
+                    Log.Error(EmailErrorFactory.LogTag, "Failed to add recipients, Error code: " + (EmailError)ret);
+                    throw EmailErrorFactory.GetException(ret);
+                }
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailRecipient.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailRecipient.cs
new file mode 100644 (file)
index 0000000..3c1fc24
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Messaging.Email
+{
+    /// <summary>
+    /// The class represents recipients of an email
+    /// </summary>
+    public class EmailRecipient
+    {
+        /// <summary>
+        /// The email address of the recipient
+        /// </summary>
+        public string Address { get; set; }
+        /// <summary>
+        /// The constructor
+        /// </summary>
+        public EmailRecipient()
+        {
+
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/EmailSender.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/EmailSender.cs
new file mode 100644 (file)
index 0000000..57220ed
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading.Tasks;
+
+namespace Tizen.Messaging.Email
+{
+    /// <summary>
+    /// The class to send email messages.
+    /// </summary>
+    public static class EmailSender
+    {
+        /// <summary>
+        /// Sends the email message.
+        /// </summary>
+        /// <param name="email">The email message</param>
+        /// <returns> Failure if email sending failed otherwise Success</returns>
+        public static async Task<EmailSendResult> SendAsync(EmailMessage email)
+        {
+            var task = new TaskCompletionSource<EmailSendResult>();
+            int ret = (int)EmailError.None;
+            bool saveToSentBox = false;
+
+            email.FillHandle();
+            email.Save();
+
+            Interop.Email.EmailSentCallback _emailSendingCallback = (IntPtr handle, int result, IntPtr userData) =>
+            {
+                task.SetResult((EmailSendResult)result);
+            };
+
+            ret = Interop.Email.SetCb(email._emailHandle, _emailSendingCallback, IntPtr.Zero);
+            if (ret != (int)EmailError.None)
+            {
+                Log.Error(EmailErrorFactory.LogTag, "Failed to set email incoming callback, Error code: " + (EmailError)ret);
+                throw EmailErrorFactory.GetException(ret);
+            }
+
+            ret = Interop.Email.SendEmail(email._emailHandle, saveToSentBox);
+            if (ret != (int)EmailError.None)
+            {
+                Log.Error(EmailErrorFactory.LogTag, "Failed to send email, Error code: " + (EmailError)ret);
+                throw EmailErrorFactory.GetException(ret);
+            }
+
+            var sendResult = await task.Task;
+
+            ret = Interop.Email.UnsetCb(email._emailHandle);
+            if (ret != (int)EmailError.None)
+            {
+                Log.Error(EmailErrorFactory.LogTag, "Failed to set email incoming callback, Error code: " + (EmailError)ret);
+                throw EmailErrorFactory.GetException(ret);
+            }
+
+            return sendResult;
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Email/NamespaceDoc.cs b/src/Tizen.Messaging/Tizen.Messaging.Email/NamespaceDoc.cs
new file mode 100755 (executable)
index 0000000..1c51cb5
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/// <summary>
+/// The <b>Tizen.Messaging.Email</b> namespace contains classes providing functionality to send emails.
+/// </summary>
+/// <remarks>
+/// The <b>Tizen.Messaging.Email</b> namespace contains classes providing functionality to send emails.
+/// </remarks>
+namespace Tizen.Messaging.Email
+{
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/CBMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/CBMessage.cs
new file mode 100755 (executable)
index 0000000..949a1c8
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class to represent cell broadcast messages.
+    /// </summary>
+    public class CBMessage : Message
+    {
+        internal CBMessage(IntPtr messageHandle) : base(messageHandle)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/Message.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/Message.cs
new file mode 100755 (executable)
index 0000000..e0e27f2
--- /dev/null
@@ -0,0 +1,335 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class to represent all messages.
+    /// </summary>
+    public abstract class Message : IDisposable
+    {
+        internal IntPtr _messageHandle = IntPtr.Zero;
+        private bool disposed = false;
+        private int _memoryPressureSize = IntPtr.Size * 11 + sizeof(int) * 5 + sizeof(bool) * 5 + sizeof(short) * 2 + sizeof(byte) * 1176;
+
+        private ICollection<MessagesAddress> _from = new Collection<MessagesAddress>();
+        internal ICollection<MessagesAddress> _to = new Collection<MessagesAddress>();
+        internal ICollection<MessagesAddress> _cc = new Collection<MessagesAddress>();
+        internal ICollection<MessagesAddress> _bcc = new Collection<MessagesAddress>();
+
+        internal Message(MessageType type)
+        {
+            int ret = Interop.Messages.CreateMessage((int)type, out _messageHandle);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to create message handle, Error - " + (MessagesError)ret);
+                MessagesErrorFactory.ThrowMessagesException(ret);
+            }
+
+            GC.AddMemoryPressure(_memoryPressureSize);
+        }
+
+        internal Message(IntPtr messageHandle)
+        {
+            _messageHandle = messageHandle;
+            GetAllAddresses();
+            GC.AddMemoryPressure(_memoryPressureSize);
+        }
+
+        internal void FillHandle()
+        {
+            SetAddresses();
+            (this as MmsMessage)?.SetAttachments();
+        }
+
+        ~Message()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+            GC.RemoveMemoryPressure(_memoryPressureSize);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+            }
+
+            // Free unmanaged objects
+            if (_messageHandle != IntPtr.Zero)
+            {
+                Interop.Messages.DestroyMessage(_messageHandle);
+                _messageHandle = IntPtr.Zero;
+            }
+            disposed = true;
+        }
+
+        internal IntPtr GetHandle()
+        {
+            return _messageHandle;
+        }
+
+        private void SetAddresses()
+        {
+            foreach (var it in _to)
+            {
+                AddAddress(it);
+            }
+
+            foreach (var it in _cc)
+            {
+                AddAddress(it);
+            }
+
+            foreach (var it in _bcc)
+            {
+                AddAddress(it);
+            }
+        }
+
+        private void AddAddress(MessagesAddress address)
+        {
+            int ret = Interop.Messages.AddAddress(_messageHandle, address.Number, (int)address.Type);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to add address, Error - " + (MessagesError)ret);
+                MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+            }
+        }
+
+        private void GetAllAddresses()
+        {
+            int count;
+
+            int ret = Interop.Messages.GetAddressCount(_messageHandle, out count);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get address count, Error - " + (MessagesError)ret);
+                MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+            }
+
+            string number;
+            int type;
+            var To = new Collection<MessagesAddress>();
+            var Cc = new Collection<MessagesAddress>();
+            var Bcc = new Collection<MessagesAddress>();
+            var From = new Collection<MessagesAddress>();
+
+            for (int i = 0; i < count; i++)
+            {
+                ret = Interop.Messages.GetAddress(_messageHandle, i, out number, out type);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get address, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+                }
+
+                var addressItem = new MessagesAddress((RecipientType)type, number);
+                switch ((RecipientType)type)
+                {
+                    case RecipientType.To:
+                        To.Add(addressItem);
+                        break;
+                    case RecipientType.Cc:
+                        Cc.Add(addressItem);
+                        break;
+                    case RecipientType.Bcc:
+                        Bcc.Add(addressItem);
+                        break;
+                    default:
+                        From.Add(addressItem);
+                        break;
+                }
+            }
+
+            _to = To;
+            _cc = Cc;
+            _bcc = Bcc;
+            _from = From;
+        }
+
+        /// <summary>
+        /// The message ID
+        /// </summary>
+        /// <remarks>
+        /// After creating Message object, default value of this property is 0. After sending, this value is changed.
+        /// </remarks>
+        public int Id
+        {
+            get
+            {
+                int id = 0;
+                int ret = Interop.Messages.GetMessageId(_messageHandle, out id);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get message id, Error - " + (MessagesError)ret);
+                }
+
+                return id;
+            }
+        }
+
+        /// <summary>
+        /// The destination port of the message
+        /// </summary>
+        public int Port
+        {
+            get
+            {
+                int port = 0;
+                int ret = Interop.Messages.GetMessagePort(_messageHandle, out port);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get message port, Error - " + (MessagesError)ret);
+                }
+
+                return port;
+            }
+        }
+
+        /// <summary>
+        /// The message box type
+        /// </summary>
+        public MessageBoxType BoxType
+        {
+            get
+            {
+                int boxType = (int)MessageBoxType.All;
+                int ret = Interop.Messages.GetMboxType(_messageHandle, out boxType);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get message box type, Error - " + (MessagesError)ret);
+                }
+
+                return (MessageBoxType)boxType;
+            }
+            set
+            {
+                int ret = Interop.Messages.SetMboxType(_messageHandle, (int)value);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to set message box type, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The text of the message
+        /// </summary>
+        public string Text
+        {
+            get
+            {
+                string text = null;
+                int ret = Interop.Messages.GetText(_messageHandle, out text);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get text, Error - " + (MessagesError)ret);
+                }
+
+                return text;
+            }
+            set
+            {
+                int ret = Interop.Messages.SetText(_messageHandle, value);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to set text, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The time of the message
+        /// </summary>
+        public DateTime Time
+        {
+            get
+            {
+                int time = 0;
+                int ret = Interop.Messages.GetTime(_messageHandle, out time);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get time, Error - " + (MessagesError)ret);
+                }
+
+                return (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddSeconds(time).ToLocalTime();
+            }
+            set
+            {
+                int ret = Interop.Messages.SetTime(_messageHandle, (int)(value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds));
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to set time, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+                }
+            }
+        }
+
+        /// <summary>
+        /// The SIM slot index of the message
+        /// </summary>
+        public SimSlotId SimId
+        {
+            get
+            {
+                int simId = (int)SimSlotId.Unknown;
+                int ret = Interop.Messages.GetSimId(_messageHandle, out simId);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get simId, Error - " + (MessagesError)ret);
+                }
+
+                return (SimSlotId)simId;
+            }
+            set
+            {
+                int ret = Interop.Messages.SetSimId(_messageHandle, (int)value);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to set simId, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Indicates sender of the message
+        /// </summary>
+        public IReadOnlyCollection<MessagesAddress> From
+        {
+            get
+            {
+                return _from as IReadOnlyCollection<MessagesAddress>;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessageReceivedEventArgs.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessageReceivedEventArgs.cs
new file mode 100755 (executable)
index 0000000..cd9f7ee
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// An extended EventArgs class which contains a received message.
+    /// </summary>
+    public class MessageReceivedEventArgs : EventArgs
+    {
+        private Message _message;
+
+        internal MessageReceivedEventArgs(Message message)
+        {
+            _message = message;
+        }
+
+        /// <summary>
+        /// The received message
+        /// </summary>
+        public Message ReceivedMessage
+        {
+            get
+            {
+                return _message;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAddress.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAddress.cs
new file mode 100755 (executable)
index 0000000..19143fb
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class to manage informations of message address.
+    /// </summary>
+    public class MessagesAddress
+    {
+        internal RecipientType Type;
+        /// <summary>
+        /// The address of the sender/recipient
+        /// </summary>
+        public string Number { get; }
+
+        /// <summary>
+        /// Creates a message address.
+        /// </summary>
+        /// <param name="number">The recipient's address to receive a message</param>
+        public MessagesAddress(string number)
+        {
+            Number = number;
+        }
+
+        internal MessagesAddress(RecipientType type, string number)
+        {
+            Type = type;
+            Number = number;
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAttachment.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesAttachment.cs
new file mode 100755 (executable)
index 0000000..6096278
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class to manage informations of message attachment.
+    /// </summary>
+    public class MessagesAttachment
+    {
+        /// <summary>
+        /// The media type of attachment
+        /// </summary>
+        public MediaType Type { get; }
+
+        /// <summary>
+        /// The file path of attachment
+        /// </summary>
+        public string FilePath { get; }
+
+        /// <summary>
+        /// Creates an attachment.
+        /// </summary>
+        /// <param name="type">The attachment's type</param>
+        /// <param name="filePath">The file path to attach</param>
+        public MessagesAttachment(MediaType type, string filePath)
+        {
+            Type = type;
+            FilePath = filePath;
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEnumerations.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEnumerations.cs
new file mode 100755 (executable)
index 0000000..dd43eb0
--- /dev/null
@@ -0,0 +1,152 @@
+/*
+* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an AS IS BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// Enumeration for the result of sending a message.
+    /// </summary>
+    public enum SentResult
+    {
+        /// <summary>
+        /// Message sending failed
+        /// </summary>
+        Failed = -1,
+        /// <summary>
+        /// Message sending succeeded
+        /// </summary>
+        Success = 0
+    }
+
+    /// <summary>
+    /// Enumeration for the message type.
+    /// </summary>
+    public enum MessageType
+    {
+        /// <summary>
+        /// Unknown type
+        /// </summary>
+        Unknown = 0,
+        /// <summary>
+        /// SMS type
+        /// </summary>
+        Sms = 1,
+        /// <summary>
+        /// MMS type
+        /// </summary>
+        Mms = 2,
+        /// <summary>
+        /// CB(Cell Broadcast) type
+        /// </summary>
+        CellBroadcast = Sms | 1 << 4,
+        /// <summary>
+        /// WAP Push type
+        /// </summary>
+        Push = Sms | 10 << 4
+    }
+
+    /// <summary>
+    /// Enumeration for the message box type.
+    /// </summary>
+    public enum MessageBoxType
+    {
+        /// <summary>
+        /// All message box type
+        /// </summary>
+        All = 0,
+        /// <summary>
+        /// Inbox type
+        /// </summary>
+        Inbox = 1,
+        /// <summary>
+        /// Outbox type
+        /// </summary>
+        Outbox = 2,
+        /// <summary>
+        /// Sentbox type
+        /// </summary>
+        Sentbox = 3,
+        /// <summary>
+        /// Draft type
+        /// </summary>
+        Draft = 4
+    }
+
+    /// <summary>
+    /// Enumeration for the SIM slot index of a message
+    /// </summary>
+    public enum SimSlotId
+    {
+        /// <summary>
+        /// Unknown SIM Slot
+        /// </summary>
+        Unknown = 0,
+        /// <summary>
+        /// SIM Slot 1
+        /// </summary>
+        Sim1 = 1,
+        /// <summary>
+        /// SIM Slot 2
+        /// </summary>
+        Sim2 = 2
+    }
+
+    /// <summary>
+    /// Enumeration for the recipient type of a message
+    /// </summary>
+    internal enum RecipientType
+    {
+        /// <summary>
+        /// Unknown
+        /// </summary>
+        Unknown = 0,
+        /// <summary>
+        /// 'To' recipient
+        /// </summary>
+        To = 1,
+        /// <summary>
+        /// 'Cc' (carbon copy) recipient
+        /// </summary>
+        Cc = 2,
+        /// <summary>
+        /// 'Bcc' (blind carbon copy) recipient
+        /// </summary>
+        Bcc = 3
+    }
+
+    /// <summary>
+    /// Enumeration for the attachment tyoe for MMS messaging.
+    /// </summary>
+    public enum MediaType
+    {
+        /// <summary>
+        /// Unknown
+        /// </summary>
+        Unknown = 0,
+        /// <summary>
+        /// The image
+        /// </summary>
+        Image = 1,
+        /// <summary>
+        /// The audio
+        /// </summary>
+        Audio = 2,
+        /// <summary>
+        /// The video
+        /// </summary>
+        Video = 3
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesErrorFactory.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesErrorFactory.cs
new file mode 100755 (executable)
index 0000000..c331aab
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Messaging.Messages
+{
+    internal enum MessagesError
+    {
+        None = ErrorCode.None,
+        OutOfMemory = ErrorCode.OutOfMemory,
+        InvalidParameter = ErrorCode.InvalidParameter,
+        ServerNotReady = -0x01710000 | 0x501,
+        CommunicationWithServerFailed = -0x01710000 | 0x502,
+        OutOfRange = -0x01710000 | 0x503,
+        SendingFailed = -0x01710000 | 0x504,
+        OperationFailed = -0x01710000 | 0x505,
+        NoSimCard = -0x01710000 | 0x506,
+        NoData = -0x01710000 | 0x507,
+        PermissionDenied = ErrorCode.PermissionDenied,
+        NotSupported = ErrorCode.NotSupported
+    }
+
+    internal static class MessagesErrorFactory
+    {
+        static internal void ThrowMessagesException(int e)
+        {
+            ThrowException(e, false);
+        }
+
+        static internal void ThrowMessagesException(int e, IntPtr handle)
+        {
+            ThrowException(e, (handle == IntPtr.Zero));
+        }
+
+        static private void ThrowException(int e, bool isHandleNull)
+        {
+            MessagesError err = (MessagesError)e;
+
+            if (isHandleNull)
+            {
+                throw new InvalidOperationException("Invalid instance (object may have been disposed or release)");
+            }
+
+            switch (err)
+            {
+                case MessagesError.OutOfMemory:
+                    throw new OutOfMemoryException(err.ToString());
+                case MessagesError.InvalidParameter:
+                    throw new ArgumentException(err.ToString());
+                case MessagesError.PermissionDenied:
+                    throw new UnauthorizedAccessException(err.ToString());
+                case MessagesError.NotSupported:
+                    throw new NotSupportedException(err.ToString());
+                default:
+                    throw new InvalidOperationException(err.ToString());
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEvent.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesEvent.cs
new file mode 100755 (executable)
index 0000000..dd0d616
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Messaging.Messages
+{
+    internal partial class MessagesManagerImpl
+    {
+        private event EventHandler<MessageReceivedEventArgs> _messageReceived;
+
+        private Interop.Messages.MessageIncomingCallback _messageReceivedCallback;
+
+        internal event EventHandler<MessageReceivedEventArgs> _MessageReceived
+        {
+            add
+            {
+                if (_messageReceived == null)
+                {
+                    RegisterMessageReceivedEvent();
+                }
+                _messageReceived += value;
+            }
+            remove
+            {
+                _messageReceived -= value;
+                if (_messageReceived == null)
+                {
+                    UnregisterMessageReceivedEvent();
+                }
+            }
+        }
+
+        private void RegisterMessageReceivedEvent()
+        {
+            _messageReceivedCallback = (IntPtr messageHandle, IntPtr userData) =>
+            {
+                try
+                {
+                    IntPtr duplicatedMessageHandle = IntPtr.Zero;
+
+                    DuplicateMessageHandle(messageHandle, out duplicatedMessageHandle);
+                    if (duplicatedMessageHandle != IntPtr.Zero)
+                    {
+                        int type = (int)MessageType.Unknown;
+                        int result = Interop.Messages.GetMessageType(duplicatedMessageHandle, out type);
+                        if (result != (int)MessagesError.None)
+                        {
+                            Log.Error(Globals.LogTag, "Failed to get message type, Error - " + (MessagesError)result);
+                        }
+
+                        switch ((MessageType)type)
+                        {
+                            case MessageType.Sms:
+                            {
+                                var receivedMessage = new SmsMessage(duplicatedMessageHandle);
+                                MessageReceivedEventArgs args = new MessageReceivedEventArgs(receivedMessage);
+                                _messageReceived?.Invoke(null, args);
+                                break;
+                            }
+                            case MessageType.Mms:
+                            {
+                                var receivedMessage = new MmsMessage(duplicatedMessageHandle);
+                                MessageReceivedEventArgs args = new MessageReceivedEventArgs(receivedMessage);
+                                _messageReceived?.Invoke(null, args);
+                                break;
+                            }
+                            case MessageType.CellBroadcast:
+                            {
+                                var receivedMessage = new CBMessage(duplicatedMessageHandle);
+                                MessageReceivedEventArgs args = new MessageReceivedEventArgs(receivedMessage);
+                                _messageReceived?.Invoke(null, args);
+                                break;
+                            }
+                            case MessageType.Push:
+                            {
+                                var receivedMessage = new PushMessage(duplicatedMessageHandle);
+                                MessageReceivedEventArgs args = new MessageReceivedEventArgs(receivedMessage);
+                                _messageReceived?.Invoke(null, args);
+                                break;
+                            }
+                            default:
+                            {
+                                Log.Error(Globals.LogTag, "Invaild message type - " + type);
+                                break;
+                            }
+                        }
+                    }
+                }
+                catch
+                {
+                    Log.Error(Globals.LogTag, "Exception in Callback");
+                }
+            };
+
+            int ret = Interop.Messages.SetMessageIncomingCb(_MessageServiceHandle, _messageReceivedCallback, IntPtr.Zero);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to set message incoming callback, Error - " + (MessagesError)ret);
+            }
+        }
+
+        private void UnregisterMessageReceivedEvent()
+        {
+            int ret = Interop.Messages.UnsetMessageIncomingCb(_MessageServiceHandle);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to unset message incoming callback, Error - " + (MessagesError)ret);
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManager.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManager.cs
new file mode 100755 (executable)
index 0000000..6b23ffa
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class for message management. It allows applications to use message service.
+    /// </summary>
+    /// <privilege>http://tizen.org/privilege/message.read</privilege>
+    public static class MessagesManager
+    {
+        /// <summary>
+        /// Sends a message.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/message.write</privilege>
+        /// <param name="message">The message to be sent</param>
+        /// <param name="saveToSentbox">The boolean variable to indicate sent message should be saved in sentbox or not</param>
+        /// <returns>A task contains the result of message sending</returns>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when message service is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when input coordinates are invalid</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public static Task<SentResult> SendMessageAsync(Message message, bool saveToSentbox)
+        {
+            return MessagesManagerImpl.Instance.SendMessageAsync(message, saveToSentbox);
+        }
+
+        /// <summary>
+        /// Searches for messages.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/message.read</privilege>
+        /// <param name="filter">The search filter for searching messages</param>
+        /// <returns>A task contains the messages which fit with search filter</returns>
+        /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
+        /// <exception cref="NotSupportedException">Thrown when message service is not supported</exception>
+        /// <exception cref="ArgumentException">Thrown when input coordinates are invalid</exception>
+        /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
+        public static Task<IEnumerable<Message>> SearchMessageAsync(MessagesSearchFilter filter)
+        {
+            return MessagesManagerImpl.Instance.SearchMessageAsync(filter);
+        }
+
+        /// <summary>
+        /// (event) MessageReceived is raised when receiving a message.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/message.read</privilege>
+        static public event EventHandler<MessageReceivedEventArgs> MessageReceived
+        {
+            add
+            {
+                MessagesManagerImpl.Instance._MessageReceived += value;
+            }
+            remove
+            {
+                MessagesManagerImpl.Instance._MessageReceived -= value;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManagerImpl.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesManagerImpl.cs
new file mode 100755 (executable)
index 0000000..63cd9fc
--- /dev/null
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+
+namespace Tizen.Messaging.Messages
+{
+    static internal class Globals
+    {
+        internal const string LogTag = "Tizen.Messaging.Messages";
+    }
+
+    internal partial class MessagesManagerImpl : IDisposable
+    {
+        private static readonly MessagesManagerImpl _instance = new MessagesManagerImpl();
+        private bool disposed = false;
+
+        private static IntPtr _MessageServiceHandle;
+
+        private Interop.Messages.MessageSentCallback _messageSentCallback;
+
+        internal static MessagesManagerImpl Instance
+        {
+            get
+            {
+                return _instance;
+            }
+        }
+
+        private MessagesManagerImpl()
+        {
+            initialize();
+        }
+
+        ~MessagesManagerImpl()
+        {
+            Dispose(false);
+        }
+
+        public void Dispose()
+        {
+            Dispose(true);
+            GC.SuppressFinalize(this);
+        }
+
+        private void Dispose(bool disposing)
+        {
+            if (disposed)
+                return;
+
+            if (disposing)
+            {
+                // Free managed objects
+            }
+
+            // Free unmanaged objects
+            deinitialize();
+            disposed = true;
+        }
+
+        private void initialize()
+        {
+            int ret;
+
+            ret = Interop.Messages.OpenService(out _MessageServiceHandle);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to open service, Error - " + (MessagesError)ret);
+                MessagesErrorFactory.ThrowMessagesException(ret);
+            }
+        }
+
+        private void deinitialize()
+        {
+            if (_MessageServiceHandle != IntPtr.Zero)
+            {
+                int ret;
+
+                ret = Interop.Messages.CloseService(_MessageServiceHandle);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to close service, Error - " + (MessagesError)ret);
+                }
+
+                _MessageServiceHandle = IntPtr.Zero;
+            }
+        }
+
+        internal Task<SentResult> SendMessageAsync(Message message, bool saveToSentbox)
+        {
+            var task = new TaskCompletionSource<SentResult>();
+
+            _messageSentCallback = (int result, IntPtr data) =>
+            {
+                task.SetResult((SentResult)result);
+            };
+
+            message.FillHandle();
+
+            int ret;
+            IntPtr messageHandle = message.GetHandle();
+
+            ret = Interop.Messages.SendMessage(_MessageServiceHandle, messageHandle, saveToSentbox, _messageSentCallback, IntPtr.Zero);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to send message, Error - " + (MessagesError)ret);
+                MessagesErrorFactory.ThrowMessagesException(ret, _MessageServiceHandle);
+            }
+
+            return task.Task;
+        }
+
+        internal Task<IEnumerable<Message>> SearchMessageAsync(MessagesSearchFilter filter)
+        {
+            return Task.Run<IEnumerable<Message>>(() =>
+            {
+                List<Message> messageList = new List<Message>();
+                int ret;
+
+                Interop.Messages.MessageSearchCallback callback = (IntPtr messageHandle, int index, int resultCount, int totalCount, IntPtr userData) =>
+                {
+                    try
+                    {
+                        if (messageHandle != IntPtr.Zero)
+                        {
+                            IntPtr duplicatedMessageHandle = IntPtr.Zero;
+
+                            DuplicateMessageHandle(messageHandle, out duplicatedMessageHandle);
+                            if (duplicatedMessageHandle != IntPtr.Zero)
+                            {
+                                int type = (int)MessageType.Unknown;
+                                int result = Interop.Messages.GetMessageType(duplicatedMessageHandle, out type);
+                                if (result != (int)MessagesError.None)
+                                {
+                                    Log.Error(Globals.LogTag, "Failed to get message type, Error - " + (MessagesError)result);
+                                }
+
+                                switch ((MessageType)type)
+                                {
+                                    case MessageType.Sms:
+                                    {
+                                        var messageItem = new SmsMessage(duplicatedMessageHandle);
+                                        messageList.Add(messageItem);
+                                        break;
+                                    }
+                                    case MessageType.Mms:
+                                    {
+                                        var messageItem = new MmsMessage(duplicatedMessageHandle);
+                                        messageList.Add(messageItem);
+                                        break;
+                                    }
+                                    case MessageType.CellBroadcast:
+                                    {
+                                        var messageItem = new CBMessage(duplicatedMessageHandle);
+                                        messageList.Add(messageItem);
+                                        break;
+                                    }
+                                    case MessageType.Push:
+                                    {
+                                        var messageItem = new PushMessage(duplicatedMessageHandle);
+                                        messageList.Add(messageItem);
+                                        break;
+                                    }
+                                    default:
+                                    {
+                                        Log.Error(Globals.LogTag, "Invaild message type - " + type);
+                                        break;
+                                    }
+                                }
+
+                                return true;
+                            }
+                        }
+                    }
+                    catch
+                    {
+                        Log.Error(Globals.LogTag, "Exception in Callback");
+                    }
+
+                    return false;
+                };
+
+                ret = Interop.Messages.SearchMessage(_MessageServiceHandle, (int)filter.MessageBoxType, (int)filter.MessageType, filter.TextKeyword, filter.AddressKeyword, 0, 0, callback, IntPtr.Zero);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to search message, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _MessageServiceHandle);
+                }
+
+                return messageList;
+            });
+        }
+
+        private void DuplicateMessageHandle(IntPtr sourceHandle, out IntPtr clonedHandle)
+        {
+            int msgId;
+            IntPtr returnedHandle = IntPtr.Zero;
+
+            int ret = Interop.Messages.GetMessageId(sourceHandle, out msgId);
+            if (ret == (int)MessagesError.None)
+            {
+                ret = Interop.Messages.GetMessageById(_MessageServiceHandle, msgId, out returnedHandle);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get message by id, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _MessageServiceHandle);
+                }
+            }
+            else
+            {
+                Log.Error(Globals.LogTag, "Failed to get message id, Error - " + (MessagesError)ret);
+                MessagesErrorFactory.ThrowMessagesException(ret, _MessageServiceHandle);
+            }
+
+            clonedHandle = returnedHandle;
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesSearchFilter.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MessagesSearchFilter.cs
new file mode 100755 (executable)
index 0000000..6561463
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class to represent message search filters.
+    /// </summary>
+    public class MessagesSearchFilter
+    {
+        /// <summary>
+        /// Create a search filter for searching messages.
+        /// </summary>
+        public MessagesSearchFilter()
+        {
+        }
+
+        /// <summary>
+        /// The message box type
+        /// </summary>
+        public MessageBoxType MessageBoxType { get; set; }
+        /// <summary>
+        /// The message type
+        /// </summary>
+        public MessageType MessageType { get; set; }
+        /// <summary>
+        /// The keyword to search in the text and subject
+        /// </summary>
+        public string TextKeyword { get; set; }
+        /// <summary>
+        /// The recipient address
+        /// </summary>
+        public string AddressKeyword { get; set; }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/MmsMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/MmsMessage.cs
new file mode 100755 (executable)
index 0000000..f73310a
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class to represent multimedia messages.
+    /// </summary>
+    public class MmsMessage : Message
+    {
+        private IList<MessagesAttachment> _attachment = new List<MessagesAttachment>();
+
+        /// <summary>
+        /// Creates a multimedia message.
+        /// </summary>
+        public MmsMessage() : base(MessageType.Mms)
+        {
+        }
+
+        internal MmsMessage(IntPtr messageHandle) : base(messageHandle)
+        {
+            GetAllAttachments();
+        }
+
+        /// <summary>
+        /// The subject of the multimedia message
+        /// </summary>
+        public string Subject
+        {
+            get
+            {
+                string subject = null;
+                int ret = Interop.Messages.GetSubject(_messageHandle, out subject);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get subject, Error - " + (MessagesError)ret);
+                }
+
+                return subject;
+            }
+            set
+            {
+                int ret = Interop.Messages.SetSubject(_messageHandle, value);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to set subject, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+                }
+            }
+        }
+
+        /// <summary>
+        /// Collection of normal message recipients
+        /// </summary>
+        public ICollection<MessagesAddress> To
+        {
+            get
+            {
+                return _to;
+            }
+        }
+
+        /// <summary>
+        /// Collection of CC(carbon copy) message recipients
+        /// </summary>
+        public ICollection<MessagesAddress> Cc
+        {
+            get
+            {
+                return _cc;
+            }
+        }
+
+        /// <summary>
+        /// Collection of BCC(blind carbon copy) message recipients
+        /// </summary>
+        public ICollection<MessagesAddress> Bcc
+        {
+            get
+            {
+                return _bcc;
+            }
+        }
+
+        /// <summary>
+        /// The list of attachment files
+        /// </summary>
+        public IList<MessagesAttachment> Attachments
+        {
+            get
+            {
+                return _attachment;
+            }
+        }
+
+        internal void SetAttachments()
+        {
+            foreach (var it in _attachment)
+            {
+                AddAttachment(it);
+            }
+        }
+
+        private void AddAttachment(MessagesAttachment attach)
+        {
+            int ret = Interop.Messages.AddAttachment(_messageHandle, (int)attach.Type, attach.FilePath);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to add attachment, Error - " + (MessagesError)ret);
+                MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+            }
+        }
+
+        private void GetAllAttachments()
+        {
+            int count;
+
+            int ret = Interop.Messages.GetAttachmentCount(_messageHandle, out count);
+            if (ret != (int)MessagesError.None)
+            {
+                Log.Error(Globals.LogTag, "Failed to get attachment count, Error - " + (MessagesError)ret);
+                MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+            }
+
+            string path;
+            int type;
+            var attachmentList = new List<MessagesAttachment>();
+
+            for (int i = 0; i < count; i++)
+            {
+                ret = Interop.Messages.GetAttachment(_messageHandle, i, out type, out path);
+                if (ret != (int)MessagesError.None)
+                {
+                    Log.Error(Globals.LogTag, "Failed to get attachment, Error - " + (MessagesError)ret);
+                    MessagesErrorFactory.ThrowMessagesException(ret, _messageHandle);
+                }
+
+                var attachmentItem = new MessagesAttachment((MediaType)type, path);
+                attachmentList.Add(attachmentItem);
+            }
+
+            _attachment = attachmentList;
+        }
+
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/NamespaceDoc.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/NamespaceDoc.cs
new file mode 100755 (executable)
index 0000000..45d5a8e
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/// <summary>
+/// The <b>Tizen.Messaging.Messages</b> namespace contains classes providing functionality to send, receive and search for messages.
+/// </summary>
+/// <remarks>
+/// The <b>Tizen.Messaging.Messages</b> namespace contains classes providing functionality to send, receive and search for messages.
+/// </remarks>
+namespace Tizen.Messaging.Messages
+{
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/PushMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/PushMessage.cs
new file mode 100755 (executable)
index 0000000..667e7ff
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class to represent WAP push messages.
+    /// </summary>
+    public class PushMessage : Message
+    {
+        internal PushMessage(IntPtr messageHandle) : base(messageHandle)
+        {
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.Messages/SmsMessage.cs b/src/Tizen.Messaging/Tizen.Messaging.Messages/SmsMessage.cs
new file mode 100755 (executable)
index 0000000..62ffd1e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Messaging.Messages
+{
+    /// <summary>
+    /// A class to represent short text messages.
+    /// </summary>
+    public class SmsMessage : Message
+    {
+        /// <summary>
+        /// Creates a short text message.
+        /// </summary>
+        public SmsMessage() : base(MessageType.Sms)
+        {
+        }
+
+        internal SmsMessage(IntPtr messageHandle) : base(messageHandle)
+        {
+        }
+
+        /// <summary>
+        /// Collection of normal message recipients
+        /// </summary>
+        public ICollection<MessagesAddress> To
+        {
+            get
+            {
+                return _to;
+            }
+        }
+    }
+}
diff --git a/src/Tizen.Messaging/Tizen.Messaging.csproj b/src/Tizen.Messaging/Tizen.Messaging.csproj
new file mode 100644 (file)
index 0000000..0b49714
--- /dev/null
@@ -0,0 +1,26 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <Version>1.0.3</Version>
+    <Authors>Samsung Electronics</Authors>
+    <Copyright>© Samsung Electronics Co., Ltd All Rights Reserved</Copyright>
+    <Description>Provides the Messaging APIs for Tizen .NET</Description>
+    <PackageProjectUrl>https://www.tizen.org/</PackageProjectUrl>
+    <PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
+    <PackageIconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</PackageIconUrl>
+  </PropertyGroup>
+
+  <PropertyGroup>
+    <TargetFramework>netstandard1.3</TargetFramework>
+    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+    <SignAssembly>True</SignAssembly>
+    <AssemblyOriginatorKeyFile>Tizen.Messaging.snk</AssemblyOriginatorKeyFile>
+    <PublicSign Condition="'$(OS)' != 'Windows_NT'">true</PublicSign>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Tizen" Version="1.0.5" />
+  </ItemGroup>
+
+</Project>
+
diff --git a/src/Tizen.Messaging/Tizen.Messaging.snk b/src/Tizen.Messaging/Tizen.Messaging.snk
new file mode 100755 (executable)
index 0000000..8694442
Binary files /dev/null and b/src/Tizen.Messaging/Tizen.Messaging.snk differ