[NUI] Window operations can get detail result
authorJiyun Yang <ji.yang@samsung.com>
Wed, 12 May 2021 07:30:32 +0000 (16:30 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Wed, 26 May 2021 01:00:09 +0000 (10:00 +0900)
Signed-off-by: Jiyun Yang <ji.yang@samsung.com>
src/Tizen.NUI.Components/Controls/Notification.cs
src/Tizen.NUI/src/internal/Interop/Interop.Window.cs
src/Tizen.NUI/src/public/Window/Window.cs

index fb0a0da..3ebe406 100755 (executable)
@@ -230,11 +230,18 @@ namespace Tizen.NUI.Components
                 return;
             }
 
-            if (!ApplyLevel(level))
+            var applyLevelResult = ApplyLevel(level);
+
+            if (applyLevelResult == Window.OperationResult.PermissionDenied)
             {
                 throw new UnauthorizedAccessException("Cannot post a Notification: Permission Denied. The privilege http://tizen.org/privilege/window.priority.set is needed.");
             }
 
+            if (applyLevelResult != Window.OperationResult.Succeed)
+            {
+                Tizen.Log.Info("NUI", "The notification window may not have proper notification level.");
+            }
+
             ApplyPositionSize(positionSize);
 
             ApplyDismissOnTouch(dismissOnTouch);
@@ -266,9 +273,19 @@ namespace Tizen.NUI.Components
         {
             this.level = level;
 
-            if (state == NotificationState.Post && !ApplyLevel(level))
+            if (state == NotificationState.Post)
             {
-                throw new UnauthorizedAccessException("Cannot set notification level: Permission Denied");
+                var result = ApplyLevel(level);
+
+                if (result == Window.OperationResult.PermissionDenied)
+                {
+                    throw new UnauthorizedAccessException("Cannot set notification level: Permission Denied. The privilege http://tizen.org/privilege/window.priority.set is needed.");
+                }
+
+                if (result != Window.OperationResult.Succeed)
+                {
+                    Tizen.Log.Info("NUI", "Cannot set notification level: Unknown reason. The notification window may not have proper notification level.");
+                }
             }
 
             return this;
@@ -440,9 +457,11 @@ namespace Tizen.NUI.Components
             notificationWindow = null;
         }
 
-        private bool ApplyLevel(NotificationLevel level)
+        private Window.OperationResult ApplyLevel(NotificationLevel level)
         {
-            return NotificationWindow.SetNotificationLevel(level);
+            var ret = (Window.OperationResult)Interop.Window.SetNotificationLevel(NotificationWindow.SwigCPtr, (int)level);
+            if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+            return ret;
         }
 
         private void ApplyPositionSize(Rectangle positionSize)
index f5caf91..53b33dc 100755 (executable)
@@ -132,7 +132,7 @@ namespace Tizen.NUI
             public static extern int GetType(global::System.Runtime.InteropServices.HandleRef jarg1);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_SetNotificationLevel")]
-            public static extern bool SetNotificationLevel(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
+            public static extern int SetNotificationLevel(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetNotificationLevel")]
             public static extern int GetNotificationLevel(global::System.Runtime.InteropServices.HandleRef jarg1);
@@ -144,13 +144,13 @@ namespace Tizen.NUI
             public static extern bool IsOpaqueState(global::System.Runtime.InteropServices.HandleRef jarg1);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_SetScreenOffMode")]
-            public static extern bool SetScreenOffMode(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
+            public static extern int SetScreenOffMode(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetScreenOffMode")]
             public static extern int GetScreenOffMode(global::System.Runtime.InteropServices.HandleRef jarg1);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_SetBrightness")]
-            public static extern bool SetBrightness(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
+            public static extern int SetBrightness(global::System.Runtime.InteropServices.HandleRef jarg1, int jarg2);
 
             [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_GetBrightness")]
             public static extern int GetBrightness(global::System.Runtime.InteropServices.HandleRef jarg1);
index 2f0bd81..e643d5a 100755 (executable)
@@ -258,6 +258,30 @@ namespace Tizen.NUI
         }
 
         /// <summary>
+        /// Enumeration for result of window operation.
+        /// </summary>
+        internal enum OperationResult
+        {
+            /// <summary>
+            /// Failed for unknown reason
+            /// </summary>
+            UnknownError = 0,
+            /// <summary>
+            /// Succeed
+            /// </summary>
+            Succeed,
+            /// <summary>
+            /// Permission denied
+            /// </summary>
+            PermissionDenied,
+            /// <summary>
+            /// The operation is not supported.
+            /// </summary>
+            NotSupported,
+        }
+
+
+        /// <summary>
         /// The stage instance property (read-only).<br />
         /// Gets the current window.<br />
         /// </summary>
@@ -647,9 +671,9 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public bool SetNotificationLevel(NotificationLevel level)
         {
-            bool ret = Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
+            var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
+            return ret == OperationResult.Succeed;
         }
 
         /// <summary>
@@ -701,9 +725,9 @@ namespace Tizen.NUI
         /// <since_tizen> 4 </since_tizen>
         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
         {
-            bool ret = Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
+            var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
+            return ret == OperationResult.Succeed;
         }
 
         /// <summary>
@@ -726,9 +750,9 @@ namespace Tizen.NUI
         /// <since_tizen> 3 </since_tizen>
         public bool SetBrightness(int brightness)
         {
-            bool ret = Interop.Window.SetBrightness(SwigCPtr, brightness);
+            var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
-            return ret;
+            return ret == OperationResult.Succeed;
         }
 
         /// <summary>