From 6454d95e62cbcfca94788d4a09b2989e06259a49 Mon Sep 17 00:00:00 2001 From: hjhun <36876573+hjhun@users.noreply.github.com> Date: Tue, 10 Sep 2019 08:47:13 +0900 Subject: [PATCH] [Applications.Common] Add a new property of AppControl (#1002) * [Applications.Common] Add a new property of AppControl This property is for getting and setting a component ID. Signed-off-by: Hwankyu Jhun * Update description Signed-off-by: Hwankyu Jhun * Update example code Signed-off-by: Hwankyu Jhun * Update description Signed-off-by: Hwankyu Jhun * Update description of ComponentId Property Signed-off-by: Hwankyu Jhun * Update description of ComponentId property Signed-off-by: Hwankyu Jhun --- .../Interop/Interop.AppControl.cs | 6 +++ .../Tizen.Applications/AppControl.cs | 47 +++++++++++++++++++ 2 files changed, 53 insertions(+) mode change 100644 => 100755 src/Tizen.Applications.Common/Interop/Interop.AppControl.cs diff --git a/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs b/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs old mode 100644 new mode 100755 index a524acd9a..6360dd9fc --- a/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs +++ b/src/Tizen.Applications.Common/Interop/Interop.AppControl.cs @@ -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); } } diff --git a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs index a85df42a7..76e0bf3ac 100755 --- a/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs +++ b/src/Tizen.Applications.Common/Tizen.Applications/AppControl.cs @@ -58,6 +58,7 @@ namespace Tizen.Applications private string _category = null; private string _applicationId = null; private ExtraDataCollection _extraData = null; + private string _componentId = null; /// /// Initializes the instance of the AppControl class. @@ -444,6 +445,52 @@ namespace Tizen.Applications } } + /// + /// Gets and sets the component ID to explicitly launch a component. + /// + /// + /// (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. + /// + /// + /// + /// AppControl appControl = new AppControl(); + /// appControl.ApplicationId = "org.tizen.component-based-app"; // component-based application + /// appControl.ComponentId = "org.tizen.frame-component"; + /// AppControl.SendLaunchRequest(appControl); + /// + /// + /// 6 + 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 /// -- 2.34.1