4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
7 * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
32 #include <dbus/dbus.h>
33 #include <dbus/dbus-glib-lowlevel.h>
37 #include <pkgmgr-info.h>
38 #include <iniparser.h>
39 #include <security-server.h>
41 /* For multi-user support */
42 #include <tzplatform_config.h>
44 #include "package-manager.h"
45 #include "pkgmgr-internal.h"
46 #include "pkgmgr-debug.h"
47 #include "pkgmgr-api.h"
48 #include "comm_client.h"
49 #include "comm_status_broadcast_server.h"
53 #define LOG_TAG "PKGMGR"
56 #define PKG_TMP_PATH tzplatform_mkpath(TZ_USER_APP, "tmp")
58 #define BINSH_NAME "/bin/sh"
61 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
63 static int _get_request_id()
65 static int internal_req_id = 1;
67 return internal_req_id++;
70 typedef struct _req_cb_info {
73 pkgmgr_handler event_cb;
75 struct _req_cb_info *next;
78 typedef struct _listen_cb_info {
80 pkgmgr_handler event_cb;
82 struct _listen_cb_info *next;
85 typedef struct _pkgmgr_client_t {
95 listen_cb_info *lhead;
103 typedef struct _iter_data {
104 pkgmgr_iter_fn iter_fn;
108 static char *__get_cookie_from_security_server(void)
111 size_t cookie_size = 0;
112 char *e_cookie = NULL;
114 //calculage cookie size
115 cookie_size = security_server_get_cookie_size();
116 retvm_if(cookie_size <= 0, NULL, "security_server_get_cookie_size : cookie_size is %d", cookie_size);
118 //get cookie from security server
119 char cookie[cookie_size];
121 ret = security_server_request_cookie(cookie, cookie_size);
122 retvm_if(ret < 0, NULL, "security_server_request_cookie fail (%d)", ret);
125 e_cookie = g_base64_encode((const guchar *)cookie, cookie_size);
126 retvm_if(e_cookie == NULL, NULL, "g_base64_encode e_cookie is NULL");
131 static int __xsystem(const char *argv[])
138 perror("fork failed");
142 execvp(argv[0], (char *const *)argv);
148 if (waitpid(pid, &status, 0) == -1) {
149 perror("waitpid failed");
152 if (WIFSIGNALED(status)) {
156 if (!WIFEXITED(status)) {
157 /* shouldn't happen */
158 perror("should not happen");
161 return WEXITSTATUS(status);
164 static void __error_to_string(int errnumber, char **errstr)
169 case PKGCMD_ERR_PACKAGE_NOT_FOUND:
170 *errstr = PKGCMD_ERR_PACKAGE_NOT_FOUND_STR;
172 case PKGCMD_ERR_PACKAGE_INVALID:
173 *errstr = PKGCMD_ERR_PACKAGE_INVALID_STR;
175 case PKGCMD_ERR_PACKAGE_LOWER_VERSION:
176 *errstr = PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR;
178 case PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND:
179 *errstr = PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR;
181 case PKGCMD_ERR_MANIFEST_INVALID:
182 *errstr = PKGCMD_ERR_MANIFEST_INVALID_STR;
184 case PKGCMD_ERR_CONFIG_NOT_FOUND:
185 *errstr = PKGCMD_ERR_CONFIG_NOT_FOUND_STR;
187 case PKGCMD_ERR_CONFIG_INVALID:
188 *errstr = PKGCMD_ERR_CONFIG_INVALID_STR;
190 case PKGCMD_ERR_SIGNATURE_NOT_FOUND:
191 *errstr = PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR;
193 case PKGCMD_ERR_SIGNATURE_INVALID:
194 *errstr = PKGCMD_ERR_SIGNATURE_INVALID_STR;
196 case PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED:
197 *errstr = PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR;
199 case PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND:
200 *errstr = PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR;
202 case PKGCMD_ERR_CERTIFICATE_INVALID:
203 *errstr = PKGCMD_ERR_CERTIFICATE_INVALID_STR;
205 case PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED:
206 *errstr = PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR;
208 case PKGCMD_ERR_CERTIFICATE_EXPIRED:
209 *errstr = PKGCMD_ERR_CERTIFICATE_EXPIRED_STR;
211 case PKGCMD_ERR_INVALID_PRIVILEGE:
212 *errstr = PKGCMD_ERR_INVALID_PRIVILEGE_STR;
214 case PKGCMD_ERR_MENU_ICON_NOT_FOUND:
215 *errstr = PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR;
217 case PKGCMD_ERR_FATAL_ERROR:
218 *errstr = PKGCMD_ERR_FATAL_ERROR_STR;
220 case PKGCMD_ERR_OUT_OF_STORAGE:
221 *errstr = PKGCMD_ERR_OUT_OF_STORAGE_STR;
223 case PKGCMD_ERR_OUT_OF_MEMORY:
224 *errstr = PKGCMD_ERR_OUT_OF_MEMORY_STR;
226 case PKGCMD_ERR_ARGUMENT_INVALID:
227 *errstr = PKGCMD_ERR_ARGUMENT_INVALID_STR;
230 *errstr = PKGCMD_ERR_UNKNOWN_STR;
235 static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
236 const char *req_key, pkgmgr_handler event_cb,
239 req_cb_info *cb_info;
240 req_cb_info *current;
243 cb_info = (req_cb_info *) calloc(1, sizeof(req_cb_info));
244 if (cb_info == NULL) {
245 _LOGD("calloc failed");
248 cb_info->request_id = request_id;
249 cb_info->req_key = strdup(req_key);
250 cb_info->event_cb = event_cb;
251 cb_info->data = data;
252 cb_info->next = NULL;
254 if (pc->info.request.rhead == NULL)
255 pc->info.request.rhead = cb_info;
257 current = prev = pc->info.request.rhead;
260 current = current->next;
263 prev->next = cb_info;
267 static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
271 tmp = pc->info.request.rhead;
274 _LOGE("tmp is NULL");
278 _LOGD("tmp->req_key %s, req_key %s", tmp->req_key, req_key);
281 if (strncmp(tmp->req_key, req_key, strlen(tmp->req_key)) == 0)
288 static void __remove_op_cbinfo(pkgmgr_client_t *pc, req_cb_info *info)
292 if (pc == NULL || pc->info.request.rhead == NULL || info == NULL)
295 tmp = pc->info.request.rhead;
297 if (tmp->next == info) {
298 tmp->next = info->next;
307 static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
308 pkgmgr_handler event_cb, void *data)
310 listen_cb_info *cb_info;
311 listen_cb_info *current;
312 listen_cb_info *prev;
314 cb_info = (listen_cb_info *) calloc(1, sizeof(listen_cb_info));
315 if (cb_info == NULL) {
316 _LOGD("calloc failed");
319 cb_info->request_id = request_id;
320 cb_info->event_cb = event_cb;
321 cb_info->data = data;
322 cb_info->next = NULL;
324 /* TODO - check the order of callback - FIFO or LIFO => Should be changed to LIFO */
325 if (pc->info.listening.lhead == NULL)
326 pc->info.listening.lhead = cb_info;
328 current = prev = pc->info.listening.lhead;
331 current = current->next;
334 prev->next = cb_info;
338 static void __operation_callback(void *cb_data, const char *req_id,
339 const char *pkg_type, const char *pkgid,
340 const char *key, const char *val)
343 req_cb_info *cb_info;
345 _LOGD("__operation_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
346 "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
348 pc = (pkgmgr_client_t *) cb_data;
350 /* find callback info */
351 cb_info = __find_op_cbinfo(pc, req_id);
355 _LOGD("__find_op_cbinfo");
358 if (cb_info->event_cb) {
359 cb_info->event_cb(cb_info->request_id, pkg_type, pkgid, key,
360 val, NULL, cb_info->data);
361 _LOGD("event_cb is called");
364 /*remove callback for last call
365 if (strcmp(key, "end") == 0) {
366 __remove_op_cbinfo(pc, cb_info);
367 _LOGD("__remove_op_cbinfo");
374 static void __status_callback(void *cb_data, const char *req_id,
375 const char *pkg_type, const char *pkgid,
376 const char *key, const char *val)
381 _LOGD("__status_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
382 "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
384 pc = (pkgmgr_client_t *) cb_data;
386 tmp = pc->info.listening.lhead;
388 if (tmp->event_cb(tmp->request_id, pkg_type, pkgid, key, val,
389 NULL, tmp->data) != 0)
397 static char *__get_req_key(const char *pkg_path)
401 char timestr[PKG_STRING_LEN_MAX];
405 gettimeofday(&tv, NULL);
406 curtime = tv.tv_sec * 1000000 + tv.tv_usec;
407 snprintf(timestr, sizeof(timestr), "%ld", curtime);
409 size = strlen(pkg_path) + strlen(timestr) + 2;
410 str_req_key = (char *)calloc(size, sizeof(char));
411 if (str_req_key == NULL) {
412 _LOGD("calloc failed");
415 snprintf(str_req_key, size, "%s_%s", pkg_path, timestr);
420 static char *__get_type_from_path(const char *pkg_path)
423 char mimetype[255] = { '\0', };
424 char extlist[256] = { '\0', };
427 ret = _get_mime_from_file(pkg_path, mimetype, sizeof(mimetype));
429 _LOGE("_get_mime_from_file() failed - error code[%d]\n",
434 ret = _get_mime_extension(mimetype, extlist, sizeof(extlist));
436 _LOGE("_get_mime_extension() failed - error code[%d]\n",
441 if (strlen(extlist) == 0)
444 if (strchr(extlist, ',')) {
445 extlist[strlen(extlist) - strlen(strchr(extlist, ','))] = '\0';
447 pkg_type = strchr(extlist, '.') + 1;
448 return strdup(pkg_type);
451 static int __get_pkgid_by_appid(const char *appid, char **pkgid)
453 pkgmgrinfo_appinfo_h pkgmgrinfo_appinfo = NULL;
456 char *pkg_id_dup = NULL;
458 if (pkgmgrinfo_appinfo_get_appinfo(appid, &pkgmgrinfo_appinfo) != PMINFO_R_OK)
461 if (pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo, &pkg_id) != PMINFO_R_OK)
464 pkg_id_dup = strdup(pkg_id);
465 if (pkg_id_dup == NULL)
472 pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo);
477 static inline ail_cb_ret_e __appinfo_cb(const ail_appinfo_h appinfo, void *user_data)
480 ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
482 ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
485 (* (char **) user_data) = strdup(package);
486 ret = AIL_CB_RET_CANCEL;
492 static char *__get_app_info_from_db_by_apppath(const char *apppath, uid_t uid)
494 char *caller_appid = NULL;
502 ret = ail_filter_new(&filter);
503 if (ret != AIL_ERROR_OK) {
507 ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath);
508 if (ret != AIL_ERROR_OK) {
509 ail_filter_destroy(filter);
513 if(uid != GLOBAL_USER)
514 ret = ail_filter_count_usr_appinfo(filter, &count, uid);
516 ret = ail_filter_count_appinfo(filter, &count);
518 if (ret != AIL_ERROR_OK) {
519 ail_filter_destroy(filter);
523 ail_filter_destroy(filter);
526 if(uid != GLOBAL_USER)
527 ail_filter_list_usr_appinfo_foreach(filter, __appinfo_cb, &caller_appid,uid);
529 ail_filter_list_appinfo_foreach(filter, __appinfo_cb, &caller_appid);
531 ail_filter_destroy(filter);
536 static inline int __read_proc(const char *path, char *buf, int size)
541 if (buf == NULL || path == NULL)
544 fd = open(path, O_RDONLY);
548 ret = read(fd, buf, size - 1);
560 char *__proc_get_cmdline_bypid(int pid)
562 char buf[PKG_STRING_LEN_MAX] = {'\0', };
565 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
566 ret = __read_proc(buf, buf, sizeof(buf));
570 /* support app launched by shell script*/
571 if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
572 return strdup(&buf[BINSH_SIZE + 1]);
577 static int __get_appid_bypid(int pid, char *pkgname, int len, uid_t uid)
579 char *cmdline = NULL;
580 char *caller_appid = NULL;
582 cmdline = __proc_get_cmdline_bypid(pid);
586 caller_appid = __get_app_info_from_db_by_apppath(cmdline, uid);
587 snprintf(pkgname, len, "%s", caller_appid);
595 static char *__get_caller_pkgid(uid_t uid)
597 char *caller_appid[PKG_STRING_LEN_MAX] = {0, };
598 char *caller_pkgid = NULL;
600 if (__get_appid_bypid(getpid(), caller_appid, sizeof(caller_appid), uid) < 0) {
601 _LOGE("get appid fail!!!\n");
604 if (__get_pkgid_by_appid(caller_appid, &caller_pkgid) < 0){
605 _LOGE("get pkgid fail!!!\n");
612 static inline int __pkgmgr_read_proc(const char *path, char *buf, int size)
617 if (buf == NULL || path == NULL)
620 fd = open(path, O_RDONLY);
624 ret = read(fd, buf, size - 1);
636 static inline int __pkgmgr_find_pid_by_cmdline(const char *dname,
637 const char *cmdline, const char *apppath)
641 if (strncmp(cmdline, apppath, PKG_STRING_LEN_MAX-1) == 0) {
643 if (pid != getpgid(pid))
651 static int __pkgmgr_proc_iter_kill_cmdline(const char *apppath)
654 struct dirent *dentry;
657 char buf[PKG_STRING_LEN_MAX];
659 dp = opendir("/proc");
664 while ((dentry = readdir(dp)) != NULL) {
665 if (!isdigit(dentry->d_name[0]))
668 snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
669 ret = __pkgmgr_read_proc(buf, buf, sizeof(buf));
673 pid = __pkgmgr_find_pid_by_cmdline(dentry->d_name, buf, apppath);
684 if (killpg(pgid, SIGKILL) < 0) {
696 static int __app_list_cb (const pkgmgr_appinfo_h handle,
700 pkgmgr_appinfo_get_exec(handle, &exec);
702 __pkgmgr_proc_iter_kill_cmdline(exec);
707 static int __sync_process(char *req_key)
709 char info_file[PKG_STRING_LEN_MAX] = {'\0', };
713 snprintf(info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_TMP_PATH, req_key);
718 vconf_get_int(VCONFKEY_PKGMGR_STATUS, &result);
720 _LOGD("file is not generated yet.... wait\n");
721 usleep(10 * 1000); /* 10ms sleep*/
723 _LOGD("info_file file is generated, result = %d. \n", result);
727 if (check_cnt > 6000) { /* 60s time over*/
728 _LOGD("wait time over!!\n");
733 vconf_set_int(VCONFKEY_PKGMGR_STATUS, -1);
737 static int __csc_process(const char *csc_path, char *result_path)
744 char *pkgtype = NULL;
746 char buf[PKG_STRING_LEN_MAX] = {0,};
747 char type_buf[1024] = { 0 };
748 char des_buf[1024] = { 0 };
749 dictionary *csc = NULL;
752 csc = iniparser_load(csc_path);
753 retvm_if(csc == NULL, PKGMGR_R_EINVAL, "cannot open parse file [%s]", csc_path);
755 file = fopen(result_path, "w");
756 tryvm_if(file == NULL, ret = PKGMGR_R_EINVAL, "cannot open result file [%s]", result_path);
758 count = iniparser_getint(csc, "csc packages:count", -1);
759 tryvm_if(count == 0, ret = PKGMGR_R_ERROR, "csc [%s] dont have packages", csc_path);
761 snprintf(buf, PKG_STRING_LEN_MAX, "[result]\n");
762 fwrite(buf, 1, strlen(buf), file);
763 snprintf(buf, PKG_STRING_LEN_MAX, "count = %d\n", count);
764 fwrite(buf, 1, strlen(buf), file);
766 for(cnt = 1 ; cnt <= count ; cnt++)
768 snprintf(type_buf, PKG_STRING_LEN_MAX - 1, "csc packages:type_%03d", cnt);
769 snprintf(des_buf, PKG_STRING_LEN_MAX - 1, "csc packages:description_%03d", cnt);
771 pkgtype = iniparser_getstring(csc, type_buf, NULL);
772 des = iniparser_getstring(csc, des_buf, NULL);
775 if (pkgtype == NULL) {
777 snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get pkgtype\n", type_buf);
778 fwrite(buf, 1, strlen(buf), file);
780 } else if (des == NULL) {
782 snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get description\n", des_buf);
783 fwrite(buf, 1, strlen(buf), file);
787 snprintf(buf, PKG_STRING_LEN_MAX, "type_%03d = %s\n", cnt, pkgtype);
788 fwrite(buf, 1, strlen(buf), file);
789 snprintf(buf, PKG_STRING_LEN_MAX, "description_%03d = %s\n", cnt, des);
790 fwrite(buf, 1, strlen(buf), file);
792 if (strcmp(pkgtype, "tpk") == 0) {
793 const char *ospinstaller_argv[] = { "/usr/bin/osp-installer", "-c", des, NULL };
794 ret = __xsystem(ospinstaller_argv);
795 } else if (strcmp(pkgtype, "wgt")== 0) {
796 const char *wrtinstaller_argv[] = { "/usr/bin/wrt-installer", "-c", des, NULL };
797 ret = __xsystem(wrtinstaller_argv);
805 __error_to_string(ret, &errstr);
806 snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = fail[%s]\n", cnt, errstr);
809 snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = success\n", cnt);
811 fwrite(buf, 1, strlen(buf), file);
815 iniparser_freedict(csc);
825 static int __get_size_process(pkgmgr_client * pc, const char *pkgid, uid_t uid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data)
827 char *req_key = NULL;
829 char *pkgtype = "rpm";
830 char *argv[PKG_ARGC_MAX] = { NULL, };
836 char buf[128] = {'\0'};
839 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
840 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
842 req_key = __get_req_key(pkgid);
844 snprintf(buf, 128, "%d", get_type);
845 argv[argcnt++] = strdup(pkgid);
846 argv[argcnt++] = strdup(buf);
848 /*** add quote in all string for special charactor like '\n'*** FIX */
849 for (i = 0; i < argcnt; i++) {
850 temp = g_shell_quote(argv[i]);
851 len += (strlen(temp) + 1);
855 args = (char *)calloc(len, sizeof(char));
856 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
858 strncpy(args, argv[0], len - 1);
860 for (i = 1; i < argcnt; i++) {
861 strncat(args, " ", strlen(" "));
862 temp = g_shell_quote(argv[i]);
863 strncat(args, temp, strlen(temp));
866 _LOGD("[args] %s [len] %d\n", args, len);
868 /* get cookie from security-server */
869 cookie = __get_cookie_from_security_server();
870 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
873 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, uid, 1);
875 _LOGE("comm_client_request failed, ret=%d\n", ret);
877 ret = __sync_process(req_key);
879 _LOGE("get size failed, ret=%d\n", ret);
882 for (i = 0; i < argcnt; i++)
893 static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, uid_t uid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data)
895 char *req_key = NULL;
898 pkgmgrinfo_pkginfo_h handle;
899 char *pkgtype = NULL;
900 char *installer_path = NULL;
901 char *argv[PKG_ARGC_MAX] = { NULL, };
907 char buf[128] = {'\0'};
908 char info_file[PKG_STRING_LEN_MAX] = {'\0', };
911 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
912 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
914 if(uid != GLOBAL_USER)
915 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
917 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
918 retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
920 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
921 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
923 installer_path = _get_backend_path_with_type(pkgtype);
924 req_key = __get_req_key(pkgid);
925 req_id = _get_request_id();
928 snprintf(buf, 128, "%d", move_type);
929 /* argv[0] installer path */
930 argv[argcnt++] = installer_path;
932 argv[argcnt++] = strdup("-k");
934 argv[argcnt++] = req_key;
936 argv[argcnt++] = strdup("-m");
938 argv[argcnt++] = strdup(pkgid);
940 argv[argcnt++] = strdup("-t");
942 argv[argcnt++] = strdup(buf);
944 argv[argcnt++] = strdup("-q");
946 /*** add quote in all string for special charactor like '\n'*** FIX */
947 for (i = 0; i < argcnt; i++) {
948 temp = g_shell_quote(argv[i]);
949 len += (strlen(temp) + 1);
953 args = (char *)calloc(len, sizeof(char));
954 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
956 strncpy(args, argv[0], len - 1);
958 for (i = 1; i < argcnt; i++) {
959 strncat(args, " ", strlen(" "));
960 temp = g_shell_quote(argv[i]);
961 strncat(args, temp, strlen(temp));
964 _LOGD("[args] %s [len] %d\n", args, len);
966 /* get cookie from security-server */
967 cookie = __get_cookie_from_security_server();
968 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
971 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie,uid, 1);
973 _LOGE("comm_client_request failed, ret=%d\n", ret);
975 snprintf(info_file, PKG_STRING_LEN_MAX, "app2sd_%s", pkgid);
976 ret = __sync_process(info_file);
978 _LOGE("move pkg failed, ret=%d\n", ret);
981 for (i = 0; i < argcnt; i++)
989 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
993 static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_client * pc, const char *pkgid, uid_t uid, void *data)
998 pkgmgrinfo_pkginfo_h handle;
1001 /* Check for NULL value of pc */
1002 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1003 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
1005 if (uid != GLOBAL_USER)
1006 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1008 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
1009 retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
1011 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
1012 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
1014 /* 2. generate req_key */
1015 req_key = __get_req_key(pkgid);
1017 /* 3. request activate */
1018 if (service_type == PM_REQUEST_KILL_APP)
1019 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_KILL_APP, pkgtype, pkgid, NULL, NULL, uid, 1);
1020 else if (service_type == PM_REQUEST_CHECK_APP)
1021 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_CHECK_APP, pkgtype, pkgid, NULL, NULL, uid, 1);
1024 _LOGE("request failed, ret=%d\n", ret);
1026 pid = __sync_process(req_key);
1027 * (int *) data = pid;
1031 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
1037 API pkgmgr_client *pkgmgr_client_new(client_type ctype)
1039 pkgmgr_client_t *pc = NULL;
1042 retvm_if(ctype != PC_REQUEST && ctype != PC_LISTENING && ctype != PC_BROADCAST, NULL, "ctype is not client_type");
1044 /* Allocate memory for ADT:pkgmgr_client */
1045 pc = calloc(1, sizeof(pkgmgr_client_t));
1046 retvm_if(pc == NULL, NULL, "No memory");
1050 pc->status_type = PKGMGR_CLIENT_STATUS_ALL;
1052 if (pc->ctype == PC_REQUEST) {
1053 pc->info.request.cc = comm_client_new();
1054 trym_if(pc->info.request.cc == NULL, "client creation failed");
1056 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.request.cc, __operation_callback, pc);
1057 trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
1058 } else if (pc->ctype == PC_LISTENING) {
1059 pc->info.listening.cc = comm_client_new();
1060 trym_if(pc->info.listening.cc == NULL, "client creation failed");
1062 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.listening.cc, __status_callback, pc);
1063 trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
1064 } else if (pc->ctype == PC_BROADCAST) {
1065 pc->info.broadcast.bc = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
1066 trym_if(pc->info.broadcast.bc == NULL, "client creation failed");
1069 return (pkgmgr_client *) pc;
1077 API int pkgmgr_client_free(pkgmgr_client *pc)
1080 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1081 retvm_if(mpc == NULL, PKGMGR_R_EINVAL, "Invalid argument");
1083 if (mpc->ctype == PC_REQUEST) {
1086 for (tmp = mpc->info.request.rhead; tmp;) {
1092 ret = comm_client_free(mpc->info.request.cc);
1093 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
1094 } else if (mpc->ctype == PC_LISTENING) {
1095 listen_cb_info *tmp;
1096 listen_cb_info *prev;
1097 for (tmp = mpc->info.listening.lhead; tmp;) {
1103 ret = comm_client_free(mpc->info.listening.cc);
1104 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
1105 } else if (mpc->ctype == PC_BROADCAST) {
1106 comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
1109 _LOGE("Invalid client type\n");
1110 return PKGMGR_R_EINVAL;
1122 return PKGMGR_R_ERROR;
1126 API int pkgmgr_client_usr_install(pkgmgr_client * pc, const char *pkg_type,
1127 const char *descriptor_path, const char *pkg_path,
1128 const char *optional_file, pkgmgr_mode mode,
1129 pkgmgr_handler event_cb, void *data, uid_t uid)
1131 char *pkgtype = NULL;
1132 char *installer_path = NULL;
1133 char *req_key = NULL;
1136 char *argv[PKG_ARGC_MAX] = { NULL, };
1142 char *cookie = NULL;
1143 char *caller_pkgid = NULL;
1145 caller_pkgid = __get_caller_pkgid(uid);
1146 if (caller_pkgid == NULL)
1147 _LOGE("caller dont have pkgid..\n");
1149 /* Check for NULL value of pc */
1150 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL");
1152 /* 0. check the pc type */
1153 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1154 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
1156 /* 1. check argument */
1157 if (descriptor_path) {
1158 retvm_if(strlen(descriptor_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "descriptor_path over PKG_STRING_LEN_MAX");
1159 retvm_if(access(descriptor_path, F_OK) != 0, PKGMGR_R_EINVAL, "descriptor_path access fail");
1162 retvm_if(pkg_path == NULL, PKGMGR_R_EINVAL, "pkg_path is NULL");
1163 retvm_if(strlen(pkg_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkg_path over PKG_STRING_LEN_MAX");
1164 retvm_if(access(pkg_path, F_OK) != 0, PKGMGR_R_EINVAL, "pkg_path access fail");
1167 retvm_if(strlen(optional_file) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
1169 /* 2. get installer path using pkg_path */
1171 installer_path = _get_backend_path_with_type(pkg_type);
1172 pkgtype = strdup(pkg_type);
1174 installer_path = _get_backend_path(pkg_path);
1175 pkgtype = __get_type_from_path(pkg_path);
1177 if (installer_path == NULL) {
1179 _LOGE("installer_path is NULL\n");
1180 return PKGMGR_R_EINVAL;
1183 /* 3. generate req_key */
1184 req_key = __get_req_key(pkg_path);
1186 /* 4. add callback info - add callback info to pkgmgr_client */
1187 req_id = _get_request_id();
1188 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1190 /* 5. generate argv */
1192 /* argv[0] installer path */
1193 argv[argcnt++] = installer_path;
1195 argv[argcnt++] = strdup("-k");
1197 argv[argcnt++] = req_key;
1199 argv[argcnt++] = strdup("-i");
1200 /* argv[(4)] if exists */
1201 if (descriptor_path)
1202 argv[argcnt++] = strdup(descriptor_path);
1204 argv[argcnt++] = strdup(pkg_path);
1205 /* argv[(5)] if exists */
1207 argv[argcnt++] = strdup("-o");
1208 argv[argcnt++] = strdup(optional_file);
1211 argv[argcnt++] = strdup("-p");
1212 argv[argcnt++] = strdup(caller_pkgid);
1216 /* argv[6] -q option should be located at the end of command !! */
1217 if (mode == PM_QUIET)
1218 argv[argcnt++] = strdup("-q");
1220 /*** add quote in all string for special charactor like '\n'*** FIX */
1221 for (i = 0; i < argcnt; i++) {
1222 temp = g_shell_quote(argv[i]);
1223 len += (strlen(temp) + 1);
1227 args = (char *)calloc(len, sizeof(char));
1228 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1230 strncpy(args, argv[0], len - 1);
1232 for (i = 1; i < argcnt; i++) {
1233 strncat(args, " ", strlen(" "));
1234 temp = g_shell_quote(argv[i]);
1235 strncat(args, temp, strlen(temp));
1238 _LOGD("[args] %s [len] %d\n", args, len);
1240 /* get cookie from security-server */
1241 cookie = __get_cookie_from_security_server();
1242 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
1243 /******************* end of quote ************************/
1245 /* 6. request install */
1246 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkg_path, args, cookie, uid, 1);
1247 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
1252 for (i = 0; i < argcnt; i++)
1267 API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
1268 const char *descriptor_path, const char *pkg_path,
1269 const char *optional_file, pkgmgr_mode mode,
1270 pkgmgr_handler event_cb, void *data)
1274 return pkgmgr_client_usr_install(pc, pkg_type,
1275 descriptor_path, pkg_path, optional_file, mode, event_cb,data, GLOBAL_USER);
1278 API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
1279 const char *optional_file, pkgmgr_mode mode,
1280 pkgmgr_handler event_cb, void *data)
1282 return pkgmgr_client_usr_reinstall(pc, pkg_type, pkgid, optional_file, mode, event_cb, data,GLOBAL_USER);
1285 API int pkgmgr_client_usr_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
1286 const char *optional_file, pkgmgr_mode mode,
1287 pkgmgr_handler event_cb, void *data, uid_t uid)
1289 char *pkgtype = NULL;
1290 char *installer_path = NULL;
1291 char *req_key = NULL;
1294 char *argv[PKG_ARGC_MAX] = { NULL, };
1300 char *cookie = NULL;
1302 /* Check for NULL value of pc */
1303 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1305 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1307 /* 0. check the pc type */
1308 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1311 /* 1. check argument */
1312 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1313 retv_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL);
1314 if (optional_file) {
1315 if (strlen(optional_file) >= PKG_STRING_LEN_MAX)
1316 return PKGMGR_R_EINVAL;
1319 /* 2. get installer path using pkg_path */
1320 installer_path = _get_backend_path_with_type(pkg_type);
1321 pkgtype = strdup(pkg_type);
1322 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path is null");
1324 /* 3. generate req_key */
1325 req_key = __get_req_key(pkgid);
1327 /* 4. add callback info - add callback info to pkgmgr_client */
1328 req_id = _get_request_id();
1329 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1331 /* 5. generate argv */
1333 /* argv[0] installer path */
1334 argv[argcnt++] = installer_path;
1336 argv[argcnt++] = strdup("-k");
1338 argv[argcnt++] = req_key;
1340 argv[argcnt++] = strdup("-r");
1342 argv[argcnt++] = strdup(pkgid);
1343 /* argv[(5)] if exists */
1345 argv[argcnt++] = strdup("-o");
1346 argv[argcnt++] = strdup(optional_file);
1349 /* argv[5] -q option should be located at the end of command !! */
1350 if (mode == PM_QUIET)
1351 argv[argcnt++] = strdup("-q");
1353 /*** add quote in all string for special charactor like '\n'*** FIX */
1354 for (i = 0; i < argcnt; i++) {
1355 temp = g_shell_quote(argv[i]);
1356 len += (strlen(temp) + 1);
1360 args = (char *)calloc(len, sizeof(char));
1361 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1363 strncpy(args, argv[0], len - 1);
1365 for (i = 1; i < argcnt; i++) {
1366 strncat(args, " ", strlen(" "));
1367 temp = g_shell_quote(argv[i]);
1368 strncat(args, temp, strlen(temp));
1371 _LOGD("[args] %s [len] %d\n", args, len);
1373 /* get cookie from security-server */
1374 cookie = __get_cookie_from_security_server();
1375 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
1376 /******************* end of quote ************************/
1378 /* 6. request install */
1379 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, uid, 1);
1380 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed");
1385 for (i = 0; i < argcnt; i++)
1398 API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
1399 const char *pkgid, pkgmgr_mode mode,
1400 pkgmgr_handler event_cb, void *data)
1402 return pkgmgr_client_usr_uninstall(pc, pkg_type,pkgid, mode, event_cb, data, GLOBAL_USER);
1404 API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
1405 const char *pkgid, pkgmgr_mode mode,
1406 pkgmgr_handler event_cb, void *data, uid_t uid)
1409 char *installer_path;
1413 char *argv[PKG_ARGC_MAX] = { NULL, };
1419 char *cookie = NULL;
1420 bool removable = false;
1421 char *caller_pkgid = NULL;
1423 caller_pkgid = __get_caller_pkgid(uid);
1424 if (caller_pkgid == NULL)
1425 _LOGD("caller dont have pkgid..\n");
1427 /* Check for NULL value of pc */
1428 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1430 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1432 /* 0. check the pc type */
1433 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1435 /* 1. check argument */
1436 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1438 pkgmgr_pkginfo_h handle;
1439 ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1441 /*check package id */
1442 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
1443 tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
1445 if (uid != GLOBAL_USER) {
1446 /*check running app , terminate app if it is running*/
1447 ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, __app_list_cb, NULL, uid);
1448 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1450 /*check running app , terminate app if it is running*/
1451 ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, __app_list_cb, NULL, uid);
1452 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1454 /*check running app , terminate app if it is running*/
1455 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
1456 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1458 /*check running app , terminate app if it is running*/
1459 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
1460 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1463 ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
1464 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
1465 tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
1467 /*check removable, execpt "rpm" type */
1468 if (strcmp(pkgtype, "rpm")) {
1469 pkgmgr_pkginfo_is_removable(handle, &removable);
1470 tryvm_if(removable == false, ret = PKGMGR_R_ERROR, "Pkgid(%s) can not be removed, This is non-removalbe package...\n", pkgid);
1473 /*check pkgid length */
1474 tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
1476 /* 2. get installer path using pkgtype */
1477 installer_path = _get_backend_path_with_type(pkgtype);
1478 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
1480 /* 3. generate req_key */
1481 req_key = __get_req_key(pkgid);
1483 /* 4. add callback info - add callback info to pkgmgr_client */
1484 req_id = _get_request_id();
1485 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1487 /* 5. generate argv */
1489 /* argv[0] installer path */
1490 argv[argcnt++] = installer_path;
1492 argv[argcnt++] = strdup("-k");
1494 argv[argcnt++] = req_key;
1496 argv[argcnt++] = strdup("-d");
1498 argv[argcnt++] = strdup(pkgid);
1500 argv[argcnt++] = strdup("-p");
1501 argv[argcnt++] = caller_pkgid;
1503 /* argv[5] -q option should be located at the end of command !! */
1504 if (mode == PM_QUIET)
1505 argv[argcnt++] = strdup("-q");
1507 /*** add quote in all string for special charactor like '\n'*** FIX */
1508 for (i = 0; i < argcnt; i++) {
1509 temp = g_shell_quote(argv[i]);
1510 len += (strlen(temp) + 1);
1514 args = (char *)calloc(len, sizeof(char));
1515 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1517 strncpy(args, argv[0], len - 1);
1519 for (i = 1; i < argcnt; i++) {
1520 strncat(args, " ", strlen(" "));
1521 temp = g_shell_quote(argv[i]);
1522 strncat(args, temp, strlen(temp));
1525 _LOGD("[args] %s [len] %d\n", args, len);
1527 /* get cookie from security-server */
1528 cookie = __get_cookie_from_security_server();
1529 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
1530 /******************* end of quote ************************/
1532 /* 6. request install */
1533 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, uid, 1);
1534 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
1539 for (i = 0; i < argcnt; i++)
1547 pkgmgr_pkginfo_destroy_pkginfo(handle);
1552 API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkg_type,
1553 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode)
1555 return pkgmgr_client_usr_move( pc,pkg_type, pkgid, move_type, mode, GLOBAL_USER);
1557 API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
1558 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode, uid_t uid)
1560 const char *pkgtype = NULL;
1561 char *installer_path = NULL;
1562 char *req_key = NULL;
1564 char *argv[PKG_ARGC_MAX] = { NULL, };
1571 char *cookie = NULL;
1572 char buf[128] = {'\0'};
1574 /* Check for NULL value of pc */
1576 _LOGD("package manager client handle is NULL\n");
1577 return PKGMGR_R_EINVAL;
1579 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1580 /*check the pc type */
1581 if (mpc->ctype != PC_REQUEST)
1582 return PKGMGR_R_EINVAL;
1586 return PKGMGR_R_EINVAL;
1588 if (pkg_type == NULL) {
1589 pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid);
1590 if (pkgtype == NULL)
1591 return PKGMGR_R_EINVAL;
1595 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1596 return PKGMGR_R_EINVAL;
1598 if ((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD))
1599 return PKGMGR_R_EINVAL;
1601 /* get installer path using pkg_path */
1602 installer_path = _get_backend_path_with_type(pkgtype);
1603 if (installer_path == NULL)
1604 return PKGMGR_R_EINVAL;
1606 /* generate req_key */
1607 req_key = __get_req_key(pkgid);
1608 req_id = _get_request_id();
1611 snprintf(buf, 128, "%d", move_type);
1612 /* argv[0] installer path */
1613 argv[argcnt++] = installer_path;
1615 argv[argcnt++] = strdup("-k");
1617 argv[argcnt++] = req_key;
1619 argv[argcnt++] = strdup("-m");
1621 argv[argcnt++] = strdup(pkgid);
1623 argv[argcnt++] = strdup("-t");
1625 argv[argcnt++] = strdup(buf);
1626 /* argv[7] -q option should be located at the end of command !! */
1627 if (mode == PM_QUIET)
1628 argv[argcnt++] = strdup("-q");
1630 /*** add quote in all string for special charactor like '\n'*** FIX */
1631 for (i = 0; i < argcnt; i++) {
1632 temp = g_shell_quote(argv[i]);
1633 len += (strlen(temp) + 1);
1637 args = (char *)calloc(len, sizeof(char));
1639 _LOGD("calloc failed");
1641 for (i = 0; i < argcnt; i++)
1644 return PKGMGR_R_ERROR;
1646 strncpy(args, argv[0], len - 1);
1648 for (i = 1; i < argcnt; i++) {
1649 strncat(args, " ", strlen(" "));
1650 temp = g_shell_quote(argv[i]);
1651 strncat(args, temp, strlen(temp));
1654 _LOGD("[args] %s [len] %d\n", args, len);
1655 /******************* end of quote ************************/
1657 /* 6. request install */
1658 ret = comm_client_request(mpc->info.request.cc, req_key,
1659 COMM_REQ_TO_MOVER, pkgtype, pkgid,
1660 args, cookie, uid, 1);
1662 _LOGE("request failed, ret=%d\n", ret);
1664 for (i = 0; i < argcnt; i++)
1668 return PKGMGR_R_ECOMM;
1671 for (i = 0; i < argcnt; i++)
1680 API int pkgmgr_client_move_pkg(pkgmgr_client *pc, const char *pkg_type,
1681 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode,
1682 pkgmgr_handler event_cb, void *data)
1684 return pkgmgr_client_move_usr_pkg(pc, pkg_type, pkgid, GLOBAL_USER, move_type, mode, event_cb, data);
1687 API int pkgmgr_client_move_usr_pkg(pkgmgr_client *pc, const char *pkg_type,
1688 const char *pkgid, uid_t uid, pkgmgr_move_type move_type, pkgmgr_mode mode,
1689 pkgmgr_handler event_cb, void *data)
1692 char *installer_path;
1696 char *argv[PKG_ARGC_MAX] = { NULL, };
1702 char *cookie = NULL;
1703 char buf[128] = {'\0'};
1705 /* Check for NULL value of pc */
1706 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1708 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1710 /* 0. check the pc type */
1711 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1713 /* 1. check argument */
1714 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1716 pkgmgr_pkginfo_h handle;
1717 if (uid != GLOBAL_USER)
1718 ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1720 ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
1722 /*check package id */
1723 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
1724 tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
1726 if (uid != GLOBAL_USER) {
1727 /*check running app , terminate app if it is running*/
1728 ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, __app_list_cb, NULL, uid);
1729 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1731 /*check running app , terminate app if it is running*/
1732 ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, __app_list_cb, NULL, uid);
1733 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1736 /*check running app , terminate app if it is running*/
1737 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
1738 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1739 /*check running app , terminate app if it is running*/
1740 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
1741 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1744 ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
1745 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
1746 tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
1748 /*check pkgid length */
1749 tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
1751 /*check move_type */
1752 tryvm_if((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "move_type is not supported");
1754 /* 2. get installer path using pkgtype */
1755 installer_path = _get_backend_path_with_type(pkgtype);
1756 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
1758 /* 3. generate req_key */
1759 req_key = __get_req_key(pkgid);
1761 /* 4. add callback info - add callback info to pkgmgr_client */
1762 req_id = _get_request_id();
1763 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1765 /* 5. generate argv */
1766 snprintf(buf, 128, "%d", move_type);
1767 /* argv[0] installer path */
1768 argv[argcnt++] = installer_path;
1770 argv[argcnt++] = strdup("-k");
1772 argv[argcnt++] = req_key;
1774 argv[argcnt++] = strdup("-m");
1776 argv[argcnt++] = strdup(pkgid);
1778 argv[argcnt++] = strdup("-t");
1780 argv[argcnt++] = strdup(buf);
1781 /* argv[5] -q option should be located at the end of command !! */
1782 if (mode == PM_QUIET)
1783 argv[argcnt++] = strdup("-q");
1785 /*** add quote in all string for special charactor like '\n'*** FIX */
1786 for (i = 0; i < argcnt; i++) {
1787 temp = g_shell_quote(argv[i]);
1788 len += (strlen(temp) + 1);
1792 args = (char *)calloc(len, sizeof(char));
1793 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1795 strncpy(args, argv[0], len - 1);
1797 for (i = 1; i < argcnt; i++) {
1798 strncat(args, " ", strlen(" "));
1799 temp = g_shell_quote(argv[i]);
1800 strncat(args, temp, strlen(temp));
1803 _LOGD("[args] %s [len] %d\n", args, len);
1805 /* get cookie from security-server */
1806 cookie = __get_cookie_from_security_server();
1807 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
1808 /******************* end of quote ************************/
1810 /* 6. request install */
1811 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie, uid, 1);
1812 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
1817 for (i = 0; i < argcnt; i++)
1825 pkgmgr_pkginfo_destroy_pkginfo(handle);
1830 API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type,
1833 return pkgmgr_client_usr_activate(pc, pkg_type, pkgid, GLOBAL_USER);
1836 API int pkgmgr_client_usr_activate(pkgmgr_client * pc, const char *pkg_type,
1837 const char *pkgid, uid_t uid)
1839 const char *pkgtype;
1841 char *cookie = NULL;
1843 /* Check for NULL value of pc */
1844 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1846 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1848 /* 0. check the pc type */
1849 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
1851 /* 1. check argument */
1852 retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
1853 retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
1855 if (pkg_type == NULL) {
1856 pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid);
1857 retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
1861 /* 2. generate req_key */
1862 req_key = __get_req_key(pkgid);
1863 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
1865 /* 3. request activate */
1866 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "1 PKG", cookie, uid, 1);
1867 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
1876 API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
1879 return pkgmgr_client_usr_deactivate(pc, pkg_type, pkgid, GLOBAL_USER);
1882 API int pkgmgr_client_usr_deactivate(pkgmgr_client *pc, const char *pkg_type,
1883 const char *pkgid, uid_t uid)
1885 const char *pkgtype;
1887 char *cookie = NULL;
1889 /* Check for NULL value of pc */
1890 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1892 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1894 /* 0. check the pc type */
1895 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
1897 /* 1. check argument */
1898 retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
1899 retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
1901 if (pkg_type == NULL) {
1902 pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid);
1903 if (pkgtype == NULL)
1904 return PKGMGR_R_EINVAL;
1908 /* 2. generate req_key */
1909 req_key = __get_req_key(pkgid);
1910 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
1912 /* 3. request activate */
1913 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "0 PKG", cookie, uid, 1);
1914 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
1923 API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
1925 return pkgmgr_client_usr_activate_app(pc,appid, GLOBAL_USER);
1928 API int pkgmgr_client_usr_activate_app(pkgmgr_client * pc, const char *appid, uid_t uid)
1930 const char *pkgtype;
1932 char *cookie = NULL;
1934 /* Check for NULL value of pc */
1935 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1937 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1939 /* 0. check the pc type */
1940 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
1942 /* 1. check argument */
1943 retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
1944 retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
1946 pkgtype = _get_pkg_type_from_desktop_file(appid, uid);
1947 retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
1949 /* 2. generate req_key */
1950 req_key = __get_req_key(appid);
1951 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
1953 /* 3. request activate */
1954 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "1 APP", cookie, uid, 1);
1955 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
1964 API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[])
1966 return pkgmgr_client_usr_activate_appv(pc, appid, argv, GLOBAL_USER);
1969 API int pkgmgr_client_usr_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[], uid_t uid)
1971 const char *pkgtype;
1973 char *cookie = NULL;
1981 /* Check for NULL value of pc */
1982 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1984 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1986 /* 0. check the pc type */
1987 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
1989 /* 1. check argument */
1990 retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
1991 retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
1993 pkgtype = _get_pkg_type_from_desktop_file(appid, uid);
1994 retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
1996 /* 2. generate req_key */
1997 req_key = __get_req_key(appid);
1998 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
2000 /*** add quote in all string for special charactor like '\n'*** FIX */
2002 for (i = 0; argv[i]; i++) {
2003 temp = g_shell_quote(argv[i]);
2004 len += (strlen(temp) + 1);
2010 args = (char *)calloc(len, sizeof(char));
2011 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
2012 strncpy(args, argv[0], len - 1);
2014 for (i = 1; i < argcnt; i++) {
2015 strncat(args, " ", strlen(" "));
2016 temp = g_shell_quote(argv[i]);
2017 strncat(args, temp, strlen(temp));
2023 argsr = (char *)calloc(strlen("1 APP")+2+len, sizeof(char));
2024 tryvm_if(argsr == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
2026 strncpy(argsr, "1 APP", strlen("1 APP"));
2028 strncat(argsr, " ", strlen(" "));
2029 strncat(argsr, args, strlen(args));
2032 _LOGD("argsr [%s]\n", argsr);
2033 /******************* end of quote ************************/
2035 /* 3. request activate */
2036 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, argsr, cookie, uid, 1);
2037 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
2051 API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
2053 return pkgmgr_client_usr_deactivate_app(pc, appid, GLOBAL_USER);
2056 API int pkgmgr_client_usr_deactivate_app(pkgmgr_client *pc, const char *appid, uid_t uid)
2058 const char *pkgtype;
2060 char *cookie = NULL;
2062 /* Check for NULL value of pc */
2063 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
2065 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2067 /* 0. check the pc type */
2068 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
2070 /* 1. check argument */
2071 retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
2072 retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
2074 pkgtype = _get_pkg_type_from_desktop_file(appid, uid);
2075 retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
2077 /* 2. generate req_key */
2078 req_key = __get_req_key(appid);
2079 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
2081 /* 3. request activate */
2082 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "0 APP", cookie, uid, 1);
2083 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
2092 API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
2093 const char *appid, pkgmgr_mode mode)
2095 return pkgmgr_client_usr_clear_user_data(pc, pkg_type, appid,mode, GLOBAL_USER);
2097 API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
2098 const char *appid, pkgmgr_mode mode, uid_t uid)
2100 const char *pkgtype;
2101 char *installer_path;
2104 char *argv[PKG_ARGC_MAX] = { NULL, };
2110 char *cookie = NULL;
2112 /* Check for NULL value of pc */
2114 _LOGD("package manager client handle is NULL\n");
2115 return PKGMGR_R_EINVAL;
2117 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2119 /* 0. check the pc type */
2120 if (mpc->ctype != PC_REQUEST)
2121 return PKGMGR_R_EINVAL;
2123 /* 1. check argument */
2125 return PKGMGR_R_EINVAL;
2128 if (pkg_type == NULL) {
2129 pkgtype = _get_pkg_type_from_desktop_file(appid, uid);
2130 if (pkgtype == NULL)
2131 return PKGMGR_R_EINVAL;
2135 if (strlen(appid) >= PKG_STRING_LEN_MAX)
2136 return PKGMGR_R_EINVAL;
2138 /* 2. get installer path using pkg_path */
2139 installer_path = _get_backend_path_with_type(pkgtype);
2140 if (installer_path == NULL)
2141 return PKGMGR_R_EINVAL;
2143 /* 3. generate req_key */
2144 req_key = __get_req_key(appid);
2146 /* 4. generate argv */
2148 /* argv[0] installer path */
2149 argv[argcnt++] = installer_path;
2151 argv[argcnt++] = strdup("-k");
2153 argv[argcnt++] = req_key;
2155 argv[argcnt++] = strdup("-c");
2157 argv[argcnt++] = strdup(appid);
2158 /* argv[5] -q option should be located at the end of command !! */
2159 if (mode == PM_QUIET)
2160 argv[argcnt++] = strdup("-q");
2162 /*** add quote in all string for special charactor like '\n'*** FIX */
2163 for (i = 0; i < argcnt; i++) {
2164 temp = g_shell_quote(argv[i]);
2165 len += (strlen(temp) + 1);
2169 args = (char *)calloc(len, sizeof(char));
2171 _LOGD("calloc failed");
2173 for (i = 0; i < argcnt; i++)
2176 return PKGMGR_R_ERROR;
2178 strncpy(args, argv[0], len - 1);
2180 for (i = 1; i < argcnt; i++) {
2181 strncat(args, " ", strlen(" "));
2182 temp = g_shell_quote(argv[i]);
2183 strncat(args, temp, strlen(temp));
2186 _LOGD("[args] %s [len] %d\n", args, len);
2187 /******************* end of quote ************************/
2189 /* 6. request clear */
2190 ret = comm_client_request(mpc->info.request.cc, req_key,
2191 COMM_REQ_TO_CLEARER, pkgtype, appid,
2192 args, cookie, uid, 1);
2194 _LOGE("request failed, ret=%d\n", ret);
2196 for (i = 0; i < argcnt; i++)
2200 return PKGMGR_R_ECOMM;
2203 for (i = 0; i < argcnt; i++)
2212 API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type)
2216 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
2217 retvm_if(status_type == PKGMGR_CLIENT_STATUS_ALL, PKGMGR_R_OK, "status_type is PKGMGR_CLIENT_STATUS_ALL");
2218 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2220 /* free listening head */
2221 listen_cb_info *tmp = NULL;
2222 listen_cb_info *prev = NULL;
2223 for (tmp = mpc->info.listening.lhead; tmp;) {
2229 /* free dbus connection */
2230 ret = comm_client_free(mpc->info.listening.cc);
2231 retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
2233 /* Manage pc for seperated event */
2234 mpc->ctype = PC_LISTENING;
2235 mpc->status_type = status_type;
2237 mpc->info.listening.cc = comm_client_new();
2238 retvm_if(mpc->info.listening.cc == NULL, PKGMGR_R_EINVAL, "client creation failed");
2240 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_INSTALL) == PKGMGR_CLIENT_STATUS_INSTALL) {
2241 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_INSTALL, mpc->info.listening.cc, __status_callback, pc);
2242 retvm_if(ret < 0, PKGMGR_R_ECOMM, "PKGMGR_CLIENT_STATUS_INSTALL failed - %d", ret);
2245 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_UNINSTALL) == PKGMGR_CLIENT_STATUS_UNINSTALL) {
2246 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_UNINSTALL, mpc->info.listening.cc, __status_callback, pc);
2247 retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_UNINSTALL failed - %d", ret);
2250 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_MOVE) == PKGMGR_CLIENT_STATUS_MOVE) {
2251 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_MOVE, mpc->info.listening.cc, __status_callback, pc);
2252 retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_MOVE failed - %d", ret);
2255 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS) == PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS) {
2256 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_INSTALL_PROGRESS, mpc->info.listening.cc, __status_callback, pc);
2257 retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_INSTALL_PROGRESS failed - %d", ret);
2260 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_UPGRADE) == PKGMGR_CLIENT_STATUS_UPGRADE) {
2261 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_UPGRADE, mpc->info.listening.cc, __status_callback, pc);
2262 retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_UPGRADE failed - %d", ret);
2268 API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
2272 /* Check for NULL value of pc */
2273 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
2274 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2276 /* 0. check input */
2277 retvm_if(mpc->ctype != PC_LISTENING, PKGMGR_R_EINVAL, "ctype is not PC_LISTENING");
2278 retvm_if(event_cb == NULL, PKGMGR_R_EINVAL, "event_cb is NULL");
2281 req_id = _get_request_id();
2283 /* 2. add callback info to pkgmgr_client */
2284 __add_stat_cbinfo(mpc, req_id, event_cb, data);
2288 API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
2289 const char *pkgid, const char *key,
2292 /* Check for NULL value of pc */
2294 _LOGD("package manager client handle is NULL\n");
2295 return PKGMGR_R_EINVAL;
2297 /* Check for valid arguments. NULL parameter causes DBUS to abort */
2298 if (pkgid == NULL || pkg_type == NULL || key == NULL || val == NULL) {
2299 _LOGD("Argument supplied is NULL\n");
2300 return PKGMGR_R_EINVAL;
2302 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2304 /* 0. check the pc type */
2305 if (mpc->ctype != PC_BROADCAST)
2306 return PKGMGR_R_EINVAL;
2308 comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, mpc->info.broadcast.bc,
2309 PKG_STATUS, pkg_type,
2315 API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
2317 return pkgmgr_info_new_from_file(NULL, pkg_path);
2320 API int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info)
2322 if (pkg_info == NULL)
2323 return PKGMGR_R_EINVAL;
2325 package_manager_pkg_detail_info_t *info = (package_manager_pkg_detail_info_t *)pkg_info;
2328 free(info->icon_buf);
2336 API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, int service_mode,
2337 pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
2338 const char *custom_info, pkgmgr_handler event_cb, void *data)
2340 return pkgmgr_client_usr_request_service(service_type, service_mode, pc, pkg_type, pkgid, GLOBAL_USER, custom_info, event_cb, data);
2343 API int pkgmgr_client_usr_request_service(pkgmgr_request_service_type service_type, int service_mode,
2344 pkgmgr_client * pc, const char *pkg_type, const char *pkgid, uid_t uid,
2345 const char *custom_info, pkgmgr_handler event_cb, void *data)
2349 /* Check for NULL value of service type */
2350 retvm_if(service_type > PM_REQUEST_MAX, PKGMGR_R_EINVAL, "service type is not defined\n");
2351 retvm_if(service_type < 0, PKGMGR_R_EINVAL, "service type is error\n");
2352 vconf_set_int(VCONFKEY_PKGMGR_STATUS, -1);
2354 switch (service_type) {
2355 case PM_REQUEST_CSC:
2356 tryvm_if(custom_info == NULL, ret = PKGMGR_R_EINVAL, "custom_info is NULL\n");
2357 tryvm_if(strlen(custom_info) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
2358 tryvm_if(data == NULL, ret = PKGMGR_R_EINVAL, "data is NULL\n");
2360 ret = __csc_process(custom_info, (char *)data);
2362 _LOGE("__csc_process fail \n");
2368 case PM_REQUEST_MOVE:
2369 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2370 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2371 tryvm_if((service_mode < PM_MOVE_TO_INTERNAL) || (service_mode > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "service_mode is wrong\n");
2373 ret = __move_pkg_process(pc, pkgid, uid, (pkgmgr_move_type)service_mode, event_cb, data);
2376 case PM_REQUEST_GET_SIZE:
2377 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2378 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2379 tryvm_if((service_mode < PM_GET_TOTAL_SIZE) || (service_mode >= PM_GET_MAX), ret = PKGMGR_R_EINVAL, "service_mode is wrong\n");
2381 ret = __get_size_process(pc, pkgid, uid, (pkgmgr_getsize_type)service_mode, event_cb, data);
2384 case PM_REQUEST_KILL_APP:
2385 case PM_REQUEST_CHECK_APP:
2386 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2387 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2389 ret = __check_app_process(service_type, pc, pkgid, uid, data);
2391 _LOGE("__check_app_process fail \n");
2398 _LOGE("Wrong Request\n");
2409 API int pkgmgr_client_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data)
2411 return pkgmgr_client_usr_get_size(pc, pkgid, get_type, event_cb, data, GLOBAL_USER);
2414 API int pkgmgr_client_usr_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data, uid_t uid)
2416 char *req_key = NULL;
2418 char *pkgtype = "rpm";
2419 char *argv[PKG_ARGC_MAX] = { NULL, };
2425 char buf[128] = {'\0'};
2426 char *cookie = NULL;
2429 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2430 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
2431 retvm_if(event_cb == NULL, PKGMGR_R_EINVAL, "event_cb is NULL\n");
2432 retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL\n");
2434 req_key = __get_req_key(pkgid);
2435 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
2437 req_id = _get_request_id();
2438 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
2440 snprintf(buf, 128, "%d", get_type);
2441 argv[argcnt++] = strdup(pkgid);
2442 argv[argcnt++] = strdup(buf);
2443 argv[argcnt++] = strdup("-k");
2444 argv[argcnt++] = req_key;
2446 /*** add quote in all string for special charactor like '\n'*** FIX */
2447 for (i = 0; i < argcnt; i++) {
2448 temp = g_shell_quote(argv[i]);
2449 len += (strlen(temp) + 1);
2453 args = (char *)calloc(len, sizeof(char));
2454 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
2456 strncpy(args, argv[0], len - 1);
2458 for (i = 1; i < argcnt; i++) {
2459 strncat(args, " ", strlen(" "));
2460 temp = g_shell_quote(argv[i]);
2461 strncat(args, temp, strlen(temp));
2464 _LOGD("[args] %s [len] %d\n", args, len);
2466 /* get cookie from security-server */
2467 cookie = __get_cookie_from_security_server();
2468 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
2471 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, uid, 1);
2473 _LOGE("comm_client_request failed, ret=%d\n", ret);
2476 for (i = 0; i < argcnt; i++)
2488 #define __START_OF_OLD_API
2489 ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
2495 iter_data *udata = (iter_data *) user_data;
2497 ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PACKAGETYPE_STR, &type);
2500 ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
2501 if (package == NULL)
2503 ail_appinfo_get_str(appinfo, AIL_PROP_VERSION_STR, &version);
2504 if (version == NULL)
2507 if (udata->iter_fn(type, package, version, udata->data) != 0)
2508 return AIL_CB_RET_CANCEL;
2510 return AIL_CB_RET_CONTINUE;
2513 API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data, uid_t uid)
2516 ail_filter_h filter;
2519 if (iter_fn == NULL)
2520 return PKGMGR_R_EINVAL;
2522 ret = ail_filter_new(&filter);
2523 if (ret != AIL_ERROR_OK) {
2524 return PKGMGR_R_ERROR;
2527 ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
2528 if (ret != AIL_ERROR_OK) {
2529 ail_filter_destroy(filter);
2530 return PKGMGR_R_ERROR;
2533 ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
2534 if (ret != AIL_ERROR_OK) {
2535 ail_filter_destroy(filter);
2536 return PKGMGR_R_ERROR;
2539 if(uid != GLOBAL_USER)
2540 ret = ail_filter_count_usr_appinfo(filter, &cnt, uid);
2542 ret = ail_filter_count_appinfo(filter, &cnt);
2543 if (ret != AIL_ERROR_OK) {
2544 ail_filter_destroy(filter);
2545 return PKGMGR_R_ERROR;
2548 iter_data *udata = calloc(1, sizeof(iter_data));
2549 if (udata == NULL) {
2550 _LOGE("calloc failed");
2551 ail_filter_destroy(filter);
2553 return PKGMGR_R_ERROR;
2555 udata->iter_fn = iter_fn;
2558 if(uid != GLOBAL_USER)
2559 ail_filter_list_usr_appinfo_foreach(filter, __appinfo_func, udata, uid);
2561 ail_filter_list_appinfo_foreach(filter, __appinfo_func, udata);
2564 ret = ail_filter_destroy(filter);
2565 if (ret != AIL_ERROR_OK) {
2566 return PKGMGR_R_ERROR;
2572 API pkgmgr_info *pkgmgr_info_new(const char *pkg_type, const char *pkgid)
2574 return pkgmgr_info_usr_new(pkg_type, pkgid, GLOBAL_USER);
2576 API pkgmgr_info *pkgmgr_info_usr_new(const char *pkg_type, const char *pkgid, uid_t uid)
2578 const char *pkgtype;
2579 pkg_plugin_set *plugin_set = NULL;
2580 package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
2582 /* 1. check argument */
2586 if (pkg_type == NULL) {
2587 pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid);
2588 if (pkgtype == NULL)
2593 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
2596 pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
2597 if (pkg_detail_info == NULL) {
2598 _LOGE("*** Failed to alloc package_handler_info.\n");
2602 plugin_set = _package_manager_load_library(pkgtype);
2603 if (plugin_set == NULL) {
2604 _LOGE("*** Failed to load library");
2605 free(pkg_detail_info);
2609 if (plugin_set->pkg_is_installed) {
2610 if (plugin_set->pkg_is_installed(pkgid) != 0) {
2611 _LOGE("*** Failed to call pkg_is_installed()");
2612 free(pkg_detail_info);
2616 if (plugin_set->get_pkg_detail_info) {
2617 if (plugin_set->get_pkg_detail_info(pkgid,
2618 pkg_detail_info) != 0) {
2619 _LOGE("*** Failed to call get_pkg_detail_info()");
2620 free(pkg_detail_info);
2626 return (pkgmgr_info *) pkg_detail_info;
2629 API char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key)
2631 package_manager_pkg_detail_info_t *pkg_detail_info;
2633 if (pkg_info == NULL)
2638 pkg_detail_info = (package_manager_pkg_detail_info_t *) pkg_info;
2640 return _get_info_string(key, pkg_detail_info);
2643 API pkgmgr_info *pkgmgr_info_new_from_file(const char *pkg_type,
2644 const char *pkg_path)
2646 pkg_plugin_set *plugin_set = NULL;
2647 package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
2649 if (pkg_path == NULL) {
2650 _LOGE("pkg_path is NULL\n");
2654 if (strlen(pkg_path) > PKG_URL_STRING_LEN_MAX) {
2655 _LOGE("length of pkg_path is too long - %d.\n",
2660 pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
2661 if (pkg_detail_info == NULL) {
2662 _LOGE("*** Failed to alloc package_handler_info.\n");
2666 if (pkg_type == NULL)
2667 pkgtype = __get_type_from_path(pkg_path);
2669 pkgtype = strdup(pkg_type);
2671 plugin_set = _package_manager_load_library(pkgtype);
2672 if (plugin_set == NULL) {
2673 free(pkg_detail_info);
2678 if (plugin_set->get_pkg_detail_info_from_package) {
2679 if (plugin_set->get_pkg_detail_info_from_package(pkg_path,
2680 pkg_detail_info) != 0) {
2681 free(pkg_detail_info);
2688 return (pkgmgr_info *) pkg_detail_info;
2691 API int pkgmgr_info_free(pkgmgr_info * pkg_info)
2693 if (pkg_info == NULL)
2694 return PKGMGR_R_EINVAL;
2702 #define __END_OF_OLD_API
2704 API int pkgmgr_pkginfo_get_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data)
2707 ret = pkgmgrinfo_pkginfo_get_list(pkg_list_cb, user_data);
2711 API int pkgmgr_pkginfo_get_usr_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
2714 ret = pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, uid);
2719 API int pkgmgr_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, pkgmgr_pkginfo_h *handle)
2722 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, handle);
2727 API int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle)
2730 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, handle);
2736 API int pkgmgr_pkginfo_get_pkgname(pkgmgr_pkginfo_h handle, char **pkg_name)
2739 ret = pkgmgrinfo_pkginfo_get_pkgname(handle, pkg_name);
2744 API int pkgmgr_pkginfo_get_pkgid(pkgmgr_pkginfo_h handle, char **pkgid)
2747 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, pkgid);
2751 API int pkgmgr_pkginfo_get_type(pkgmgr_pkginfo_h handle, char **type)
2754 ret = pkgmgrinfo_pkginfo_get_type(handle, type);
2758 API int pkgmgr_pkginfo_get_version(pkgmgr_pkginfo_h handle, char **version)
2761 ret = pkgmgrinfo_pkginfo_get_version(handle, version);
2765 API int pkgmgr_pkginfo_get_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location)
2768 pkgmgrinfo_install_location loc;
2769 ret = pkgmgrinfo_pkginfo_get_install_location(handle, &loc);
2774 API int pkgmgr_pkginfo_get_package_size(pkgmgr_pkginfo_h handle, int *size)
2777 ret = pkgmgrinfo_pkginfo_get_package_size(handle, size);
2781 API int pkgmgr_pkginfo_get_icon(pkgmgr_pkginfo_h handle, char **icon)
2784 ret = pkgmgrinfo_pkginfo_get_icon(handle, icon);
2788 API int pkgmgr_pkginfo_get_label(pkgmgr_pkginfo_h handle, char **label)
2791 ret = pkgmgrinfo_pkginfo_get_label(handle, label);
2795 API int pkgmgr_pkginfo_get_description(pkgmgr_pkginfo_h handle, char **description)
2798 ret = pkgmgrinfo_pkginfo_get_description(handle, description);
2802 API int pkgmgr_pkginfo_get_author_name(pkgmgr_pkginfo_h handle, char **author_name)
2805 ret = pkgmgrinfo_pkginfo_get_author_name(handle, author_name);
2809 API int pkgmgr_pkginfo_get_author_email(pkgmgr_pkginfo_h handle, char **author_email)
2812 ret = pkgmgrinfo_pkginfo_get_author_email(handle, author_email);
2816 API int pkgmgr_pkginfo_get_author_href(pkgmgr_pkginfo_h handle, char **author_href)
2819 ret = pkgmgrinfo_pkginfo_get_author_href(handle, author_href);
2823 API int pkgmgr_pkginfo_is_removable(pkgmgr_pkginfo_h handle, bool *removable)
2826 ret = pkgmgrinfo_pkginfo_is_removable(handle, removable);
2830 API int pkgmgr_pkginfo_is_preload(pkgmgr_pkginfo_h handle, bool *preload)
2833 ret = pkgmgrinfo_pkginfo_is_preload(handle, preload);
2837 API int pkgmgr_pkginfo_is_readonly(pkgmgr_pkginfo_h handle, bool *readonly)
2840 ret = pkgmgrinfo_pkginfo_is_readonly(handle, readonly);
2844 API int pkgmgr_pkginfo_is_for_all_users(pkgmgr_pkginfo_h handle, bool *for_all_users)
2847 ret = pkgmgrinfo_pkginfo_is_for_all_users(handle, for_all_users);
2851 API int pkgmgr_pkginfo_is_accessible(pkgmgr_pkginfo_h handle, bool *accessible)
2854 ret = pkgmgrinfo_pkginfo_is_accessible(handle, accessible);
2858 API int pkgmgr_pkginfo_destroy_pkginfo(pkgmgr_pkginfo_h handle)
2861 ret = pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2865 API int pkgmgr_pkginfo_get_installed_storage(pkgmgr_pkginfo_h handle, pkgmgr_installed_storage *storage)
2868 pkgmgrinfo_installed_storage sto;
2869 ret = pkgmgrinfo_pkginfo_get_installed_storage(handle, &sto);
2874 API int pkgmgr_pkginfo_get_installed_time(pkgmgr_pkginfo_h handle, int *installed_time)
2877 ret = pkgmgrinfo_pkginfo_get_installed_time(handle, installed_time);
2881 API int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
2882 pkgmgr_info_app_list_cb app_func, void *user_data)
2885 ret = pkgmgrinfo_appinfo_get_list(handle, component, app_func, user_data);
2889 API int pkgmgr_appinfo_get_usr_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
2890 pkgmgr_info_app_list_cb app_func, void *user_data, uid_t uid)
2893 ret = pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, uid);
2897 API int pkgmgr_appinfo_foreach_category(pkgmgr_appinfo_h handle, pkgmgr_info_app_category_list_cb category_func,
2901 ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, user_data);
2905 API int pkgmgr_appinfo_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle)
2908 ret = pkgmgrinfo_appinfo_get_appinfo(appid, handle);
2912 API int pkgmgr_appinfo_get_appid(pkgmgr_appinfo_h handle, char **appid)
2915 ret = pkgmgrinfo_appinfo_get_appid(handle, appid);
2919 API int pkgmgr_appinfo_get_pkgname(pkgmgr_appinfo_h handle, char **pkg_name)
2922 ret = pkgmgrinfo_appinfo_get_pkgname(handle, pkg_name);
2926 API int pkgmgr_appinfo_get_pkgid(pkgmgr_appinfo_h handle, char **pkgid)
2929 ret = pkgmgrinfo_appinfo_get_pkgid(handle, pkgid);
2933 API int pkgmgr_appinfo_get_icon(pkgmgr_appinfo_h handle, char **icon)
2936 ret = pkgmgrinfo_appinfo_get_icon(handle, icon);
2940 API int pkgmgr_appinfo_get_label(pkgmgr_appinfo_h handle, char **label)
2943 ret = pkgmgrinfo_appinfo_get_label(handle, label);
2947 API int pkgmgr_appinfo_get_exec(pkgmgr_appinfo_h handle, char **exec)
2950 ret = pkgmgrinfo_appinfo_get_exec(handle, exec);
2954 API int pkgmgr_appinfo_get_component(pkgmgr_appinfo_h handle, pkgmgr_app_component *component)
2957 pkgmgrinfo_app_component comp;
2958 ret = pkgmgrinfo_appinfo_get_component(handle, &comp);
2963 API int pkgmgr_appinfo_get_apptype(pkgmgr_appinfo_h handle, char **app_type)
2966 ret = pkgmgrinfo_appinfo_get_apptype(handle, app_type);
2970 API int pkgmgr_appinfo_is_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay)
2973 ret = pkgmgrinfo_appinfo_is_nodisplay(handle, nodisplay);
2977 API int pkgmgr_appinfo_is_multiple(pkgmgr_appinfo_h handle, bool *multiple)
2980 ret = pkgmgrinfo_appinfo_is_multiple(handle, multiple);
2984 API int pkgmgr_appinfo_is_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage)
2987 ret = pkgmgrinfo_appinfo_is_taskmanage(handle, taskmanage);
2991 API int pkgmgr_appinfo_get_hwacceleration(pkgmgr_appinfo_h handle, pkgmgr_hwacceleration_type *hwacceleration)
2994 pkgmgrinfo_app_hwacceleration hwacc;
2995 ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
2996 *hwacceleration = hwacc;
3000 API int pkgmgr_appinfo_is_onboot(pkgmgr_appinfo_h handle, bool *onboot)
3003 ret = pkgmgrinfo_appinfo_is_onboot(handle, onboot);
3007 API int pkgmgr_appinfo_is_autorestart(pkgmgr_appinfo_h handle, bool *autorestart)
3010 ret = pkgmgrinfo_appinfo_is_autorestart(handle, autorestart);
3014 API int pkgmgr_appinfo_destroy_appinfo(pkgmgr_appinfo_h handle)
3017 ret = pkgmgrinfo_appinfo_destroy_appinfo(handle);
3021 API int pkgmgr_pkginfo_create_certinfo(pkgmgr_certinfo_h *handle)
3024 ret = pkgmgrinfo_pkginfo_create_certinfo(handle);
3028 API int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle)
3031 ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle);
3035 API int pkgmgr_pkginfo_get_cert_value(pkgmgr_certinfo_h handle, pkgmgr_cert_type cert_type, const char **cert_value)
3038 ret = pkgmgrinfo_pkginfo_get_cert_value(handle, cert_type, cert_value);
3042 API int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle)
3045 ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
3049 API int pkgmgr_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
3052 ret = pkgmgrinfo_datacontrol_get_info(providerid, type, appid, access);