--- /dev/null
+bin/
+obj/
+*.exe
+*.dll
+*.csproj.user
+*.lock.json
+.vs/
--- /dev/null
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
--- /dev/null
+/*
+ * 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_recipient")]
+ 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);
+ }
+}
--- /dev/null
+/*
+ * 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";
+ }
+}
--- /dev/null
+/*
+ * 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);
+
+ }
+}
--- /dev/null
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Tizen.Messaging")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Samsung Electronics")]
+[assembly: AssemblyProduct("Tizen.Messaging")]
+[assembly: AssemblyCopyright("Copyright (c) 2016 Samsung Electronics Co., Ltd")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("1f097c95-dedf-47f2-bc90-eef737fee686")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
--- /dev/null
+/*
+ * 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; }
+ }
+}
--- /dev/null
+/*
+* 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
+ }
+}
--- /dev/null
+/*
+ * 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");
+ }
+ }
+ }
+}
--- /dev/null
+/*
+* 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>
+ /// <remarks>
+ /// The maximum attachment file size is 10 MB.
+ /// </remarks>
+ 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;
+ }
+ }
+
+ /// <summary>
+ /// Saves the email message
+ /// </summary>
+ public 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);
+ }
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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; }
+ }
+}
--- /dev/null
+/*
+ * 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>
+ /// <param name="saveToSentBox">true to save the message in the sentbox</param>
+ /// <returns> Failure if email sending failed otherwise Success</returns>
+ public static async Task<EmailSendResult> SendAsync(EmailMessage email, bool saveToSentBox)
+ {
+ var task = new TaskCompletionSource<EmailSendResult>();
+ int ret = (int)EmailError.None;
+
+ 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;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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)
+ {
+ }
+ }
+}
--- /dev/null
+/*
+* 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
+ {
+ protected IntPtr _messageHandle = IntPtr.Zero;
+ private bool disposed = false;
+
+ private MessagesAddress _from = null;
+ protected ICollection<MessagesAddress> _to = new Collection<MessagesAddress>();
+ protected ICollection<MessagesAddress> _cc = new Collection<MessagesAddress>();
+ protected ICollection<MessagesAddress> _bcc = new Collection<MessagesAddress>();
+
+ protected 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);
+ }
+ }
+
+ protected Message(IntPtr messageHandle)
+ {
+ _messageHandle = messageHandle;
+ GetAllAddresses();
+ }
+
+ internal void FillHandle()
+ {
+ SetAddresses();
+ (this as MmsMessage)?.SetAttachments();
+ }
+
+ ~Message()
+ {
+ 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
+ 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>();
+
+ 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 = addressItem;
+ break;
+ }
+ }
+
+ _to = To;
+ _cc = Cc;
+ _bcc = Bcc;
+ }
+
+ 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;
+ }
+ }
+
+ 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;
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ 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);
+ }
+ }
+ }
+
+ public MessagesAddress From
+ {
+ get
+ {
+ return _from;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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
+{
+ public class MessageReceivedEventArgs : EventArgs
+ {
+ private Message _message;
+
+ internal MessageReceivedEventArgs(Message message)
+ {
+ _message = message;
+ }
+
+ public Message ReceivedMessage
+ {
+ get
+ {
+ return _message;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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;
+ 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;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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
+ {
+ public MediaType Type { get; }
+
+ 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;
+ }
+ }
+}
--- /dev/null
+/*
+* 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 = Mms | 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>
+ SimSlotId1 = 1,
+ /// <summary>
+ /// SIM Slot 2
+ /// </summary>
+ SimSlotId2 = 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
+ }
+}
--- /dev/null
+/*
+ * 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)");
+ }
+
+ if (err == MessagesError.InvalidParameter)
+ {
+ throw new ArgumentException(err.ToString());
+ }
+ else if (err == MessagesError.NotSupported)
+ {
+ throw new NotSupportedException("Not supported");
+ }
+ else
+ {
+ throw new InvalidOperationException(err.ToString());
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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);
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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>
+ 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>
+ 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>
+ public static Task<IEnumerable<Message>> SearchMessageAsync(MessagesSearchFilter filter)
+ {
+ return MessagesManagerImpl.Instance.SearchMessageAsync(filter);
+ }
+
+ /// <summary>
+ /// (event) MessageReceived is raised when receiving a message.
+ /// </summary>
+ static public event EventHandler<MessageReceivedEventArgs> MessageReceived
+ {
+ add
+ {
+ MessagesManagerImpl.Instance._MessageReceived += value;
+ }
+ remove
+ {
+ MessagesManagerImpl.Instance._MessageReceived -= value;
+ }
+ }
+ }
+}
--- /dev/null
+/*
+ * 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;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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
+ {
+ public MessageBoxType MessageBoxType { get; set; }
+ public MessageType MessageType { get; set; }
+ public string TextKeyword { get; set; }
+ public string AddressKeyword { get; set; }
+ }
+}
--- /dev/null
+/*
+ * 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();
+ }
+
+ 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);
+ }
+ }
+ }
+
+ public ICollection<MessagesAddress> To
+ {
+ get
+ {
+ return _to;
+ }
+ }
+
+ public ICollection<MessagesAddress> Cc
+ {
+ get
+ {
+ return _cc;
+ }
+ }
+
+ public ICollection<MessagesAddress> Bcc
+ {
+ get
+ {
+ return _bcc;
+ }
+ }
+
+ 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;
+ }
+
+ }
+}
--- /dev/null
+/*
+ * 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)
+ {
+ }
+ }
+}
--- /dev/null
+/*
+ * 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)
+ {
+ }
+
+ public ICollection<MessagesAddress> To
+ {
+ get
+ {
+ return _to;
+ }
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup>\r
+ <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>\r
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>\r
+ <ProductVersion>8.0.30703</ProductVersion>\r
+ <SchemaVersion>2.0</SchemaVersion>\r
+ <ProjectGuid>{1F097C95-DEDF-47F2-BC90-EEF737FEE686}</ProjectGuid>\r
+ <OutputType>Library</OutputType>\r
+ <AppDesignerFolder>Properties</AppDesignerFolder>\r
+ <RootNamespace>Tizen.Messaging</RootNamespace>\r
+ <AssemblyName>Tizen.Messaging</AssemblyName>\r
+ <FileAlignment>512</FileAlignment>\r
+ <DefaultLanguage>en-US</DefaultLanguage>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <TargetFrameworkIdentifier>.NETStandard</TargetFrameworkIdentifier>\r
+ <TargetFrameworkVersion>v1.3</TargetFrameworkVersion>\r
+ <NuGetTargetMoniker>.NETStandard,Version=v1.3</NuGetTargetMoniker>\r
+ <AddAdditionalExplicitAssemblyReferences>false</AddAdditionalExplicitAssemblyReferences>\r
+ <NoStdLib>true</NoStdLib>\r
+ <NoWarn>$(NoWarn);1701</NoWarn>\r
+ <UseVSHostingProcess>false</UseVSHostingProcess>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">\r
+ <DebugSymbols>true</DebugSymbols>\r
+ <DebugType>full</DebugType>\r
+ <Optimize>false</Optimize>\r
+ <OutputPath>bin\Debug\</OutputPath>\r
+ <DefineConstants>DEBUG;TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">\r
+ <DebugType>pdbonly</DebugType>\r
+ <Optimize>true</Optimize>\r
+ <OutputPath>bin\Release\</OutputPath>\r
+ <DefineConstants>TRACE</DefineConstants>\r
+ <ErrorReport>prompt</ErrorReport>\r
+ <WarningLevel>4</WarningLevel>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <SignAssembly>true</SignAssembly>\r
+ </PropertyGroup>\r
+ <PropertyGroup>\r
+ <AssemblyOriginatorKeyFile>Tizen.Messaging.snk</AssemblyOriginatorKeyFile>\r
+ </PropertyGroup>\r
+ <ItemGroup>\r
+ <None Include="Tizen.Messaging.project.json" />\r
+ <None Include="Tizen.Messaging.snk" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Compile Include="Interop\Interop.Email.cs" />\r
+ <Compile Include="Interop\Interop.Libraries.cs" />\r
+ <Compile Include="Interop\Interop.Messages.cs" />\r
+ <Compile Include="Properties\AssemblyInfo.cs" />\r
+ <Compile Include="Tizen.Messaging.Email\EmailSender.cs" />\r
+ <Compile Include="Tizen.Messaging.Email\EmailMessage.cs" />\r
+ <Compile Include="Tizen.Messaging.Email\EmailAttachment.cs" />\r
+ <Compile Include="Tizen.Messaging.Email\EmailEnumerations.cs" />\r
+ <Compile Include="Tizen.Messaging.Email\EmailErrorFactory.cs" />\r
+ <Compile Include="Tizen.Messaging.Email\EmailRecipient.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessageReceivedEventArgs.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessagesAddress.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessagesAttachment.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\CBMessage.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessagesErrorFactory.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessagesEvent.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessagesManager.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessagesManagerImpl.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessagesEnumerations.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\Message.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MmsMessage.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\PushMessage.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\MessagesSearchFilter.cs" />\r
+ <Compile Include="Tizen.Messaging.Messages\SmsMessage.cs" />\r
+ </ItemGroup>\r
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />\r
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->\r
+ <PropertyGroup>\r
+ <!-- https://github.com/dotnet/corefxlab/tree/master/samples/NetCoreSample and
+ https://docs.microsoft.com/en-us/dotnet/articles/core/tutorials/target-dotnetcore-with-msbuild
+ -->\r
+ <!-- We don't use any of MSBuild's resolution logic for resolving the framework, so just set these two
+ properties to any folder that exists to skip the GetReferenceAssemblyPaths task (not target) and
+ to prevent it from outputting a warning (MSB3644).
+ -->\r
+ <_TargetFrameworkDirectories>$(MSBuildThisFileDirectory)</_TargetFrameworkDirectories>\r
+ <_FullFrameworkReferenceAssemblyPaths>$(MSBuildThisFileDirectory)</_FullFrameworkReferenceAssemblyPaths>\r
+ <AutoUnifyAssemblyReferences>true</AutoUnifyAssemblyReferences>\r
+ </PropertyGroup>\r
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0"?>
+<package>
+ <metadata>
+ <id>Tizen.Messaging</id>
+ <version>$version$</version>
+ <authors>Samsung Electronics</authors>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <licenseUrl>https://www.apache.org/licenses/LICENSE-2.0</licenseUrl>
+ <projectUrl>https://www.tizen.org/</projectUrl>
+ <iconUrl>https://developer.tizen.org/sites/default/files/images/tizen-pinwheel-on-light-rgb_64_64.png</iconUrl>
+ <copyright>© Samsung Electronics Co., Ltd All Rights Reserved</copyright>
+ <description>Provides the Messaging APIs for Tizen.Messaging</description>
+ <dependencies>
+ <dependency id="Tizen" version="1.0.2" />
+ <dependency id="Tizen.System" version="1.0.5" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="bin/$Configuration$/Tizen.Messaging.dll" target="lib/netstandard1.3" />
+ </files>
+</package>
--- /dev/null
+{\r
+ "dependencies": {\r
+ "NETStandard.Library": "1.6.0",\r
+ "Tizen": "1.0.1"\r
+ },\r
+ "frameworks": {\r
+ "netstandard1.3": {}\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio 14\r
+VisualStudioVersion = 14.0.25420.1\r
+MinimumVisualStudioVersion = 10.0.40219.1\r
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Messaging", "Tizen.Messaging.csproj", "{1F097C95-DEDF-47F2-BC90-EEF737FEE686}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Any CPU = Debug|Any CPU\r
+ Release|Any CPU = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {1F097C95-DEDF-47F2-BC90-EEF737FEE686}.Debug|Any CPU.ActiveCfg = Debug|Any CPU\r
+ {1F097C95-DEDF-47F2-BC90-EEF737FEE686}.Debug|Any CPU.Build.0 = Debug|Any CPU\r
+ {1F097C95-DEDF-47F2-BC90-EEF737FEE686}.Release|Any CPU.ActiveCfg = Release|Any CPU\r
+ {1F097C95-DEDF-47F2-BC90-EEF737FEE686}.Release|Any CPU.Build.0 = Release|Any CPU\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+%{!?dotnet_assembly_path: %define dotnet_assembly_path /opt/usr/share/dotnet.tizen/framework}
+%{!?dotnet_core_path: %define dotnet_core_path %{_datadir}/tizen.net/ref}
+
+%if 0%{?tizen_build_devel_mode}
+%define BUILDCONF Debug
+%else
+%define BUILDCONF Release
+%endif
+
+Name: csapi-messaging
+Summary: Tizen Messaging API for C#
+Version: 1.0.0
+Release: 1
+Group: Development/Libraries
+License: Apache-2.0
+URL: https://www.tizen.org
+Source0: %{name}-%{version}.tar.gz
+Source1: %{name}.manifest
+
+AutoReqProv: no
+
+BuildRequires: mono-compiler
+BuildRequires: mono-devel
+
+BuildRequires: dotnet-build-tools
+
+# C# API Requires
+BuildRequires: csapi-tizen-nuget
+
+%description
+Tizen Messaging API for C#
+
+%prep
+%setup -q
+cp %{SOURCE1} .
+
+%define Assemblies Tizen.Messaging
+
+%build
+for ASM in %{Assemblies}; do
+# NuGet Restore
+find $ASM/*.project.json -exec nuget restore {} \;
+# Build
+find $ASM/*.csproj -exec xbuild {} /p:Configuration=%{BUILDCONF} \;
+# NuGet Pack
+nuget pack $ASM/$ASM.nuspec -Version %{version} -Properties Configuration=%{BUILDCONF}
+
+done
+
+%install
+# Runtime Binary
+mkdir -p %{buildroot}%{dotnet_assembly_path}
+for ASM in %{Assemblies}; do
+%if 0%{?_with_corefx}
+ install -p -m 644 $ASM/bin/%{BUILDCONF}/$ASM.dll %{buildroot}%{dotnet_assembly_path}
+%else
+ install -p -m 644 $ASM/bin/%{BUILDCONF}/Net45/$ASM.dll %{buildroot}%{dotnet_assembly_path}
+%endif
+done
+
+# NuGet
+mkdir -p %{buildroot}/nuget
+install -p -m 644 *.nupkg %{buildroot}/nuget
+
+%files
+%manifest %{name}.manifest
+%license LICENSE
+%attr(644,root,root) %{dotnet_assembly_path}/*.dll
+
+%package nuget
+Summary: NuGet package for %{name}
+Group: Development/Libraries
+
+%description nuget
+NuGet package for %{name}
+
+%files nuget
+/nuget/*.nupkg