From dd2576565205f906fa8d8b578b8f1e917c475e3f Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Tue, 22 Mar 2016 16:44:00 +0900 Subject: [PATCH] Refactor to simple model Change-Id: I09342b8e55b77389c00e8fd7874768a1ede5aa89 --- .gitignore | 1 + AppFW.sln | 18 ++ .../Interop.AppCommon.cs} | 11 +- Tizen.Applications/Interop/Interop.AppControl.cs | 15 +- Tizen.Applications/Interop/Interop.AppEvent.cs | 72 +++++ Tizen.Applications/Interop/Interop.Application.cs | 14 +- Tizen.Applications/Interop/Interop.Aul.cs | 37 --- Tizen.Applications/Interop/Interop.Libraries.cs | 7 +- Tizen.Applications/Interop/Interop.Service.cs | 39 +++ Tizen.Applications/Interop/Interop.Window.cs | 29 -- Tizen.Applications/Tizen.Applications.csproj | 28 +- .../Tizen.Applications/AppControlEventArgs.cs | 13 + .../Tizen.Applications/AppControlFilter.cs | 134 -------- .../Tizen.Applications/Application.cs | 359 +++------------------ .../Tizen.Applications/ApplicationInfo.cs | 33 ++ Tizen.Applications/Tizen.Applications/Bundle.cs | 44 +-- Tizen.Applications/Tizen.Applications/Context.cs | 59 ---- .../Tizen.Applications/Controller.cs | 117 ------- .../Tizen.Applications/LocaleChangedEventArgs.cs | 5 +- .../LowMemoryEventArgs.cs} | 8 +- .../Tizen.Applications/LowMemoryStatus.cs | 38 +++ .../Tizen.Applications/ServiceApplication.cs | 58 ++++ .../TizenSynchronizationContext.cs | 2 +- .../Tizen.Applications/UIApplication.cs | 75 +++++ .../Tizen.Applications/UIController.cs | 101 ------ Tizen.Applications/Tizen.UI/IUIContext.cs | 26 -- Tizen.Applications/Tizen.UI/Window.cs | 64 ---- Tizen.UI/Properties/AssemblyInfo.cs | 36 --- Tizen.UI/Tizen.UI.csproj | 55 ---- packaging/csapi-application.spec | 3 +- 30 files changed, 468 insertions(+), 1033 deletions(-) rename Tizen.Applications/{Tizen.Applications/ServiceController.cs => Interop/Interop.AppCommon.cs} (71%) create mode 100755 Tizen.Applications/Interop/Interop.AppEvent.cs delete mode 100755 Tizen.Applications/Interop/Interop.Aul.cs mode change 100644 => 100755 Tizen.Applications/Interop/Interop.Libraries.cs create mode 100755 Tizen.Applications/Interop/Interop.Service.cs delete mode 100755 Tizen.Applications/Interop/Interop.Window.cs mode change 100644 => 100755 Tizen.Applications/Tizen.Applications.csproj create mode 100755 Tizen.Applications/Tizen.Applications/AppControlEventArgs.cs delete mode 100755 Tizen.Applications/Tizen.Applications/AppControlFilter.cs create mode 100755 Tizen.Applications/Tizen.Applications/ApplicationInfo.cs mode change 100644 => 100755 Tizen.Applications/Tizen.Applications/Bundle.cs delete mode 100755 Tizen.Applications/Tizen.Applications/Context.cs delete mode 100755 Tizen.Applications/Tizen.Applications/Controller.cs rename Tizen.UI/Tizen.UI/Window.cs => Tizen.Applications/Tizen.Applications/LocaleChangedEventArgs.cs (52%) rename Tizen.Applications/{Tizen.UI/Page.cs => Tizen.Applications/LowMemoryEventArgs.cs} (76%) create mode 100755 Tizen.Applications/Tizen.Applications/LowMemoryStatus.cs create mode 100755 Tizen.Applications/Tizen.Applications/ServiceApplication.cs create mode 100755 Tizen.Applications/Tizen.Applications/UIApplication.cs delete mode 100755 Tizen.Applications/Tizen.Applications/UIController.cs delete mode 100755 Tizen.Applications/Tizen.UI/IUIContext.cs delete mode 100755 Tizen.Applications/Tizen.UI/Window.cs delete mode 100755 Tizen.UI/Properties/AssemblyInfo.cs delete mode 100755 Tizen.UI/Tizen.UI.csproj diff --git a/.gitignore b/.gitignore index 8fd3218..1b085dd 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ obj/ *.exe *.dll .vs/ +Test/ diff --git a/AppFW.sln b/AppFW.sln index a7f4b55..b31afed 100755 --- a/AppFW.sln +++ b/AppFW.sln @@ -5,6 +5,12 @@ VisualStudioVersion = 14.0.24720.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Applications", "Tizen.Applications\Tizen.Applications.csproj", "{663C5A3D-E631-4987-AEE7-F498C56A40FC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen", "..\tizen\Tizen\Tizen.csproj", "{7659CA59-410D-41A1-9841-586E88BC78C9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tizen.Internals", "..\tizen\Tizen.Internals\Tizen.Internals.csproj", "{B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{296FB4FC-D152-45AF-99BF-09CC7A212262}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -15,6 +21,18 @@ Global {663C5A3D-E631-4987-AEE7-F498C56A40FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {663C5A3D-E631-4987-AEE7-F498C56A40FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {663C5A3D-E631-4987-AEE7-F498C56A40FC}.Release|Any CPU.Build.0 = Release|Any CPU + {7659CA59-410D-41A1-9841-586E88BC78C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7659CA59-410D-41A1-9841-586E88BC78C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7659CA59-410D-41A1-9841-586E88BC78C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7659CA59-410D-41A1-9841-586E88BC78C9}.Release|Any CPU.Build.0 = Release|Any CPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B9AA1CB2-F72D-4A30-A33B-A20C850A38A0}.Release|Any CPU.Build.0 = Release|Any CPU + {296FB4FC-D152-45AF-99BF-09CC7A212262}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {296FB4FC-D152-45AF-99BF-09CC7A212262}.Debug|Any CPU.Build.0 = Debug|Any CPU + {296FB4FC-D152-45AF-99BF-09CC7A212262}.Release|Any CPU.ActiveCfg = Release|Any CPU + {296FB4FC-D152-45AF-99BF-09CC7A212262}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Tizen.Applications/Tizen.Applications/ServiceController.cs b/Tizen.Applications/Interop/Interop.AppCommon.cs similarity index 71% rename from Tizen.Applications/Tizen.Applications/ServiceController.cs rename to Tizen.Applications/Interop/Interop.AppCommon.cs index 906de6e..fa4a190 100755 --- a/Tizen.Applications/Tizen.Applications/ServiceController.cs +++ b/Tizen.Applications/Interop/Interop.AppCommon.cs @@ -8,13 +8,14 @@ using System; +using System.Runtime.InteropServices; -namespace Tizen.Applications +using Tizen.Internals.Errors; + +internal static partial class Interop { - /// - /// - /// - public abstract class ServiceController : Controller + internal static partial class AppCommon { } } + diff --git a/Tizen.Applications/Interop/Interop.AppControl.cs b/Tizen.Applications/Interop/Interop.AppControl.cs index 84ff6c9..90595e7 100755 --- a/Tizen.Applications/Interop/Interop.AppControl.cs +++ b/Tizen.Applications/Interop/Interop.AppControl.cs @@ -14,22 +14,25 @@ internal static partial class Interop { internal static partial class AppControl { - [DllImport(Libraries.Application, EntryPoint = "app_control_create")] + [DllImport(Libraries.AppControl, EntryPoint = "app_control_create")] internal static extern int Create(out SafeAppControlHandle handle); - [DllImport(Libraries.Application, EntryPoint = "app_control_get_app_id", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Libraries.AppControl, EntryPoint = "app_control_clone")] + internal static extern int Clone(out SafeAppControlHandle clone, SafeAppControlHandle handle); + + [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_app_id", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetAppId(IntPtr app_control, out IntPtr app_id); - [DllImport(Libraries.Application, EntryPoint = "app_control_get_operation", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_operation", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetOperation(SafeAppControlHandle handle, out string operation); - [DllImport(Libraries.Application, EntryPoint = "app_control_get_uri", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_uri", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetUri(SafeAppControlHandle handle, out string uri); - [DllImport(Libraries.Application, EntryPoint = "app_control_get_mime", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Libraries.AppControl, EntryPoint = "app_control_get_mime", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetMime(SafeAppControlHandle handle, out string mime); - [DllImport(Libraries.Application, EntryPoint = "app_control_destroy", CallingConvention = CallingConvention.Cdecl)] + [DllImport(Libraries.AppControl, EntryPoint = "app_control_destroy", CallingConvention = CallingConvention.Cdecl)] private static extern int DangerousDestroy(IntPtr handle); internal sealed class SafeAppControlHandle : SafeHandle diff --git a/Tizen.Applications/Interop/Interop.AppEvent.cs b/Tizen.Applications/Interop/Interop.AppEvent.cs new file mode 100755 index 0000000..53c6c7b --- /dev/null +++ b/Tizen.Applications/Interop/Interop.AppEvent.cs @@ -0,0 +1,72 @@ +/// Copyright 2016 by Samsung Electronics, Inc., +/// +/// This software is the confidential and proprietary information +/// of Samsung Electronics, Inc. ("Confidential Information"). You +/// shall not disclose such Confidential Information and shall use +/// it only in accordance with the terms of the license agreement +/// you entered into with Samsung. + + +using System; +using System.Runtime.InteropServices; + +using Tizen.Internals.Errors; + +internal static partial class Interop +{ + internal static partial class AppEvent + { + internal delegate void AppEventCallback(string eventName, IntPtr bundle, IntPtr data); + + [DllImport(Libraries.AppEvent, EntryPoint = "event_add_event_handler")] + internal static extern ErrorCode AddEventHandler(string eventName, AppEventCallback callback, IntPtr data, out SafeAppEventHandle eventHandler); + + [DllImport(Libraries.AppEvent, EntryPoint = "event_remove_event_handler")] + internal static extern ErrorCode DangerousRemoveEventHandler(IntPtr eventHandler); + + [DllImport(Libraries.AppEvent, EntryPoint = "event_publish_app_event")] + internal static extern ErrorCode Publish(string eventName, IntPtr bundle); + + [DllImport(Libraries.AppEvent, EntryPoint = "event_publish_trusted_app_event")] + internal static extern ErrorCode PublishTrusted(string eventName, IntPtr bundle); + + internal sealed class SafeAppEventHandle : SafeHandle + { + public SafeAppEventHandle() : base(IntPtr.Zero, true) + { + } + + public override bool IsInvalid + { + get { return handle == IntPtr.Zero; } + } + + protected override bool ReleaseHandle() + { + DangerousRemoveEventHandler(handle); + SetHandle(IntPtr.Zero); + return true; + } + } + + internal class EventNames + { + internal const string LowMemory = "tizen.system.event.low_memory"; + internal const string LanguageSet = "tizen.system.event.language_set"; + } + + internal class EventKeys + { + internal const string LowMemory = "low_memory"; + internal const string LanguageSet = "language_set"; + } + + internal class EventValues + { + internal const string MemoryNormal = "normal"; + internal const string MemorySoftWarning = "soft_warning"; + internal const string MemoryHardWarning = "hard_warning"; + } + } +} + diff --git a/Tizen.Applications/Interop/Interop.Application.cs b/Tizen.Applications/Interop/Interop.Application.cs index bbb04fe..d155754 100755 --- a/Tizen.Applications/Interop/Interop.Application.cs +++ b/Tizen.Applications/Interop/Interop.Application.cs @@ -14,26 +14,21 @@ internal static partial class Interop { internal static partial class Application { - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate bool AppCreateCallback(IntPtr userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void AppPauseCallback(IntPtr userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void AppResumeCallback(IntPtr userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void AppTerminateCallback(IntPtr userData); - [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void AppControlCallback(IntPtr appControl, IntPtr userData); - [DllImport(Libraries.Application, EntryPoint = "ui_app_main", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UIAppMain(int argc, string[] argv, ref UIAppLifecycleCallbacks callback, IntPtr userData); + [DllImport(Libraries.Application, EntryPoint = "ui_app_main")] + internal static extern int Main(int argc, string[] argv, ref UIAppLifecycleCallbacks callback, IntPtr userData); - [DllImport(Libraries.Application, EntryPoint = "ui_app_exit", CallingConvention = CallingConvention.Cdecl)] - internal static extern void UIAppExit(); + [DllImport(Libraries.Application, EntryPoint = "ui_app_exit")] + internal static extern void Exit(); [StructLayoutAttribute(LayoutKind.Sequential)] internal struct UIAppLifecycleCallbacks @@ -46,3 +41,4 @@ internal static partial class Interop } } } + diff --git a/Tizen.Applications/Interop/Interop.Aul.cs b/Tizen.Applications/Interop/Interop.Aul.cs deleted file mode 100755 index 0100d72..0000000 --- a/Tizen.Applications/Interop/Interop.Aul.cs +++ /dev/null @@ -1,37 +0,0 @@ -/// Copyright 2016 by Samsung Electronics, Inc., -/// -/// This software is the confidential and proprietary information -/// of Samsung Electronics, Inc. ("Confidential Information"). You -/// shall not disclose such Confidential Information and shall use -/// it only in accordance with the terms of the license agreement -/// you entered into with Samsung. - - -using System.Runtime.InteropServices; -using System.Text; - -internal static partial class Interop -{ - internal static partial class Aul - { - private const int MaxMimeLength = 128; - private const string FileSchemaPrefix = "file://"; - - internal static string GetMimeFromUri(string uri) - { - StringBuilder sb = new StringBuilder(MaxMimeLength); - int err = aul_get_mime_from_file(uri.StartsWith(FileSchemaPrefix) ? uri.Substring(FileSchemaPrefix.Length) : uri, sb, MaxMimeLength); - if (err == 0) - { - return sb.ToString(); - } - else - { - return null; - } - } - - [DllImport(Libraries.Aul, CallingConvention = CallingConvention.Cdecl)] - private static extern int aul_get_mime_from_file(string filename, StringBuilder mimetype, int len); - } -} diff --git a/Tizen.Applications/Interop/Interop.Libraries.cs b/Tizen.Applications/Interop/Interop.Libraries.cs old mode 100644 new mode 100755 index f7a4aa0..5ce88c4 --- a/Tizen.Applications/Interop/Interop.Libraries.cs +++ b/Tizen.Applications/Interop/Interop.Libraries.cs @@ -10,11 +10,12 @@ internal static partial class Interop { internal static partial class Libraries { - public const string Aul = "libaul.so.0"; public const string Application = "libcapi-appfw-application.so.0"; + public const string AppCommon = "libcapi-appfw-app-common.so.0"; + public const string AppControl = "libcapi-appfw-app-control.so.0"; + public const string AppEvent = "libcapi-appfw-event.so.0"; + public const string AppcoreAgent = "libappcore-agent.so.1"; public const string Bundle = "libbundle.so.0"; public const string Glib = "libglib-2.0.so.0"; - public const string Elementary = "libelementary.so.1"; - public const string Evas = "libevas.so.1"; } } diff --git a/Tizen.Applications/Interop/Interop.Service.cs b/Tizen.Applications/Interop/Interop.Service.cs new file mode 100755 index 0000000..2fdacea --- /dev/null +++ b/Tizen.Applications/Interop/Interop.Service.cs @@ -0,0 +1,39 @@ +/// Copyright 2016 by Samsung Electronics, Inc., +/// +/// This software is the confidential and proprietary information +/// of Samsung Electronics, Inc. ("Confidential Information"). You +/// shall not disclose such Confidential Information and shall use +/// it only in accordance with the terms of the license agreement +/// you entered into with Samsung. + + +using System; +using System.Runtime.InteropServices; + +using Tizen.Internals.Errors; + +internal static partial class Interop +{ + internal static partial class Service + { + internal delegate bool ServiceAppCreateCallback(IntPtr userData); + + internal delegate void ServiceAppTerminateCallback(IntPtr userData); + + internal delegate void ServiceAppControlCallback(IntPtr appControl, IntPtr userData); + + [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_main")] + internal static extern int Main(int argc, string[] argv, ref ServiceAppLifecycleCallbacks callback, IntPtr userData); + + [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_exit")] + internal static extern void Exit(); + + [StructLayoutAttribute(LayoutKind.Sequential)] + internal struct ServiceAppLifecycleCallbacks + { + public ServiceAppCreateCallback OnCreate; + public ServiceAppTerminateCallback OnTerminate; + public ServiceAppControlCallback OnAppControl; + } + } +} diff --git a/Tizen.Applications/Interop/Interop.Window.cs b/Tizen.Applications/Interop/Interop.Window.cs deleted file mode 100755 index 30e8bd9..0000000 --- a/Tizen.Applications/Interop/Interop.Window.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Runtime.InteropServices; - -internal static partial class Interop -{ - internal static partial class Window - { - [DllImport(Libraries.Elementary, CallingConvention = CallingConvention.Cdecl)] - internal static extern IntPtr elm_win_add(IntPtr parent, string name, int type); - - [DllImport(Libraries.Evas, CallingConvention = CallingConvention.Cdecl)] - internal static extern void evas_object_show(IntPtr obj); - - [DllImport(Libraries.Evas, CallingConvention = CallingConvention.Cdecl)] - internal static extern void evas_object_hide(IntPtr obj); - - [DllImport(Libraries.Evas, CallingConvention = CallingConvention.Cdecl)] - internal static extern bool evas_object_visible_get(IntPtr obj); - - [DllImport(Libraries.Evas, CallingConvention = CallingConvention.Cdecl)] - internal static extern void evas_object_unref(IntPtr obj); - - [DllImport(Libraries.Elementary, CallingConvention = CallingConvention.Cdecl)] - internal static extern void elm_win_activate(IntPtr obj); - - [DllImport(Libraries.Elementary, CallingConvention = CallingConvention.Cdecl)] - internal static extern void elm_win_lower(IntPtr obj); - } -} diff --git a/Tizen.Applications/Tizen.Applications.csproj b/Tizen.Applications/Tizen.Applications.csproj old mode 100644 new mode 100755 index ffb1e57..3536789 --- a/Tizen.Applications/Tizen.Applications.csproj +++ b/Tizen.Applications/Tizen.Applications.csproj @@ -47,34 +47,40 @@ - ..\..\tizen\Tizen.Internals\bin\Debug\Tizen.Internals.dll + ..\..\tizen\Tizen.Internals\obj\Debug\Tizen.Internals.dll + + - - + - - + + + + + + + - - - - - - + + + {7659ca59-410d-41a1-9841-586e88bc78c9} + Tizen + + - \ No newline at end of file diff --git a/packaging/csapi-application.spec b/packaging/csapi-application.spec index 0f5f59d..ce5de3a 100644 --- a/packaging/csapi-application.spec +++ b/packaging/csapi-application.spec @@ -19,10 +19,11 @@ BuildRequires: mono-devel BuildRequires: pkgconfig(csapi-tizen) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(appcore-agent) Requires: glib-2.0 Requires: capi-appfw-application -Requires: evas +Requires: appcore-agent Requires(post): mono-core Requires(postun): mono-core -- 2.7.4