[NUI] Add KeyboardRepeatInfo APIs to Window (#274)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / VersionCheck.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System;
19 using System.Diagnostics;
20
21 namespace Tizen.NUI
22 {
23     //This version should be updated and synced for every Dali native release
24     internal static class Version
25     {
26         //Lower than dali_1.2.85 : NUI internal API version 400
27         //dali_1.2.86 ~ dali_1.2.89 : NUI internal API version 401
28         //dali_1.2.90 : NUI internal API version 402
29         public const int nuiAPIVer = 402;
30         public const int reservedVer1 = 0;
31         public const int reservedVer2 = 0;
32
33         static internal bool DaliVersionMatchWithNUI()
34         {
35             int ver1 = -1;
36             int ver2 = -1;
37             int ver3 = -1;
38
39             try
40             {
41                 if (NDalicManualPINVOKE.InternalAPIVersionCheck(ref ver1, ref ver2, ref ver3) == true)
42                 {
43                     if (ver1 != nuiAPIVer)
44                     {
45                         NUILog.Error($"NUI API version mismatch error! NUI API Version: ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})");
46                         throw new System.InvalidOperationException($"NUI API version mismatch error! NUI API version should be ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})");
47                     }
48                 }
49                 else
50                 {
51                     NUILog.Error($"NUI API version mismatch error! NUI API Version: ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})");
52                     throw new System.InvalidOperationException($"NUI API version mismatch error! NUI API version should be ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})");
53                 }
54             }
55             catch (Exception)
56             {
57                 NUILog.Error($"NUI API version mismatch error! NUI API Version: ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})");
58                 throw new System.InvalidOperationException($"NUI API version mismatch error! NUI API version should be ({nuiAPIVer}) but read version from native: ({ver1}.{ver2}.{ver3})");
59             }
60
61             PrintDaliNativeVersion();
62             return true;
63         }
64
65         [Conditional("DEBUG_ON")]
66         static private void PrintDaliNativeVersion()
67         {
68             int ver1 = -1;
69             int ver2 = -1;
70             int ver3 = -1;
71
72             NDalicManualPINVOKE.NativeVersionCheck(ref ver1, ref ver2, ref ver3);
73             NUILog.Debug($"DALi Version: ({ver1}.{ver2}.{ver3}), NUI API Version: ({nuiAPIVer})");
74         }
75     }
76 }