Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Messaging / Tizen.Messaging.Messages / MessagesManager.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using System.Collections.Generic;
19 using System.Threading.Tasks;
20
21 namespace Tizen.Messaging.Messages
22 {
23     /// <summary>
24     /// A class for message management. It allows applications to use message service.
25     /// </summary>
26     /// <privilege>http://tizen.org/privilege/message.read</privilege>
27     public static class MessagesManager
28     {
29         /// <summary>
30         /// Sends a message.
31         /// </summary>
32         /// <privilege>http://tizen.org/privilege/message.write</privilege>
33         /// <param name="message">The message to be sent</param>
34         /// <param name="saveToSentbox">The boolean variable to indicate sent message should be saved in sentbox or not</param>
35         /// <returns>A task contains the result of message sending</returns>
36         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
37         /// <exception cref="NotSupportedException">Thrown when message service is not supported</exception>
38         /// <exception cref="ArgumentException">Thrown when input coordinates are invalid</exception>
39         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
40         public static Task<SentResult> SendMessageAsync(Message message, bool saveToSentbox)
41         {
42             return MessagesManagerImpl.Instance.SendMessageAsync(message, saveToSentbox);
43         }
44
45         /// <summary>
46         /// Searches for messages.
47         /// </summary>
48         /// <privilege>http://tizen.org/privilege/message.read</privilege>
49         /// <param name="filter">The search filter for searching messages</param>
50         /// <returns>A task contains the messages which fit with search filter</returns>
51         /// <exception cref="InvalidOperationException">Thrown when method failed due to invalid operation</exception>
52         /// <exception cref="NotSupportedException">Thrown when message service is not supported</exception>
53         /// <exception cref="ArgumentException">Thrown when input coordinates are invalid</exception>
54         /// <exception cref="OutOfMemoryException">Thrown when failed due to out of memory</exception>
55         /// <exception cref="UnauthorizedAccessException">Thrown when application does not have proper privileges</exception>
56         public static Task<IEnumerable<Message>> SearchMessageAsync(MessagesSearchFilter filter)
57         {
58             return MessagesManagerImpl.Instance.SearchMessageAsync(filter);
59         }
60
61         /// <summary>
62         /// (event) MessageReceived is raised when receiving a message.
63         /// </summary>
64         /// <privilege>http://tizen.org/privilege/message.read</privilege>
65         static public event EventHandler<MessageReceivedEventArgs> MessageReceived
66         {
67             add
68             {
69                 MessagesManagerImpl.Instance._MessageReceived += value;
70             }
71             remove
72             {
73                 MessagesManagerImpl.Instance._MessageReceived -= value;
74             }
75         }
76     }
77 }