4 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #include <Elementary.h>
20 #include <app_manager.h>
21 #include <app_manager_extension.h>
22 #include <app_control.h>
23 #include <app_common.h>
31 Eina_Bool util_kill_app(const char *appid)
33 app_context_h context = NULL;
34 Eina_Bool ret = EINA_TRUE;
36 retv_if(!appid, EINA_FALSE);
38 ret = app_manager_get_app_context(appid, &context);
39 if (ret != APP_MANAGER_ERROR_NONE) {
40 _E("fail to app_manager_get_app_context(%d)", ret);
44 ret = app_manager_terminate_app(context);
45 app_context_destroy(context);
47 if (ret != APP_MANAGER_ERROR_NONE) {
48 _E("fail to terminate_app (%d)", ret);
52 _D("terminate app = %s", appid);
59 Eina_Bool util_launch_app(const char *appid)
64 if (!appid || strlen(appid) == 0) {
65 _E("Fail to launch, due to Null appid.");
68 _D("Launching: %s", appid);
69 ret = app_manager_is_running(appid, &running);
70 retv_if(APP_MANAGER_ERROR_NONE != ret, EINA_FALSE);
73 _D("THE APP IS RUNNING");
75 app_context_h context = NULL;
76 ret = app_manager_get_app_context(appid, &context);
77 if (ret != APP_MANAGER_ERROR_NONE) {
78 _E("fail to app_manager_get_app_context(%d)", ret);
82 ret = app_manager_resume_app(context);
83 app_context_destroy(context);
85 if (ret != APP_MANAGER_ERROR_NONE) {
86 _E("fail to app_manager_resume_app(%d)", ret);
91 _D("THE APP IS NOT RUNNING");
93 app_control_h service = NULL;
94 retv_if(APP_CONTROL_ERROR_NONE != app_control_create(&service), EINA_FALSE);
95 retv_if(!service, EINA_FALSE);
97 app_control_set_operation(service, APP_CONTROL_OPERATION_MAIN);
98 app_control_set_app_id(service, appid);
100 ret = app_control_send_launch_request(service, NULL, NULL);
101 (void)app_control_destroy(service);
102 retv_if(APP_CONTROL_ERROR_NONE != ret, EINA_FALSE);
108 const char *util_get_file_path(app_subdir dir, const char *relative)
110 static char buf[PATH_MAX];
115 prefix = app_get_data_path();
118 prefix = app_get_cache_path();
120 case APP_DIR_RESOURCE:
121 prefix = app_get_resource_path();
123 case APP_DIR_SHARED_DATA:
124 prefix = app_get_shared_data_path();
126 case APP_DIR_SHARED_RESOURCE:
127 prefix = app_get_shared_resource_path();
129 case APP_DIR_SHARED_TRUSTED:
130 prefix = app_get_shared_trusted_path();
132 case APP_DIR_EXTERNAL_DATA:
133 prefix = app_get_external_data_path();
135 case APP_DIR_EXTERNAL_CACHE:
136 prefix = app_get_external_cache_path();
138 case APP_DIR_EXTERNAL_SHARED_DATA:
139 prefix = app_get_external_shared_data_path();
142 _E("Not handled directory type.");
145 size_t res = eina_file_path_join(buf, sizeof(buf), prefix, relative);
147 if (res > sizeof(buf)) {
148 _E("Path exceeded PATH_MAX");