Disabling libimaevm error checking is now possible by define. 86/21386/1
authorJanusz Kozerski <j.kozerski@samsung.com>
Mon, 28 Apr 2014 08:59:47 +0000 (10:59 +0200)
committerJanusz Kozerski <j.kozerski@samsung.com>
Mon, 19 May 2014 12:13:35 +0000 (14:13 +0200)
Add define that can be used to test the UI without checking the
values reduned by libimaevm (no library error checking).

Change-Id: Iae86a87bbd003a4685bd1eb62ee3bc8cf3fe1221
Signed-off-by: Janusz Kozerski <j.kozerski@samsung.com>
src/im-main-menu.c

index d57abfc..a326c69 100644 (file)
 #include "im-load-policy.h"
 #include "im-get-policy.h"
 
+// FIXME: For testing/debug purpose only
+//        This flag cause that errors from libimaevm will be ignored.
+//#define DO_NOT_CHECK_ERROR
+
 static int _ima_state;     // 0 for disabled, 1 for enabled
 static int _ima_fix_state; // 0 for fix off (ima enabled), 1 for fix on
 
@@ -170,16 +174,18 @@ static void genlist_ima_enable_disable_clicked_cb(void *data, Evas_Object *obj,
         if (_ima_fix_state == 1) {
             ret = ima_set_state(IMA_STATE_FIX);
             printf("result of ima_set_state(IMA_STATE_FIX): %d\n", ret);
-            // FIXME: this code is commented for testing purpose
-            // if (ret) // Error
-            //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+            if (ret != LIB_SUCCESS) // Error
+                goto out;
+#endif
         }
         else {
             ret = ima_set_state(IMA_STATE_ENABLED);
             printf("result of ima_set_state(IMA_STATE_ENABLED): %d\n", ret);
-            // FIXME: this code is commented for testing purpose
-            // if (ret) // Error
-            //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+            if (ret != LIB_SUCCESS) // Error
+                goto out;
+#endif
         }
         _ima_state = 1;
         ((ItemData_t *)data)->check_status = EINA_TRUE;
@@ -188,14 +194,18 @@ static void genlist_ima_enable_disable_clicked_cb(void *data, Evas_Object *obj,
     else { // Turning off the IMA
         ret = ima_set_state(IMA_STATE_DISABLED);
         printf("result of ima_set_state(IMA_STATE_DISABLED): %d\n", ret);
-        // FIXME: this code is commented for testing purpose
-        // if (ret) // Error
-        //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+        if (ret != LIB_SUCCESS) // Error
+            goto out;
+#endif
         _ima_state = 0;
         ((ItemData_t *)data)->check_status = EINA_FALSE;
         _ima_disable_all_items(it);
     }
-// out:
+#ifndef DO_NOT_CHECK_ERROR
+out:
+#endif
+
     elm_genlist_item_update(it);
     elm_genlist_item_selected_set(it, EINA_FALSE);
 }
@@ -214,9 +224,10 @@ static void genlist_ima_fix_mode_enable_disable_clicked_cb(void *data, Evas_Obje
         if (_ima_state == 1) { // If IMA is enabled then turn on FIX mode
             ret = ima_set_state(IMA_STATE_FIX);
             printf("result of ima_set_state(FIX): %d\n", ret);
-            // FIXME: this code is commented for testing purpose
-            // if (ret) // Error
-            //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+            if (ret != LIB_SUCCESS) // Error
+                goto out;
+#endif
         }
         // If IMA is disabled then just change the state in UI
         _ima_fix_state = 1;
@@ -226,21 +237,25 @@ static void genlist_ima_fix_mode_enable_disable_clicked_cb(void *data, Evas_Obje
         if (_ima_state == 1) {
             ret = ima_set_state(IMA_STATE_ENABLED);
             printf("result of ima_set_state(IMA_STATE_ENABLED): %d\n", ret);
-            // FIXME: this code is commented for testing purpose
-            // if (ret) // Error
-            //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+            if (ret != LIB_SUCCESS) // Error
+                goto out;
+#endif
         }
         // If IMA is disabled then just change the state in UI
         _ima_fix_state = 0;
         ((ItemData_t *)data)->check_status = EINA_FALSE;
     }
-//out:
+#ifndef DO_NOT_CHECK_ERROR
+out:
+#endif
+
     elm_genlist_item_selected_set(it, EINA_FALSE);
     elm_genlist_item_update(it);
 }
 
 // ------------------ EVM ------------------
-// FIXME: Copy-paste code. Merge it with IMA switch callbacks if possible
+// FIXME: Copy-paste code. Merge it with IMA switch callbacks if possible.
 
 static void genlist_evm_enable_disable_clicked_cb(void *data, Evas_Object *obj, void *event_info)
 {
@@ -257,16 +272,18 @@ static void genlist_evm_enable_disable_clicked_cb(void *data, Evas_Object *obj,
         if (_evm_fix_state == 1) {
             ret = evm_set_state(EVM_STATE_FIX);
             printf("result of evm_set_state(EVM_STATE_FIX): %d\n", ret);
-            // FIXME: this code is commented for testing purpose
-            // if (ret) // Error
-            //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+            if (ret != LIB_SUCCESS) // Error
+                goto out;
+#endif
         }
         else {
             ret = evm_set_state(EVM_STATE_ENABLED);
             printf("result of evm_set_state(EVM_STATE_ENABLED): %d\n", ret);
-            // FIXME: this code is commented for testing purpose
-            // if (ret) // Error
-            //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+            if (ret != LIB_SUCCESS) // Error
+                goto out;
+#endif
         }
         _evm_state = 1;
         ((ItemData_t *)data)->check_status = EINA_TRUE;
@@ -275,14 +292,18 @@ static void genlist_evm_enable_disable_clicked_cb(void *data, Evas_Object *obj,
     else { // Turning off the EVM
         ret = evm_set_state(EVM_STATE_DISABLED);
         printf("result of evm_set_state(EVM_STATE_DISABLED): %d\n", ret);
-        // FIXME: this code is commented for testing purpose
-        // if (ret) // Error
-        //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+        if (ret != LIB_SUCCESS) // Error
+            goto out;
+#endif
         _evm_state = 0;
         ((ItemData_t *)data)->check_status = EINA_FALSE;
         _ima_disable_all_items(it);
     }
-// out:
+#ifndef DO_NOT_CHECK_ERROR
+out:
+#endif
+
     elm_genlist_item_update(it);
     elm_genlist_item_selected_set(it, EINA_FALSE);
 }
@@ -301,9 +322,10 @@ static void genlist_evm_fix_mode_enable_disable_clicked_cb(void *data, Evas_Obje
         if (_evm_state == 1) { // If EVM is enabled then turn on FIX mode
             ret = evm_set_state(EVM_STATE_FIX);
             printf("result of evm_set_state(FIX): %d\n", ret);
-            // FIXME: this code is commented for testing purpose
-            // if (ret) // Error
-            //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+            if (ret != LIB_SUCCESS) // Error
+                goto out;
+#endif
         }
         // If EVM is disabled then just change the state in UI
         _evm_fix_state = 1;
@@ -313,15 +335,19 @@ static void genlist_evm_fix_mode_enable_disable_clicked_cb(void *data, Evas_Obje
         if (_evm_state == 1) {
             ret = evm_set_state(EVM_STATE_ENABLED);
             printf("result of evm_set_state(EVM_STATE_ENABLED): %d\n", ret);
-            // FIXME: this code is commented for testing purpose
-            // if (ret) // Error
-            //    goto out;
+#ifndef DO_NOT_CHECK_ERROR
+            if (ret != LIB_SUCCESS) // Error
+                goto out;
+#endif
         }
         // If EVM is disabled then just change the state in UI
         _evm_fix_state = 0;
         ((ItemData_t *)data)->check_status = EINA_FALSE;
     }
-//out:
+#ifndef DO_NOT_CHECK_ERROR
+out:
+#endif
+
     elm_genlist_item_selected_set(it, EINA_FALSE);
     elm_genlist_item_update(it);
 }