From: Jiyun Yang Date: Wed, 12 May 2021 07:30:32 +0000 (+0900) Subject: [NUI] Window operations can get detail result X-Git-Tag: accepted/tizen/unified/20231205.024657~1852 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2eaf6d2410e184cd559e75f73ac5eb3d71161068;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [NUI] Window operations can get detail result Signed-off-by: Jiyun Yang --- diff --git a/src/Tizen.NUI.Components/Controls/Notification.cs b/src/Tizen.NUI.Components/Controls/Notification.cs index fb0a0da..3ebe406 100755 --- a/src/Tizen.NUI.Components/Controls/Notification.cs +++ b/src/Tizen.NUI.Components/Controls/Notification.cs @@ -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) diff --git a/src/Tizen.NUI/src/internal/Interop/Interop.Window.cs b/src/Tizen.NUI/src/internal/Interop/Interop.Window.cs index f5caf91..53b33dc 100755 --- a/src/Tizen.NUI/src/internal/Interop/Interop.Window.cs +++ b/src/Tizen.NUI/src/internal/Interop/Interop.Window.cs @@ -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); diff --git a/src/Tizen.NUI/src/public/Window/Window.cs b/src/Tizen.NUI/src/public/Window/Window.cs index 2f0bd81..e643d5a 100755 --- a/src/Tizen.NUI/src/public/Window/Window.cs +++ b/src/Tizen.NUI/src/public/Window/Window.cs @@ -258,6 +258,30 @@ namespace Tizen.NUI } /// + /// Enumeration for result of window operation. + /// + internal enum OperationResult + { + /// + /// Failed for unknown reason + /// + UnknownError = 0, + /// + /// Succeed + /// + Succeed, + /// + /// Permission denied + /// + PermissionDenied, + /// + /// The operation is not supported. + /// + NotSupported, + } + + + /// /// The stage instance property (read-only).
/// Gets the current window.
///
@@ -647,9 +671,9 @@ namespace Tizen.NUI /// 3 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; } /// @@ -701,9 +725,9 @@ namespace Tizen.NUI /// 4 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; } /// @@ -726,9 +750,9 @@ namespace Tizen.NUI /// 3 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; } ///