Update the summary that describes the class
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.NotificationEventListener / Tizen.Applications.NotificationEventListener / NotificationEventArgs.cs
1 /*
2  * Copyright (c) 2017 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 namespace Tizen.Applications.NotificationEventListener
18 {
19     using System;
20     using System.Collections.Generic;
21     using System.ComponentModel;
22
23     /// <summary>
24     /// This class provides the methods and properties to get information about the posted or updated notification.
25     /// </summary>
26     public partial class NotificationEventArgs
27     {
28         private const string LogTag = "Tizen.Applications.NotificationEventListener";
29
30         internal IDictionary<string, StyleArgs> Style;
31         internal IDictionary<string, Bundle> Extender;
32         internal Interop.NotificationEventListener.SafeNotificationHandle Handle;
33
34         /// <summary>
35         /// Initializes a new instance of the <see cref="NotificationEventArgs"/> class.
36         /// </summary>
37         public NotificationEventArgs()
38         {
39             Style = new Dictionary<string, StyleArgs>();
40             Extender = new Dictionary<string, Bundle>();
41         }
42
43         /// <summary>
44         /// Gets the unique id of Notification.
45         /// </summary>
46         /// <example>
47         /// <code>
48         /// int uniqueNumber = NotificationEventArgs.UniqueNumber;
49         /// </code>
50         /// </example>
51         public int UniqueNumber { get; internal set; }
52
53         /// <summary>
54         /// Gets the appId of Notification.
55         /// </summary>
56         /// <example>
57         /// <code>
58         /// string appId = NotificationEventArgs.AppID;
59         /// </code>
60         /// </example>
61         public string AppID { get; internal set; }
62
63         /// <summary>
64         /// Gets the title of Notification.
65         /// </summary>
66         /// <example>
67         /// <code>
68         /// string title = NotificationEventArgs.Title;
69         /// </code>
70         /// </example>
71         public string Title { get; internal set; }
72
73         /// <summary>
74         /// Gets the content text of Notification.
75         /// </summary>
76         /// <example>
77         /// <code>
78         /// string content = NotificationEventArgs.Content;
79         /// </code>
80         /// </example>
81         public string Content { get; internal set; }
82
83         /// <summary>
84         /// Gets the icon's path of Notification.
85         /// </summary>
86         /// <example>
87         /// <code>
88         /// string icon = NotificationEventArgs.Icon;
89         /// </code>
90         /// </example>
91         public string Icon { get; internal set; }
92
93         /// <summary>
94         /// Gets the sub icon path of Notification.
95         /// </summary>
96         /// <example>
97         /// <code>
98         /// string subIcon = NotificationEventArgs.SubIcon;
99         /// </code>
100         /// </example>
101         public string SubIcon { get; internal set; }
102
103         /// <summary>
104         /// Gets the Timestamp of notification is visible or not.
105         /// </summary>
106         public bool IsTimeStampVisible { get; internal set; }
107
108         /// <summary>
109         /// Gets time of Notification.
110         /// </summary>
111         /// <example>
112         /// <code>
113         /// DateTime timeStamp = NotificationEventArgs.TimeStamp;
114         /// </code>
115         /// </example>
116         public DateTime TimeStamp { get; internal set; }
117
118         /// <summary>
119         /// Gets the count which is displayed at the right side of notification.
120         /// </summary>
121         /// <example>
122         /// <code>
123         /// int count = NotificationEventArgs.Count;
124         /// </code>
125         /// </example>
126         public int Count { get; internal set; }
127
128         /// <summary>
129         /// Gets the Tag of notification.
130         /// </summary>
131         /// <example>
132         /// <code>
133         /// string tag = NotificationEventArgs.Tag;
134         /// </code>
135         /// </example>
136         public string Tag { get; internal set; }
137
138         /// <summary>
139         /// Gets a value to check if it is an ongoing type.
140         /// </summary>
141         /// <example>
142         /// <code>
143         /// bool isongoing = NotificationEventArgs.IsOngoing;
144         /// </code>
145         /// </example>
146         [EditorBrowsable(EditorBrowsableState.Never)]
147         public bool IsOngoing { get; internal set; } = false;
148
149         /// <summary>
150         /// Gets a value that determines whether notification is displayed on the default viewer.
151         /// If you set false and add style, you can see only style notification.
152         /// </summary>
153         /// <example>
154         /// <code>
155         /// bool isDisplay = NotificationEventArgs.IsDisplay;
156         /// </code>
157         /// </example>
158         public bool IsDisplay { get; internal set; } = true;
159
160         /// <summary>
161         /// Gets the event flag.
162         /// </summary>
163         /// <example>
164         /// <code>
165         /// bool eventFlag = NotificationEventArgs.HasEventFlag;
166         /// </code>
167         /// </example>
168         [EditorBrowsable(EditorBrowsableState.Never)]
169         public bool HasEventFlag { get; internal set; } = false;
170
171         /// <summary>
172         /// Gets the AppControl which is invoked when notification is clicked.
173         /// </summary>
174         /// <example>
175         /// <code>
176         /// AppControl action = NotificationEventArgs.Action;
177         /// </code>
178         /// </example>
179         public AppControl Action { get; internal set; }
180
181         /// <summary>
182         /// Gets the object of the progress notification.
183         /// </summary>
184         /// <example>
185         /// <code>
186         /// ProgressCategory category = NotificationEventArgs.Progress.Category;
187         /// double current = NotificationEventArgs.Progress.Current;
188         /// double max = NotificationEventArgs.Progress.Max;
189         /// </code>
190         /// </example>
191         public ProgressArgs Progress { get; internal set; }
192
193         /// <summary>
194         /// Gets the AccessoryArgs which has option of Sound, Vibration, LED.
195         /// </summary>
196         /// <example>
197         /// <code>
198         /// string soundPath = NotificationEventArgs.Accessory.SountPath;
199         /// </code>
200         /// </example>
201         public AccessoryArgs Accessory { get; internal set; }
202
203         /// <summary>
204         /// Gets the key for extender.
205         /// </summary>
206         /// <example>
207         /// <code>
208         /// ICollection<string> extenderkey = NotificationEventArgs.ExtenderKey;
209         /// foreach (string key in extenderkey)
210         /// {
211         /// ...
212         /// }
213         /// </code>
214         /// </example>
215         public ICollection<string> ExtenderKey
216         {
217             get
218             {
219                 return Extender.Keys;
220             }
221         }
222
223         /// <summary>
224         /// Gets the property.
225         /// </summary>
226         /// <example>
227         /// <code>
228         /// int property = NotificationEventArgs.Property;
229         /// </code>
230         /// </example>
231         public NotificationProperty Property { get; internal set; }
232
233         /// <summary>
234         /// Gets the styleArgs of active, lock, indicator, bigpicture.
235         /// </summary>
236         /// <typeparam name="T">Type of notification style to be queried</typeparam>
237         /// <returns>The Notification.Style object associated with the given style</returns>
238         /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
239         /// <example>
240         /// <code>
241         /// NotificationEventArgs.ActiveStyleArgs style = NotificationEventArgs.GetStyle<NotificationEventArgs.ActiveStyleArgs>();
242         /// autoremove = style.IsAutoRemove;
243         /// </code>
244         /// </example>
245         public T GetStyle<T>() where T : StyleArgs, new()
246         {
247             T type = new T();
248             StyleArgs style = null;
249
250             Style.TryGetValue(type.Key, out style);
251
252             if (style == null)
253             {
254                 Log.Error(LogTag, "Invalid Style");
255                 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
256             }
257             else
258             {
259                 return style as T;
260             }
261         }
262
263         /// <summary>
264         /// Gets the ExtenderArgs.
265         /// </summary>
266         /// <param name="key">The key that specifies which extender</param>
267         /// <returns>Returns the bundle for key</returns>
268         /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
269         /// <example>
270         /// <code>
271         /// Bundle extender = NotificationEventArgs.GetExtender("key");
272         /// </code>
273         /// </example>
274         public Bundle GetExtender(string key)
275         {
276             Bundle bundle;
277
278             if (string.IsNullOrEmpty(key))
279             {
280                 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered");
281             }
282
283             if (Extender.TryGetValue(key, out bundle) == false)
284             {
285                 throw NotificationEventListenerErrorFactory.GetException(Interop.NotificationEventListener.ErrorCode.InvalidParameter, "invalid parameter entered : " + key);
286             }
287
288             return bundle;
289         }
290     }
291 }