[Notification/NotificationEventListener]Fix wrong spelling
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Notification / Tizen.Applications.Notifications / Notification.cs
index ec7202a..8ac2c21 100755 (executable)
@@ -21,7 +21,7 @@ namespace Tizen.Applications.Notifications
     using System.ComponentModel;
 
     /// <summary>
-    /// Class containing common properties and methods of Notifications
+    /// This class contains common properties and methods of notifications.
     /// </summary>
     /// <remarks>
     /// A notification is a message that is displayed on the notification area.
@@ -36,77 +36,89 @@ namespace Tizen.Applications.Notifications
         private bool disposed = false;
 
         private IDictionary<string, StyleBase> styleDictionary;
-        private IDictionary<string, Bundle> extenderDictionary;
+        private IDictionary<string, Bundle> extraDataDictionary;
         private int count = 0;
 
         /// <summary>
         /// Initializes a new instance of the <see cref="Notification"/> class.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public Notification()
         {
             styleDictionary = new Dictionary<string, StyleBase>();
-            extenderDictionary = new Dictionary<string, Bundle>();
+            extraDataDictionary = new Dictionary<string, Bundle>();
         }
 
         /// <summary>
-        /// Gets or sets Tag of Notification.
+        /// Gets or sets the tag of notification.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string Tag { get; set; } = string.Empty;
 
         /// <summary>
-        /// Gets or sets Title of Notification.
+        /// Gets or sets the title of notification.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string Title { get; set; } = string.Empty;
 
         /// <summary>
-        /// Gets or sets icon of Notification.
+        /// Gets or sets the icon of notification.
+        /// You should set an absolute path for an image file.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string Icon { get; set; } = string.Empty;
 
         /// <summary>
-        /// Gets or sets sub icon of Notification.
+        /// Gets or sets the sub icon of notification.
         /// This SubIcon is displayed in Icon you set.
+        /// You should set an absolute path for an image file.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string SubIcon { get; set; } = string.Empty;
 
         /// <summary>
-        /// Gets or sets content of Notification.
+        /// Gets or sets the content of notification.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public string Content { get; set; } = string.Empty;
 
         /// <summary>
-        /// Gets or sets a value indicating whether TimeStamp of Notification is Visible or not.
+        /// Gets or sets a value indicating whether TimeStamp of the notification is Visible or not.
         /// Default to true.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public bool IsTimeStampVisible { get; set; } = true;
 
         /// <summary>
-        /// Gets or sets TimeStamp of Notification.
+        /// Gets or sets the TimeStamp of notification.
         /// </summary>
         /// <remarks>
-        /// If you don't set TimeStamp, It will be set value that time when the notification is posted.
+        /// If you don't set TimeStamp, it will set the value when the notification is posted.
         /// TimeStamp requires NotificationManager.Post() to be called.
-        /// If you set IsVisibleTimeStamp property is false, TimeStamp is not Visible in Notification.
+        /// If you set IsVisibleTimeStamp property to false, TimeStamp is not visible in notification.
         /// </remarks>
+        /// <since_tizen> 3 </since_tizen>
         public DateTime TimeStamp { get; set; }
 
         /// <summary>
-        /// Gets or sets Action which is invoked when notification is clicked
+        /// Gets or sets action, which is invoked when the notification is clicked.
         /// </summary>
         /// <remarks>
         /// If you set it to null, the already set AppControl will be removed and nothing will happen when you click on notification.
         /// </remarks>
         /// <seealso cref="Tizen.Applications.AppControl"></seealso>
+        /// <since_tizen> 3 </since_tizen>
         public AppControl Action { get; set; }
 
         /// <summary>
-        /// Gets or sets Count which is displayed at the right side of notification.
+        /// Gets or sets count, which is displayed at the right side of the notification.
         /// </summary>
         /// <remarks>
         /// You must set only positive number.
-        /// If you set count to negative number, This property throw exception.
+        /// If you set count to negative number, this property throws exception.
         /// </remarks>
-        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public int Count
         {
             get
@@ -126,23 +138,30 @@ namespace Tizen.Applications.Notifications
             }
         }
 
+        /// <summary>
+        /// Gets or sets a value indicating whether the notification is Onging or not.
+        /// Default value is false.
+        /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         [EditorBrowsable(EditorBrowsableState.Never)]
         public bool IsOngoing { get; set; } = false;
 
         /// <summary>
-        /// Gets or sets property
+        /// Gets or sets property.
         /// </summary>
         /// <seealso cref="Tizen.Applications.Notifications.NotificationProperty"></seealso>
+        /// <since_tizen> 3 </since_tizen>
         public NotificationProperty Property { get; set; } = NotificationProperty.None;
 
         /// <summary>
-        /// Gets or sets <see cref="Notification.ProgressType"/> object for display at notification
+        /// Gets or sets <see cref="Notification.ProgressType"/> object for display at notification.
         /// </summary>
         /// <seealso cref="Tizen.Applications.Notifications.Notification.ProgressType"></seealso>
+        /// <since_tizen> 3 </since_tizen>
         public ProgressType Progress { get; set; }
 
         /// <summary>
-        /// Gets or sets <see cref="Notification.AccessorySet"/> which is included vibration, led and sound option to be applied at Notification.
+        /// Gets or sets <see cref="Notification.AccessorySet"/> which is included vibration, LED and sound option to be applied at notification.
         /// </summary>
         /// <remarks>
         /// If you set it to null, the already set AccessorySet will be initialized.
@@ -173,16 +192,18 @@ namespace Tizen.Applications.Notifications
         /// NotificationManager.Post(notification);
         /// </code>
         /// </example>
+        /// <since_tizen> 3 </since_tizen>
         public AccessorySet Accessory { get; set; }
 
         /// <summary>
-        /// Gets or sets a value indicating whether notification is displayed on default viewer.
+        /// Gets or sets a value indicating whether notification is displayed on the default viewer.
         /// If you set false and add style, you can see only style notification.
         /// </summary>
-        public bool IsDisplay { get; set; } = true;
+        /// <since_tizen> 4 </since_tizen>
+        public bool IsVisible { get; set; } = true;
 
         /// <summary>
-        /// Gets or sets NotificationSafeHandle
+        /// Gets or sets NotificationSafeHandle.
         /// </summary>
         internal NotificationSafeHandle Handle
         {
@@ -204,19 +225,19 @@ namespace Tizen.Applications.Notifications
         }
 
         /// <summary>
-        /// Gets or sets Private ID
+        /// Gets or sets private ID.
         /// </summary>
         internal int PrivID { get; set; } = -1;
 
         /// <summary>
-        /// Method to add various style to be applied to notification.
+        /// Method for adding various styles to be applied to notification.
         /// </summary>
         /// <remarks>
-        /// The user always see about valid notification style. If you add style which is not supported in platform,
+        /// The user always see about valid notification style. If you add style which is not supported in platform,
         /// this method has no effect.
         /// </remarks>
-        /// <param name="style">The style to be applied to notification</param>
-        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <param name="style">The style to be applied to notification.</param>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
         /// <example>
         /// <code>
         /// Notification notification = new Notification
@@ -238,6 +259,7 @@ namespace Tizen.Applications.Notifications
         /// NotificationManager.Post(notification);
         /// </code>
         /// </example>
+        /// <since_tizen> 3 </since_tizen>
         public void AddStyle(StyleBase style)
         {
             if (style == null)
@@ -260,8 +282,9 @@ namespace Tizen.Applications.Notifications
         /// <summary>
         /// Method to remove style you already added.
         /// </summary>
-        /// <typeparam name="T">Type of notification style to be queried</typeparam>
-        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <typeparam name="T">Type of notification style to be queried.</typeparam>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public void RemoveStyle<T>() where T : Notification.StyleBase, new()
         {
             T type = new T();
@@ -280,11 +303,12 @@ namespace Tizen.Applications.Notifications
         /// <summary>
         /// Method to get style you already added.
         /// </summary>
-        /// <typeparam name="T">Type of notification style to be queried</typeparam>
+        /// <typeparam name="T">Type of notification style to be queried.</typeparam>
         /// <returns>
-        /// The Notification.Style object associated with the given style
+        /// The Notification.Style object associated with the given style.
         /// </returns>
-        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+        /// <since_tizen> 3 </since_tizen>
         public T GetStyle<T>() where T : Notification.StyleBase, new()
         {
             T type = new T();
@@ -304,14 +328,14 @@ namespace Tizen.Applications.Notifications
         }
 
         /// <summary>
-        /// Method to set extender data to add extra data
+        /// Method to set extra data to add extra data.
         /// </summary>
         /// <remarks>
-        /// The type of extra data is Bundle.
+        /// The type of extra data is bundle.
         /// </remarks>
         /// <param name="key">The key of the extra data you want to add.</param>
         /// <param name="value">The value you want to add.</param>
-        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
         /// <example>
         /// <code>
         /// Notification notification = new Notification
@@ -324,46 +348,48 @@ namespace Tizen.Applications.Notifications
         /// Bundle bundle = new Bundle();
         /// bundle.AddItem("key", "value");
         ///
-        /// notification.SetExtender("firstKey", bundle);
+        /// notification.SetExtraData("firstKey", bundle);
         /// </code>
         /// </example>
-        public void SetExtender(string key, Bundle value)
+        /// <since_tizen> 4 </since_tizen>
+        public void SetExtraData(string key, Bundle value)
         {
             if (value == null || value.SafeBundleHandle.IsInvalid || string.IsNullOrEmpty(key))
             {
                 throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
             }
 
-            if (extenderDictionary.ContainsKey(key) == true)
+            if (extraDataDictionary.ContainsKey(key) == true)
             {
                 Log.Info(LogTag, "The key is existed, so extender data is replaced");
-                extenderDictionary.Remove(key);
-                extenderDictionary.Add(key, value);
+                extraDataDictionary.Remove(key);
+                extraDataDictionary.Add(key, value);
             }
             else
             {
-                extenderDictionary.Add(key, value);
+                extraDataDictionary.Add(key, value);
             }
         }
 
         /// <summary>
-        /// Method to remove extender you already added.
+        /// Method to remove extra you already added.
         /// </summary>
         /// <remarks>
-        /// The type of extra data is Bundle.
+        /// The type of extra data is bundle.
         /// </remarks>
         /// <param name="key">The key of the extra data to add.</param>
-        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
-        public void RemoveExtender(string key)
+        /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+        /// <since_tizen> 4 </since_tizen>
+        public void RemoveExtraData(string key)
         {
             if (string.IsNullOrEmpty(key))
             {
                 throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered");
             }
 
-            if (extenderDictionary.ContainsKey(key))
+            if (extraDataDictionary.ContainsKey(key))
             {
-                extenderDictionary.Remove(key);
+                extraDataDictionary.Remove(key);
             }
             else
             {
@@ -372,12 +398,13 @@ namespace Tizen.Applications.Notifications
         }
 
         /// <summary>
-        /// Method to get extender data you already set
+        /// Method to get extra data you already set.
         /// </summary>
         /// <param name="key">The key of the extra data to get.</param>
-        /// <returns>Bundle Object that include extender data</returns>
-        /// <exception cref="ArgumentException">Thrown when argument is invalid</exception>
-        public Bundle GetExtender(string key)
+        /// <returns>Bundle Object that include extra data</returns>
+        /// <exception cref="ArgumentException">Thrown when argument is invalid.</exception>
+        /// <since_tizen> 4 </since_tizen>
+        public Bundle GetExtraData(string key)
         {
             if (string.IsNullOrEmpty(key))
             {
@@ -385,7 +412,7 @@ namespace Tizen.Applications.Notifications
             }
 
             Bundle bundle;
-            if (extenderDictionary.TryGetValue(key, out bundle) == false)
+            if (extraDataDictionary.TryGetValue(key, out bundle) == false)
             {
                 throw NotificationErrorFactory.GetException(NotificationError.InvalidParameter, "invalid parameter entered : " + key);
             }
@@ -396,6 +423,7 @@ namespace Tizen.Applications.Notifications
         /// <summary>
         /// Releases any unmanaged resources used by this object.
         /// </summary>
+        /// <since_tizen> 3 </since_tizen>
         public void Dispose()
         {
             Dispose(true);
@@ -409,7 +437,7 @@ namespace Tizen.Applications.Notifications
                 return;
             }
 
-            if (disposing)
+            if (disposing && Handle != null && Handle.IsInvalid == false)
             {
                 Handle.Dispose();
             }
@@ -422,9 +450,9 @@ namespace Tizen.Applications.Notifications
             return styleDictionary;
         }
 
-        internal IDictionary<string, Bundle> GetExtenderDictionary()
+        internal IDictionary<string, Bundle> GetextraDataDictionary()
         {
-            return extenderDictionary;
+            return extraDataDictionary;
         }
 
         internal StyleBase GetStyle(string key)
@@ -448,10 +476,10 @@ namespace Tizen.Applications.Notifications
         {
             NotificationBinder.BindObject(this);
 
-            foreach (string key in GetExtenderDictionary().Keys)
+            foreach (string key in GetextraDataDictionary().Keys)
             {
                 Log.Info(LogTag, "Start to bind Notification.ExtenderData to SafeHandle");
-                Interop.Notification.SetExtentionData(Handle, key, extenderDictionary[key].SafeBundleHandle);
+                Interop.Notification.SetExtensionData(Handle, key, extraDataDictionary[key].SafeBundleHandle);
             }
 
             foreach (Notification.StyleBase style in styleDictionary.Values)
@@ -475,21 +503,24 @@ namespace Tizen.Applications.Notifications
 
         internal Notification Build()
         {
-            IntPtr extention = IntPtr.Zero;
-            IntPtr extentionBundlePtr = IntPtr.Zero;
+            IntPtr extension = IntPtr.Zero;
+            IntPtr extensionBundlePtr = IntPtr.Zero;
 
             NotificationBinder.BindSafeHandle(this);
 
-            Interop.Notification.GetExtentionBundle(Handle, out extention, out extentionBundlePtr);
+            Interop.Notification.GetExtensionBundle(Handle, out extension, out extensionBundlePtr);
 
-            if (extention != IntPtr.Zero)
+            if (extension != IntPtr.Zero)
             {
-                Bundle bundle = new Bundle(new SafeBundleHandle(extention, false));
+                Bundle bundle = new Bundle(new SafeBundleHandle(extension, false));
                 foreach (string key in bundle.Keys)
                 {
+                    if (key.StartsWith("_NOTIFICATION_EXTENSION_EVENT_"))
+                        continue;
+
                     SafeBundleHandle sbh;
-                    Interop.Notification.GetExtentionData(Handle, key, out sbh);
-                    extenderDictionary.Add(key, new Bundle(sbh));
+                    Interop.Notification.GetExtensionData(Handle, key, out sbh);
+                    extraDataDictionary.Add(key, new Bundle(sbh));
                 }
             }