From 96683dd04190cfdef12057c35f17df1e1e0bec56 Mon Sep 17 00:00:00 2001 From: JongHeon Choi Date: Mon, 25 Sep 2017 15:34:25 +0900 Subject: [PATCH] [Tizen] Add new DotnetUtil class providing Tizen .NET API version Change-Id: I34c9fc033fdb599c5c36bbfcc9b7df8bf5358983 --- src/Tizen/Interop/Interop.CommonError.cs | 5 --- src/Tizen/Interop/Interop.DotnetUtil.cs | 27 +++++++++++++++ src/Tizen/Interop/Interop.Libraries.cs | 24 +++++++++++++ src/Tizen/Tizen.Common/DotnetUtil.cs | 44 ++++++++++++++++++++++++ src/Tizen/Tizen.Common/DotnetUtilErrorFactory.cs | 40 +++++++++++++++++++++ src/Tizen/Tizen.csproj | 4 +++ 6 files changed, 139 insertions(+), 5 deletions(-) create mode 100644 src/Tizen/Interop/Interop.DotnetUtil.cs create mode 100644 src/Tizen/Interop/Interop.Libraries.cs create mode 100644 src/Tizen/Tizen.Common/DotnetUtil.cs create mode 100644 src/Tizen/Tizen.Common/DotnetUtilErrorFactory.cs diff --git a/src/Tizen/Interop/Interop.CommonError.cs b/src/Tizen/Interop/Interop.CommonError.cs index 284ba22..0710d5f 100644 --- a/src/Tizen/Interop/Interop.CommonError.cs +++ b/src/Tizen/Interop/Interop.CommonError.cs @@ -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 index 0000000..68ba363 --- /dev/null +++ b/src/Tizen/Interop/Interop.DotnetUtil.cs @@ -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 index 0000000..506d911 --- /dev/null +++ b/src/Tizen/Interop/Interop.Libraries.cs @@ -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 index 0000000..2799561 --- /dev/null +++ b/src/Tizen/Tizen.Common/DotnetUtil.cs @@ -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 +{ + /// + /// The DotnetAPIs class provides the .NET api version. + /// + public static class DotnetUtil + { + /// + /// Gets the version of Tizen .NET API. + /// + /// The Tizen .NET API version + 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 index 0000000..677844a --- /dev/null +++ b/src/Tizen/Tizen.Common/DotnetUtilErrorFactory.cs @@ -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"); + } + } + } +} diff --git a/src/Tizen/Tizen.csproj b/src/Tizen/Tizen.csproj index dbdcea4..8b42da5 100644 --- a/src/Tizen/Tizen.csproj +++ b/src/Tizen/Tizen.csproj @@ -4,4 +4,8 @@ netstandard2.0 + + + + -- 2.7.4