Implements Tizen.Applications.ApplicationInfo
authorSeungkeun Lee <sngn.lee@samsung.com>
Wed, 23 Mar 2016 05:41:19 +0000 (14:41 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Wed, 23 Mar 2016 05:43:08 +0000 (14:43 +0900)
 - AppCommon API in C#

Change-Id: Iec780775eb9d24ec598663140400f759ea05a08b

Tizen.Applications/Interop/Interop.AppCommon.cs
Tizen.Applications/Tizen.Applications/Application.cs
Tizen.Applications/Tizen.Applications/ApplicationInfo.cs
Tizen.Applications/Tizen.Applications/ServiceApplication.cs
Tizen.Applications/Tizen.Applications/UIApplication.cs

index fa4a190..7373549 100755 (executable)
@@ -16,6 +16,44 @@ internal static partial class Interop
 {
     internal static partial class AppCommon
     {
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_id", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern ErrorCode AppGetId(out string appId);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_name", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern ErrorCode AppGetName(out string name);
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_resource_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetResourcePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_data_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetDataPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_cache_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetCachePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_shared_data_path, CallingConvention = CallingConvention.Cdecl")]
+        internal static extern string AppGetSharedDataPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_shared_resource_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetSharedResourcePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_shared_trusted_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetSharedTrustedPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_tep_resource_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetTepResourcePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_external_cache_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetExternalCachePath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_external_data_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetExternalDataPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_external_shared_data_path", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern string AppGetExternalSharedDataPath();
+
+        [DllImport(Libraries.AppCommon, EntryPoint = "app_get_version", CallingConvention = CallingConvention.Cdecl)]
+        internal static extern ErrorCode AppGetVersion(out string version);
     }
 }
 
index a35894a..fd8a5d9 100755 (executable)
@@ -58,6 +58,11 @@ namespace Tizen.Applications
         /// </summary>
         public abstract void Exit();
 
+        internal void SendCreate()
+        {
+            ApplicationInfo = new ApplicationInfo();
+            OnCreate();
+        }
         protected virtual void OnCreate()
         {
         }
index f939bc6..4122d7e 100755 (executable)
@@ -16,18 +16,201 @@ using System.Threading.Tasks;
 namespace Tizen.Applications
 {
     /// <summary>
-    /// 
+    ///
     /// </summary>
     public class ApplicationInfo
     {
+        private SharedPaths _shared = null;
+        private ExternalPaths _external = null;
+
+        internal ApplicationInfo()
+        {
+
+        }
+
+        /// <summary>
+        /// The ID of the application.
+        /// </summary>
+        public string Id
+        {
+            get
+            {
+                string value;
+                Interop.AppCommon.AppGetId(out value);
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// The localized name of the application.
+        /// </summary>
+        public string Name
+        {
+            get
+            {
+                string value;
+                Interop.AppCommon.AppGetName(out value);
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// The version of the application package.
+        /// </summary>
+        public string Version
+        {
+            get
+            {
+                string value;
+                Interop.AppCommon.AppGetVersion(out value);
+                return value;
+            }
+        }
+
+        /// <summary>
+        /// The absolute path to the application's data directory which is used to store private data of the application.
+        /// </summary>
+        public string DataPath
+        {
+            get
+            {
+                return Interop.AppCommon.AppGetDataPath();
+            }
+        }
+
+        /// <summary>
+        /// The absolute path to the application's cache directory which is used to store temporary data of the application.
+        /// </summary>
+        public string CachePath
+        {
+            get
+            {
+                return Interop.AppCommon.AppGetCachePath();
+            }
+        }
+
+        /// <summary>
+        /// The absolute path to the application resource directory. The resource files are delivered with the application package.
+        /// </summary>
+        public string ResourcePath
+        {
+            get
+            {
+                return Interop.AppCommon.AppGetResourcePath();
+            }
+        }
+
+        /// <summary>
+        /// The shared paths
+        /// </summary>
+        public SharedPaths Shared
+        {
+            get
+            {
+                if (_shared == null)
+                    _shared = new SharedPaths();
+                return _shared;
+            }
+        }
+
         /// <summary>
-        /// 
+        /// The external paths
         /// </summary>
-        public string Id { get; internal set; }
+        public ExternalPaths External
+        {
+            get
+            {
+                if (_external == null)
+                    _external = new ExternalPaths();
+                return _external;
+            }
+        }
 
         /// <summary>
-        /// 
+        /// The absolute path to the application's TEP(Tizen Expansion Package) directory. The resource files are delivered with the expansion package.
         /// </summary>
-        public string Name { get; internal set; }
+        public string ExpansionPackageResourcePath
+        {
+            get
+            {
+                return Interop.AppCommon.AppGetTepResourcePath();
+            }
+        }
+
+
+        public class SharedPaths
+        {
+            internal SharedPaths() { }
+            /// <summary>
+            /// The absolute path to the application's shared data directory which is used to share data with other applications.
+            /// </summary>
+            public string DataPath
+            {
+                get
+                {
+                    return Interop.AppCommon.AppGetSharedDataPath();
+                }
+            }
+
+            /// <summary>
+            /// The absolute path to the application's shared resource directory which is used to share resources with other applications.
+            /// </summary>
+            public string ResourcePath
+            {
+                get
+                {
+                    return Interop.AppCommon.AppGetSharedResourcePath();
+                }
+            }
+
+            /// <summary>
+            /// The absolute path to the application's shared trusted directory which is used to share data with a family of trusted applications.
+            /// </summary>
+            public string TrustedPath
+            {
+                get
+                {
+                    return Interop.AppCommon.AppGetSharedTrustedPath();
+                }
+            }
+        }
+
+        public class ExternalPaths
+        {
+            internal ExternalPaths() { }
+
+            /// <summary>
+            /// The absolute path to the application's external data directory which is used to store data of the application.
+            /// </summary>
+            public string DataPath
+            {
+                get
+                {
+                    return Interop.AppCommon.AppGetExternalDataPath();
+                }
+            }
+
+            /// <summary>
+            /// The absolute path to the application's external cache directory which is used to store temporary data of the application.
+            /// </summary>
+            public string CachePath
+            {
+                get
+                {
+                    return Interop.AppCommon.AppGetExternalCachePath();
+                }
+            }
+
+            /// <summary>
+            /// The absolute path to the application's external shared data directory which is used to share data with other applications.
+            /// </summary>
+            public string SharedDataPath
+            {
+                get
+                {
+                    return Interop.AppCommon.AppGetExternalSharedDataPath();
+                }
+            }
+        }
     }
 }
index 6dde93d..90c4872 100755 (executable)
@@ -31,7 +31,7 @@ namespace Tizen.Applications
             Interop.Service.ServiceAppLifecycleCallbacks ops;
             ops.OnCreate = (data) =>
             {
-                OnCreate();
+                SendCreate();
                 return true;
             };
             ops.OnTerminate = (data) =>
index 11a17bf..0e605dc 100755 (executable)
@@ -32,7 +32,7 @@ namespace Tizen.Applications
             Interop.Application.UIAppLifecycleCallbacks ops;
             ops.OnCreate = (data) =>
             {
-                OnCreate();
+                SendCreate();
                 return true;
             };
             ops.OnTerminate = (data) =>