From: WonYoung Choi Date: Wed, 9 Mar 2016 13:53:29 +0000 (+0900) Subject: Refactor Tizen.Applications X-Git-Tag: submit/trunk/20170823.075128~121^2~223 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90a6c434a7f88216a4213e1295be287c91506457;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Refactor Tizen.Applications - Rename ContextGroup to ActorGroup - Manage Service in Application - Manage ActorLifecycle in ActorGroup - Apply CodeFormatter Change-Id: I5f616979e0f34868ea5e5faacbe3aa7b9c0e19f5 --- diff --git a/Tizen.Applications/Interop/Interop.AppControl.cs b/Tizen.Applications/Interop/Interop.AppControl.cs index c5a6013..2f3ac14 100755 --- a/Tizen.Applications/Interop/Interop.AppControl.cs +++ b/Tizen.Applications/Interop/Interop.AppControl.cs @@ -6,6 +6,7 @@ /// it only in accordance with the terms of the license agreement /// you entered into with Samsung. + using System; using System.Runtime.InteropServices; @@ -30,7 +31,7 @@ internal static partial class Interop [DllImport(Libraries.Application, EntryPoint = "app_control_get_mime", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetMime(SafeAppControlHandle handle, out string mime); - + internal sealed class SafeAppControlHandle : SafeHandle { public SafeAppControlHandle() : base(IntPtr.Zero, true) diff --git a/Tizen.Applications/Interop/Interop.Application.cs b/Tizen.Applications/Interop/Interop.Application.cs index eee2c77..31e5304 100755 --- a/Tizen.Applications/Interop/Interop.Application.cs +++ b/Tizen.Applications/Interop/Interop.Application.cs @@ -6,6 +6,7 @@ /// it only in accordance with the terms of the license agreement /// you entered into with Samsung. + using System; using System.Runtime.InteropServices; @@ -41,5 +42,7 @@ internal static partial class Interop [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_exit", CallingConvention = CallingConvention.Cdecl)] + internal static extern void UIAppExit(); } } diff --git a/Tizen.Applications/Interop/Interop.Aul.cs b/Tizen.Applications/Interop/Interop.Aul.cs index 260892a..439a35a 100755 --- a/Tizen.Applications/Interop/Interop.Aul.cs +++ b/Tizen.Applications/Interop/Interop.Aul.cs @@ -6,6 +6,7 @@ /// it only in accordance with the terms of the license agreement /// you entered into with Samsung. + using System.Text; using System.Runtime.InteropServices; diff --git a/Tizen.Applications/Interop/Interop.Glib.cs b/Tizen.Applications/Interop/Interop.Glib.cs index 9104e63..57c6e85 100755 --- a/Tizen.Applications/Interop/Interop.Glib.cs +++ b/Tizen.Applications/Interop/Interop.Glib.cs @@ -6,6 +6,7 @@ /// it only in accordance with the terms of the license agreement /// you entered into with Samsung. + using System; using System.Text; using System.Runtime.InteropServices; diff --git a/Tizen.Applications/Interop/Interop.Window.cs b/Tizen.Applications/Interop/Interop.Window.cs index 4c42d8c..30e8bd9 100755 --- a/Tizen.Applications/Interop/Interop.Window.cs +++ b/Tizen.Applications/Interop/Interop.Window.cs @@ -1,8 +1,10 @@ using System; using System.Runtime.InteropServices; -internal static partial class Interop { - internal static partial class Window { +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); diff --git a/Tizen.Applications/Tizen.Applications.csproj b/Tizen.Applications/Tizen.Applications.csproj index 325cbe8..22e61c3 100755 --- a/Tizen.Applications/Tizen.Applications.csproj +++ b/Tizen.Applications/Tizen.Applications.csproj @@ -7,7 +7,8 @@ {663C5A3D-E631-4987-AEE7-F498C56A40FC} Library Properties - + + Tizen.Applications v4.5 512 @@ -57,9 +58,8 @@ - - + @@ -75,4 +75,4 @@ --> - + \ No newline at end of file diff --git a/Tizen.Applications/Tizen.Applications/Actor.cs b/Tizen.Applications/Tizen.Applications/Actor.cs index 4052cef..3886320 100755 --- a/Tizen.Applications/Tizen.Applications/Actor.cs +++ b/Tizen.Applications/Tizen.Applications/Actor.cs @@ -1,12 +1,46 @@ +/// 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 Tizen.UI; + namespace Tizen.Applications { + /// + /// + /// public abstract class Actor : Context { + private ActorGroup _group; + + /// + /// + /// + internal protected Page MainPage { get; set; } + + /// + /// + /// protected virtual void OnPaused() { } + + /// + /// + /// protected virtual void OnResumed() { } + internal void Create(ActorGroup group) + { + _group = group; + base.Create(); + } + internal void Pause() { OnPaused(); @@ -15,29 +49,36 @@ namespace Tizen.Applications internal void Resume() { OnResumed(); + MainPage.Show(); } + /// + /// + /// + /// + /// protected void StartActor(Actor actor, AppControl control) { - Actor target = (Actor)CurrentGroup.MoveToTop(actor); - if (target != null) - { - Pause(); - target.Start(control); - target.Resume(); - } + _group.StartActor(actor, control); } + /// + /// + /// + /// + /// protected override void StartActor(Type actorType, AppControl control) { - Application.StartActor(CurrentGroup, actorType, control); + Application.StartActor(_group, actorType, control); } + /// + /// + /// protected override void Finish() { - Application.StopActor(CurrentGroup, this); + Application.StopActor(_group, this); } - } } diff --git a/Tizen.Applications/Tizen.Applications/ActorGroup.cs b/Tizen.Applications/Tizen.Applications/ActorGroup.cs new file mode 100755 index 0000000..f2efd86 --- /dev/null +++ b/Tizen.Applications/Tizen.Applications/ActorGroup.cs @@ -0,0 +1,103 @@ +/// 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.Collections.Generic; +using System.Linq; + +namespace Tizen.Applications +{ + internal class ActorGroup + { + private readonly List _actorList; + + public bool IsEmpty + { + get + { + return _actorList.Count == 0; + } + } + + public Actor TopActor + { + get + { + return _actorList.LastOrDefault(null); + } + } + + public ActorGroup() + { + _actorList = new List(); + } + + public void StartActor(Type actorType, AppControl control) + { + Actor actor = (Actor)Activator.CreateInstance(actorType); + actor.Create(this); + if (actor.MainPage == null) + { + throw new ArgumentNullException("Actor's MainPage is not set."); + } + + Actor prevTop = TopActor; + _actorList.Add(actor); + if (prevTop != null) + { + prevTop.Pause(); + } + actor.Start(control); + actor.Resume(); + } + + public void StartActor(Actor actor, AppControl control) + { + if (actor.MainPage == null) + { + throw new ArgumentNullException("Actor's MainPage is not set."); + } + + Actor prevTop = TopActor; + _actorList.Remove(actor); + _actorList.Add(actor); + if (prevTop != actor) + { + prevTop.Pause(); + } + actor.Start(control); + actor.Resume(); + } + + public void StopActor(Actor actor) + { + Actor prevTop = TopActor; + _actorList.Remove(actor); + actor.Pause(); + actor.Terminate(); + if (prevTop == actor) + { + if (TopActor != null) + { + TopActor.Resume(); + } + } + } + + public Actor FindActor(Type type) + { + return _actorList.Find(s => s.GetType() == type); + } + + public Actor FindActor(Actor actor) + { + return _actorList.Find(s => s == actor); + } + } +} diff --git a/Tizen.Applications/Tizen.Applications/AppControl.cs b/Tizen.Applications/Tizen.Applications/AppControl.cs index 17b507f..1eda855 100755 --- a/Tizen.Applications/Tizen.Applications/AppControl.cs +++ b/Tizen.Applications/Tizen.Applications/AppControl.cs @@ -1,15 +1,28 @@ +/// 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.Collections.Generic; -using System.Runtime.InteropServices; namespace Tizen.Applications { + /// + /// + /// public class AppControl { - private string _operation; - private string _mime; - private string _uri; + private readonly string _operation; + private readonly string _mime; + private readonly string _uri; + /// + /// + /// public static class Operations { public const string Main = "http://tizen.org/appcontrol/operation/main"; @@ -41,8 +54,19 @@ namespace Tizen.Applications public const string SettingWifi = "http://tizen.org/appcontrol/operation/setting/wifi"; } + /// + /// + /// public string Operation { get { return _operation; } } + + /// + /// + /// public string Mime { get { return _mime; } } + + /// + /// + /// public string Uri { get { return _uri; } } internal AppControl(IntPtr appControlHandle) @@ -53,11 +77,12 @@ namespace Tizen.Applications Interop.AppControl.GetUri(handle, out _uri); } - internal bool IsService - { - get { return false; } - } - + /// + /// + /// + /// + /// + /// public AppControl(string operation, string mime, string uri) { _operation = operation; @@ -65,11 +90,15 @@ namespace Tizen.Applications _uri = uri; } - public bool IsLaunchOperation() + internal bool IsLaunchOperation() { if (_operation == null) return false; return (_operation == Operations.Main) || (_operation == Operations.Default); } + internal bool IsService + { + get { return false; } + } } } diff --git a/Tizen.Applications/Tizen.Applications/AppControlFilter.cs b/Tizen.Applications/Tizen.Applications/AppControlFilter.cs index 38adcb3..2896c60 100755 --- a/Tizen.Applications/Tizen.Applications/AppControlFilter.cs +++ b/Tizen.Applications/Tizen.Applications/AppControlFilter.cs @@ -1,8 +1,20 @@ +/// 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.Text.RegularExpressions; namespace Tizen.Applications { + /// + /// + /// [AttributeUsage(AttributeTargets.Class)] public class AppControlFilter : Attribute { @@ -10,10 +22,27 @@ namespace Tizen.Applications private readonly string _mime; private readonly string _uri; + /// + /// + /// public string Operation { get { return _operation; } } + + /// + /// + /// public string Mime { get { return _mime; } } + + /// + /// + /// public string Uri { get { return _uri; } } + /// + /// + /// + /// + /// + /// public AppControlFilter(string operation, string mime = null, string uri = null) { _operation = operation; @@ -21,6 +50,11 @@ namespace Tizen.Applications _uri = uri; } + /// + /// + /// + /// + /// public override bool Equals(object obj) { AppControlFilter f = obj as AppControlFilter; @@ -29,6 +63,10 @@ namespace Tizen.Applications return (_operation == f._operation) & (_mime == f._mime) & (_uri == f._uri); } + /// + /// + /// + /// public override int GetHashCode() { int hash = 0; @@ -83,7 +121,7 @@ namespace Tizen.Applications return _uri == uri; } - public bool IsMatch(AppControl e) + internal bool IsMatch(AppControl e) { string mime = e.Mime; if (String.IsNullOrEmpty(mime) && !String.IsNullOrEmpty(e.Uri)) @@ -93,5 +131,4 @@ namespace Tizen.Applications return _operation == e.Operation && IsMimeMatched(mime) && IsUriMatched(e.Uri); } } - } diff --git a/Tizen.Applications/Tizen.Applications/Application.cs b/Tizen.Applications/Tizen.Applications/Application.cs index 39dfca6..d7b224c 100755 --- a/Tizen.Applications/Tizen.Applications/Application.cs +++ b/Tizen.Applications/Tizen.Applications/Application.cs @@ -1,21 +1,33 @@ +/// 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.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Runtime.InteropServices; + +using Tizen.UI; namespace Tizen.Applications { + /// + /// Provides static methods and properties to manage an application, such as methods to register Actors and Services, + /// to start an application. + /// public static class Application { - private static Dictionary s_filterMap = new Dictionary(); - private static ContextGroup s_serviceGroup = new ContextGroup(); - private static List s_actorGroupList = new List(); + private static readonly Dictionary s_filterMap = new Dictionary(); + private static readonly List s_serviceList = new List(); + private static readonly List s_actorGroupList = new List(); - private static Window s_window = null; + private static readonly Window s_window = null; - private static ContextGroup CurrentActorGroup + private static ActorGroup CurrentActorGroup { get { @@ -23,10 +35,21 @@ namespace Tizen.Applications } } + /// + /// Occurs when the application starts. + /// public static event EventHandler Created = delegate { }; + + /// + /// Occurs when the application's main loop exits. + /// public static event EventHandler Exited = delegate { }; - public static int Run(string[] args) + /// + /// Runs the application's main loop. + /// + /// The command-line arguments + public static void Run(string[] args) { Interop.Application.UIAppLifecycleCallbacks ops; ops.OnCreate = (userData) => @@ -36,9 +59,9 @@ namespace Tizen.Applications }; ops.OnPause = (userData) => { - if (CurrentActorGroup != null && CurrentActorGroup.TopContext != null) + if (CurrentActorGroup != null && CurrentActorGroup.TopActor != null) { - Actor actor = CurrentActorGroup.TopContext as Actor; + Actor actor = CurrentActorGroup.TopActor as Actor; if (actor != null) { actor.Pause(); @@ -47,9 +70,9 @@ namespace Tizen.Applications }; ops.OnResume = (userData) => { - if (CurrentActorGroup != null && CurrentActorGroup.TopContext != null) + if (CurrentActorGroup != null && CurrentActorGroup.TopActor != null) { - Actor actor = CurrentActorGroup.TopContext as Actor; + Actor actor = CurrentActorGroup.TopActor as Actor; if (actor != null) { actor.Resume(); @@ -76,12 +99,6 @@ namespace Tizen.Applications { if (item.Key.IsMatch(appControl) && item.Value.IsSubclassOf(typeof(Actor))) { - // Window was created when the first UI Actor was created - if (s_window == null) - { - s_window = new Window(); - } - if (CurrentActorGroup == null || !appControl.IsLaunchOperation()) { StartActor(null, item.Value, appControl); @@ -98,69 +115,103 @@ namespace Tizen.Applications TizenSynchronizationContext.Initialize(); - int ret = Interop.Application.UIAppMain(args.Length, args, ref ops, IntPtr.Zero); - - return ret; + // TODO: check ret of UIAppMain and throw exceptions when errors are returned. + Interop.Application.UIAppMain(args.Length, args, ref ops, IntPtr.Zero); } + /// + /// Hides the application. + /// public static void Hide() { if (s_window != null) s_window.InActive(); } + /// + /// Exits the main loop of application. + /// public static void Exit() { - Exited(null, null); - throw new NotImplementedException(); + Exited(null, null); + // TODO: clear context and group + Interop.Application.UIAppExit(); } - public static void RegisterActor(Type clazz) + /// + /// Registers an Actor class type. + /// + /// The type of Actor class. + public static void RegisterActor(Type actorType) { - RegisterActor(clazz, new AppControlFilter[0] { }); + RegisterActor(actorType, new AppControlFilter[0] { }); } - public static void RegisterActor(Type clazz, AppControlFilter filter) + /// + /// Registers an Actor class type. + /// + /// The type of Actor class. + /// The filter to match Actor and AppControl. + public static void RegisterActor(Type actorType, AppControlFilter filter) { - RegisterActor(clazz, new AppControlFilter[] { filter }); + RegisterActor(actorType, new AppControlFilter[] { filter }); } - public static void RegisterActor(Type clazz, AppControlFilter[] filters) + /// + /// Registers an Actor class type. + /// + /// The type of Actor class. + /// The array of filters to match Actor and AppControl. + public static void RegisterActor(Type actorType, AppControlFilter[] filters) { - if (!clazz.IsSubclassOf(typeof(Actor))) - throw new ArgumentException(clazz.FullName + " is not a subclass of Actor."); + if (!actorType.IsSubclassOf(typeof(Actor))) + throw new ArgumentException(actorType.FullName + " is not a subclass of Actor."); - RegisterContext(clazz, filters); + RegisterContext(actorType, filters); } - public static void RegisterService(Type clazz) + /// + /// Registers an Service class type. + /// + /// The type of Service class. + public static void RegisterService(Type serviceType) { - RegisterService(clazz, new AppControlFilter[0] { }); + RegisterService(serviceType, new AppControlFilter[0] { }); } - public static void RegisterService(Type clazz, AppControlFilter filter) + /// + /// Registers an Service class type. + /// + /// The type of Service class. + /// The filter to match Service and AppControl. + public static void RegisterService(Type serviceType, AppControlFilter filter) { - RegisterService(clazz, new AppControlFilter[] { filter }); + RegisterService(serviceType, new AppControlFilter[] { filter }); } - public static void RegisterService(Type clazz, AppControlFilter[] filters) + /// + /// Registers an Service class type. + /// + /// The type of Service class. + /// The array of filters to match Service and AppControl. + public static void RegisterService(Type serviceType, AppControlFilter[] filters) { - if (!clazz.IsSubclassOf(typeof(Service))) - throw new ArgumentException(clazz.FullName + " is not a subclass of Service."); + if (!serviceType.IsSubclassOf(typeof(Service))) + throw new ArgumentException(serviceType.FullName + " is not a subclass of Service."); - RegisterContext(clazz, filters); + RegisterContext(serviceType, filters); } - private static void RegisterContext(Type clazz, AppControlFilter[] filters) + private static void RegisterContext(Type contextType, AppControlFilter[] filters) { - foreach (var prop in clazz.GetProperties()) + foreach (var prop in contextType.GetProperties()) { foreach (var attr in prop.GetCustomAttributes(false)) { var filter = attr as AppControlFilter; if (filter != null) { - s_filterMap.Add(filter, clazz); + s_filterMap.Add(filter, contextType); } } } @@ -168,47 +219,48 @@ namespace Tizen.Applications { foreach (var filter in filters) { - s_filterMap.Add(filter, clazz); + s_filterMap.Add(filter, contextType); } } } - internal static void StartActor(ContextGroup group, Type actorType, AppControl control) + internal static void StartActor(ActorGroup group, Type actorType, AppControl control) { if (!actorType.IsSubclassOf(typeof(Actor))) { throw new ArgumentException(actorType.FullName + " is not a subclass of Actor."); } - Actor actor = (Actor)Activator.CreateInstance(actorType); - ContextGroup ctxGroup = group; - if (ctxGroup == null) + // Window was created when the first UI Actor was created + //if (s_window == null) + //{ + // s_window = new Window(); + //} + + ActorGroup actorGroup = group; + if (actorGroup == null) { - ctxGroup = new ContextGroup(); - s_actorGroupList.Add(ctxGroup); + actorGroup = new ActorGroup(); + s_actorGroupList.Add(actorGroup); } - ctxGroup.AddContext(actor); - actor.Create(ctxGroup); - actor.Start(control); + actorGroup.StartActor(actorType, control); // TODO: consider resume operation - if (!s_window.Visible) - { - s_window.Active(); - s_window.Show(); - actor.Resume(); - } + //if (!s_window.Visible) + //{ + // s_window.Active(); + // s_window.Show(); + // actor.Resume(); + //} } - internal static void StopActor(ContextGroup group, Actor actor) + internal static void StopActor(ActorGroup group, Actor actor) { - actor.Pause(); - actor.Terminate(); - group.RemoveContext(actor); + group.StopActor(actor); if (group.IsEmpty) { s_actorGroupList.Remove(group); - if (s_actorGroupList.Count == 0 && s_serviceGroup.IsEmpty) + if (s_actorGroupList.Count == 0 && s_serviceList.Count == 0) { Exit(); } @@ -217,14 +269,6 @@ namespace Tizen.Applications Hide(); } } - else - { - Actor nextActor = group.TopContext as Actor; - if (nextActor != null) - { - nextActor.Resume(); - } - } } internal static void StartService(Type serviceType, AppControl control) @@ -234,15 +278,14 @@ namespace Tizen.Applications throw new ArgumentException(serviceType.FullName + " is not a subclass of Service."); } - Context ctx = s_serviceGroup.FindContext(serviceType); - if (ctx == null) + Service svc = s_serviceList.Find(s => s.GetType() == serviceType); + if (svc == null) { - // Register ContextRemoved Handler once - ctx = (Service)Activator.CreateInstance(serviceType); - s_serviceGroup.AddContext(ctx); - ctx.Create(s_serviceGroup); + svc = (Service)Activator.CreateInstance(serviceType); + s_serviceList.Add(svc); + svc.Create(); } - ctx.Start(control); + svc.Start(control); } internal static void StopService(Type serviceType) @@ -252,17 +295,14 @@ namespace Tizen.Applications throw new ArgumentException(serviceType.FullName + " is not a subclass of Service."); } - Context ctx = s_serviceGroup.FindContext(serviceType); - if (ctx != null) + Service svc = s_serviceList.Find(s => s.GetType() == serviceType); + if (svc != null) { - ctx.Terminate(); - s_serviceGroup.RemoveContext(ctx); - if (s_serviceGroup.IsEmpty) + svc.Terminate(); + s_serviceList.Remove(svc); + if (s_actorGroupList.Count == 0 && s_serviceList.Count == 0) { - if (s_actorGroupList.Count == 0) - { - Exit(); - } + Exit(); } } } diff --git a/Tizen.Applications/Tizen.Applications/CodeExample.cs b/Tizen.Applications/Tizen.Applications/CodeExample.cs deleted file mode 100755 index 54d83a0..0000000 --- a/Tizen.Applications/Tizen.Applications/CodeExample.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace Tizen.Applications -{ - public class ViewActor : Actor - { - public string Type { get; set; } - protected override void OnCreated() - { - Console.WriteLine(); - } - - protected override void OnStarted() - { - } - - private void DoSomething() - { - } - } - - [AppControlFilter("http://tizen.org/appcontrol/operation/default")] - public class DefaultActor : Actor - { - protected override void OnCreated() - { - } - - protected override void OnStarted() - { - } - } - - public class Test - { - static void test(string[] args) // main - { - Application.Created += Application_Create; - Application.Exited += Application_Terminate; - Application.RegisterActor(typeof(DefaultActor)); - Application.RegisterActor(typeof(ViewActor), new AppControlFilter[] { - new AppControlFilter("http://tizen.org/appcontrol/view", "image/*"), - new AppControlFilter("http://tizen.org/appcontrol/view", "text/*") - }); - - Application.Run(args); - } - - private static void Application_Create(object sender, EventArgs e) - { - Console.WriteLine("Hello Application!"); - } - - private static void Application_Terminate(object sender, EventArgs e) - { - Console.WriteLine("Goodbye Application!"); - } - } - - -} diff --git a/Tizen.Applications/Tizen.Applications/Context.cs b/Tizen.Applications/Tizen.Applications/Context.cs index 9183239..e359bda 100755 --- a/Tizen.Applications/Tizen.Applications/Context.cs +++ b/Tizen.Applications/Tizen.Applications/Context.cs @@ -1,24 +1,26 @@ +/// 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.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Tizen.Applications { + /// + /// + /// public abstract class Context { - private ContextGroup _group; private AppControl _control; - internal ContextGroup CurrentGroup - { - get - { - return _group; - } - } - + /// + /// + /// protected AppControl ReceivedAppControl { get @@ -27,13 +29,23 @@ namespace Tizen.Applications } } + /// + /// + /// protected virtual void OnCreated() { } + + /// + /// + /// protected virtual void OnStarted() { } + + /// + /// + /// protected virtual void OnTerminated() { } - internal void Create(ContextGroup group) + internal void Create() { - _group = group; OnCreated(); } @@ -48,20 +60,42 @@ namespace Tizen.Applications OnTerminated(); } + /// + /// + /// + /// + /// protected abstract void StartActor(Type actorType, AppControl control); + /// + /// + /// + /// + /// protected void StartService(Type serviceType, AppControl control) { Application.StartService(serviceType, control); } + /// + /// + /// + /// protected void StopService(Type serviceType) { Application.StopService(serviceType); } + /// + /// + /// protected abstract void Finish(); + /// + /// + /// + /// + /// protected void SendAppControl(AppControl control, string destination) { throw new NotImplementedException(); diff --git a/Tizen.Applications/Tizen.Applications/ContextGroup.cs b/Tizen.Applications/Tizen.Applications/ContextGroup.cs deleted file mode 100755 index afe0a59..0000000 --- a/Tizen.Applications/Tizen.Applications/ContextGroup.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tizen.Applications -{ - internal class ContextGroup - { - private List _contextList; - - public bool IsEmpty - { - get - { - return _contextList.Count == 0; - } - } - - public Context TopContext - { - get - { - return _contextList.LastOrDefault(null); - } - } - - public ContextGroup() - { - _contextList = new List(); - } - - public void AddContext(Context ctx) - { - _contextList.Add(ctx); - } - - public void RemoveContext(Context ctx) - { - _contextList.Remove(ctx); - } - - public Context FindContext(Type type) - { - return _contextList.Find(s => s.GetType() == type); - } - - public Context FindContext(Context ctx) - { - return _contextList.Find(s => s == ctx); - } - - public Context MoveToTop(Context ctx) - { - var found = FindContext(ctx); - if (found != null) - { - _contextList.Remove(found); - _contextList.Add(found); - } - return found; - } - } -} diff --git a/Tizen.Applications/Tizen.Applications/Service.cs b/Tizen.Applications/Tizen.Applications/Service.cs index 07f926c..10c23cc 100755 --- a/Tizen.Applications/Tizen.Applications/Service.cs +++ b/Tizen.Applications/Tizen.Applications/Service.cs @@ -1,14 +1,34 @@ +/// 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; namespace Tizen.Applications { + /// + /// + /// public abstract class Service : Context { + /// + /// + /// + /// + /// protected override void StartActor(Type actorType, AppControl control) { Application.StartActor(null, actorType, control); } + /// + /// + /// protected override void Finish() { Application.StopService(GetType()); diff --git a/Tizen.Applications/Tizen.Applications/TizenSynchronizationContext.cs b/Tizen.Applications/Tizen.Applications/TizenSynchronizationContext.cs index c1d9560..26da27f 100755 --- a/Tizen.Applications/Tizen.Applications/TizenSynchronizationContext.cs +++ b/Tizen.Applications/Tizen.Applications/TizenSynchronizationContext.cs @@ -1,3 +1,12 @@ +/// 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.Collections.Generic; using System.Threading; @@ -10,14 +19,14 @@ namespace Tizen.Applications { SetSynchronizationContext(new TizenSynchronizationContext()); } - private Interop.Glib.GSourceFunc wrapperHandler; - private Object transactionLock = new Object(); - private int transactionID = 0; - private Dictionary handlerMap = new Dictionary(); + private Interop.Glib.GSourceFunc _wrapperHandler; + private Object _transactionLock = new Object(); + private int _transactionID = 0; + private Dictionary _handlerMap = new Dictionary(); - TizenSynchronizationContext() + private TizenSynchronizationContext() { - wrapperHandler = new Interop.Glib.GSourceFunc(Handler); + _wrapperHandler = new Interop.Glib.GSourceFunc(Handler); } public override void Post(SendOrPostCallback d, object state) @@ -57,24 +66,23 @@ namespace Tizen.Applications public void Post(Action action) { int id = 0; - lock (transactionLock) + lock (_transactionLock) { - id = transactionID++; + id = _transactionID++; } - handlerMap.Add(id, action); - Interop.Glib.IdleAdd(wrapperHandler, (IntPtr)id); + _handlerMap.Add(id, action); + Interop.Glib.IdleAdd(_wrapperHandler, (IntPtr)id); } public bool Handler(IntPtr userData) { int key = (int)userData; - if (handlerMap.ContainsKey(key)) + if (_handlerMap.ContainsKey(key)) { - handlerMap[key](); - handlerMap.Remove(key); + _handlerMap[key](); + _handlerMap.Remove(key); } return false; } - } } diff --git a/Tizen.Applications/Tizen.UI/Page.cs b/Tizen.Applications/Tizen.UI/Page.cs new file mode 100755 index 0000000..390d5a7 --- /dev/null +++ b/Tizen.Applications/Tizen.UI/Page.cs @@ -0,0 +1,24 @@ +/// 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.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tizen.UI +{ + public class Page + { + internal void Show() + { + + } + } +} diff --git a/Tizen.Applications/Tizen.Applications/Window.cs b/Tizen.Applications/Tizen.UI/Window.cs similarity index 73% rename from Tizen.Applications/Tizen.Applications/Window.cs rename to Tizen.Applications/Tizen.UI/Window.cs index a2a61b6..e2e134b 100755 --- a/Tizen.Applications/Tizen.Applications/Window.cs +++ b/Tizen.Applications/Tizen.UI/Window.cs @@ -1,8 +1,17 @@ +/// 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; -namespace Tizen.Applications +namespace Tizen.UI { - class Window : IDisposable + internal class Window : IDisposable { private IntPtr _native_window = IntPtr.Zero; @@ -17,22 +26,27 @@ namespace Tizen.Applications { _native_window = Interop.Window.elm_win_add(IntPtr.Zero, "Window", 0); } + ~Window() { Dispose(); } + public void Show() { Interop.Window.evas_object_show(_native_window); } + public void Hide() { Interop.Window.evas_object_hide(_native_window); } + public void Active() { Interop.Window.elm_win_activate(_native_window); } + public void InActive() { Interop.Window.elm_win_lower(_native_window); diff --git a/packaging/csapi-application.spec b/packaging/csapi-application.spec index c6acbc9..fa35b1f 100644 --- a/packaging/csapi-application.spec +++ b/packaging/csapi-application.spec @@ -56,6 +56,7 @@ cp %{SOURCE1} . mcs -target:library -out:%{dllname} -keyfile:Tizen.Applications/Tizen.Applications.snk \ Tizen.Applications/Properties/AssemblyInfo.cs \ Tizen.Applications/Tizen.Applications/*.cs \ + Tizen.Applications/Tizen.UI/*.cs \ Tizen.Applications/Interop/*.cs # check p/invoke