* limitations under the License.
*/
-#include <aul.h>
#include <app.h>
#include <appsvc.h>
#include <bundle.h>
#include <pkgmgr-info.h>
#include <widget_service.h>
#include <bundle_internal.h>
+#include <app_control.h>
#include <unicode/unum.h>
#include <unicode/ustring.h>
HAPI int util_launch_app(const char *appid, const char *key, const char *value)
{
- int pid = 0;
retv_if(!appid, W_HOME_ERROR_INVALID_PARAMETER);
- if (key && value) {
- bundle *b = bundle_create();
- retv_if(!b, 0);
-
- bundle_add(b, key, value);
- home_dbus_cpu_booster_signal_send();
- pid = aul_launch_app(appid, b);
- bundle_free(b);
- } else {
- home_dbus_cpu_booster_signal_send();
- pid = aul_launch_app(appid, NULL);
- }
-
- if (pid < 0)
- _E("Failed to launch %s(%d)", appid, pid);
+ int ret = APP_CONTROL_ERROR_NONE;
+ app_control_h app_control = NULL;
+ ret = app_control_create(&app_control);
+ app_control_set_app_id(app_control, appid);
+ home_dbus_cpu_booster_signal_send();
+ if (key && value)
+ app_control_add_extra_data(app_control, key, value);
+ ret = app_control_send_launch_request(app_control, NULL, NULL);
+ if(ret != APP_CONTROL_ERROR_NONE)
+ _E("app_control_send_launch_request failed!");
+ app_control_destroy(app_control);
- return pid;
+ return ret;
}
#define LAYOUT_BLOCK_INTERVAL 1.0
-HAPI void apps_util_launch(Evas_Object *win, const char *package, const char *name)
-{
- ret_if(NULL == package);
-
- if (!name) name = package;
- if (LAUNCH_WITH_SPECIAL_ROUTINE && _launch_special_package(package, name))
- return;
-
- home_dbus_cpu_booster_signal_send();
-
- int ret_aul = aul_open_app(package);
- if (ret_aul < AUL_R_OK) {
-
- if (ret_aul == AUL_R_EREJECTED && cooldown_mode_warning_get()) {
- util_create_toast_popup(win, _("IDS_SM_BODY_THE_DEVICE_TEMPERATURE_IS_TOO_HIGH"));
- } else {
- char* inform;
- char* inform_with_ret;
- int len;
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- return;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- return;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, ret_aul);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- }
- } else {
- _D("Launch app's ret : [%d]", ret_aul);
- _T(package);
-
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(NULL == layout);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, layout);
- }
-}
-
-
-
-HAPI void apps_util_launch_main_operation(Evas_Object *win, const char *app_id, const char *name)
-{
- ret_if(NULL == app_id);
-
- if (!name) name = app_id;
- app_control_h service = NULL;
- ret_if(APP_CONTROL_ERROR_NONE != app_control_create(&service));
- ret_if(NULL == service);
-
- app_control_set_operation(service, APP_CONTROL_OPERATION_MAIN);
- app_control_set_app_id(service, app_id);
-
- home_dbus_cpu_booster_signal_send();
-
- int ret = app_control_send_launch_request(service, NULL, NULL);
- if (APP_CONTROL_ERROR_NONE != ret) {
-
- if (ret == APP_CONTROL_ERROR_LAUNCH_REJECTED && cooldown_mode_warning_get()) {
- util_create_toast_popup(win, _("IDS_SM_BODY_THE_DEVICE_TEMPERATURE_IS_TOO_HIGH"));
- } else {
- char* inform;
- char* inform_with_ret;
- int len;
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- goto ERROR;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- goto ERROR;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, ret);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- }
- } else {
- _SD("Launch an app(%s:%s) ret : [%d]", app_id, name, ret);
- _T(app_id);
-
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(NULL == layout);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, layout);
- }
-
-ERROR:
- app_control_destroy(service);
-}
-
-
-
-HAPI void apps_util_launch_with_arg(Evas_Object *win, const char *app_id, const char *arg, const char *name)
-{
- ret_if(NULL == app_id);
- ret_if(NULL == arg);
-
- if (!name) name = app_id;
- if (LAUNCH_WITH_SPECIAL_ROUTINE && _launch_special_package(app_id, name))
- return;
-
- _SD("Argument:(%s)", arg);
- int len = strlen(arg);
-
- bundle *b = NULL;
- b = bundle_decode((bundle_raw *) arg, len);
-
- /* AUL requests : Reset the caller appid as App-tray */
- const char *value = (char *)bundle_get_val(b, AUL_K_CALLER_APPID);
- if (value) bundle_del(b, AUL_K_CALLER_APPID);
-
- home_dbus_cpu_booster_signal_send();
-
- int ret = aul_launch_app(app_id, b);
- bundle_free(b);
-
- if (0 > ret) {
- char* inform;
- char* inform_with_ret;
- int len;
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- return;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- return;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, ret);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- } else {
- _SD("Launch an app(%s:%s) ret : [%d]", app_id, name, ret);
- _T(app_id);
-
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(NULL == layout);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, layout);
- }
-}
-
-
-
-HAPI void apps_util_launch_with_bundle(Evas_Object *win, const char *app_id, bundle *b, const char *name)
-{
- ret_if(NULL == app_id);
- ret_if(NULL == b);
-
- if (!name) name = app_id;
- if (LAUNCH_WITH_SPECIAL_ROUTINE && _launch_special_package(app_id, name))
- return;
-
- home_dbus_cpu_booster_signal_send();
-
- int ret = aul_launch_app(app_id, b);
- if (0 > ret) {
- char* inform;
- char* inform_with_ret;
- int len;
-
- // IDS_AT_TPOP_UNABLE_TO_OPEN_PS : "Unable to open %s"
- len = strlen(_("IDS_AT_TPOP_UNABLE_TO_OPEN_PS")) + strlen(name) + SPARE_LEN;
-
- inform = calloc(len, sizeof(char));
- if (!inform) {
- _E("cannot calloc for information");
- return;
- }
- snprintf(inform, len, _("IDS_AT_TPOP_UNABLE_TO_OPEN_PS"), name);
-
- inform_with_ret = calloc(len, sizeof(char));
- if (!inform_with_ret) {
- _E("cannot calloc for information");
- free(inform);
- return;
- }
- snprintf(inform_with_ret, len, "%s(%d)", inform, ret);
- notification_status_message_post(inform_with_ret);
-
- free(inform);
- free(inform_with_ret);
- } else {
- _SD("Launch an app(%s:%s) ret : [%d]", app_id, name, ret);
- _T(app_id);
-
- Evas_Object *layout = evas_object_data_get(win, DATA_KEY_LAYOUT);
- ret_if(NULL == layout);
- ecore_timer_add(LAYOUT_BLOCK_INTERVAL, _unblock_cb, layout);
- }
-}