[Tizen.Applications.AttachPanel] Add attach_panel feature checking routine (#85) 5.0.0.14265
authorhallower <hallower@gmail.com>
Thu, 8 Feb 2018 23:40:37 +0000 (08:40 +0900)
committerGitHub <noreply@github.com>
Thu, 8 Feb 2018 23:40:37 +0000 (08:40 +0900)
* [AttachPanel] Add attach-panel feature check code and exceptions

* Fix exception description

Signed-off-by: csk <hallower@gmail.com>
* Remove unnecessary file(coding rule checker)

Signed-off-by: csk <hallower@gmail.com>
* Add feature description, fix reviewed issues.

Signed-off-by: csk <hallower@gmail.com>
src/Tizen.Applications.AttachPanel/Interop/Interop.AttachPanel.cs
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.csproj
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel.sln
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/AttachPanel.cs
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/AttachPanelInternal.cs
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/ContentCategory.cs
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/EventType.cs
src/Tizen.Applications.AttachPanel/Tizen.Applications.AttachPanel/StateType.cs

index 12940dc..8d5560b 100755 (executable)
@@ -22,6 +22,7 @@ internal static partial class Interop
             NotInitialized = -0x02850000 | 0x02,
             UnsupportedContentCategory = -0x02850000 | 0x03,
             AlreadyDestroyed = -0x02850000 | 0x05,
+            NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
         }
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
@@ -30,7 +31,7 @@ internal static partial class Interop
         internal delegate void AttachPanelResultCallback(IntPtr attachPanel, int category, IntPtr result, int resultCode, IntPtr userData);
 
         [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_create")]
-        internal static extern ErrorCode CreateAttachPanel(IntPtr conform, ref IntPtr attach_panel);
+        internal static extern ErrorCode CreateAttachPanel(IntPtr conform, out IntPtr attach_panel);
 
         [DllImport(Libraries.AttachPanel, EntryPoint = "attach_panel_destroy")]
         internal static extern ErrorCode DestroyAttachPanel(IntPtr attach_panel);
index b16fa50..f358b07 100755 (executable)
@@ -7,6 +7,7 @@
   <ItemGroup>
     <ProjectReference Include="..\ElmSharp\ElmSharp.csproj" />
     <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+    <ProjectReference Include="..\Tizen.System.Information\Tizen.System.Information.csproj" />
   </ItemGroup>
 
 </Project>
index 644bd5d..d9ec1c8 100755 (executable)
@@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.AttachPanel", "Tizen.Applications.AttachPanel.csproj", "{C8C93D46-CACE-4BF1-8B50-6A6A00967045}"
        ProjectSection(ProjectDependencies) = postProject
                {AF2CEEB1-B3B2-4E2D-8854-A54871CD0D1C} = {AF2CEEB1-B3B2-4E2D-8854-A54871CD0D1C}
+               {0FF56FE4-CBFA-4E8E-B0A2-0FEDB856498D} = {0FF56FE4-CBFA-4E8E-B0A2-0FEDB856498D}
        EndProjectSection
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Common", "..\Tizen.Applications.Common\Tizen.Applications.Common.csproj", "{D2B5F854-4FE1-473C-A8E3-53ABB0A966AA}"
@@ -16,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\Tizen.Log\T
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElmSharp", "..\ElmSharp\ElmSharp.csproj", "{AF2CEEB1-B3B2-4E2D-8854-A54871CD0D1C}"
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.System.Information", "..\Tizen.System.Information\Tizen.System.Information.csproj", "{0FF56FE4-CBFA-4E8E-B0A2-0FEDB856498D}"
+EndProject
 Global
        GlobalSection(SolutionConfigurationPlatforms) = preSolution
                Debug|Any CPU = Debug|Any CPU
@@ -42,6 +45,10 @@ Global
                {AF2CEEB1-B3B2-4E2D-8854-A54871CD0D1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
                {AF2CEEB1-B3B2-4E2D-8854-A54871CD0D1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
                {AF2CEEB1-B3B2-4E2D-8854-A54871CD0D1C}.Release|Any CPU.Build.0 = Release|Any CPU
+               {0FF56FE4-CBFA-4E8E-B0A2-0FEDB856498D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+               {0FF56FE4-CBFA-4E8E-B0A2-0FEDB856498D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+               {0FF56FE4-CBFA-4E8E-B0A2-0FEDB856498D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+               {0FF56FE4-CBFA-4E8E-B0A2-0FEDB856498D}.Release|Any CPU.Build.0 = Release|Any CPU
        EndGlobalSection
        GlobalSection(SolutionProperties) = preSolution
                HideSolutionNode = FALSE
index 7838b87..13ccd38 100755 (executable)
@@ -13,29 +13,41 @@ namespace Tizen.Applications.AttachPanel
         /// </summary>
         /// <since_tizen> 4 </since_tizen>
         /// <param name="conformant">The caller's conformant.</param>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
+        /// <exception cref="ArgumentNullException">Thrown when the parameter is null</exception>
         /// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate the memory fails.</exception>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel already exists or the <paramref name="conformant"/> is not a conformant object.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         public AttachPanel(EvasObject conformant)
         {
             if (conformant == IntPtr.Zero)
             {
-                throw new ArgumentNullException("Use the value property, not null value");
+                throw new ArgumentNullException("Invalid conformant, it's null");
             }
 
-            IntPtr candidateAttachPanel = new IntPtr();
-            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.CreateAttachPanel(conformant, ref candidateAttachPanel);
+            if (IsAttachPanelSupported() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+            }
+
+            if (IsInitialized())
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.AlreadyExists);
+            }
+
+            var candidateAttachPanel = IntPtr.Zero;
+            var err = Interop.AttachPanel.CreateAttachPanel(conformant, out candidateAttachPanel);
             CheckException(err);
 
             Tizen.Log.Debug("AttachPanelSharp", "Success to create an AttachPanel Instance");
-            isCreationSucceed = true;
-            _attachPanel = candidateAttachPanel;
+            s_attachPanel = candidateAttachPanel;
 
-            if (_eventEventHandler == null)
+            if (s_eventEventHandler == null)
             {
                 StateEventListenStart();
             }
 
-            if (_resultEventHandler == null)
+            if (s_resultEventHandler == null)
             {
                 ResultEventListenStart();
             }
@@ -46,32 +58,13 @@ namespace Tizen.Applications.AttachPanel
         /// </summary>
         /// <since_tizen> 4 </since_tizen>
         /// <param name="conformant">The caller's conformant.</param>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
         /// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate the memory fails.</exception>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel already exists or the <paramref name="conformant"/> is not a conformant object.</exception>
-        public AttachPanel(Conformant conformant)
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
+        /// <exception cref="ArgumentNullException">Thrown when the parameter is null</exception>
+        public AttachPanel(Conformant conformant) : this(conformant as EvasObject)
         {
-            if (conformant == IntPtr.Zero)
-            {
-                throw new ArgumentNullException("Use the value property, not null value");
-            }
-
-            IntPtr candidateAttachPanel = new IntPtr();
-            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.CreateAttachPanel(conformant, ref candidateAttachPanel);
-            CheckException(err);
-
-            Tizen.Log.Debug("AttachPanelSharp", "Success to create an AttachPanel Instance");
-            isCreationSucceed = true;
-            _attachPanel = candidateAttachPanel;
-
-            if (_eventEventHandler == null)
-            {
-                StateEventListenStart();
-            }
-
-            if (_resultEventHandler == null)
-            {
-                ResultEventListenStart();
-            }
         }
 
         /// <summary>
@@ -79,12 +72,10 @@ namespace Tizen.Applications.AttachPanel
         /// </summary>
         ~AttachPanel()
         {
-            if (isCreationSucceed &&
-                _attachPanel != IntPtr.Zero)
+            if (IsInitialized())
             {
-                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.DestroyAttachPanel(_attachPanel);
-                CheckException(err);
-                _attachPanel = IntPtr.Zero;
+                Interop.AttachPanel.DestroyAttachPanel(s_attachPanel);
+                s_attachPanel = IntPtr.Zero;
             }
         }
 
@@ -93,15 +84,28 @@ namespace Tizen.Applications.AttachPanel
         /// </summary>
         /// <value>The AttachPanel window state.</value>
         /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or is already destroyed.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
+        /// <exception cref="ArgumentException">Thrown when the parameter is invalid</exception>
         public StateType State
         {
             get
             {
-                int interopState;
-                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.GetState(_attachPanel, out interopState);
+                if (IsAttachPanelSupported() == false)
+                {
+                    CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+                }
+
+                if (IsInitialized() == false)
+                {
+                    CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+                }
+
+                var err = Interop.AttachPanel.GetState(s_attachPanel, out int interopState);
                 CheckException(err);
-                StateType state = (StateType)Enum.ToObject(typeof(StateType), interopState);
-                return state;
+
+                return (StateType)Enum.ToObject(typeof(StateType), interopState);
             }
         }
 
@@ -110,14 +114,27 @@ namespace Tizen.Applications.AttachPanel
         /// </summary>
         /// <value>Visible value of the AttachPanel state.</value>
         /// <since_tizen> 4 </since_tizen>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
+        /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or is already destroyed.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         public bool Visible
         {
             get
             {
-                int visible;
-                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.GetVisibility(_attachPanel, out visible);
+                if (IsAttachPanelSupported() == false)
+                {
+                    CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+                }
+
+                if (IsInitialized() == false)
+                {
+                    CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+                }
+
+                var err = Interop.AttachPanel.GetVisibility(s_attachPanel, out int visible);
                 CheckException(err);
-                return (visible == 1);
+
+                return visible == 1;
             }
         }
 
@@ -132,11 +149,12 @@ namespace Tizen.Applications.AttachPanel
         /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
         /// <feature>http://tizen.org/feature/camera</feature>
         /// <feature>http://tizen.org/feature/microphone</feature>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
         /// <remarks>
         /// The caller application has to check the return value of this function.
         /// Content categories will be shown as the sequence of using AddCategory.
         /// Some contents need time to load it all.
-        /// So, it is needed to use this before the mainloop of the Show.
+        /// So, it is needed to use this before the main-loop of the Show.
         /// Privileges,
         /// http://tizen.org/privilege/mediastorage, for using Image or Camera.
         /// http://tizen.org/privilege/camera, for using Camera or TakePicture.
@@ -144,6 +162,7 @@ namespace Tizen.Applications.AttachPanel
         /// http://tizen.org/privilege/appmanager.launch, for adding content categories on the More tab.
         /// http://tizen.org/feature/camera, for using Camera or TakePicture.
         /// http://tizen.org/feature/microphone, for using Voice.
+        /// http://tizen.org/feature/attach_panel, for using attach panel
         /// Deliver more information to the callee with a bundle if you need.
         /// http://tizen.org/appcontrol/data/total_count
         /// http://tizen.org/appcontrol/data/total_size
@@ -152,16 +171,27 @@ namespace Tizen.Applications.AttachPanel
         /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have the privilege to access this method.</exception>
         /// <exception cref="NotSupportedException">Thrown when the device does not support the <paramref name="category"/> feature.</exception>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or is already destroyed.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         /// <since_tizen> 4 </since_tizen>
         public void AddCategory(ContentCategory category, Bundle extraData)
         {
-            IntPtr bundle = IntPtr.Zero;
+            if (IsAttachPanelSupported() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+            }
+
+            if (IsInitialized() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+            }
+
+            var bundle = IntPtr.Zero;
             if (extraData != null)
             {
                 bundle = extraData.SafeBundleHandle.DangerousGetHandle();
             }
 
-            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.AddCategory(_attachPanel, (int)category, bundle);
+            var err = Interop.AttachPanel.AddCategory(s_attachPanel, (int)category, bundle);
             CheckException(err);
         }
 
@@ -169,12 +199,24 @@ namespace Tizen.Applications.AttachPanel
         /// Removes the ContentCategory from the AttachPanel.
         /// </summary>
         /// <param name="category">The ContentCategory to be added in the AttachPanel.</param>
-        ///  <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category.</exception>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
+        /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category.</exception>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or is already destroyed.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         /// <since_tizen> 4 </since_tizen>
         public void RemoveCategory(ContentCategory category)
         {
-            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.RemoveCategory(_attachPanel, (int)category);
+            if (IsAttachPanelSupported() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+            }
+
+            if (IsInitialized() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+            }
+
+            var err = Interop.AttachPanel.RemoveCategory(s_attachPanel, (int)category);
             CheckException(err);
         }
 
@@ -183,9 +225,11 @@ namespace Tizen.Applications.AttachPanel
         /// </summary>
         /// <param name="category">The ContentCategory that some information is to be set, in the AttachPanel.</param>
         /// <param name="extraData">The AttachPanel sends some information using a Bundle.</param>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
         /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category.</exception>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
         /// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate the memory fails.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         /// <since_tizen> 4 </since_tizen>
         public void SetExtraData(ContentCategory category, Bundle extraData)
         {
@@ -194,24 +238,46 @@ namespace Tizen.Applications.AttachPanel
                 CheckException(Interop.AttachPanel.ErrorCode.InvalidParameter);
             }
 
-            IntPtr bundle = IntPtr.Zero;
+            if (IsAttachPanelSupported() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+            }
+
+            if (IsInitialized() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+            }
+
+            var bundle = IntPtr.Zero;
             if (extraData != null)
             {
                 bundle = extraData.SafeBundleHandle.DangerousGetHandle();
             }
 
-            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.SetExtraData(_attachPanel, (int)category, bundle);
+            var err = Interop.AttachPanel.SetExtraData(s_attachPanel, (int)category, bundle);
             CheckException(err);
         }
 
         /// <summary>
         /// Shows the attach panel with the animations.
         /// </summary>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         /// <since_tizen> 4 </since_tizen>
         public void Show()
         {
-            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Show(_attachPanel);
+            if (IsAttachPanelSupported() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+            }
+
+            if (IsInitialized() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+            }
+
+            var err = Interop.AttachPanel.Show(s_attachPanel);
             CheckException(err);
         }
 
@@ -219,18 +285,30 @@ namespace Tizen.Applications.AttachPanel
         /// Shows the attach panel and selects whether or not to animate.
         /// </summary>
         /// <param name="animation">A flag which turns on or turns off the animation while the attach panel is showing.</param>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         /// <since_tizen> 4 </since_tizen>
         public void Show(bool animation)
         {
+            if (IsAttachPanelSupported() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+            }
+
+            if (IsInitialized() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+            }
+
             if (animation)
             {
-                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Show(_attachPanel);
+                var err = Interop.AttachPanel.Show(s_attachPanel);
                 CheckException(err);
             }
             else
             {
-                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.ShowWithoutAnimation(_attachPanel);
+                var err = Interop.AttachPanel.ShowWithoutAnimation(s_attachPanel);
                 CheckException(err);
             }
         }
@@ -238,11 +316,23 @@ namespace Tizen.Applications.AttachPanel
         /// <summary>
         /// Hides the attach panel with the animations.
         /// </summary>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         /// <since_tizen> 4 </since_tizen>
         public void Hide()
         {
-            Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Hide(_attachPanel);
+            if (IsAttachPanelSupported() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+            }
+
+            if (IsInitialized() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+            }
+
+            var err = Interop.AttachPanel.Hide(s_attachPanel);
             CheckException(err);
         }
 
@@ -250,18 +340,30 @@ namespace Tizen.Applications.AttachPanel
         /// Hides the attach panel and selects whether or not to animate.
         /// </summary>
         /// <param name="animation">A flag which turns on or turns off the animation while the attach panel is hiding.</param>
+        /// <feature>http://tizen.org/feature/attach_panel</feature>
         /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
+        /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
         /// <since_tizen> 4 </since_tizen>
         public void Hide(bool animation)
         {
+            if (IsAttachPanelSupported() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+            }
+
+            if (IsInitialized() == false)
+            {
+                CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+            }
+
             if (animation)
             {
-                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Hide(_attachPanel);
+                var err = Interop.AttachPanel.Hide(s_attachPanel);
                 CheckException(err);
             }
             else
             {
-                Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.HideWithoutAnimation(_attachPanel);
+                var err = Interop.AttachPanel.HideWithoutAnimation(s_attachPanel);
                 CheckException(err);
             }
         }
@@ -274,18 +376,18 @@ namespace Tizen.Applications.AttachPanel
         {
             add
             {
-                if (_eventEventHandler == null)
+                if (s_eventEventHandler == null)
                 {
                     StateEventListenStart();
                 }
 
-                _eventEventHandler += value;
+                s_eventEventHandler += value;
             }
 
             remove
             {
-                _eventEventHandler -= value;
-                if (_eventEventHandler == null)
+                s_eventEventHandler -= value;
+                if (s_eventEventHandler == null)
                 {
                     StateEventListenStop();
                 }
@@ -300,18 +402,18 @@ namespace Tizen.Applications.AttachPanel
         {
             add
             {
-                if (_resultEventHandler == null)
+                if (s_resultEventHandler == null)
                 {
                     ResultEventListenStart();
                 }
 
-                _resultEventHandler += value;
+                s_resultEventHandler += value;
             }
 
             remove
             {
-                _resultEventHandler -= value;
-                if (_resultEventHandler == null)
+                s_resultEventHandler -= value;
+                if (s_resultEventHandler == null)
                 {
                     ResultEventListenStop();
                 }
index 827ebdd..bb4ac40 100755 (executable)
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using Tizen.System;
 
 namespace Tizen.Applications.AttachPanel
 {
@@ -9,51 +10,46 @@ namespace Tizen.Applications.AttachPanel
     /// <since_tizen> 4 </since_tizen>
     public partial class AttachPanel
     {
-        private static IntPtr _attachPanel;
-        private bool isCreationSucceed;
+        private static IntPtr s_attachPanel = IntPtr.Zero;
 
-        private static event EventHandler<StateEventArgs> _eventEventHandler;
-        private static event EventHandler<ResultEventArgs> _resultEventHandler;
+        private static event EventHandler<StateEventArgs> s_eventEventHandler;
 
-        private static Interop.AttachPanel.AttachPanelEventCallback SetEventListener;
-        private static Interop.AttachPanel.AttachPanelResultCallback SetResultListener;
+        private static event EventHandler<ResultEventArgs> s_resultEventHandler;
+
+        private static Interop.AttachPanel.AttachPanelEventCallback s_setEventListener;
+        private static Interop.AttachPanel.AttachPanelResultCallback s_setResultListener;
 
         private void StateEventListenStart()
         {
-            Interop.AttachPanel.ErrorCode err = 0;
-
-            SetEventListener = (attachPanel, eventType, eventInfo, userData) =>
+            s_setEventListener = (attachPanel, eventType, eventInfo, userData) =>
             {
-                _eventEventHandler?.Invoke(null, new StateEventArgs((EventType)eventType));
+                s_eventEventHandler?.Invoke(null, new StateEventArgs((EventType)eventType));
             };
-            err = Interop.AttachPanel.SetEventCb(_attachPanel, SetEventListener, IntPtr.Zero);
+            var err = Interop.AttachPanel.SetEventCb(s_attachPanel, s_setEventListener, IntPtr.Zero);
             CheckException(err);
         }
 
         private void StateEventListenStop()
         {
-            Interop.AttachPanel.ErrorCode err = 0;
-            err = Interop.AttachPanel.UnsetEventCb(_attachPanel);
+            var err = Interop.AttachPanel.UnsetEventCb(s_attachPanel);
             CheckException(err);
         }
 
         private void ResultEventListenStart()
         {
-            Interop.AttachPanel.ErrorCode err = 0;
-            SetResultListener = (attachPanel, category, resulthandler, resultCode, userData) =>
+            s_setResultListener = (attachPanel, category, resulthandler, resultCode, userData) =>
             {
                 SafeAppControlHandle handle = new SafeAppControlHandle(resulthandler, false);
                 AppControl result = new AppControl(handle);
-                _resultEventHandler?.Invoke(null, new ResultEventArgs((ContentCategory)category, result, (AppControlReplyResult)resultCode));
+                s_resultEventHandler?.Invoke(null, new ResultEventArgs((ContentCategory)category, result, (AppControlReplyResult)resultCode));
             };
-            err = Interop.AttachPanel.SetResultCb(_attachPanel, SetResultListener, IntPtr.Zero);
+            var err = Interop.AttachPanel.SetResultCb(s_attachPanel, s_setResultListener, IntPtr.Zero);
             CheckException(err);
         }
 
         private void ResultEventListenStop()
         {
-            Interop.AttachPanel.ErrorCode err = 0;
-            err = Interop.AttachPanel.UnsetResultCb(_attachPanel);
+            var err = Interop.AttachPanel.UnsetResultCb(s_attachPanel);
             CheckException(err);
         }
 
@@ -62,20 +58,32 @@ namespace Tizen.Applications.AttachPanel
             switch (err)
             {
                 case Interop.AttachPanel.ErrorCode.InvalidParameter:
-                    throw new ArgumentOutOfRangeException("Invalid parameter error at unmanaged code");
+                    throw new ArgumentOutOfRangeException("Invalid parameter");
                 case Interop.AttachPanel.ErrorCode.OutOfMemory:
                     throw new OutOfMemoryException("Out of Memory");
                 case Interop.AttachPanel.ErrorCode.PermissionDenied:
                     throw new UnauthorizedAccessException();
                 case Interop.AttachPanel.ErrorCode.AlreadyExists:
-                    throw new InvalidOperationException("Already Exists");
+                    throw new InvalidOperationException("AttachPanel is already exists");
                 case Interop.AttachPanel.ErrorCode.NotInitialized:
-                    throw new InvalidOperationException("Not initialized");
+                    throw new InvalidOperationException("AttachPanel is not initialized");
                 case Interop.AttachPanel.ErrorCode.UnsupportedContentCategory:
-                    throw new NotSupportedException("Unsupported Content Category");
+                    throw new NotSupportedException("Unsupported content category");
                 case Interop.AttachPanel.ErrorCode.AlreadyDestroyed:
-                    throw new InvalidOperationException("Already Destroyed");
+                    throw new InvalidOperationException("AttachPanel is already destroyed");
+                case Interop.AttachPanel.ErrorCode.NotSupported:
+                    throw new NotSupportedException("AttachPanel is not supported in this device");
             }
         }
+
+        internal static bool IsAttachPanelSupported()
+        {
+            return Information.TryGetValue("http://tizen.org/feature/attach_panel", out bool isAttachPanelSupported) && isAttachPanelSupported;
+        }
+
+        internal static bool IsInitialized()
+        {
+            return s_attachPanel != IntPtr.Zero;
+        }
     }
 }
index 845fd81..bc65fc6 100755 (executable)
@@ -10,46 +10,57 @@ namespace Tizen.Applications.AttachPanel
         /// Attaching images from the gallery.
         /// </summary>
         Image = 1,
+
         /// <summary>
         /// Taking pictures to attach.
         /// </summary>
         Camera,
+
         /// <summary>
         /// Taking a voice clip to attach.
         /// </summary>
         Voice,
+
         /// <summary>
         /// Attaching video from the gallery.
         /// </summary>
         Video,
+
         /// <summary>
         /// Attaching audio from my files.
         /// </summary>
         Audio,
+
         /// <summary>
         /// Attaching calendar data from the calendar.
         /// </summary>
         Calendar,
+
         /// <summary>
         /// Attaching contact data from the contacts.
         /// </summary>
         Contact,
+
         /// <summary>
         /// Attaching files data from my files.
         /// </summary>
         Myfiles,
+
         /// <summary>
         /// Taking a video clip to attach.
         /// </summary>
         VideoRecorder,
+
         /// <summary>
         /// Attaching files from the document list.
         /// </summary>
         Document,
+
         /// <summary>
         /// Launching apps to take pictures will be attached.
         /// </summary>
         TakePicture,
+
         /// <summary>
         /// Attaching memo data from the memo.
         /// </summary>
index a4f76da..f5906a6 100755 (executable)
@@ -10,14 +10,17 @@ namespace Tizen.Applications.AttachPanel
         /// Attach panel starts the effect to show.
         /// </summary>
         ShowStart = 1,
+
         /// <summary>
         /// Attach panel finishes the effect to show.
         /// </summary>
         ShowFinish,
+
         /// <summary>
         /// Attach panel starts the effect to hide the panel.
         /// </summary>
         HideStart,
+
         /// <summary>
         /// Attach panel finishes the effect to hide the panel.
         /// </summary>
index 770e46f..da250b6 100755 (executable)
@@ -10,10 +10,12 @@ namespace Tizen.Applications.AttachPanel
         /// Attach panel is not visible.
         /// </summary>
         Hidden = 0,
+
         /// <summary>
         /// Attach panel is in the partial window mode.
         /// </summary>
         Partial,
+
         /// <summary>
         /// Attach panel is in the full screen mode.
         /// </summary>