Use event functions of appcore_agent instead of event_xxx API
authorWonYoung Choi <wy80.choi@samsung.com>
Tue, 7 Jun 2016 06:54:38 +0000 (15:54 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Tue, 7 Jun 2016 06:57:38 +0000 (15:57 +0900)
Change-Id: I251176c568a343a1c83aaa0f94e107927f9c5ae0

13 files changed:
Tizen.Applications/Interop/Interop.AppCommon.cs [changed mode: 0755->0644]
Tizen.Applications/Interop/Interop.AppEvent.cs [deleted file]
Tizen.Applications/Interop/Interop.Application.cs [changed mode: 0755->0644]
Tizen.Applications/Interop/Interop.Service.cs [changed mode: 0755->0644]
Tizen.Applications/Tizen.Applications.csproj [changed mode: 0755->0644]
Tizen.Applications/Tizen.Applications/Application.cs
Tizen.Applications/Tizen.Applications/LocaleChangedEventArgs.cs [changed mode: 0755->0644]
Tizen.Applications/Tizen.Applications/LowBatteryEventArgs.cs [new file with mode: 0644]
Tizen.Applications/Tizen.Applications/LowBatteryStatus.cs [new file with mode: 0644]
Tizen.Applications/Tizen.Applications/LowMemoryEventArgs.cs [changed mode: 0755->0644]
Tizen.Applications/Tizen.Applications/RegionFormatChangedEventArgs.cs [new file with mode: 0644]
Tizen.Applications/Tizen.Applications/ServiceApplication.cs
Tizen.Applications/Tizen.Applications/UIApplication.cs

old mode 100755 (executable)
new mode 100644 (file)
index 74494f6..fb9a4a6
@@ -6,14 +6,28 @@
 // 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;
+using Tizen.Applications;
 
 internal static partial class Interop
 {
     internal static partial class AppCommon
     {
+        internal enum AppEventType
+        {
+            LowMemory = 0,
+            LowBattery,
+            LanguageChanged,
+            DeviceOrientationChanged,
+            RegionFormatChanged,
+            SuspendedStateChanged
+        }
+
+        internal delegate void AppEventCallback(IntPtr handle, IntPtr data);
+
         [DllImport(Libraries.AppCommon, EntryPoint = "app_get_id")]
         internal static extern ErrorCode AppGetId(out string appId);
 
@@ -52,6 +66,19 @@ internal static partial class Interop
 
         [DllImport(Libraries.AppCommon, EntryPoint = "app_get_version")]
         internal static extern ErrorCode AppGetVersion(out string version);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_memory_status")]
+        internal static extern ErrorCode AppEventGetLowMemoryStatus(IntPtr handle, out LowMemoryStatus status);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_low_battery_status")]
+        internal static extern ErrorCode AppEventGetLowBatteryStatus(IntPtr handle, out LowBatteryStatus status);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_language")]
+        internal static extern ErrorCode AppEventGetLanguage(IntPtr handle, out string lang);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_event_get_region_format")]
+        internal static extern ErrorCode AppEventGetRegionFormat(IntPtr handle, out string region);
+
     }
 }
 
diff --git a/Tizen.Applications/Interop/Interop.AppEvent.cs b/Tizen.Applications/Interop/Interop.AppEvent.cs
deleted file mode 100755 (executable)
index a6b0d98..0000000
+++ /dev/null
@@ -1,71 +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;
-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 static class EventNames
-        {
-            public const string LowMemory = "tizen.system.event.low_memory";
-            public const string LanguageSet = "tizen.system.event.language_set";
-        }
-
-        internal static class EventKeys
-        {
-            public const string LowMemory = "low_memory";
-            public const string LanguageSet = "language_set";
-        }
-
-        internal static class EventValues
-        {
-            public const string MemoryNormal = "normal";
-            public const string MemorySoftWarning = "soft_warning";
-            public const string MemoryHardWarning = "hard_warning";
-        }
-    }
-}
-
old mode 100755 (executable)
new mode 100644 (file)
index 9e524f4..56db6e6
@@ -9,6 +9,8 @@
 using System;
 using System.Runtime.InteropServices;
 
+using Tizen.Internals.Errors;
+
 internal static partial class Interop
 {
     internal static partial class Application
@@ -24,12 +26,18 @@ internal static partial class Interop
         internal delegate void AppControlCallback(IntPtr appControl, IntPtr userData);
 
         [DllImport(Libraries.Application, EntryPoint = "ui_app_main")]
-        internal static extern int Main(int argc, string[] argv, ref UIAppLifecycleCallbacks callback, IntPtr userData);
+        internal static extern ErrorCode Main(int argc, string[] argv, ref UIAppLifecycleCallbacks callback, IntPtr userData);
 
         [DllImport(Libraries.Application, EntryPoint = "ui_app_exit")]
         internal static extern void Exit();
 
-        [StructLayoutAttribute(LayoutKind.Sequential)]
+        [DllImport(Libraries.Application, EntryPoint = "ui_app_add_event_handler")]
+        internal static extern ErrorCode AddEventHandler(out IntPtr handle, AppCommon.AppEventType eventType, AppCommon.AppEventCallback callback, IntPtr data);
+
+        [DllImport(Libraries.Application, EntryPoint = "ui_app_remove_event_handler")]
+        internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
+
+        [StructLayout(LayoutKind.Sequential)]
         internal struct UIAppLifecycleCallbacks
         {
             public AppCreateCallback OnCreate;
old mode 100755 (executable)
new mode 100644 (file)
index 26cb4f6..cda4b1b
@@ -9,6 +9,8 @@
 using System;
 using System.Runtime.InteropServices;
 
+using Tizen.Internals.Errors;
+
 internal static partial class Interop
 {
     internal static partial class Service
@@ -20,11 +22,17 @@ internal static partial class Interop
         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);
+        internal static extern ErrorCode Main(int argc, string[] argv, ref ServiceAppLifecycleCallbacks callback, IntPtr userData);
 
         [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_exit")]
         internal static extern void Exit();
 
+        [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_add_event_handler")]
+        internal static extern ErrorCode AddEventHandler(out IntPtr handle, AppCommon.AppEventType eventType, AppCommon.AppEventCallback callback, IntPtr data);
+
+        [DllImport(Libraries.AppcoreAgent, EntryPoint = "service_app_remove_event_handler")]
+        internal static extern ErrorCode RemoveEventHandler(IntPtr handle);
+
         [StructLayoutAttribute(LayoutKind.Sequential)]
         internal struct ServiceAppLifecycleCallbacks
         {
old mode 100755 (executable)
new mode 100644 (file)
index 57bb922..fc11fc8
@@ -53,7 +53,6 @@
     <Compile Include="GlobalSuppressions.cs" />
     <Compile Include="Interop\Interop.AppCommon.cs" />
     <Compile Include="Interop\Interop.AppControl.cs" />
-    <Compile Include="Interop\Interop.AppEvent.cs" />
     <Compile Include="Interop\Interop.Application.cs" />
     <Compile Include="Interop\Interop.ApplicationManager.cs" />
     <Compile Include="Interop\Interop.Bundle.cs" />
     <Compile Include="Tizen.Applications\ApplicationTerminatedEventArgs.cs" />
     <Compile Include="Tizen.Applications\DirectoryInfo.cs" />
     <Compile Include="Tizen.Applications\LocaleChangedEventArgs.cs" />
+    <Compile Include="Tizen.Applications\LowBatteryEventArgs.cs" />
+    <Compile Include="Tizen.Applications\LowBatteryStatus.cs" />
     <Compile Include="Tizen.Applications\LowMemoryEventArgs.cs" />
     <Compile Include="Tizen.Applications\LowMemoryStatus.cs" />
     <Compile Include="Tizen.Applications\ReceivedAppControl.cs" />
+    <Compile Include="Tizen.Applications\RegionFormatChangedEventArgs.cs" />
     <Compile Include="Tizen.Applications\SafeAppControlHandle.cs" />
     <Compile Include="Tizen.Applications\ServiceApplication.cs" />
     <Compile Include="Tizen.Applications\UIApplication.cs" />
   <Target Name="AfterBuild">
   </Target>
   -->
-</Project>
+</Project>
\ No newline at end of file
index e60a096..74055c7 100644 (file)
@@ -17,26 +17,34 @@ namespace Tizen.Applications
     /// </summary>
     public abstract class Application : IDisposable
     {
-        private const string LogTag = "Tizen.Applications";
+        internal const string LogTag = "Tizen.Applications";
 
         private static Application s_CurrentApplication = null;
 
-        private Interop.AppEvent.SafeAppEventHandle _lowMemoryNativeHandle;
-        private Interop.AppEvent.SafeAppEventHandle _localeChangedNativeHandle;
+        private object _lock = new object();
 
-        private Interop.AppEvent.AppEventCallback _appEventCallback;
+        private Interop.AppCommon.AppEventCallback _lowMemoryCallback;
+        private Interop.AppCommon.AppEventCallback _lowBatteryCallback;
+        private Interop.AppCommon.AppEventCallback _localeChangedCallback;
+        private Interop.AppCommon.AppEventCallback _regionChangedCallback;
 
-        private object _lock = new object();
+        private IntPtr _lowMemoryEventHandle = IntPtr.Zero;
+        private IntPtr _lowBatteryEventHandle = IntPtr.Zero;
+        private IntPtr _localeChangedEventHandle = IntPtr.Zero;
+        private IntPtr _regionChangedEventHandle = IntPtr.Zero;
 
         private DirectoryInfo _directoryInfo;
         private ApplicationInfo _applicationInfo;
 
         /// <summary>
-        /// Initializes Application instance.
+        /// Initializes the Application class.
         /// </summary>
         public Application()
         {
-            _appEventCallback = new Interop.AppEvent.AppEventCallback(HandleAppEvent);
+            _lowMemoryCallback = new Interop.AppCommon.AppEventCallback(OnLowMemoryNative);
+            _lowBatteryCallback = new Interop.AppCommon.AppEventCallback(OnLowBatteryNative);
+            _localeChangedCallback = new Interop.AppCommon.AppEventCallback(OnLocaleChangedNative);
+            _regionChangedCallback = new Interop.AppCommon.AppEventCallback(OnRegionChangedNative);
         }
 
         /// <summary>
@@ -60,11 +68,21 @@ namespace Tizen.Applications
         public event EventHandler<LowMemoryEventArgs> LowMemory;
 
         /// <summary>
+        /// Occurs when the system battery is low.
+        /// </summary>
+        public event EventHandler<LowBatteryEventArgs> LowBattery;
+
+        /// <summary>
         /// Occurs when the system language is chagned.
         /// </summary>
         public event EventHandler<LocaleChangedEventArgs> LocaleChanged;
 
         /// <summary>
+        /// Occurs when the region format is changed.
+        /// </summary>
+        public event EventHandler<RegionFormatChangedEventArgs> RegionFormatChanged;
+
+        /// <summary>
         /// Gets the instance of current application.
         /// </summary>
         public static Application Current { get { return s_CurrentApplication; } }
@@ -121,10 +139,34 @@ namespace Tizen.Applications
                 throw new ArgumentNullException("args");
             }
 
+            TizenSynchronizationContext.Initialize();
+
             s_CurrentApplication = this;
 
-            Interop.AppEvent.AddEventHandler(Interop.AppEvent.EventNames.LowMemory, _appEventCallback, IntPtr.Zero, out _lowMemoryNativeHandle);
-            Interop.AppEvent.AddEventHandler(Interop.AppEvent.EventNames.LanguageSet, _appEventCallback, IntPtr.Zero, out _localeChangedNativeHandle);
+            ErrorCode err = ErrorCode.None;
+            err = AddEventHandler(out _lowMemoryEventHandle, Interop.AppCommon.AppEventType.LowMemory, _lowMemoryCallback);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LowMemory event. Err = " + err);
+            }
+
+            err = AddEventHandler(out _lowBatteryEventHandle, Interop.AppCommon.AppEventType.LowBattery, _lowBatteryCallback);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LowBattery event. Err = " + err);
+            }
+
+            err = AddEventHandler(out _localeChangedEventHandle, Interop.AppCommon.AppEventType.LanguageChanged, _localeChangedCallback);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for LocaleChanged event. Err = " + err);
+            }
+
+            err = AddEventHandler(out _regionChangedEventHandle, Interop.AppCommon.AppEventType.RegionFormatChanged, _regionChangedCallback);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to add event handler for RegionFormatChanged event. Err = " + err);
+            }
         }
 
         /// <summary>
@@ -170,6 +212,15 @@ namespace Tizen.Applications
         }
 
         /// <summary>
+        /// Overrides this method if want to handle behavior when the system battery is low.
+        /// If base.OnLowBattery() is not called, the event 'LowBattery' will not be emitted.
+        /// </summary>
+        protected virtual void OnLowBattery(LowBatteryEventArgs e)
+        {
+            LowBattery?.Invoke(this, e);
+        }
+
+        /// <summary>
         /// Overrides this method if want to handle behavior when the system language is changed.
         /// If base.OnLocaleChanged() is not called, the event 'LocaleChanged' will not be emitted.
         /// </summary>
@@ -178,29 +229,67 @@ namespace Tizen.Applications
             LocaleChanged?.Invoke(this, e);
         }
 
-        private void HandleAppEvent(string eventName, IntPtr eventData, IntPtr data)
+        /// <summary>
+        /// Overrides this method if want to handle behavior when the region format is changed.
+        /// If base.OnRegionFormatChanged() is not called, the event 'RegionFormatChanged' will not be emitted.
+        /// </summary>
+        protected virtual void OnRegionFormatChanged(RegionFormatChangedEventArgs e)
+        {
+            RegionFormatChanged?.Invoke(this, e);
+        }
+
+        internal virtual ErrorCode AddEventHandler(out IntPtr handle, Interop.AppCommon.AppEventType type, Interop.AppCommon.AppEventCallback callback)
+        {
+            handle = IntPtr.Zero;
+            return ErrorCode.None;
+        }
+
+        internal virtual void RemoveEventHandler(IntPtr handle)
         {
-            Bundle b = new Bundle(eventData);
-            if (eventName == Interop.AppEvent.EventNames.LowMemory)
+        }
+
+        private void OnLowMemoryNative(IntPtr infoHandle, IntPtr data)
+        {
+            LowMemoryStatus status = LowMemoryStatus.None;
+            ErrorCode err = Interop.AppCommon.AppEventGetLowMemoryStatus(infoHandle, out status);
+            if (err != ErrorCode.None)
             {
-                string value = b.GetItem<string>(Interop.AppEvent.EventKeys.LowMemory);
-                LowMemoryStatus status = LowMemoryStatus.Normal;
-                if (value == Interop.AppEvent.EventValues.MemorySoftWarning)
-                {
-                    status = LowMemoryStatus.SoftWarning;
-                }
-                else if (value == Interop.AppEvent.EventValues.MemoryHardWarning)
-                {
-                    status = LowMemoryStatus.HardWarning;
-                }
-                OnLowMemory(new LowMemoryEventArgs { LowMemoryStatus = status });
+                Log.Error(LogTag, "Failed to get memory status. Err = " + err);
             }
-            else if (eventName == Interop.AppEvent.EventNames.LanguageSet)
+            OnLowMemory(new LowMemoryEventArgs(status));
+        }
+
+        private void OnLowBatteryNative(IntPtr infoHandle, IntPtr data)
+        {
+            LowBatteryStatus status = LowBatteryStatus.None;
+            ErrorCode err = Interop.AppCommon.AppEventGetLowBatteryStatus(infoHandle, out status);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to get battery status. Err = " + err);
+            }
+            OnLowBattery(new LowBatteryEventArgs(status));
+        }
+
+        private void OnLocaleChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            string lang;
+            ErrorCode err = Interop.AppCommon.AppEventGetLanguage(infoHandle, out lang);
+            if (err != ErrorCode.None)
             {
-                string value = b.GetItem<string>(Interop.AppEvent.EventKeys.LanguageSet);
-                OnLocaleChanged(new LocaleChangedEventArgs { Locale = value });
+                Log.Error(LogTag, "Failed to get changed language. Err = " + err);
             }
-            b.Dispose();
+            OnLocaleChanged(new LocaleChangedEventArgs(lang));
+        }
+
+        private void OnRegionChangedNative(IntPtr infoHandle, IntPtr data)
+        {
+            string region;
+            ErrorCode err = Interop.AppCommon.AppEventGetRegionFormat(infoHandle, out region);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to get changed region format. Err = " + err);
+            }
+            OnRegionFormatChanged(new RegionFormatChangedEventArgs(region));
         }
 
         #region IDisposable Support
@@ -220,14 +309,23 @@ namespace Tizen.Applications
                     {
                         _applicationInfo.Dispose();
                     }
-                    if (_lowMemoryNativeHandle != null && !_lowMemoryNativeHandle.IsInvalid)
-                    {
-                        _lowMemoryNativeHandle.Dispose();
-                    }
-                    if (_localeChangedNativeHandle != null && !_localeChangedNativeHandle.IsInvalid)
-                    {
-                        _localeChangedNativeHandle.Dispose();
-                    }
+                }
+
+                if (_lowMemoryEventHandle != IntPtr.Zero)
+                {
+                    RemoveEventHandler(_lowMemoryEventHandle);
+                }
+                if (_lowBatteryEventHandle != IntPtr.Zero)
+                {
+                    RemoveEventHandler(_lowBatteryEventHandle);
+                }
+                if (_localeChangedEventHandle != IntPtr.Zero)
+                {
+                    RemoveEventHandler(_localeChangedEventHandle);
+                }
+                if (_regionChangedEventHandle != IntPtr.Zero)
+                {
+                    RemoveEventHandler(_regionChangedEventHandle);
                 }
 
                 disposedValue = true;
old mode 100755 (executable)
new mode 100644 (file)
index 3836cea..8304a66
@@ -15,9 +15,24 @@ namespace Tizen.Applications
     /// </summary>
     public class LocaleChangedEventArgs : EventArgs
     {
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="locale"></param>
+        public LocaleChangedEventArgs(string locale)
+        {
+            Locale = locale;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Locale { get; private set; }
+
         /// <summary>
         /// 
         /// </summary>
-        public string Locale { get; internal set; }
+        public string Region { get; internal set; }
     }
 }
diff --git a/Tizen.Applications/Tizen.Applications/LowBatteryEventArgs.cs b/Tizen.Applications/Tizen.Applications/LowBatteryEventArgs.cs
new file mode 100644 (file)
index 0000000..b523f0b
--- /dev/null
@@ -0,0 +1,30 @@
+// 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.
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class LowBatteryEventArgs
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="status"></param>
+        public LowBatteryEventArgs(LowBatteryStatus status)
+        {
+            LowBatteryStatus = status;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public LowBatteryStatus LowBatteryStatus { get; private set; }
+    }
+}
diff --git a/Tizen.Applications/Tizen.Applications/LowBatteryStatus.cs b/Tizen.Applications/Tizen.Applications/LowBatteryStatus.cs
new file mode 100644 (file)
index 0000000..6419733
--- /dev/null
@@ -0,0 +1,31 @@
+// 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.
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// Enumeration for low battery status.
+    /// </summary>
+    public enum LowBatteryStatus
+    {
+        /// <summary>
+        /// 
+        /// </summary>
+        None = 0,
+
+        /// <summary>
+        /// The battery status is under 1%
+        /// </summary>
+        PowerOff = 1,
+
+        /// <summary>
+        /// The battery status is under 5%
+        /// </summary>
+        CriticalLow
+    }
+}
old mode 100755 (executable)
new mode 100644 (file)
index 0a9c897..356112c
@@ -18,6 +18,15 @@ namespace Tizen.Applications
         /// <summary>
         /// 
         /// </summary>
-        public LowMemoryStatus LowMemoryStatus { get; internal set; }
+        /// <param name="status"></param>
+        public LowMemoryEventArgs(LowMemoryStatus status)
+        {
+            LowMemoryStatus = status;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public LowMemoryStatus LowMemoryStatus { get; private set; }
     }
 }
diff --git a/Tizen.Applications/Tizen.Applications/RegionFormatChangedEventArgs.cs b/Tizen.Applications/Tizen.Applications/RegionFormatChangedEventArgs.cs
new file mode 100644 (file)
index 0000000..54a3264
--- /dev/null
@@ -0,0 +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;
+
+namespace Tizen.Applications
+{
+    /// <summary>
+    /// 
+    /// </summary>
+    public class RegionFormatChangedEventArgs : EventArgs
+    {
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="region"></param>
+        public RegionFormatChangedEventArgs(string region)
+        {
+            Region = region;
+        }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Region { get; private set; }
+    }
+}
index 10b6aea..a443acd 100644 (file)
@@ -8,6 +8,8 @@
 
 using System;
 
+using Tizen.Internals.Errors;
+
 namespace Tizen.Applications
 {
     /// <summary>
@@ -35,8 +37,11 @@ namespace Tizen.Applications
         {
             base.Run(args);
 
-            TizenSynchronizationContext.Initialize();
-            Interop.Service.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
+            ErrorCode err = Interop.Service.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to run the service. Err = " + err);
+            }
         }
 
         /// <summary>
@@ -47,6 +52,16 @@ namespace Tizen.Applications
             Interop.Service.Exit();
         }
 
+        internal override ErrorCode AddEventHandler(out IntPtr handle, Interop.AppCommon.AppEventType type, Interop.AppCommon.AppEventCallback callback)
+        {
+            return Interop.Service.AddEventHandler(out handle, type, callback, IntPtr.Zero);
+        }
+
+        internal override void RemoveEventHandler(IntPtr handle)
+        {
+            Interop.Service.RemoveEventHandler(handle);
+        }
+
         private bool OnCreateNative(IntPtr data)
         {
             OnCreate();
index 170e56b..9648ef0 100644 (file)
@@ -7,6 +7,7 @@
 // you entered into with Samsung.
 
 using System;
+using Tizen.Internals.Errors;
 using Tizen.UI;
 
 namespace Tizen.Applications
@@ -56,8 +57,11 @@ namespace Tizen.Applications
         {
             base.Run(args);
 
-            TizenSynchronizationContext.Initialize();
-            Interop.Application.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
+            ErrorCode err = Interop.Application.Main(args.Length, args, ref _callbacks, IntPtr.Zero);
+            if (err != ErrorCode.None)
+            {
+                Log.Error(LogTag, "Failed to run the application. Err = " + err);
+            }
         }
 
         /// <summary>
@@ -86,6 +90,16 @@ namespace Tizen.Applications
             Paused?.Invoke(this, EventArgs.Empty);
         }
 
+        internal override ErrorCode AddEventHandler(out IntPtr handle, Interop.AppCommon.AppEventType type, Interop.AppCommon.AppEventCallback callback)
+        {
+            return Interop.Application.AddEventHandler(out handle, type, callback, IntPtr.Zero);
+        }
+
+        internal override void RemoveEventHandler(IntPtr handle)
+        {
+            Interop.Application.RemoveEventHandler(handle);
+        }
+
         private bool OnCreateNative(IntPtr data)
         {
             Window = new Window("C# UI Application");