* @brief
*/
+#include <ima-evm-server.h>
+
#include "im-common.h"
#include "im-uigadget.h"
#include "im-load-policy.h"
#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)
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;