diff options
author | Junghyun Kim <jh1114.kim@samsung.com> | 2012-08-21 20:20:51 +0900 |
---|---|---|
committer | Junghyun Kim <jh1114.kim@samsung.com> | 2012-08-21 20:20:51 +0900 |
commit | 705b925c45567f2fc5a002fd3fd89d94e66bc2f6 (patch) | |
tree | 2074280b0ea934170b6eef3dbe445bf9bccddd73 /src/ps_app_interface.cpp | |
parent | bf8879b3c9c9a58111b20ea76263a5845a2f56fb (diff) | |
download | smartsearch-705b925c45567f2fc5a002fd3fd89d94e66bc2f6.tar.gz smartsearch-705b925c45567f2fc5a002fd3fd89d94e66bc2f6.tar.bz2 smartsearch-705b925c45567f2fc5a002fd3fd89d94e66bc2f6.zip |
Update changed code
Diffstat (limited to 'src/ps_app_interface.cpp')
-rwxr-xr-x | src/ps_app_interface.cpp | 377 |
1 files changed, 271 insertions, 106 deletions
diff --git a/src/ps_app_interface.cpp b/src/ps_app_interface.cpp index 56968f6..b4c277f 100755 --- a/src/ps_app_interface.cpp +++ b/src/ps_app_interface.cpp @@ -1,12 +1,12 @@ /* * Copyright 2012 Samsung Electronics Co., Ltd - * + * * Licensed under the Flora License, Version 1.0 (the License); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.tizenopensource.org/license - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an AS IS BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -25,7 +25,8 @@ #include <ui-gadget.h> #include <contacts-ug.h> #include <aul_service.h> -#include <appsvc.h> +#include <app.h> +#include <app_manager.h> #include <bundle.h> #define UG_NAME_LEN 50 @@ -82,13 +83,11 @@ static void __search_effect_layout_render_flush_post_cb(void *data, Evas * e, SEARCH_FUNC_END; } -static void __search_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, +static void __search_ug_layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv) { SEARCH_FUNC_START; - struct appdata *ad = (struct appdata *)priv; - Evas_Object *base = (Evas_Object *) ug_get_layout(ug); if (!base) @@ -100,7 +99,7 @@ static void __search_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, elm_object_part_content_set(ad->effect_layout, "elm.swallow.content", base); //B. Add the callback event for the EVAS_RENDER_FLUSH_POST - //B. This is one method to not skip the total effect time in creating the ug object. + //B. This is one method to not skip the total effect time in creating the ug object. evas_event_callback_add(evas_object_evas_get(ad->effect_layout), EVAS_CALLBACK_RENDER_FLUSH_POST, __search_effect_layout_render_flush_post_cb, @@ -112,12 +111,10 @@ static void __search_ug_layout_cb(struct ui_gadget *ug, enum ug_mode mode, SEARCH_FUNC_END; } -static void __search_ug_closed_cb(struct ui_gadget *ug, void *priv) +static void __search_ug_closed_cb(ui_gadget_h ug, void *priv) { SEARCH_FUNC_START; - struct appdata *ad = (struct appdata *)priv; - #ifdef ENABLE_UG_EFFECT edje_object_signal_emit(elm_layout_edje_get(ad->effect_layout), "elm,state,hide", ""); @@ -171,27 +168,46 @@ void search_launch_contact_view(void *data, void *record_info) struct search_item_sel *cur_category_mem = (struct search_item_sel *)record_info; - bundle *kb; + service_h service = NULL; + int ret = 0; + bool err_popup_show = true; - struct ui_gadget *ug; + ui_gadget_h ug = NULL; struct ug_cbs cbs = { 0, }; char buf[10] = { 0, }; + if (!cur_category_mem || strlen(cur_category_mem->main_id) < 0 ) { + SEARCH_DEBUG_ERROR("Selected item does not have data!"); + goto out_func; + } else { if (ad->detail_ug) { - SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug"); + SEARCH_DEBUG_WARNING("\n prev ug is exist. destroy prev ug"); __search_layout_ug_destroy(ad); - } + } - kb = bundle_create(); - if (!kb) { - SEARCH_DEBUG_ERROR("contact bundle_create"); - return; + ret = service_create(&service); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to create service handle!"); + goto out_func; } snprintf(buf, sizeof(buf), "%d", CT_UG_REQUEST_DETAIL); - bundle_add(kb, CT_UG_BUNDLE_TYPE, buf); - bundle_add(kb, CT_UG_BUNDLE_ID, cur_category_mem->main_id); + ret = service_add_extra_data(service, CT_UG_BUNDLE_TYPE, buf); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to add service extra data : parameter 1!"); + goto out_func; + } + + ret = service_add_extra_data(service, CT_UG_BUNDLE_ID, + cur_category_mem->main_id); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to add service extra data : parameter 2!"); + goto out_func; + } #ifdef ENABLE_UG_EFFECT __search_create_effect_layout(ad->win_main, ad); @@ -200,17 +216,25 @@ void search_launch_contact_view(void *data, void *record_info) cbs.layout_cb = __search_ug_layout_cb; cbs.result_cb = NULL; cbs.destroy_cb = __search_ug_closed_cb; - cbs.priv = ad; + cbs.priv = ad; + + ug = ug_create(NULL, UG_CONTACTS_DETAILS, UG_MODE_FULLVIEW, service, &cbs); - ug = ug_create(NULL, UG_CONTACTS_DETAILS, UG_MODE_FULLVIEW, kb, &cbs); if (!ug) { SEARCH_DEBUG_ERROR(" ... ug_create: failed !!!"); - search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); + goto out_func; } else { ad->detail_ug = ug; - } + err_popup_show = false; + } + } + +out_func: + if (err_popup_show == true) + search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); - bundle_free(kb); + if (service != NULL) + service_destroy(service); SEARCH_FUNC_END; } @@ -231,16 +255,16 @@ void search_launch_msg_view(void *data, void *record_info) SEARCH_DEBUG_ERROR("search_launch_msg_view : bundle_create failed"); return; } - + bundle_add(b, "type", "msg_id"); bundle_add(b, "msgId", cur_category_mem->main_id); ret = aul_launch_app("org.tizen.message", b); - if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){ + if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){ SEARCH_DEBUG_ERROR("msg aul launch app error(%d)", ret); search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); } - bundle_free(b); + bundle_free(b); SEARCH_FUNC_END; } @@ -320,20 +344,21 @@ void search_launch_image_view(void *data, void *record_info) SEARCH_DEBUG_LOG("cur_category_mem->path : %s", cur_category_mem->path); - bundle* bd = NULL; - bd = bundle_create(); + service_h service; + ret = service_create(&service); - if (bd != NULL) { - appsvc_set_operation(bd, APPSVC_OPERATION_VIEW); - appsvc_set_uri(bd, cur_category_mem->path); - ret = appsvc_run_service(bd, 0, NULL, NULL); + if (ret == 0) { + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_category_mem->path); + ret = service_send_launch_request(service, NULL, NULL); - if (ret < 0 ) + if (ret != 0) { + SEARCH_DEBUG_ERROR("image app service launching error(%d)", ret); search_launch_popup_error(LAUNCH_ERROR_APPSVC, - ad); - bundle_free(bd); + ad); } - + service_destroy(service); + } } SEARCH_FUNC_END; @@ -353,20 +378,24 @@ void search_launch_video_view(void *data, void *record_info) cur_category_mem->path); search_launch_popup_error(LAUNCH_ERROR_FILE_NOT_FOUND, ad); } else { - bundle* bd = NULL; - bd = bundle_create(); - - appsvc_set_operation(bd, APPSVC_OPERATION_VIEW); - appsvc_set_uri(bd, cur_category_mem->path); - ret = appsvc_run_service(bd, 0, NULL, NULL); - - if (ret < 0) { - SEARCH_DEBUG_ERROR("video app service error(%d) : %s", - ret, cur_category_mem->path); - search_launch_popup_error(LAUNCH_ERROR_APPSVC, ad); - } + SEARCH_DEBUG_LOG("cur_category_mem->path : %s", + cur_category_mem->path); + + service_h service; + ret = service_create(&service); - bundle_free(bd); + if (ret == 0) { + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_category_mem->path); + ret = service_send_launch_request(service, NULL, NULL); + + if (ret != 0) { + SEARCH_DEBUG_ERROR("video app service launching error(%d)", ret); + search_launch_popup_error(LAUNCH_ERROR_APPSVC, + ad); + } + service_destroy(service); + } } SEARCH_FUNC_END; @@ -388,22 +417,21 @@ void search_launch_music_view(void *data, void *record_info) } else { SEARCH_DEBUG_LOG("cur_category_mem->path : %s", cur_category_mem->path); - - bundle* bd = NULL; - bd = bundle_create(); - - if (bd != NULL) { - appsvc_set_operation(bd, APPSVC_OPERATION_VIEW); - appsvc_set_uri(bd, cur_category_mem->path); - ret = appsvc_run_service(bd, 0, NULL, NULL); - - if (ret < 0) { - SEARCH_DEBUG_ERROR("music app service error(%d) : %s", - ret, cur_category_mem->path); + + service_h service; + ret = service_create(&service); + + if (ret == 0) { + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_category_mem->path); + ret = service_send_launch_request(service, NULL, NULL); + + if (ret != 0) { + SEARCH_DEBUG_ERROR("music app service launching error(%d)", ret); search_launch_popup_error(LAUNCH_ERROR_APPSVC, ad); } - bundle_free(bd); + service_destroy(service); } } @@ -417,35 +445,56 @@ void search_launch_calendar_view(void *data, void *record_info) struct appdata *ad = (struct appdata *)data; struct search_item_sel *cur_category_mem = (struct search_item_sel *)record_info; - struct ui_gadget *ug; + ui_gadget_h ug = NULL; struct ug_cbs cbs = { 0, }; + int ret = 0; + bool err_popup_show = true; + service_h service = NULL; - bundle *b; - int ret; + if (!cur_category_mem && strlen(cur_category_mem->main_id) < 0) { + SEARCH_DEBUG_ERROR("Selected item does not have data!"); + goto out_func; + } else { + ret = service_create(&service); - if (ad->detail_ug) { - SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug"); + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to create service handle!"); + goto out_func; + } - __search_layout_ug_destroy(ad); + ret = service_add_extra_data(service, "index", cur_category_mem->main_id); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to add service extra data : parameter 1!"); + goto out_func; } - b = bundle_create(); - if (!b) - return; +#ifdef ENABLE_UG_EFFECT + __search_create_effect_layout(ad->win_main, ad); +#endif + cbs.destroy_cb = __search_ug_closed_cb; + cbs.layout_cb = __search_ug_layout_cb; + cbs.result_cb = NULL; + cbs.priv = ad; + + ug = ug_create(NULL, "calendar-detail-efl", UG_MODE_FULLVIEW, service, &cbs); - bundle_add(b, AUL_K_SERVICE_NAME, "view_event"); - bundle_add(b, "index", cur_category_mem->main_id); + if (!ug) { + SEARCH_DEBUG_ERROR("... create_ug_calendar : failed !!!"); + goto out_func; + } - SEARCH_DEBUG_LOG("index : %s", cur_category_mem->main_id); + ad->detail_ug = ug; + err_popup_show = false; + } - ret = aul_launch_app("org.tizen.efl-calendar", b); - if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){ - SEARCH_DEBUG_ERROR("calendar aul launch app error(%d)", ret); +out_func: + if (err_popup_show == true) search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); - } - bundle_free(b); - + if (service != NULL) + service_destroy(service); + SEARCH_FUNC_END; } @@ -456,39 +505,62 @@ void search_launch_memo_view(void *data, void *record_info) struct appdata *ad = (struct appdata *)data; struct search_item_sel *cur_category_mem = (struct search_item_sel *)record_info; - struct ui_gadget *ug; + ui_gadget_h ug = NULL; struct ug_cbs cbs = { 0, }; - bundle *b; + int ret = 0; + bool err_popup_show = true; + + service_h service = NULL; + if (!cur_category_mem && strlen(cur_category_mem->main_id) < 0) { + SEARCH_DEBUG_ERROR("Selected item does not have data!"); + goto out_func; + } else { if (ad->detail_ug) { SEARCH_DEBUG_WARNING("prev ug is exist. destroy prev ug"); + __search_layout_ug_destroy(ad); + } - __search_layout_ug_destroy(ad); + ret = service_create(&service); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to create service handle!"); + goto out_func; } - b = bundle_create(); - if (!b) - return; + ret = service_add_extra_data(service, "index", cur_category_mem->main_id); - bundle_add(b, "index", cur_category_mem->main_id); + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to add service extra data : parameter 1!"); + goto out_func; + } +#ifdef ENABLE_UG_EFFECT __search_create_effect_layout(ad->win_main, ad); - +#endif cbs.layout_cb = __search_ug_layout_cb; cbs.result_cb = NULL; cbs.destroy_cb = __search_ug_closed_cb; cbs.priv = ad; - ug = ug_create(NULL, "memo-efl", UG_MODE_FULLVIEW, b, &cbs); + ug = ug_create(NULL, "memo-efl", UG_MODE_FULLVIEW, service, &cbs); + if (!ug) { SEARCH_DEBUG_ERROR("... create_ug_email : failed !!!"); - search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); + goto out_func; } ad->detail_ug = ug; + err_popup_show = false; + } - bundle_free(b); +out_func: + if (err_popup_show == true) + search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); + + if (service != NULL) + service_destroy(service); SEARCH_FUNC_END; } @@ -500,21 +572,114 @@ void search_launch_menu_view(void *data, void *record_info) struct appdata *ad = (struct appdata *)data; struct search_item_sel *cur_category_mem = (struct search_item_sel *)record_info; + char *pkg_name = cur_category_mem->path; + bool is_running = false; + app_context_h app_h; + + bool err_popup_show = true; int ret; + service_h service = NULL; - ret = aul_launch_app(cur_category_mem->path, NULL); + if (pkg_name != NULL && strlen(pkg_name)) { + ret = app_manager_is_running(pkg_name, &is_running); - SEARCH_DEBUG_WARNING("path : %s, ret : %d", cur_category_mem->path, ret); - - if( (ret <= 0) && (ret != AUL_R_ETIMEOUT) ){ - SEARCH_DEBUG_ERROR("menu aul launch app error(%d) : %s", ret, - cur_category_mem->path); - search_launch_popup_error(LAUNCH_ERROR_AUL_LAUNCH, ad); + if (ret != APP_MANAGER_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to get info : app_manager_is_running [%d]", ret); + goto out_func; + } + + if (is_running == true) { + ret = app_manager_get_app_context(pkg_name, &app_h); + if (ret != APP_MANAGER_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to get info : app_manager_get_app_context [%d]", ret); + goto out_func; + } + + ret = app_manager_resume_app(app_h); + + if (ret != APP_MANAGER_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to get info : app_manager_resume_app [%d]", ret); + goto out_func; + } + err_popup_show = false; + } else { + ret = service_create(&service); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to create service header : [%d]", ret); + goto out_func; + } + + ret = service_set_operation(service, SERVICE_OPERATION_DEFAULT); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to set operation : [%d]", ret); + goto out_func; + } + + ret = service_set_package(service, pkg_name); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to set package : [%d]", ret); + goto out_func; + } + + ret = service_send_launch_request(service, NULL, NULL); + + if (ret != SERVICE_ERROR_NONE) { + SEARCH_DEBUG_ERROR("Fail to send launch request : [%d]", ret); + goto out_func; + } + err_popup_show = false; + } + } else { + SEARCH_DEBUG_ERROR("Pkg name is NULL!"); + } + +out_func: + if (err_popup_show == true) + search_launch_popup_error(LAUNCH_ERROR_APPSVC, ad); + + if (service != NULL) { + ret = service_destroy(service); + + if (ret != SERVICE_ERROR_NONE) + SEARCH_DEBUG_ERROR("Fail to destroy service header : [%d]", ret); } SEARCH_FUNC_END; } +void search_launch_browser_view(void *data, void *record_info) +{ + SEARCH_FUNC_START; + + struct appdata *ad = (struct appdata *)data; + struct search_item_sel *cur_category_mem = + (struct search_item_sel *)record_info; + int ret; + + SEARCH_DEBUG_LOG("cur_category_mem->path : %s", + cur_category_mem->path); + + service_h service; + ret = service_create(&service); + + if (ret == 0 && strlen(cur_category_mem->path) > 0 ) { + service_set_operation(service, SERVICE_OPERATION_VIEW); + service_set_uri(service, cur_category_mem->path); + ret = service_send_launch_request(service, NULL, NULL); + + if (ret != 0) { + SEARCH_DEBUG_ERROR("browser app service launching error(%d)", ret); + search_launch_popup_error(LAUNCH_ERROR_APPSVC, + ad); + } + service_destroy(service); + } + +} + static void __search_launch_popup_error_response_cb(void *data, Evas_Object * obj, void *event_info) @@ -558,19 +723,19 @@ void search_launch_popup_error(int error_type, void *data) case LAUNCH_ERROR_AUL_LAUNCH: /* This Message String enable to be another string in the future */ elm_object_text_set(popup, - dgettext("sys_string", - "IDS_COM_POP_SERVICE_UNAVAILABLE")); + gettext("IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST")); break; case LAUNCH_ERROR_APPSVC: elm_object_text_set(popup, - dgettext("sys_string", - "IDS_COM_POP_SERVICE_UNAVAILABLE")); + gettext("IDS_SSEARCH_POP_SELECTED_DATA_DOES_NOT_EXIST")); break; } btn1 = elm_button_add(popup); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, - dgettext("sys_string","IDS_COM_SK_OK")); + dgettext("sys_string","IDS_COM_POP_CLOSE")); evas_object_smart_callback_add(btn1, "clicked", __search_launch_popup_error_response_cb, ad); |