[NUI] Add internal class for version checking 75/158975/1
authordongsug.song <dongsug.song@samsung.com>
Mon, 6 Nov 2017 06:52:49 +0000 (15:52 +0900)
committerdongsug.song <dongsug.song@samsung.com>
Mon, 6 Nov 2017 07:39:55 +0000 (16:39 +0900)
Change-Id: I27495a28c8df9c6d7708148f859ab6d35e73737c
Signed-off-by: dongsug.song <dongsug.song@samsung.com>
src/Tizen.NUI/src/internal/Application.cs
src/Tizen.NUI/src/internal/VersionCheck.cs [new file with mode: 0755]

index fa69d30..f74d695 100755 (executable)
@@ -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 (executable)
index 0000000..46b96b4
--- /dev/null
@@ -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;
+        }
+    }
+}