From 452ceae878de1290e834d99964ca0d3a50d934db Mon Sep 17 00:00:00 2001 From: "dongsug.song" Date: Mon, 6 Nov 2017 15:52:49 +0900 Subject: [PATCH] [NUI] Add internal class for version checking Change-Id: I27495a28c8df9c6d7708148f859ab6d35e73737c Signed-off-by: dongsug.song --- src/Tizen.NUI/src/internal/Application.cs | 5 +++ src/Tizen.NUI/src/internal/VersionCheck.cs | 67 ++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100755 src/Tizen.NUI/src/internal/VersionCheck.cs diff --git a/src/Tizen.NUI/src/internal/Application.cs b/src/Tizen.NUI/src/internal/Application.cs index fa69d30..f74d695 100755 --- a/src/Tizen.NUI/src/internal/Application.cs +++ b/src/Tizen.NUI/src/internal/Application.cs @@ -515,6 +515,11 @@ namespace Tizen.NUI // Callback for Application InitSignal private void OnApplicationInit(IntPtr data) { + if (Version.DaliVersionMatchWithNUI() == false) + { + Tizen.Log.Fatal("NUI", "Dali and NUI are version mismatched!"); + } + // Initialize DisposeQueue Singleton class. This is also required to create DisposeQueue on main thread. DisposeQueue.Instance.Initialize(); NUIApplicationInitEventArgs e = new NUIApplicationInitEventArgs(); diff --git a/src/Tizen.NUI/src/internal/VersionCheck.cs b/src/Tizen.NUI/src/internal/VersionCheck.cs new file mode 100755 index 0000000..46b96b4 --- /dev/null +++ b/src/Tizen.NUI/src/internal/VersionCheck.cs @@ -0,0 +1,67 @@ +/* + * Copyright(c) 2017 Samsung Electronics Co., Ltd. + * + * 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.NUI +{ + //This version should be updated and synced for every Dali native release + internal static class Version + { + public const int daliVer1 = 1; + public const int daliVer2 = 2; + public const int daliVer3 = 61002; + public const int nuiVer1 = 0; + public const int nuiVer2 = 2; + public const int nuiVer3 = 61002; + public const string nuiRelease = ""; + + + static internal bool DaliVersionMatchWithNUI() + { + int ver1 = -1; + int ver2 = -1; + int ver3 = -1; + + try + { + if (NDalicManualPINVOKE.NativeVersionCheck(ref ver1, ref ver2, ref ver3)) + { + if (ver1 != daliVer1 || ver2 != daliVer2 || ver3 != daliVer3) + { + Tizen.Log.Fatal("NUI", $"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali= { ver1 }.{ ver2}.{ ver3}"); + throw new System.InvalidOperationException($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali={ ver1 }.{ ver2}.{ ver3}"); + return false; + } + } + else + { + Tizen.Log.Fatal("NUI", $"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali= { ver1 }.{ ver2}.{ ver3}"); + throw new System.InvalidOperationException($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali={ ver1 }.{ ver2}.{ ver3}"); + return false; + } + } + catch (Exception exc) + { + Tizen.Log.Fatal("NUI", $"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali= { ver1 }.{ ver2}.{ ver3}"); + throw new System.InvalidOperationException($"Dali native version mismatch error! nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3} but dali={ ver1 }.{ ver2}.{ ver3}"); + } + Tizen.Log.Fatal("NUI", $"version info: nui={ nuiVer1}.{ nuiVer2}.{ nuiVer3}, dali= { ver1 }.{ ver2}.{ ver3}"); + return true; + } + } +} -- 2.7.4