ui_app_exit();
}
-void print_msg(Evas_Object *obj, const char* msg, ...)
+void msg_print(Evas_Object *obj, const char* msg, ...)
{
va_list args;
va_start(args, msg);
const char* separator = "";
- print_msg(ad->msg_box, buffer);
- print_msg(ad->msg_box, separator);
+ msg_print(ad->msg_box, buffer);
+ msg_print(ad->msg_box, separator);
dlog_print(DLOG_INFO, LOG_TAG, buffer);
dlog_print(DLOG_INFO, LOG_TAG, separator);
}
+void log_result(appdata_s *ad, ppm_request_result_e result, const char *privilege)
+{
+ switch (result)
+ {
+ case PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_ALLOW_FOREVER:
+ log_msg(ad, "A user granted permission to use the %s privilege for an indefinite period of time.", privilege);
+ break;
+ case PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_DENY_FOREVER:
+ log_msg(ad, "A user did not grant permission to use the %s privilege for an indefinite period of time.", privilege);
+ break;
+ case PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_DENY_ONCE:
+ log_msg(ad, "A user did not grant permission to use the %s privilege once.", privilege);
+ break;
+ default:
+ log_msg(ad, "Unknown result (%d) for the %s privilege.", result, privilege);
+ break;
+ }
+}
+
static void _btn_clear_cb(void *data, Evas_Object *btn, void *event_info)
{
appdata_s *ad = data;
return bt;
}
-void log_privilege(appdata_s *ad, const char* privilege, const char* msg)
-{
- if (msg == NULL)
- return;
- if (privilege != NULL)
- {
- print_msg(ad->msg_box, "----------<br>Privilege: %s<br>Message: %s", privilege, msg);
- dlog_print(DLOG_INFO, LOG_TAG, "----------\nPrivilege: %s\nMessage: %s", privilege, msg);
- }
- else
- {
- print_msg(ad->msg_box, "----------<br><br>Message: %s", msg);
- dlog_print(DLOG_INFO, LOG_TAG, "----------\\nMessage: %s", msg);
- }
-}
-
-void log_result(appdata_s *ad, ppm_request_result_e result, const char *privilege)
-{
- switch (result)
- {
- case PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_ALLOW_FOREVER:
- log_privilege(ad, privilege, "A user granted permission to use a privilege for an indefinite period of time.");
- break;
- case PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_DENY_FOREVER:
- log_privilege(ad, privilege, "A user did not grant permission to use a privilege for an indefinite period of time.");
- break;
- case PRIVACY_PRIVILEGE_MANAGER_REQUEST_RESULT_DENY_ONCE:
- log_privilege(ad, privilege, "A user did not grant permission to use a privilege once.");
- break;
- default:
- {
- char msg[BUFFER_SIZE];
- snprintf(msg, BUFFER_SIZE, "unknown result: %d", result);
- log_privilege(ad, privilege, "Unknown result: ");
- break;
- }
- }
-}
-
void ppm_popup_response_cb_function(ppm_call_cause_e cause, ppm_request_result_e result, const char *privilege, void *user_data)
{
appdata_s *ad = user_data;
switch (cause)
{
case PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ANSWER:
- log_privilege(ad, privilege, "Callback was called with a valid answer.");
+ log_msg(ad, "Callback for the %s privilege was called with a valid answer.", privilege);
log_result(ad, result, privilege);
break;
case PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ERROR:
- log_privilege(ad, privilege, "Callback was called because of an error.");
+ log_msg(ad, "Callback for the %s privilege was called because of an error.", privilege);
break;
default:
- {
- char msg[BUFFER_SIZE];
- snprintf(msg, BUFFER_SIZE, "Unknown cause: %d", cause);
- log_privilege(ad, privilege, msg);
+ log_msg(ad, "Callback for the %s privilege was called because of an unknown cause: %d.", privilege, cause);
break;
- }
}
}
case PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ANSWER:
for (int it = 0; it < privileges_count; ++it)
{
- log_privilege(ad, privileges[it], "Callback was called with a valid answer.");
+ log_msg(ad, "Callback for the %s privilege was called with a valid answer.", privileges[it]);
log_result(ad, results[it], privileges[it]);
}
break;
case PRIVACY_PRIVILEGE_MANAGER_CALL_CAUSE_ERROR:
for (int it = 0; it < privileges_count; ++it)
{
- log_privilege(ad, privileges[it], "Callback was called because of an error.");
+ log_msg(ad, "Callback for the %s privilege was called because of an error.", privileges[it]);
}
break;
default:
- {
- char msg[BUFFER_SIZE];
- snprintf(msg, BUFFER_SIZE, "Unknown cause: %d", cause);
for (int it = 0; it < privileges_count; ++it)
{
- log_privilege(ad, privileges[it], msg);
+ log_msg(ad, "Callback for the %s privilege was called because of an unknown cause: %d.", privileges[it], cause);
}
break;
- }
}
if (second_request)
{
switch (result) // Allow, deny or ask.
{
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW:
- log_privilege(ad, privilege, "An application has permission to use a privilege.");
+ log_msg(ad, "An application has permission to use the %s privilege.", privilege);
break;
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_DENY:
- log_privilege(ad, privilege, "An application doesn't have permission to use a privilege.");
+ log_msg(ad, "An application doesn't have permission to use the %s privilege.", privilege);
break;
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ASK:
- {
- log_privilege(ad, privilege, "A user has to be asked whether to grant permission to use a privilege.");
+ log_msg(ad, "A user has to be asked whether to grant permission to use the %s privilege.", privilege);
int ret_popup = ppm_request_permission(privilege, ppm_popup_response_cb_function, ad);
if (ret_popup != PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE)
{
return;
}
break;
- }
default:
- {
- char msg[BUFFER_SIZE];
- snprintf(msg, BUFFER_SIZE, "Unknown result: %d", result);
- log_privilege(ad, privilege, msg);
+ log_msg(ad, "Unknown result (%d) for the %s privilege.", result, privilege);
break;
- }
}
}
log_msg(ad, "A user has to be asked whether to grant a permission to use the privilege %s for the following application: %s.", privilege, app_id);
break;
default:
- log_msg(ad, "Unknown result (%d) for %s privilege and %s app.", result, privilege, app_id);
+ log_msg(ad, "Unknown result (%d) for the %s privilege and the %s app.", result, privilege, app_id);
break;
}
}
ppm_check_result_e* results = malloc(sizeof(ppm_check_result_e) * privileges_count);
if (!results)
{
- print_msg(ad->msg_box, "----------<br>unable to allocate memory for check_results.");
- dlog_print(DLOG_INFO, LOG_TAG, "----------\nunable to allocate memory for check_results.");
+ log_msg(ad, "Unable to allocate memory for check_results.");
return;
}
}
if (!privs_to_ask)
{
- print_msg(ad->msg_box, "----------<br>unable to allocate memory for privileges to ask.");
- dlog_print(DLOG_INFO, LOG_TAG, "----------\nunable to allocate memory for privileges to ask.");
+ log_msg(ad, "Unable to allocate memory for privileges to ask.");
free(results);
return;
}
switch (results[it]) // Allow, deny or ask.
{
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW:
- {
- log_privilege(ad, privileges[it], "An application has permission to use a privilege.");
+ log_msg(ad, "An application has permission to use the %s privilege.", privileges[it]);
break;
- }
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_DENY:
- {
- log_privilege(ad, privileges[it], "An application doesn't have permission to use a privilege.");
+ log_msg(ad, "An application doesn't have permission to use the %s privilege.", privileges[it]);
break;
- }
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ASK:
- {
- log_privilege(ad, privileges[it], "A user has to be asked whether to grant permission to use a privilege.");
+ log_msg(ad, "A user has to be asked whether to grant permission to use the %s privilege.", privileges[it]);
if (!request_privs_ignore_ask_status)
{
privs_to_ask[askable_privs_it++] = (char*)privileges[it];
}
break;
- }
default:
- {
- char msg[BUFFER_SIZE];
- snprintf(msg, BUFFER_SIZE, "Unknown result: %d", results[it]);
- log_privilege(ad, privileges[it], msg);
+ log_msg("Unknown result (%d) for the %s privilege.", results[it], privileges[it]);
break;
- }
}
}
free(results);
{
for (int it = 0; it < askable_privs_it; ++it)
{
- log_privilege(ad, privs_to_ask[it], "Unable to request permissions");
+ log_msg(ad, "Unable to request permission for the %s privilege.", privs_to_ask[it]);
}
}
if (!request_privs_ignore_ask_status)
switch (results[it]) // Allow, deny or ask.
{
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ALLOW:
- log_msg(ad, "The application %s has a permission to use the following privilege: %s.", app_id, privileges[it]);
+ log_msg(ad, "The application %s has a permission to use the %s privilege.", app_id, privileges[it]);
break;
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_DENY:
- log_msg(ad, "The application %s doesn't have a permission to use the following privilege: %s.", app_id, privileges[it]);
+ log_msg(ad, "The application %s doesn't have a permission to use the %s privilege.", app_id, privileges[it]);
break;
case PRIVACY_PRIVILEGE_MANAGER_CHECK_RESULT_ASK:
- log_msg(ad, "A user has to be asked whether to grant a permission to use the privilege %s for the following application: %s.", privileges[it], app_id);
+ log_msg(ad, "A user has to be asked whether to grant a permission to use the %s privilege for the %s application.", privileges[it], app_id);
break;
default:
log_msg(ad, "Unknown result (%d) for %s privilege and %s app.", results[it], privileges[it], app_id);
/**
* @file ppmtester.h
* @author Ernest Borowski <e.borowski@partner.samsung.com>
+ * @author Pawel Kowalski <p.kowalski2@partner.samsung.com>
* @brief The header of testing application of the PPM CAPI.
*/
static void win_delete_request_cb(void *data, Evas_Object *obj, void *event_info);
/**
- * @brief Prints massage into the message box.
+ * @brief Prints message into the message box.
*
* @param[in] obj The message box.
* @param[in] msg The text message that is written to the message box.
* @param[in] ... Additional arguments declared in the text message.
*/
-void print_msg(Evas_Object *obj, const char* msg, ...);
+void msg_print(Evas_Object *obj, const char* msg, ...);
/**
* @brief Prints massage into the message box and into the dlogutil logger.
void log_msg(appdata_s *ad, const char* msg, ...);
/**
+ * @brief Logs result from ppm_check_pemission(s) callback.
+ *
+ * @details In order to read a message using dlogutil, type in the emulator's
+ * terminal: dlogutil ppmtester. The 'ppmtester' flag is set using LOG_TAG constant.
+ *
+ * @param[in] ad The structure with GUI elements.
+ * @param[in] result The result of request.
+ * @param[in] privilege A privilege that is to be logged.
+ */
+void log_result(appdata_s *ad, ppm_request_result_e result, const char *privilege);
+
+/**
* @brief Clears the message box.
*
* @param[in] data User specific data.
Evas_Object *_new_button(appdata_s *ad, Evas_Object *display, const char *name, void *cb);
/**
- * @brief Writes text into dlogutil and into GUI.
- *
- * @details In order to read a message using dlogutil,
- * type in the emulator's terminal: dlogutil ppmtester
- * The 'ppmtester' flag is set using LOG_TAG constant.
- *
- * @param[in] ad The structure with GUI elements.
- * @param[in] privilege A privilege that is to be logged.
- * @param[in] msg A text that is to be written.
- */
-void log_privilege(appdata_s *ad, const char* privilege, const char* msg);
-
-/**
- * @brief Logs result from ppm_check_pemission(s) callback
- *
- * @details In order to read a message using dlogutil,
- * type in the emulator's terminal: dlogutil ppmtester
- * The 'ppmtester' flag is set using LOG_TAG constant.
- *
- * @param[in] ad The structure with GUI elements.
- * @param[in] result The result of request.
- * @param[in] privilege A privilege that is to be logged.
- */
-void log_result(appdata_s *ad, ppm_request_result_e result, const char *privilege);
-
-/**
* @brief Based on ppm_popup_response_cb prototype from privacy-privilege-manager.h.
*
* @param[in] cause A value representing the reason why this callback