--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+
+internal static partial class Interop
+{
+ internal static partial class EflCBApplication
+ {
+ [DllImport(Libraries.CompApplication, EntryPoint = "frame_component_get_resource_id")]
+ internal static extern int GetResourceId(IntPtr win, out int resId);
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+
+internal static partial class Interop
+{
+ internal static partial class Elementary
+ {
+ [DllImport(Libraries.Elementary, EntryPoint = "elm_init")]
+ internal static extern void ElmInit(int argc, string[] argv);
+
+ [DllImport(Libraries.Elementary, EntryPoint = "elm_config_accel_preference_set")]
+ internal static extern IntPtr ElmConfigAccelPreferenceSet(string preference);
+
+ [DllImport(Libraries.Elementary, EntryPoint = "elm_run")]
+ internal static extern void ElmRun();
+
+ [DllImport(Libraries.Elementary, EntryPoint = "elm_exit")]
+ internal static extern void ElmExit();
+
+ [DllImport(Libraries.Elementary, EntryPoint = "elm_shutdown")]
+ internal static extern void ElmShutdown();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string Elementary = "libelementary.so.1";
+ public const string CompApplication = "libcomponent-based-application.so";
+ }
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <!-- Property Group for Tizen Project -->
+ <PropertyGroup>
+ <TargetFramework>netstandard2.0</TargetFramework>
+ <TizenCreateTpkOnBuild>false</TizenCreateTpkOnBuild>
+ </PropertyGroup>
+
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>portable</DebugType>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>None</DebugType>
+ </PropertyGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\ElmSharp\ElmSharp.csproj" />
+ <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+ <ProjectReference Include="..\Tizen.Applications.ComponentBased\Tizen.Applications.ComponentBased.csproj" />
+ <ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
+ <ProjectReference Include="..\Tizen\Tizen.csproj" />
+ </ItemGroup>
+
+ <!-- Include Nuget Package for Tizen Project building -->
+
+</Project>
\ No newline at end of file
--- /dev/null
+using ElmSharp;
+using System;
+using System.Collections.Generic;
+using Tizen.Applications.ComponentBased.Common;
+
+namespace Tizen.Applications.ComponentBased.Default
+{
+ /// <summary>
+ /// The basic EFL component-based application class.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class EFLComponentBasedApplication : ComponentBasedApplication
+ {
+ private const string LogTag = "Tizen.Applications.ComponentBasedApplication";
+
+ /// <summary>
+ /// Initializes the ComponentBasedApplication class.
+ /// </summary>
+ /// <param name="typeInfo">The component type information.
+ /// The key should be a class type of BaseComponent subclass.
+ /// The value should be a component id which is declared in tizen-manifest.xml.
+ /// </param>
+ /// <since_tizen> 6 </since_tizen>
+ public EFLComponentBasedApplication(IDictionary<Type, string> typeInfo) : base(typeInfo)
+ {
+ }
+
+ /// <summary>
+ /// This method will be called before running main-loop
+ /// </summary>
+ /// <param name="args"></param>
+ /// <since_tizen> 6 </since_tizen>
+ protected override void OnInit(string[] args)
+ {
+ Interop.Elementary.ElmInit(args.Length, args);
+ string hwacc = Environment.GetEnvironmentVariable("HWACC");
+
+ if (hwacc == "USE")
+ {
+ Interop.Elementary.ElmConfigAccelPreferenceSet("hw");
+ Log.Info(LogTag, "elm_config_accel_preference_set: hw");
+ }
+ else if (hwacc == "NOT_USE")
+ {
+ Interop.Elementary.ElmConfigAccelPreferenceSet("none");
+ Log.Info(LogTag, "elm_config_accel_preference_set: none");
+ }
+ else
+ {
+ Log.Info(LogTag, "elm_config_accel_preference_set is not called");
+ }
+ }
+
+ /// <summary>
+ /// This method will be called after exiting main-loop
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ protected override void OnFinished()
+ {
+ Interop.Elementary.ElmShutdown();
+ if (Environment.GetEnvironmentVariable("AUL_LOADER_INIT") == null)
+ return;
+
+ Environment.SetEnvironmentVariable("AUL_LOADER_INIT", null);
+ Interop.Elementary.ElmShutdown();
+ }
+
+ /// <summary>
+ /// This method will be called to start main-loop
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ protected override void OnRun()
+ {
+ Interop.Elementary.ElmRun();
+ }
+
+ /// <summary>
+ /// This method will be called to exit main-loop
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ protected override void OnExit()
+ {
+ Interop.Elementary.ElmExit();
+ }
+ }
+}
--- /dev/null
+using ElmSharp;
+using System;
+using Tizen.Applications.ComponentBased.Common;
+
+namespace Tizen.Applications.ComponentBased.Default
+{
+ /// <summary>
+ /// Window information class for ComponentBasedApplication
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public class EFLWindowInfo : IWindowInfo
+ {
+ private const string LogTag = "Tizen.Applications.EFLWindow";
+ private Window _win;
+ private int _resId;
+
+ /// <summary>
+ /// Initializes the EFLWindow class.
+ /// </summary>
+ /// <param name="win">The window object of component.</param>
+ /// <since_tizen> 6 </since_tizen>
+ public EFLWindowInfo(Window win)
+ {
+ _win = win;
+ }
+
+ /// <summary>
+ /// Gets the resource ID of window
+ /// </summary>
+ /// <returns>The native handle of window</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public int ResourceId
+ {
+ get
+ {
+ if (_resId == 0)
+ {
+ int err = Interop.EflCBApplication.GetResourceId(_win.RealHandle, out _resId);
+ if (err != 0)
+ Log.Info(LogTag, "Fail to get resource ID");
+ }
+
+ return _resId;
+ }
+ }
+
+ }
+
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+ internal static partial class AppControl
+ {
+ [DllImport(Libraries.AppControl, EntryPoint = "app_control_set_caller_instance_compId")]
+ internal static extern int SetCallerInstanceId(SafeAppControlHandle appControl, string instanceId);
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using System.Text;
+using Tizen.Applications;
+
+internal static partial class Interop
+{
+ internal static partial class CBApplication
+ {
+ internal delegate void CBAppInitCallback(int argc, string[] argv, IntPtr userData);
+ internal delegate void CBAppFiniCallback(IntPtr userData);
+ internal delegate void CBAppRunCallback(IntPtr userData);
+ internal delegate void CBAppExitCallback(IntPtr userData);
+ internal delegate IntPtr CBAppCreateCallback(IntPtr userData);
+ internal delegate void CBAppTerminateCallback(IntPtr userData);
+ [StructLayoutAttribute(LayoutKind.Sequential)]
+ internal struct CBAppLifecycleCallbacks
+ {
+ public CBAppInitCallback OnInit;
+ public CBAppFiniCallback OnFinished;
+ public CBAppRunCallback OnRun;
+ public CBAppExitCallback OnExit;
+ public CBAppCreateCallback OnCreate;
+ public CBAppTerminateCallback OnTerminate;
+ }
+
+ internal enum ErrorCode : int
+ {
+ None = Tizen.Internals.Errors.ErrorCode.None,
+ InvalidParameter = Tizen.Internals.Errors.ErrorCode.InvalidParameter,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ InvalidContext = -0x03030000 | 0x01,
+ NotSupported = Tizen.Internals.Errors.ErrorCode.NotSupported,
+ NotFound = -0x03030000 | 0x02,
+ LaunchRejected = -0x03030000 | 0x03,
+ LaunchFailed = -0x03030000 | 0x04,
+ TimedOut = Tizen.Internals.Errors.ErrorCode.TimedOut,
+ PermissionDenied = Tizen.Internals.Errors.ErrorCode.PermissionDenied,
+ }
+
+ internal enum NativeComponentType
+ {
+ Frame = 0,
+ Service
+ }
+
+ internal enum NativeDisplayStatus {
+ On,
+ Off
+ }
+
+ internal delegate IntPtr FrameCreateCallback(IntPtr context, IntPtr userData);
+ internal delegate void FrameStartCallback(IntPtr context, IntPtr appControl, bool restarted, IntPtr userData);
+ internal delegate void FrameResumeCallback(IntPtr context, IntPtr userData);
+ internal delegate void FramePauseCallback(IntPtr context, IntPtr userData);
+ internal delegate void FrameStopCallback(IntPtr context, IntPtr userData);
+ internal delegate void FrameDestroyCallback(IntPtr context, IntPtr userData);
+ internal delegate void FrameRestoreCallback(IntPtr context, IntPtr content, IntPtr userData);
+ internal delegate void FrameSaveCallback(IntPtr context, IntPtr content, IntPtr userData);
+ internal delegate void FrameActionCallback(IntPtr context, string action, IntPtr appControl, IntPtr userData);
+ internal delegate void FrameDeviceOrientationChangedCallback(IntPtr context, int orientation, IntPtr userData);
+ internal delegate void FrameLanguageChangedCallback(IntPtr context, string language, IntPtr userData);
+ internal delegate void FrameRegionFormatChangedCallback(IntPtr context, string region, IntPtr userData);
+ internal delegate void FrameLowBatteryCallback(IntPtr context, int status, IntPtr userData);
+ internal delegate void FrameLowMemoryCallback(IntPtr context, int status, IntPtr userData);
+ internal delegate void FrameSuspendedStateCallback(IntPtr context, int state, IntPtr userData);
+
+ internal struct FrameLifecycleCallbacks
+ {
+ public FrameCreateCallback OnCreate;
+ public FrameStartCallback OnStart;
+ public FrameResumeCallback OnResume;
+ public FramePauseCallback OnPause;
+ public FrameStopCallback OnStop;
+ public FrameDestroyCallback OnDestroy;
+ public FrameRestoreCallback OnRestore;
+ public FrameSaveCallback OnSave;
+ public FrameActionCallback OnAction;
+ public FrameDeviceOrientationChangedCallback OnDeviceOrientationChanged;
+ public FrameLanguageChangedCallback OnLanguageChanged;
+ public FrameRegionFormatChangedCallback OnRegionFormatChanged;
+ public FrameLowBatteryCallback OnLowBattery;
+ public FrameLowMemoryCallback OnLowMemory;
+ public FrameSuspendedStateCallback OnSuspendedState;
+ }
+
+ internal delegate bool ServiceCreateCallback(IntPtr context, IntPtr userData);
+ internal delegate void ServiceStartCommandCallback(IntPtr context, IntPtr appControl, bool restarted, IntPtr userData);
+ internal delegate void ServiceDestroyCallback(IntPtr context, IntPtr userData);
+ internal delegate void ServiceRestoreCallback(IntPtr context, IntPtr content, IntPtr userData);
+ internal delegate void ServiceSaveCallback(IntPtr context, IntPtr content, IntPtr userData);
+ internal delegate void ServiceActionCallback(IntPtr context, string action, IntPtr appControl, IntPtr userData);
+ internal delegate void ServiceDeviceOrientationChangedCallback(IntPtr context, int orientation, IntPtr userData);
+ internal delegate void ServiceLanguageChangedCallback(IntPtr context, string language, IntPtr userData);
+ internal delegate void ServiceRegionFormatChangedCallback(IntPtr context, string region, IntPtr userData);
+ internal delegate void ServiceLowBatteryCallback(IntPtr context, int status, IntPtr userData);
+ internal delegate void ServiceLowMemoryCallback(IntPtr context, int status, IntPtr userData);
+ internal delegate void ServiceSuspendedStateCallback(IntPtr context, int state, IntPtr userData);
+
+ internal struct ServiceLifecycleCallbacks
+ {
+ public ServiceCreateCallback OnCreate;
+ public ServiceStartCommandCallback OnStart;
+ public ServiceDestroyCallback OnDestroy;
+ public ServiceRestoreCallback OnRestore;
+ public ServiceSaveCallback OnSave;
+ public ServiceActionCallback OnAction;
+ public ServiceDeviceOrientationChangedCallback OnDeviceOrientationChanged;
+ public ServiceLanguageChangedCallback OnLanguageChanged;
+ public ServiceRegionFormatChangedCallback OnRegionFormatChanged;
+ public ServiceLowBatteryCallback OnLowBattery;
+ public ServiceLowMemoryCallback OnLowMemory;
+ public ServiceSuspendedStateCallback OnSuspendedState;
+ }
+
+ internal delegate IntPtr BaseCreateCallback(IntPtr context, IntPtr userData);
+ internal delegate void BaseDestroyCallback(IntPtr context, IntPtr userData);
+ internal delegate void BaseRestoreCallback(IntPtr context, IntPtr content, IntPtr userData);
+ internal delegate void BaseSaveCallback(IntPtr context, IntPtr content, IntPtr userData);
+ internal delegate void BaseDeviceOrientationChangedCallback(IntPtr context, int orientation, IntPtr userData);
+ internal delegate void BaseLanguageChangedCallback(IntPtr context, string language, IntPtr userData);
+ internal delegate void BaseRegionFormatChangedCallback(IntPtr context, string region, IntPtr userData);
+ internal delegate void BaseLowBatteryCallback(IntPtr context, int status, IntPtr userData);
+ internal delegate void BaseLowMemoryCallback(IntPtr context, int status, IntPtr userData);
+ internal delegate void BaseSuspendedStateCallback(IntPtr context, int state, IntPtr userData);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "component_based_app_base_main")]
+ internal static extern ErrorCode BaseMain(int argc, string[] argv, ref CBAppLifecycleCallbacks callback, IntPtr userData);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "component_based_app_base_exit")]
+ internal static extern ErrorCode BaseExit();
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "component_based_app_base_add_frame_component")]
+ internal static extern IntPtr BaseAddFrameComponent(IntPtr comp_class, string compId, ref FrameLifecycleCallbacks callback, IntPtr userData);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "component_based_app_base_add_service_component")]
+ internal static extern IntPtr BaseAddServiceComponent(IntPtr comp_class, string compId, ref ServiceLifecycleCallbacks callback, IntPtr userData);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "base_frame_create_window")]
+ internal static extern IntPtr BaseFrameCreateWindow(out IntPtr winHandle, int winId, IntPtr raw);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "base_frame_window_get_compId")]
+ internal static extern IntPtr BaseFrameWindowGetId(IntPtr winHandle, out int winId);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "base_frame_window_get_raw")]
+ internal static extern IntPtr BaseFrameWindowGetRaw(IntPtr winHandle, out IntPtr raw);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "base_frame_get_display_status")]
+ internal static extern ErrorCode BaseFrameGetDisplayStatus(IntPtr context, out NativeDisplayStatus status);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "component_get_instance_id")]
+ internal static extern ErrorCode GetInstanceId(IntPtr context, out string instanceId);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ReplyCallback(IntPtr request, IntPtr reply, int result, IntPtr userData);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ internal delegate void ResultCallback(IntPtr request, int result, IntPtr userData);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "component_send_launch_request_async")]
+ internal static extern ErrorCode SendLaunchRequestAsync(IntPtr context, SafeAppControlHandle appControl,
+ ResultCallback resultCallback, ReplyCallback replyCallback, IntPtr userData);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "component_send_launch_request_sync")]
+ internal static extern ErrorCode SendLaunchRequestSync(IntPtr context, SafeAppControlHandle appControl,
+ SafeAppControlHandle replyControl, out int result);
+
+ [DllImport(Libraries.CompCoreBase, EntryPoint = "component_finish")]
+ internal static extern ErrorCode ComponentFinish(IntPtr context);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+internal static partial class Interop
+{
+ internal static partial class Libraries
+ {
+ public const string CompCoreBase = "libcomponent-based-core-base.so";
+ public const string CompApplication = "libcomponent-based-application.so";
+ public const string CompAppControl = "libcomponent-based-app-control.so";
+ public const string CompUri = "libcomponent-based-uri.so";
+ public const string AppControl = "libcapi-appfw-app-control.so.0";
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ /// <summary>
+ /// This is a base-component class.
+ /// It provides common functions of FrameComponent and ServiceComponent.
+ /// </summary>
+ /// <remarks>
+ /// This class cannot be registered by ComponentBased applications.
+ /// </remarks>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class BaseComponent
+ {
+ internal IntPtr Handle;
+
+ /// <summary>
+ /// Occurs when the system memory is low.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public event EventHandler<LowMemoryEventArgs> LowMemory;
+
+ /// <summary>
+ /// Occurs when the system battery is low.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public event EventHandler<LowBatteryEventArgs> LowBattery;
+
+ /// <summary>
+ /// Occurs when the system language is chagned.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public event EventHandler<LocaleChangedEventArgs> LocaleChanged;
+
+ /// <summary>
+ /// Occurs when the region format is changed.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public event EventHandler<RegionFormatChangedEventArgs> RegionFormatChanged;
+
+ /// <summary>
+ /// Occurs when the device orientation is changed.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public event EventHandler<DeviceOrientationEventArgs> DeviceOrientationChanged;
+
+ /// <summary>
+ /// Occurs when the device orientation is changed.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public event EventHandler<SuspendedStateEventArgs> SuspendedStateChanged;
+
+ /// <summary>
+ /// A component instance ID.
+ /// It will be created after OnCreate method is invoked.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public string Id { get; private set; }
+
+ /// <summary>
+ /// A component ID
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public string ComponentId { get; private set; }
+
+ /// <summary>
+ /// Parent object
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public ComponentBasedApplication Parent { get; private set; }
+
+ /// <summary>
+ /// Finish current component
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public void Finish()
+ {
+ Interop.CBApplication.ComponentFinish(Handle);
+ }
+
+ internal void Bind(IntPtr handle, string compId, string instanceId, ComponentBasedApplication parent)
+ {
+ Handle = handle;
+ Id = instanceId;
+ ComponentId = compId;
+ Parent = parent;
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior to restore the previous status.
+ /// </summary>
+ /// <param name="c">Contents. It can be used only in the callback. To use outside, make a copy. </param>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnRestoreContents(Bundle c)
+ {
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior to save current status.
+ /// </summary>
+ /// <param name="c">Contents. It can be used only in the callback. To use outside, make a copy. </param>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnSaveContent(Bundle c)
+ {
+ }
+
+ internal void OnLanguageChangedCallback(string language)
+ {
+ LocaleChanged?.Invoke(this, new LocaleChangedEventArgs(language));
+ }
+
+ internal void OnDeviceOrientationChangedCallback(int orientation)
+ {
+ DeviceOrientationChanged?.Invoke(this, new DeviceOrientationEventArgs((DeviceOrientation)orientation));
+ }
+
+ internal void OnLowBatteryCallback(int status)
+ {
+ LowBattery?.Invoke(this, new LowBatteryEventArgs((LowBatteryStatus)status));
+ }
+
+ internal void OnLowMemoryCallback(int status)
+ {
+ LowMemory?.Invoke(this, new LowMemoryEventArgs((LowMemoryStatus)status));
+ }
+
+ internal void OnRegionFormatChangedCallback(string region)
+ {
+ RegionFormatChanged?.Invoke(this, new RegionFormatChangedEventArgs(region));
+ }
+
+ internal void OnSuspendedStateCallback(int state)
+ {
+ SuspendedStateChanged?.Invoke(this, new SuspendedStateEventArgs((SuspendedState)state));
+ }
+
+ /// <summary>
+ /// Sends the launch request asynchronously.
+ /// </summary>
+ /// <remarks>
+ /// To use group mode, you must use this function instead of SendLaunchRequestAsync().
+ /// </remarks>
+ /// <param name="control">appcontrol object</param>
+ /// <param name="replyAfterLaunching">The callback function to be called when the reply is delivered.</param>
+ /// <returns>A task with the result of the launch request.</returns>
+ /// <exception cref="ArgumentException">Thrown when failed because of the argument is invalid.</exception>
+ /// <exception cref="InvalidOperationException">Thrown when fail to set component information to the AppControl.</exception>
+ /// <exception cref="Exceptions.AppNotFoundException">Thrown when the application to run is not found.</exception>
+ /// <exception cref="Exceptions.LaunchRejectedException">Thrown when the launch request is rejected.</exception>
+ /// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ /// <since_tizen> 6 </since_tizen>
+ public Task<AppControlResult> SendLaunchRequestAsync(AppControl control, AppControlReplyCallback replyAfterLaunching)
+ {
+ int ret = Interop.AppControl.SetCallerInstanceId(control.SafeAppControlHandle, Id);
+ if (ret != 0)
+ throw new InvalidOperationException("Failed to set id");
+
+ return AppControl.SendLaunchRequestAsync(control, replyAfterLaunching);
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ /// <summary>
+ /// The class for supporting multi-components based application model.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class ComponentBasedApplication : Application
+ {
+ private const string LogTag = "Tizen.Applications.ComponentBasedApplicationBase";
+ private Dictionary<Type, ComponentStateManger> _componentFactories = new Dictionary<Type, ComponentStateManger>();
+ private Interop.CBApplication.CBAppLifecycleCallbacks _callbacks;
+
+ /// <summary>
+ /// Initializes the ComponentBasedApplicationBase class.
+ /// </summary>
+ /// <param name="typeInfo">The component type information.
+ /// The key should be a class type of FrameComponent or SubComponent subclass.
+ /// The value should be a component id which is declared in tizen-manifest.xml.
+ /// </param>
+ /// <since_tizen> 6 </since_tizen>
+ public ComponentBasedApplication(IDictionary<Type, string> typeInfo)
+ {
+ _callbacks.OnInit = new Interop.CBApplication.CBAppInitCallback(OnInitNative);
+ _callbacks.OnFinished = new Interop.CBApplication.CBAppFiniCallback(OnFinishedNative);
+ _callbacks.OnRun = new Interop.CBApplication.CBAppRunCallback(OnRunNative);
+ _callbacks.OnExit = new Interop.CBApplication.CBAppExitCallback(OnExitNative);
+ _callbacks.OnCreate = new Interop.CBApplication.CBAppCreateCallback(OnCreateNative);
+ _callbacks.OnTerminate = new Interop.CBApplication.CBAppTerminateCallback(OnTerminateNative);
+
+ foreach (var component in typeInfo)
+ {
+ RegisterComponent(component.Key, component.Value);
+ }
+ }
+
+ /// <summary>
+ /// Registers a component.
+ /// </summary>
+ /// <param name="compType">Class type</param>
+ /// <param name="compId">Component ID</param>
+ /// <exception cref="ArgumentException">Thrown when component type is already added or not sub-class of FrameComponent or ServiceComponent</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public void RegisterComponent(Type compType, string compId)
+ {
+ if (_componentFactories.ContainsKey(compType))
+ {
+ throw new ArgumentException("Already exist type");
+ }
+
+ if (typeof(FrameComponent).IsAssignableFrom(compType))
+ {
+ Log.Info(LogTag, "Add frame component");
+ _componentFactories.Add(compType, new FrameComponentStateManager(compType, compId, this));
+ }
+ else if (typeof(ServiceComponent).IsAssignableFrom(compType))
+ {
+ Log.Info(LogTag, "Add service component");
+ _componentFactories.Add(compType, new ServiceComponentStateManager(compType, compId, this));
+ }
+ else
+ {
+ throw new ArgumentException("compType must be sub type of FrameComponent or ServiceComponent", "compType");
+ }
+ }
+
+ /// <summary>
+ /// Runs the application's main loop.
+ /// </summary>
+ /// <param name="args">Arguments from commandline.</param>
+ /// <exception cref="InvalidOperationException">Thrown when component type is already added to the component.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public override void Run(string[] args)
+ {
+ base.Run(args);
+
+ string[] argsClone = new string[args.Length + 1];
+ if (args.Length > 1)
+ {
+ args.CopyTo(argsClone, 1);
+ }
+ argsClone[0] = string.Empty;
+
+ Interop.CBApplication.ErrorCode err = Interop.CBApplication.BaseMain(argsClone.Length, argsClone, ref _callbacks, IntPtr.Zero);
+ if (err != Interop.CBApplication.ErrorCode.None)
+ {
+ Log.Error(LogTag, "Failed to run the application. Err = " + err);
+ throw new InvalidOperationException("Fail to run application : err(" + err + ")");
+ }
+ }
+
+ /// <summary>
+ /// Exits the main loop of the application.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public override void Exit()
+ {
+ Interop.CBApplication.BaseExit();
+ }
+
+ private IntPtr OnCreateNative(IntPtr data)
+ {
+ Log.Debug(LogTag, "On create");
+ IntPtr nativeComponentFactoryMap = IntPtr.Zero;
+ foreach (KeyValuePair<Type, ComponentStateManger> entry in _componentFactories)
+ {
+ nativeComponentFactoryMap = entry.Value.Bind(nativeComponentFactoryMap);
+ }
+
+ return nativeComponentFactoryMap;
+ }
+
+ private void OnTerminateNative(IntPtr data)
+ {
+ }
+
+ private void OnRunNative(IntPtr data)
+ {
+ OnRun();
+ }
+
+ private void OnExitNative(IntPtr data)
+ {
+ OnExit();
+ }
+
+ private void OnInitNative(int argc, string[] argv, IntPtr userData)
+ {
+ OnInit(argv);
+ }
+
+ private void OnFinishedNative(IntPtr data)
+ {
+ OnFinished();
+ }
+
+ /// <summary>
+ /// This method will be called before running main-loop
+ /// </summary>
+ /// <param name="args"></param>
+ /// <since_tizen> 6 </since_tizen>
+ protected virtual void OnInit(string[] args)
+ {
+ }
+
+ /// <summary>
+ /// This method will be called after exiting main-loop
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ protected virtual void OnFinished()
+ {
+ }
+
+ /// <summary>
+ /// This method will be called to start main-loop
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ protected abstract void OnRun();
+
+ /// <summary>
+ /// This method will be called to exit main-loop
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ protected virtual void OnExit()
+ {
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Tizen.Applications.CoreBackend;
+using static Interop.CBApplication;
+using static Tizen.Applications.CoreBackend.DefaultCoreBackend;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ internal abstract class ComponentStateManger
+ {
+ private IList<BaseComponent> ComponentInstances { get; }
+ public IEnumerable<BaseComponent> Instances => ComponentInstances;
+ protected void AddComponent(BaseComponent comp)
+ {
+ ComponentInstances.Add(comp);
+ }
+
+ protected void RemoveComponent(BaseComponent comp)
+ {
+ ComponentInstances.Remove(comp);
+ }
+ public Type ComponentClassType { get; }
+ public string ComponentId { get; }
+ protected ComponentBasedApplication Parent { get; set; }
+
+ internal ComponentStateManger(Type ctype, string id, ComponentBasedApplication parent)
+ {
+ ComponentClassType = ctype;
+ ComponentId = id;
+ ComponentInstances = new List<BaseComponent>();
+ Parent = parent;
+ }
+
+ protected void OnLanguageChangedCallback(IntPtr context, string language, IntPtr userData)
+ {
+ foreach (BaseComponent com in ComponentInstances)
+ {
+ if (com.Handle == context)
+ {
+ com.OnLanguageChangedCallback(language);
+ }
+ }
+ }
+
+ protected void OnDeviceOrientationChangedCallback(IntPtr context, int orientation, IntPtr userData)
+ {
+ foreach (BaseComponent com in ComponentInstances)
+ {
+ if (com.Handle == context)
+ {
+ com.OnDeviceOrientationChangedCallback(orientation);
+ }
+ }
+ }
+
+ protected void OnLowBatteryCallback(IntPtr context, int status, IntPtr userData)
+ {
+ foreach (BaseComponent com in ComponentInstances)
+ {
+ if (com.Handle == context)
+ {
+ com.OnLowBatteryCallback(status);
+ }
+ }
+ }
+
+ protected void OnLowMemoryCallback(IntPtr context, int status, IntPtr userData)
+ {
+ foreach (BaseComponent com in ComponentInstances)
+ {
+ if (com.Handle == context)
+ {
+ com.OnLowMemoryCallback(status);
+ }
+ }
+ }
+
+ protected void OnRegionFormatChangedCallback(IntPtr context, string region, IntPtr userData)
+ {
+ foreach (BaseComponent com in ComponentInstances)
+ {
+ if (com.Handle == context)
+ {
+ com.OnRegionFormatChangedCallback(region);
+ }
+ }
+ }
+
+ protected void OnSuspendedStateCallback(IntPtr context, int state, IntPtr userData)
+ {
+ foreach (BaseComponent com in ComponentInstances)
+ {
+ if (com.Handle == context)
+ {
+ com.OnSuspendedStateCallback(state);
+ }
+ }
+ }
+
+ protected void OnRestoreCallback(IntPtr context, IntPtr content, IntPtr userData)
+ {
+ foreach (BaseComponent com in ComponentInstances)
+ {
+ if (com.Handle == context)
+ {
+ Bundle bundle = null;
+
+ if (content != IntPtr.Zero)
+ bundle = new Bundle(new SafeBundleHandle(content, false));
+ com.OnRestoreContents(bundle);
+ break;
+ }
+ }
+ }
+
+ protected void OnSaveCallback(IntPtr context, IntPtr content, IntPtr userData)
+ {
+ foreach (BaseComponent com in ComponentInstances)
+ {
+ if (com.Handle == context)
+ {
+ Bundle bundle = null;
+
+ if (content != IntPtr.Zero)
+ bundle = new Bundle(new SafeBundleHandle(content, false));
+ com.OnSaveContent(bundle);
+ break;
+ }
+ }
+ }
+
+ internal abstract IntPtr Bind(IntPtr h);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Threading.Tasks;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ /// <summary>
+ /// Enumeration for display status.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public enum DisplayStatus
+ {
+ /// <summary>
+ /// The display status is on
+ /// </summary>
+ On = Interop.CBApplication.NativeDisplayStatus.On,
+
+ /// <summary>
+ /// The display status is off
+ /// </summary>
+ Off = Interop.CBApplication.NativeDisplayStatus.Off
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ /// <summary>
+ /// The class for showing UI module
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class FrameComponent : BaseComponent
+ {
+ /// <summary>
+ /// Gets the display status of a component.
+ /// </summary>
+ /// <exception cref="InvalidOperationException">Thrown when component type is already added to the component.</exception>
+ /// <since_tizen> 6 </since_tizen>
+ public DisplayStatus DisplayStatus
+ {
+ get
+ {
+ Interop.CBApplication.NativeDisplayStatus status;
+ Interop.CBApplication.ErrorCode err = Interop.CBApplication.BaseFrameGetDisplayStatus(Handle, out status);
+ if (err != Interop.CBApplication.ErrorCode.None)
+ throw new InvalidOperationException("Fail to get display status : err(" + err + ")");
+
+ return (DisplayStatus)status;
+ }
+ }
+
+ /// <summary>
+ /// Overrides this method to handle behavior when the component is launched.
+ /// </summary>
+ /// <returns>True if a service component is successfully created</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract bool OnCreate();
+
+ /// <summary>
+ /// Overrides this method to create window. It will be called before OnCreate method.
+ /// </summary>
+ /// <returns>Window object to use</returns>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract IWindowInfo CreateWindowInfo();
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the component receives the appcontrol message.
+ /// </summary>
+ /// <param name="appControl">appcontrol object</param>
+ /// <param name="restarted">True if it was restarted</param>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnStart(AppControl appControl, bool restarted)
+ {
+ }
+
+ /// <summary>
+ /// Overrides this method if you want to handle the behavior when the component is resumed.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnResume()
+ {
+ }
+
+ /// <summary>
+ /// Overrides this method if you want to handle the behavior when the component is paused.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnPause()
+ {
+ }
+
+ /// <summary>
+ /// Overrides this method if you want to handle the behavior when the component is stopped.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnStop()
+ {
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the component is destroyed.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnDestroy()
+ {
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ internal class FrameComponentStateManager : ComponentStateManger
+ {
+ private Interop.CBApplication.FrameLifecycleCallbacks _callbacks;
+ private const string LogTag = "Tizen.Applications.FrameComponentStateManager";
+
+ internal FrameComponentStateManager(Type ctype, string id, ComponentBasedApplication parent) : base(ctype, id, parent)
+ {
+ _callbacks.OnAction = new Interop.CBApplication.FrameActionCallback(OnActionCallback);
+ _callbacks.OnDeviceOrientationChanged = new Interop.CBApplication.FrameDeviceOrientationChangedCallback(OnDeviceOrientationChangedCallback);
+ _callbacks.OnLanguageChanged = new Interop.CBApplication.FrameLanguageChangedCallback(OnLanguageChangedCallback);
+ _callbacks.OnLowBattery = new Interop.CBApplication.FrameLowBatteryCallback(OnLowBatteryCallback);
+ _callbacks.OnLowMemory = new Interop.CBApplication.FrameLowMemoryCallback(OnLowMemoryCallback);
+ _callbacks.OnRegionFormatChanged = new Interop.CBApplication.FrameRegionFormatChangedCallback(OnRegionFormatChangedCallback);
+ _callbacks.OnRestore = new Interop.CBApplication.FrameRestoreCallback(OnRestoreCallback);
+ _callbacks.OnSave = new Interop.CBApplication.FrameSaveCallback(OnSaveCallback);
+ _callbacks.OnSuspendedState = new Interop.CBApplication.FrameSuspendedStateCallback(OnSuspendedStateCallback);
+ _callbacks.OnCreate = new Interop.CBApplication.FrameCreateCallback(OnCreateCallback);
+ _callbacks.OnDestroy = new Interop.CBApplication.FrameDestroyCallback(OnDestroyCallback);
+ _callbacks.OnPause = new Interop.CBApplication.FramePauseCallback(OnPauseCallback);
+ _callbacks.OnResume = new Interop.CBApplication.FrameResumeCallback(OnResumeCallback);
+ _callbacks.OnStart = new Interop.CBApplication.FrameStartCallback(OnStartCallback);
+ _callbacks.OnStop = new Interop.CBApplication.FrameStopCallback(OnStopCallback);
+ Parent = parent;
+ }
+
+ private IntPtr OnCreateCallback(IntPtr context, IntPtr userData)
+ {
+ FrameComponent fc = Activator.CreateInstance(ComponentClassType) as FrameComponent;
+ if (fc == null)
+ {
+ Log.Error(LogTag, "Fail to create instance");
+ return IntPtr.Zero;
+ }
+
+ string id;
+ Interop.CBApplication.GetInstanceId(context, out id);
+ fc.Bind(context, ComponentId, id, Parent);
+
+ IntPtr winHandle;
+ IWindowInfo win = fc.CreateWindowInfo();
+ if (win == null)
+ return IntPtr.Zero;
+
+ if (!fc.OnCreate())
+ {
+ Log.Error(LogTag, "OnCreate fail");
+ return IntPtr.Zero;
+ }
+ Interop.CBApplication.BaseFrameCreateWindow(out winHandle, win.ResourceId, IntPtr.Zero);
+
+ AddComponent(fc);
+ return winHandle;
+ }
+
+ private void OnStartCallback(IntPtr context, IntPtr appControl, bool restarted, IntPtr userData)
+ {
+ foreach (FrameComponent fc in Instances)
+ {
+ if (fc.Handle == context)
+ {
+ SafeAppControlHandle handle = new SafeAppControlHandle(appControl, false);
+ AppControl control = new AppControl(handle);
+ fc.OnStart(control, restarted);
+ break;
+ }
+ }
+ }
+
+ private void OnResumeCallback(IntPtr context, IntPtr userData)
+ {
+ foreach (FrameComponent fc in Instances)
+ {
+ if (fc.Handle == context)
+ {
+ fc.OnResume();
+ break;
+ }
+ }
+ }
+
+ private void OnPauseCallback(IntPtr context, IntPtr userData)
+ {
+ foreach (FrameComponent fc in Instances)
+ {
+ if (fc.Handle == context)
+ {
+ fc.OnPause();
+ break;
+ }
+ }
+ }
+
+ private void OnStopCallback(IntPtr context, IntPtr userData)
+ {
+ foreach (FrameComponent fc in Instances)
+ {
+ if (fc.Handle == context)
+ {
+ fc.OnStop();
+ break;
+ }
+ }
+ }
+
+ private void OnDestroyCallback(IntPtr context, IntPtr userData)
+ {
+ foreach (FrameComponent fc in Instances)
+ {
+ if (fc.Handle == context)
+ {
+ fc.OnDestroy();
+ RemoveComponent(fc);
+ break;
+ }
+ }
+ return;
+ }
+
+ private void OnActionCallback(IntPtr context, string action, IntPtr appControl, IntPtr userData)
+ {
+ }
+
+ internal override IntPtr Bind(IntPtr h)
+ {
+ return Interop.CBApplication.BaseAddFrameComponent(h, ComponentId, ref _callbacks, IntPtr.Zero);
+ }
+ }
+}
--- /dev/null
+using System;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ /// <summary>
+ /// Interface for window information
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public interface IWindowInfo
+ {
+ /// <summary>
+ /// Gets window resource ID
+ /// </summary>
+ /// <returns></returns>
+ int ResourceId { get; }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ /// <summary>
+ /// The class for showing service module
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public abstract class ServiceComponent : BaseComponent
+ {
+ /// <summary>
+ /// Overrides this method to handle behavior when the component is created.
+ /// </summary>
+ /// <returns>True if a service component is successfully created</returns>
+ public abstract bool OnCreate();
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the component receives the start command message.
+ /// </summary>
+ /// <param name="appControl">appcontrol object</param>
+ /// <param name="restarted">True if it was restarted</param>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnStartCommand(AppControl appControl, bool restarted)
+ {
+ }
+
+ /// <summary>
+ /// Overrides this method if want to handle behavior when the component is destroyed.
+ /// </summary>
+ /// <since_tizen> 6 </since_tizen>
+ public virtual void OnDestroy()
+ {
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.Applications.ComponentBased.Common
+{
+ internal class ServiceComponentStateManager : ComponentStateManger
+ {
+ private Interop.CBApplication.ServiceLifecycleCallbacks _callbacks;
+
+ internal ServiceComponentStateManager(Type ctype, string id, ComponentBasedApplication parent) : base(ctype, id, parent)
+ {
+ _callbacks.OnAction = new Interop.CBApplication.ServiceActionCallback(OnActionCallback);
+ _callbacks.OnDeviceOrientationChanged = new Interop.CBApplication.ServiceDeviceOrientationChangedCallback(OnDeviceOrientationChangedCallback);
+ _callbacks.OnLanguageChanged = new Interop.CBApplication.ServiceLanguageChangedCallback(OnLanguageChangedCallback);
+ _callbacks.OnLowBattery = new Interop.CBApplication.ServiceLowBatteryCallback(OnLowBatteryCallback);
+ _callbacks.OnLowMemory = new Interop.CBApplication.ServiceLowMemoryCallback(OnLowMemoryCallback);
+ _callbacks.OnRegionFormatChanged = new Interop.CBApplication.ServiceRegionFormatChangedCallback(OnRegionFormatChangedCallback);
+ _callbacks.OnRestore = new Interop.CBApplication.ServiceRestoreCallback(OnRestoreCallback);
+ _callbacks.OnSave = new Interop.CBApplication.ServiceSaveCallback(OnSaveCallback);
+ _callbacks.OnSuspendedState = new Interop.CBApplication.ServiceSuspendedStateCallback(OnSuspendedStateCallback);
+ _callbacks.OnCreate = new Interop.CBApplication.ServiceCreateCallback(OnCreateCallback);
+ _callbacks.OnDestroy = new Interop.CBApplication.ServiceDestroyCallback(OnDestroyCallback);
+ _callbacks.OnStart = new Interop.CBApplication.ServiceStartCommandCallback(OnStartCallback);
+ Parent = parent;
+ }
+
+ private bool OnCreateCallback(IntPtr context, IntPtr userData)
+ {
+ ServiceComponent sc = Activator.CreateInstance(ComponentClassType) as ServiceComponent;
+ if (sc == null)
+ return false;
+
+ string id;
+ Interop.CBApplication.GetInstanceId(context, out id);
+ sc.Bind(context, ComponentId, id, Parent);
+
+ if (!sc.OnCreate())
+ {
+ return false;
+ }
+
+ AddComponent(sc);
+ return true;
+ }
+
+ private void OnStartCallback(IntPtr context, IntPtr appControl, bool restarted, IntPtr userData)
+ {
+ foreach (ServiceComponent sc in Instances)
+ {
+ if (sc.Handle == context)
+ {
+ SafeAppControlHandle handle = new SafeAppControlHandle(appControl, false);
+ AppControl control = new AppControl(handle);
+ sc.OnStartCommand(control, restarted);
+ break;
+ }
+ }
+ }
+
+ private void OnDestroyCallback(IntPtr context, IntPtr userData)
+ {
+ foreach (ServiceComponent sc in Instances)
+ {
+ if (sc.Handle == context)
+ {
+ sc.OnDestroy();
+ RemoveComponent(sc);
+ break;
+ }
+ }
+ return;
+ }
+
+ private void OnActionCallback(IntPtr context, string action, IntPtr appControl, IntPtr userData)
+ {
+ }
+
+ internal override IntPtr Bind(IntPtr h)
+ {
+ return Interop.CBApplication.BaseAddServiceComponent(h, ComponentId, ref _callbacks, IntPtr.Zero);
+ }
+ }
+}
--- /dev/null
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>netstandard2.0</TargetFramework>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\Tizen.Applications.Common\Tizen.Applications.Common.csproj" />
+ </ItemGroup>
+
+
+</Project>
--- /dev/null
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.26124.0
+MinimumVisualStudioVersion = 15.0.26124.0
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.ComponentBased", "Tizen.Applications.ComponentBased.csproj", "{AD96625A-6D22-4488-AB3A-2EAD2A895931}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Applications.Common", "..\Tizen.Applications.Common\Tizen.Applications.Common.csproj", "{355E4947-6FCB-44B8-8EEF-2A97FA942502}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen.Log", "..\Tizen.Log\Tizen.Log.csproj", "{2C5A9D7F-0527-4012-9566-70E2BC97B619}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tizen", "..\Tizen\Tizen.csproj", "{518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ElmSharp", "..\ElmSharp\ElmSharp.csproj", "{EC949A36-62F5-41B7-9D1F-7139F1D53C99}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications.ComponentBased.Default", "..\Tizen.Applications.ComponentBased.Default\Tizen.Applications.ComponentBased.Default.csproj", "{AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Debug|x64.Build.0 = Debug|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Debug|x86.Build.0 = Debug|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Release|x64.ActiveCfg = Release|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Release|x64.Build.0 = Release|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Release|x86.ActiveCfg = Release|Any CPU
+ {AD96625A-6D22-4488-AB3A-2EAD2A895931}.Release|x86.Build.0 = Release|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Debug|x64.Build.0 = Debug|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Debug|x86.Build.0 = Debug|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Release|Any CPU.Build.0 = Release|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Release|x64.ActiveCfg = Release|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Release|x64.Build.0 = Release|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Release|x86.ActiveCfg = Release|Any CPU
+ {355E4947-6FCB-44B8-8EEF-2A97FA942502}.Release|x86.Build.0 = Release|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Debug|x64.Build.0 = Debug|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Debug|x86.Build.0 = Debug|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Release|x64.ActiveCfg = Release|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Release|x64.Build.0 = Release|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Release|x86.ActiveCfg = Release|Any CPU
+ {2C5A9D7F-0527-4012-9566-70E2BC97B619}.Release|x86.Build.0 = Release|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Debug|x64.Build.0 = Debug|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Debug|x86.Build.0 = Debug|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Release|x64.ActiveCfg = Release|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Release|x64.Build.0 = Release|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Release|x86.ActiveCfg = Release|Any CPU
+ {518F51D4-0C4E-4B37-82B0-93DC5C5DB45F}.Release|x86.Build.0 = Release|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Debug|x64.Build.0 = Debug|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Debug|x86.Build.0 = Debug|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Release|Any CPU.Build.0 = Release|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Release|x64.ActiveCfg = Release|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Release|x64.Build.0 = Release|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Release|x86.ActiveCfg = Release|Any CPU
+ {EC949A36-62F5-41B7-9D1F-7139F1D53C99}.Release|x86.Build.0 = Release|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Debug|x64.Build.0 = Debug|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Debug|x86.Build.0 = Debug|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Release|x64.ActiveCfg = Release|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Release|x64.Build.0 = Release|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Release|x86.ActiveCfg = Release|Any CPU
+ {AA75A4EC-AE72-4954-AD43-A9B2FAA69CDF}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {32D5E43C-CB76-49CC-A427-0A9C98ADEF3B}
+ EndGlobalSection
+EndGlobal