[Tizen] Add new DotnetUtil class providing Tizen .NET API version 38/152138/14 preview1-00334
authorJongHeon Choi <j-h.choi@samsung.com>
Mon, 25 Sep 2017 06:34:25 +0000 (15:34 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Tue, 24 Oct 2017 06:44:28 +0000 (06:44 +0000)
Change-Id: I34c9fc033fdb599c5c36bbfcc9b7df8bf5358983

src/Tizen/Interop/Interop.CommonError.cs
src/Tizen/Interop/Interop.DotnetUtil.cs [new file with mode: 0644]
src/Tizen/Interop/Interop.Libraries.cs [new file with mode: 0644]
src/Tizen/Tizen.Common/DotnetUtil.cs [new file with mode: 0644]
src/Tizen/Tizen.Common/DotnetUtilErrorFactory.cs [new file with mode: 0644]
src/Tizen/Tizen.csproj

index 284ba22..0710d5f 100644 (file)
@@ -19,11 +19,6 @@ using System.Runtime.InteropServices;
 
 internal static partial class Interop
 {
-    internal static partial class Libraries
-    {
-        public const string Base = "libcapi-base-common.so.0";
-    }
-
     internal static partial class CommonError
     {
         [DllImport(Libraries.Base, EntryPoint = "get_last_result")]
diff --git a/src/Tizen/Interop/Interop.DotnetUtil.cs b/src/Tizen/Interop/Interop.DotnetUtil.cs
new file mode 100644 (file)
index 0000000..68ba363
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+using System;
+using System.Runtime.InteropServices;
+
+internal static partial class Interop
+{
+    internal static partial class DotnetUtil
+    {
+        [DllImport(Libraries.Vconf, EntryPoint = "vconf_get_int")]
+        internal static extern int GetVconfInt(string key, out int value);
+    }
+}
diff --git a/src/Tizen/Interop/Interop.Libraries.cs b/src/Tizen/Interop/Interop.Libraries.cs
new file mode 100644 (file)
index 0000000..506d911
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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 Base = "libcapi-base-common.so.0";
+        public const string Vconf = "libvconf.so.0";
+    }
+}
diff --git a/src/Tizen/Tizen.Common/DotnetUtil.cs b/src/Tizen/Tizen.Common/DotnetUtil.cs
new file mode 100644 (file)
index 0000000..2799561
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+
+using System;
+
+namespace Tizen.Common
+{
+    /// <summary>
+    /// The DotnetAPIs class provides the .NET api version.
+    /// </summary>
+    public static class DotnetUtil
+    {
+        /// <summary>
+        /// Gets the version of Tizen .NET API.
+        /// </summary>
+        /// <returns>The Tizen .NET API version</returns>
+        public static int TizenAPIVersion
+        {
+            get
+            {
+                int version = 0;
+                DotnetUtilError ret = (DotnetUtilError)Interop.DotnetUtil.GetVconfInt("db/dotnet/tizen_api_version", out version);
+                if (ret != DotnetUtilError.None)
+                {
+                    Log.Warn(DotnetUtilErrorFactory.LogTag, "unable to get Tizen .NET API version.");
+                }
+                return version;
+            }
+        }
+    }
+}
diff --git a/src/Tizen/Tizen.Common/DotnetUtilErrorFactory.cs b/src/Tizen/Tizen.Common/DotnetUtilErrorFactory.cs
new file mode 100644 (file)
index 0000000..677844a
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+* 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.
+*/
+
+using System;
+using Tizen.Internals.Errors;
+
+namespace Tizen.Common
+{
+    internal enum DotnetUtilError
+    {
+        None = ErrorCode.None,
+    }
+
+    internal static class DotnetUtilErrorFactory
+    {
+        internal const string LogTag = "Tizen.Common.DotnetUtil";
+
+        internal static void ThrowException(DotnetUtilError err)
+        {
+            DotnetUtilError error = err;
+            if (error != DotnetUtilError.None)
+            {
+                throw new ArgumentException("Vconf error");
+            }
+        }
+    }
+}
index dbdcea4..8b42da5 100644 (file)
@@ -4,4 +4,8 @@
     <TargetFramework>netstandard2.0</TargetFramework>
   </PropertyGroup>
 
+  <ItemGroup>
+    <ProjectReference Include="..\Tizen.Log\Tizen.Log.csproj" />
+  </ItemGroup>
+
 </Project>