2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 using Tizen.Applications;
20 namespace Tizen.Content.Download
23 /// The Notification class consists of all the properties required to set notifications for download operation.
25 /// <since_tizen> 3 </since_tizen>
26 public class Notification
28 private int _downloadId;
30 internal Notification(int requestId)
32 _downloadId = requestId;
36 /// Title of the notification.
37 /// If user tries to get before setting, empty string is returned.
39 /// <since_tizen> 3 </since_tizen>
40 /// <privilege>http://tizen.org/privilege/download</privilege>
41 /// <exception cref="ArgumentException">Thrown when it is failed due to an invalid parameter.</exception>
42 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation</exception>
43 /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
49 int ret = Interop.Download.GetNotificationTitle(_downloadId, out title);
50 if (ret != (int)DownloadError.None)
52 Log.Error(Globals.LogTag, "Failed to get Notification Title, " + (DownloadError)ret);
59 int ret = Interop.Download.SetNotificationTitle(_downloadId, value.ToString());
60 if (ret != (int)DownloadError.None)
62 DownloadErrorFactory.ThrowException(ret, "Failed to set Notification Title");
68 /// Description of the notification.
69 /// If user tries to get before setting, empty string is returned.
71 /// <since_tizen> 3 </since_tizen>
72 /// <privilege>http://tizen.org/privilege/download</privilege>
73 /// <exception cref="ArgumentException">Thrown when it is failed due to an invalid parameter.</exception>
74 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation</exception>
75 /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
76 public string Description
81 int ret = Interop.Download.GetNotificationDescription(_downloadId, out description);
82 if (ret != (int)DownloadError.None)
84 Log.Error(Globals.LogTag, "Failed to get Notification Description, " + (DownloadError)ret);
91 int ret = Interop.Download.SetNotificationDescription(_downloadId, value.ToString());
92 if (ret != (int)DownloadError.None)
94 DownloadErrorFactory.ThrowException(ret, "Failed to set Notification Description");
100 /// Type of Notification.
101 /// If user tries to get before setting, default NotificationType None is returned.
103 /// <since_tizen> 3 </since_tizen>
104 /// <privilege>http://tizen.org/privilege/download</privilege>
105 /// <exception cref="ArgumentException">Thrown when it is failed due to an invalid parameter.</exception>
106 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation</exception>
107 /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
108 public NotificationType Type
113 int ret = Interop.Download.GetNotificationType(_downloadId, out type);
114 if (ret != (int)DownloadError.None)
116 Log.Error(Globals.LogTag, "Failed to get NotificationType, " + (DownloadError)ret);
119 return (NotificationType)type;
123 int ret = Interop.Download.SetNotificationType(_downloadId, (int)value);
124 if (ret != (int)DownloadError.None)
126 DownloadErrorFactory.ThrowException(ret, "Failed to set NotificationType");
132 /// AppControl for an ongoing download notification.
133 /// If user tries to get before setting, null is returned.
135 /// <since_tizen> 3 </since_tizen>
136 /// <privilege>http://tizen.org/privilege/download</privilege>
138 /// When the notification message is clicked, the action is decided by the app control.
140 /// <exception cref="ArgumentException">Thrown when it is failed due to an invalid parameter.</exception>
141 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation</exception>
142 /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
143 public AppControl AppControlOngoing
147 SafeAppControlHandle handle;
148 int ret = Interop.Download.GetNotificationAppControl(_downloadId, (int)NotificationAppControlType.Downloading, out handle);
149 if (ret != (int)DownloadError.None)
151 Log.Error(Globals.LogTag, "Failed to get Ongoing type NotificationAppControl, " + (DownloadError)ret);
154 return new AppControl(handle);
158 int ret = Interop.Download.SetNotificationAppControl(_downloadId, (int)NotificationAppControlType.Downloading, value.SafeAppControlHandle);
159 if (ret != (int)DownloadError.None)
161 DownloadErrorFactory.ThrowException(ret, "Failed to set Ongoing type NotificationAppControl");
167 /// AppControl for a completed download notification.
168 /// If user tries to get before setting, null is returned.
170 /// <since_tizen> 3 </since_tizen>
171 /// <privilege>http://tizen.org/privilege/download</privilege>
173 /// When the notification message is clicked, the action is decided by the app control
175 /// <exception cref="ArgumentException">Thrown when it is failed due to an invalid parameter.</exception>
176 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation</exception>
177 /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
178 public AppControl AppControlCompleted
182 SafeAppControlHandle handle;
183 int ret = Interop.Download.GetNotificationAppControl(_downloadId, (int)NotificationAppControlType.Completed, out handle);
184 if (ret != (int)DownloadError.None)
186 Log.Error(Globals.LogTag, "Failed to get Complete type NotificationAppControl, " + (DownloadError)ret);
189 return new AppControl(handle);
193 int ret = Interop.Download.SetNotificationAppControl(_downloadId, (int)NotificationAppControlType.Completed, value.SafeAppControlHandle);
194 if (ret != (int)DownloadError.None)
196 DownloadErrorFactory.ThrowException(ret, "Failed to set Complete type NotificationAppControl");
202 /// AppControl for a failed download notification.
203 /// If user tries to get before setting, null is returned.
205 /// <since_tizen> 3 </since_tizen>
206 /// <privilege>http://tizen.org/privilege/download</privilege>
208 /// When the notification message is clicked, the action is decided by the app control
210 /// <exception cref="ArgumentException">Thrown when it is failed due to an invalid parameter.</exception>
211 /// <exception cref="InvalidOperationException">Thrown when it is failed due to invalid operation</exception>
212 /// <exception cref="UnauthorizedAccessException">Thrown when permission is denied.</exception>
213 public AppControl AppControlFailed
217 SafeAppControlHandle handle;
218 int ret = Interop.Download.GetNotificationAppControl(_downloadId, (int)NotificationAppControlType.Failed, out handle);
219 if (ret != (int)DownloadError.None)
221 Log.Error(Globals.LogTag, "Failed to get Fail type NotificationAppControl, " + (DownloadError)ret);
224 return new AppControl(handle);
228 int ret = Interop.Download.SetNotificationAppControl(_downloadId, (int)NotificationAppControlType.Failed, value.SafeAppControlHandle);
229 if (ret != (int)DownloadError.None)
231 DownloadErrorFactory.ThrowException(ret, "Failed to set Fail type NotificationAppControl");