static void app_control(app_control_h app_control, void *data)
{
LOGD("app_control()");
+
/* Handle the launch request. */
app_data_s *ad = (app_data_s *)data;
+ if (ad->popup_num >= MAX_POPUP_NUM) {
+ LOGE("Requested popup num exceed MAX_POPUP_NUM. Ignore.");
+ return;
+ }
+
int ret = 0;
char* caller_appid = NULL;
ui_app_exit();
}
- ret = app_info_get_package(app_info, &(ad->caller_pkgid));
+ char* caller_pkgid = NULL;
+
+ ret = app_info_get_package(app_info, &caller_pkgid);
if (ret != APP_MANAGER_ERROR_NONE) {
LOGE("app_info_get_package() failed. ret = %d", ret);
ui_app_exit();
}
+ if (!ad->caller_pkgid) {
+ ad->caller_pkgid = strdup(caller_pkgid);
+ free(caller_pkgid);
+ } else {
+ if (strcmp(caller_pkgid, ad->caller_pkgid) != 0) {
+ LOGE("Received data isn't from the same caller app! Orig: %s, New: %s", ad->caller_pkgid, caller_pkgid);
+ free(caller_pkgid);
+ ui_app_exit();
+ }
+ free(caller_pkgid);
+ }
+
if (ad->caller_pkgid == NULL) {
LOGE("Failed to get caller_pkgid");
ui_app_exit();
}
+ init_popup_data(&(ad->popups[ad->popup_num]));
+
bundle *b = NULL;
ret = app_control_to_bundle(app_control, &b);
ret = bundle_get_byte(b, "popup_id", (void**)&popup_id, &popup_id_size);
if (ret == BUNDLE_ERROR_NONE) {
- ad->popup_id = *popup_id;
+ ad->popups[ad->popup_num].popup_id = *popup_id;
LOGD("popup_id = %d", *popup_id);
} else {
LOGE("caller pkgid [%s]: bundle_get_byte() failed. ret = %d", ad->caller_pkgid, ret);
ui_app_exit();
}
if (privacy_num < 1) {
- LOGE("caller_pkgid [%s]: key 'privacy_list' len: %d < 1", ad->caller_pkgid, ad->privacy_num);
+ LOGE("caller_pkgid [%s]: key 'privacy_list' len: %d < 1", ad->caller_pkgid, ad->popups[ad->popup_num].privacy_num);
ui_app_exit();
}
- ad->privacy_num = privacy_num;
- LOGD("privacy num = %d", ad->privacy_num);
+ ad->popups[ad->popup_num].privacy_num = privacy_num;
+ LOGD("privacy num = %d", ad->popups[ad->popup_num].privacy_num);
int i = 0;
- for (i = 0; i < ad->privacy_num; ++i) {
+ for (i = 0; i < ad->popups[ad->popup_num].privacy_num; ++i) {
LOGD("privacy_list: %s", privacy_list[i]);
privacy_data_s *pd = new_privacy_data();
pd->privacy = strdup(privacy_list[i]);
- ad->privacy_list = g_list_append(ad->privacy_list, pd);
+ ad->popups[ad->popup_num].privacy_list = g_list_append(ad->popups[ad->popup_num].privacy_list, pd);
}
- if (ad->privacy_num > 1) {
- ad->launch_type = strdup("multi");
+ if (ad->popups[ad->popup_num].privacy_num > 1) {
+ ad->popups[ad->popup_num].launch_type = strdup("multi");
} else {
- ad->launch_type = strdup("single");
+ ad->popups[ad->popup_num].launch_type = strdup("single");
}
- if (!ad->launch_type) {
+ if (!ad->popups[ad->popup_num].launch_type) {
LOGE("caller pkgid [%s]: strdup of 'launch_type' failed.", ad->caller_pkgid);
ui_app_exit();
}
- LOGD("launch_type : %s", ad->launch_type);
- create_view(ad);
+ LOGD("launch_type : %s", ad->popups[ad->popup_num].launch_type);
+ ad->popup_num++;
+ if (ad->popup_num == 1) {
+ ad->popup_idx = 0;
+ create_view(ad);
+ }
}
static void app_pause(void *data)
/* Take necessary actions when application becomes visible. */
}
-static void app_terminate(void *data)
+static bool send_response(app_data_s* ad, int idx)
{
- LOGD("app_terminate()");
-
- app_data_s *ad = (app_data_s*)data;
int ret = 0;
- char *privacies[ad->privacy_num];
- ppm_popup_response_e responses[ad->privacy_num];
+ char *privacies[ad->popups[idx].privacy_num];
+ ppm_popup_response_e responses[ad->popups[idx].privacy_num];
int i = 0;
- for (i = 0; i < ad->privacy_num; ++i) {
- privacy_data_s *pd = (privacy_data_s*)g_list_nth_data(ad->privacy_list, i);
+ for (i = 0; i < ad->popups[idx].privacy_num; ++i) {
+ privacy_data_s *pd = (privacy_data_s*)g_list_nth_data(ad->popups[idx].privacy_list, i);
privacies[i] = strdup(pd->privacy);
responses[i] = pd->response;
}
- ret = ppm_popup_send_response(ad->popup_id, (const char**)privacies, responses, ad->privacy_num);
+ ret = ppm_popup_send_response(ad->popups[idx].popup_id, (const char**)privacies, responses, ad->popups[idx].privacy_num);
- for (i = 0; i < ad->privacy_num; ++i) {
+ for (i = 0; i < ad->popups[idx].privacy_num; ++i) {
free(privacies[i]);
}
- if (ret != PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE)
+ if (ret != PRIVACY_PRIVILEGE_MANAGER_ERROR_NONE) {
LOGE("ppm_popup_send_response() failed. ret = %d", ret);
+ return false;
+ }
+ return true;
+}
+
+static void app_terminate(void *data)
+{
+ LOGD("app_terminate()");
+
+ app_data_s *ad = (app_data_s*)data;
+ int i = 0;
+ for (i = 0; i < ad->popup_num; ++i) {
+ if (!send_response(ad, i))
+ LOGE("send_response() failed.");
+ }
free_app_data(ad);
int main(int argc, char *argv[])
{
- LOGD("main");
int ret = 0;
app_data_s ad;
memset(&ad, 0x0, sizeof(app_data_s));
void save_response(ppm_popup_response_e response, app_data_s *ad)
{
- privacy_data_s *pd = (privacy_data_s *)g_list_nth_data(ad->privacy_list, ad->privacy_idx);
+ privacy_data_s *pd = (privacy_data_s *)g_list_nth_data(ad->popups[ad->popup_idx].privacy_list, ad->popups[ad->popup_idx].privacy_idx);
pd->response = response;
}
}
static void __set_popup_contents(app_data_s *ad)
{
- privacy_data_s *pd = (privacy_data_s *)g_list_nth_data(ad->privacy_list, ad->privacy_idx);
+ privacy_data_s *pd = (privacy_data_s *)g_list_nth_data(ad->popups[ad->popup_idx].privacy_list, ad->popups[ad->popup_idx].privacy_idx);
char* message = __get_message(ad->caller_pkgid, (const char*)pd->privacy);
elm_object_text_set(ad->label, message);
elm_atspi_accessible_name_set(ad->label, message);
if (strlen(message) > 0)
free(message);
- if (!strcmp(ad->launch_type, "multi")) {
+ if (!strcmp(ad->popups[ad->popup_idx].launch_type, "multi")) {
char counter[COUNTER_LEN];
- int ret = snprintf(counter, COUNTER_LEN, "%d / %d", (ad->privacy_idx) + 1, ad->privacy_num);
+ int ret = snprintf(counter, COUNTER_LEN, "%d / %d", (ad->popups[ad->popup_idx].privacy_idx) + 1, ad->popups[ad->popup_idx].privacy_num);
if (ret < 0 || ret >= COUNTER_LEN) {
LOGE("snprintf() for counter failed. ret = %d", ret);
} else {
static void __check_next_privacy(app_data_s *ad)
{
LOGD("__check_next_privacy()");
- ad->privacy_idx++;
- if (ad->privacy_idx >= ad->privacy_num) {
- ad->all_responded = true;
- LOGD("all_responded, close the popup");
+ ad->popups[ad->popup_idx].privacy_idx++;
+ if (ad->popups[ad->popup_idx].privacy_idx >= ad->popups[ad->popup_idx].privacy_num) {
+ ad->popup_idx++;
+ if (ad->popup_idx >= ad->popup_num) {
+ ad->all_responded = true;
+ LOGD("all_responded, close the popup");
+ } else {
+ __set_popup_contents(ad);
+ }
} else {
__set_popup_contents(ad);
}