[Applications.Common] Add a new property of AppControl (#1002)
authorhjhun <36876573+hjhun@users.noreply.github.com>
Mon, 9 Sep 2019 23:47:13 +0000 (08:47 +0900)
committerpjh9216 <jh9216.park@samsung.com>
Mon, 9 Sep 2019 23:47:13 +0000 (08:47 +0900)
* [Applications.Common] Add a new property of AppControl

This property is for getting and setting a component ID.

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
* Update description

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
* Update example code

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
* Update description

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
* Update description of ComponentId Property

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
* Update description of ComponentId property

Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/Tizen.Applications.Common/Interop/Interop.AppControl.cs [changed mode: 0644->0755]
src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs

old mode 100644 (file)
new mode 100755 (executable)
index a524acd..6360dd9
@@ -145,5 +145,11 @@ internal static partial class Interop
 
         [DllImport(Libraries.AppControl, EntryPoint = "app_control_send_launch_request_async")]
         internal static extern ErrorCode SendLaunchRequestAsync(SafeAppControlHandle handle, ResultCallback resultCallback, ReplyCallback replyCallback, IntPtr userData);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_component_id")]
+        internal static extern ErrorCode SetComponentId(SafeAppControlHandle handle, string componentId);
+
+        [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_component_id")]
+        internal static extern ErrorCode GetComponentId(SafeAppControlHandle handle, out string componentId);
     }
 }
index a85df42..76e0bf3 100755 (executable)
@@ -58,6 +58,7 @@ namespace Tizen.Applications
         private string _category = null;
         private string _applicationId = null;
         private ExtraDataCollection _extraData = null;
+        private string _componentId = null;
 
         /// <summary>
         /// Initializes the instance of the AppControl class.
@@ -444,6 +445,52 @@ namespace Tizen.Applications
             }
         }
 
+        /// <summary>
+        /// Gets and sets the component ID to explicitly launch a component.
+        /// </summary>
+        /// <value>
+        /// (if the component ID is null for setter, it clears the previous value.)
+        /// From Tizen 5.5, a new application model is supported that is component-based application.
+        /// This property is for launching component-based application. If it's not set, the main component of component-based application will be launched.
+        /// If the target app is not component-based application, setting property is meaningless.
+        /// </value>
+        /// <example>
+        /// <code>
+        /// AppControl appControl = new AppControl();
+        /// appControl.ApplicationId = "org.tizen.component-based-app"; // component-based application
+        /// appControl.ComponentId = "org.tizen.frame-component";
+        /// AppControl.SendLaunchRequest(appControl);
+        /// </code>
+        /// </example>
+        /// <since_tizen> 6 </since_tizen>
+        public string ComponentId
+        {
+            get
+            {
+                if (String.IsNullOrEmpty(_componentId))
+                {
+                    Interop.AppControl.ErrorCode err = Interop.AppControl.GetComponentId(_handle, out _componentId);
+                    if (err != Interop.AppControl.ErrorCode.None)
+                    {
+                        Log.Warn(LogTag, "Failed to get the component id from the AppControl. Err = " + err);
+                    }
+                }
+                return _componentId;
+            }
+            set
+            {
+                Interop.AppControl.ErrorCode err = Interop.AppControl.SetComponentId(_handle, value);
+                if (err == Interop.AppControl.ErrorCode.None)
+                {
+                    _componentId = value;
+                }
+                else
+                {
+                    Log.Warn(LogTag, "Failed to set the component id to the AppControl. Err = " + err);
+                }
+            }
+        }
+
 #endregion // Public Properties
 
         /// <summary>