[Applications.Common] Add a new property of AppControl (#1002)
[platform/core/csapi/tizenfx.git] / src / Tizen.Applications.Common / Tizen.Applications / AppControl.cs
index 3d05d1f..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>
@@ -588,7 +635,7 @@ namespace Tizen.Applications
                     case Interop.AppControl.ErrorCode.OutOfMemory:
                         throw new Exceptions.OutOfMemoryException("Out-of-memory");
                     case Interop.AppControl.ErrorCode.AppNotFound:
-                        throw new Exceptions.AppNotFoundException("App not found");
+                        throw new Exceptions.AppNotFoundException("App(" + launchRequest.ApplicationId + ") not found. Operation(" + launchRequest.Operation + ")");
                     case Interop.AppControl.ErrorCode.LaunchRejected:
                         throw new Exceptions.LaunchRejectedException("Launch rejected");
                     case Interop.AppControl.ErrorCode.LaunchFailed:
@@ -710,7 +757,7 @@ namespace Tizen.Applications
                     case Interop.AppControl.ErrorCode.InvalidParameter:
                         throw new ArgumentException("Invalid Arguments");
                     case Interop.AppControl.ErrorCode.AppNotFound:
-                        throw new Exceptions.AppNotFoundException("App not found");
+                        throw new Exceptions.AppNotFoundException("App(" + launchRequest.ApplicationId + ") not found. Operation(" + launchRequest.Operation + ")");
                     case Interop.AppControl.ErrorCode.LaunchRejected:
                         throw new Exceptions.LaunchRejectedException("Launch rejected");
                     case Interop.AppControl.ErrorCode.PermissionDenied: