Add policy loading from UI 43/26743/1
authorJanusz Kozerski <j.kozerski@samsung.com>
Fri, 22 Aug 2014 13:50:22 +0000 (15:50 +0200)
committerJanusz Kozerski <j.kozerski@samsung.com>
Thu, 28 Aug 2014 11:41:59 +0000 (13:41 +0200)
The UI uses the ima_evm_server_set_policy_file()
Add "Error: " message

Change-Id: Idf7eb32524674c127bb9933178903de99cdfd501
Signed-off-by: Janusz Kozerski <j.kozerski@samsung.com>
po/en.po
po/en_US.po
src/im-load-policy.c

index d5eb8f9..97e0ab7 100644 (file)
--- a/po/en.po
+++ b/po/en.po
@@ -13,6 +13,9 @@ msgstr "Policy from file "
 msgid "IDS_ST_POLICY_LOAD_MSG_END"
 msgstr " was loaded"
 
+msgid "IDS_ST_ERROR_MSG"
+msgstr "Error: "
+
 msgid "IDS_ST_POLICY_LOAD_TITLE"
 msgstr "Load policy"
 
index d5eb8f9..97e0ab7 100644 (file)
@@ -13,6 +13,9 @@ msgstr "Policy from file "
 msgid "IDS_ST_POLICY_LOAD_MSG_END"
 msgstr " was loaded"
 
+msgid "IDS_ST_ERROR_MSG"
+msgstr "Error: "
+
 msgid "IDS_ST_POLICY_LOAD_TITLE"
 msgstr "Load policy"
 
index 5723c0b..048a9c6 100644 (file)
@@ -20,6 +20,8 @@
  * @brief
  */
 
+#include <ima-evm-server.h>
+
 #include "im-common.h"
 #include "im-uigadget.h"
 #include "im-load-policy.h"
@@ -27,6 +29,7 @@
 #define LOAD_POLICY_DEFAULT_PATH "/"
 #define MESSAGE_BEGIN            "IDS_ST_POLICY_LOAD_MSG_BEGIN"
 #define MESSAGE_END              "IDS_ST_POLICY_LOAD_MSG_END"
+#define MESSAGE_ERROR            "IDS_ST_ERROR_MGS"
 #define FILE_SELECTOR_TITLE      "IDS_ST_POLICY_LOAD_TITLE"
 
 void im_load_policy_cb (void *data, Evas_Object *obj, void *event_info)
@@ -43,19 +46,30 @@ void im_load_policy_cb (void *data, Evas_Object *obj, void *event_info)
     show_file_selector(ad, dgettext(PACKAGE, FILE_SELECTOR_TITLE));
 }
 
+// Loading policy from file (path)
+// Signature of the policy have to be placed in "path.sig" file
 int im_load_policy_wrapper (struct ug_data *ad, const char* const file_path)
 {
     LOGD("Enter function: %s", __func__);
     // TODO: This function should internally call
     //       policy loader from ima-evm-utils library
+    int ret = ima_evm_server_set_policy_file(file_path);
 
-    size_t size =  strlen(dgettext(PACKAGE, MESSAGE_BEGIN)) +
-                   strlen(dgettext(PACKAGE, MESSAGE_END)) +
-                   strlen(file_path) + 1;                    // Use asprintf?
-    ad->popup_content = malloc(sizeof(char) * size);  // One more char to add NULL at the end
-    snprintf(ad->popup_content, size, "%s%s%s", dgettext(PACKAGE, MESSAGE_BEGIN),
-            file_path, dgettext(PACKAGE, MESSAGE_END));
-    ad->popup_content[size-1] = '\0';
+    if (ret == IMA_EVM_SERVER_API_SUCCESS) {
+        size_t size = strlen(dgettext(PACKAGE, MESSAGE_BEGIN)) +
+                      strlen(dgettext(PACKAGE, MESSAGE_END)) +
+                      strlen(file_path) + 1;                    // Use asprintf?
+        ad->popup_content = malloc(sizeof(char) * size);  // One more char to add NULL at the end
+        snprintf(ad->popup_content, size, "%s%s%s", dgettext(PACKAGE, MESSAGE_BEGIN),
+                file_path, dgettext(PACKAGE, MESSAGE_END));
+        ad->popup_content[size-1] = '\0';
+    }
+    else { // Error
+        size_t size = strlen(dgettext(PACKAGE, MESSAGE_ERROR)) + 3 + 1;
+        ad->popup_content = malloc(sizeof(char) * size);
+        snprintf(ad->popup_content, size, "%s%d", dgettext(PACKAGE, MESSAGE_ERROR), ret);
+        ad->popup_content[size-1] = '\0';
+    }
 
     create_ok_popup(ad);
     return 0;