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>
40 /* For multi-user support */
41 #include <tzplatform_config.h>
43 #include "package-manager.h"
44 #include "pkgmgr-internal.h"
45 #include "pkgmgr-debug.h"
46 #include "pkgmgr-api.h"
47 #include "comm_client.h"
48 #include "comm_status_broadcast_server.h"
50 #define PKG_TMP_PATH tzplatform_mkpath(TZ_USER_APP, "tmp")
52 #define BINSH_NAME "/bin/sh"
55 #define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
57 static int _get_request_id()
59 static int internal_req_id = 1;
61 return internal_req_id++;
64 typedef struct _req_cb_info {
67 pkgmgr_handler event_cb;
69 struct _req_cb_info *next;
72 typedef struct _listen_cb_info {
74 pkgmgr_handler event_cb;
76 struct _listen_cb_info *next;
79 typedef struct _pkgmgr_client_t {
89 listen_cb_info *lhead;
98 typedef struct _iter_data {
99 pkgmgr_iter_fn iter_fn;
103 static int __xsystem(const char *argv[])
110 perror("fork failed");
114 execvp(argv[0], (char *const *)argv);
120 if (waitpid(pid, &status, 0) == -1) {
121 perror("waitpid failed");
124 if (WIFSIGNALED(status)) {
128 if (!WIFEXITED(status)) {
129 /* shouldn't happen */
130 perror("should not happen");
133 return WEXITSTATUS(status);
136 static void __error_to_string(int errnumber, char **errstr)
141 case PKGCMD_ERR_PACKAGE_NOT_FOUND:
142 *errstr = PKGCMD_ERR_PACKAGE_NOT_FOUND_STR;
144 case PKGCMD_ERR_PACKAGE_INVALID:
145 *errstr = PKGCMD_ERR_PACKAGE_INVALID_STR;
147 case PKGCMD_ERR_PACKAGE_LOWER_VERSION:
148 *errstr = PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR;
150 case PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND:
151 *errstr = PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR;
153 case PKGCMD_ERR_MANIFEST_INVALID:
154 *errstr = PKGCMD_ERR_MANIFEST_INVALID_STR;
156 case PKGCMD_ERR_CONFIG_NOT_FOUND:
157 *errstr = PKGCMD_ERR_CONFIG_NOT_FOUND_STR;
159 case PKGCMD_ERR_CONFIG_INVALID:
160 *errstr = PKGCMD_ERR_CONFIG_INVALID_STR;
162 case PKGCMD_ERR_SIGNATURE_NOT_FOUND:
163 *errstr = PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR;
165 case PKGCMD_ERR_SIGNATURE_INVALID:
166 *errstr = PKGCMD_ERR_SIGNATURE_INVALID_STR;
168 case PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED:
169 *errstr = PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR;
171 case PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND:
172 *errstr = PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR;
174 case PKGCMD_ERR_CERTIFICATE_INVALID:
175 *errstr = PKGCMD_ERR_CERTIFICATE_INVALID_STR;
177 case PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED:
178 *errstr = PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR;
180 case PKGCMD_ERR_CERTIFICATE_EXPIRED:
181 *errstr = PKGCMD_ERR_CERTIFICATE_EXPIRED_STR;
183 case PKGCMD_ERR_INVALID_PRIVILEGE:
184 *errstr = PKGCMD_ERR_INVALID_PRIVILEGE_STR;
186 case PKGCMD_ERR_MENU_ICON_NOT_FOUND:
187 *errstr = PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR;
189 case PKGCMD_ERR_FATAL_ERROR:
190 *errstr = PKGCMD_ERR_FATAL_ERROR_STR;
192 case PKGCMD_ERR_OUT_OF_STORAGE:
193 *errstr = PKGCMD_ERR_OUT_OF_STORAGE_STR;
195 case PKGCMD_ERR_OUT_OF_MEMORY:
196 *errstr = PKGCMD_ERR_OUT_OF_MEMORY_STR;
198 case PKGCMD_ERR_ARGUMENT_INVALID:
199 *errstr = PKGCMD_ERR_ARGUMENT_INVALID_STR;
202 *errstr = PKGCMD_ERR_UNKNOWN_STR;
207 static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
208 const char *req_key, pkgmgr_handler event_cb, void *new_event_cb,
211 req_cb_info *cb_info;
212 req_cb_info *current;
215 cb_info = (req_cb_info *) calloc(1, sizeof(req_cb_info));
216 if (cb_info == NULL) {
217 DBG("calloc failed");
220 cb_info->request_id = request_id;
221 cb_info->req_key = strdup(req_key);
222 cb_info->event_cb = event_cb;
223 cb_info->data = data;
224 cb_info->next = NULL;
225 pc->new_event_cb = new_event_cb;
227 if (pc->info.request.rhead == NULL)
228 pc->info.request.rhead = cb_info;
230 current = prev = pc->info.request.rhead;
233 current = current->next;
236 prev->next = cb_info;
240 static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
244 tmp = pc->info.request.rhead;
251 DBG("tmp->req_key %s, req_key %s", tmp->req_key, req_key);
254 if (strncmp(tmp->req_key, req_key, strlen(tmp->req_key)) == 0)
261 static void __remove_op_cbinfo(pkgmgr_client_t *pc, req_cb_info *info)
265 if (pc == NULL || pc->info.request.rhead == NULL || info == NULL)
268 tmp = pc->info.request.rhead;
270 if (tmp->next == info) {
271 tmp->next = info->next;
280 static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
281 pkgmgr_handler event_cb, void *data)
283 listen_cb_info *cb_info;
284 listen_cb_info *current;
285 listen_cb_info *prev;
287 cb_info = (listen_cb_info *) calloc(1, sizeof(listen_cb_info));
288 if (cb_info == NULL) {
289 DBG("calloc failed");
292 cb_info->request_id = request_id;
293 cb_info->event_cb = event_cb;
294 cb_info->data = data;
295 cb_info->next = NULL;
297 /* TODO - check the order of callback - FIFO or LIFO => Should be changed to LIFO */
298 if (pc->info.listening.lhead == NULL)
299 pc->info.listening.lhead = cb_info;
301 current = prev = pc->info.listening.lhead;
304 current = current->next;
307 prev->next = cb_info;
311 static void __operation_callback(void *cb_data, uid_t target_uid,
312 const char *req_id, const char *pkg_type,
313 const char *pkgid, const char *key,
317 req_cb_info *cb_info;
319 DBG("__operation_callback() target_uid[%u] req_id[%s] pkg_type[%s] "
320 "pkgid[%s] key[%s] val[%s]\n",
321 target_uid, req_id, pkg_type, pkgid, key, val);
323 pc = (pkgmgr_client_t *) cb_data;
325 /* find callback info */
326 cb_info = __find_op_cbinfo(pc, req_id);
330 DBG("__find_op_cbinfo");
333 if (cb_info->event_cb) {
334 if (pc->new_event_cb) {
335 cb_info->event_cb(target_uid, cb_info->request_id,
336 pkg_type, pkgid, key, val, pc,
339 cb_info->event_cb(target_uid, cb_info->request_id,
340 pkg_type, pkgid, key, val, NULL,
343 DBG("event_cb is called");
346 /*remove callback for last call
347 if (strcmp(key, "end") == 0) {
348 __remove_op_cbinfo(pc, cb_info);
349 DBG("__remove_op_cbinfo");
356 static void __status_callback(void *cb_data, uid_t target_uid,
357 const char *req_id, const char *pkg_type,
358 const char *pkgid, const char *key,
364 DBG("__status_callback() target_uid[%u] req_id[%s] pkg_type[%s] "
365 "pkgid[%s] key[%s] val[%s]\n", target_uid, req_id, pkg_type,
368 pc = (pkgmgr_client_t *) cb_data;
370 tmp = pc->info.listening.lhead;
372 if (tmp->event_cb(target_uid, tmp->request_id, pkg_type, pkgid,
373 key, val, NULL, tmp->data) != 0)
381 static char *__get_req_key(const char *pkg_path)
385 char timestr[PKG_STRING_LEN_MAX];
389 gettimeofday(&tv, NULL);
390 curtime = tv.tv_sec * 1000000 + tv.tv_usec;
391 snprintf(timestr, sizeof(timestr), "%ld", curtime);
393 size = strlen(pkg_path) + strlen(timestr) + 2;
394 str_req_key = (char *)calloc(size, sizeof(char));
395 if (str_req_key == NULL) {
396 DBG("calloc failed");
399 snprintf(str_req_key, size, "%s_%s", pkg_path, timestr);
404 static char *__get_type_from_path(const char *pkg_path)
407 char mimetype[255] = { '\0', };
408 char extlist[256] = { '\0', };
411 ret = _get_mime_from_file(pkg_path, mimetype, sizeof(mimetype));
413 ERR("_get_mime_from_file() failed - error code[%d]\n",
418 ret = _get_mime_extension(mimetype, extlist, sizeof(extlist));
420 ERR("_get_mime_extension() failed - error code[%d]\n",
425 if (strlen(extlist) == 0)
428 if (strchr(extlist, ',')) {
429 extlist[strlen(extlist) - strlen(strchr(extlist, ','))] = '\0';
431 pkg_type = strchr(extlist, '.') + 1;
432 return strdup(pkg_type);
435 static int __get_pkgid_by_appid(const char *appid, char **pkgid)
437 pkgmgrinfo_appinfo_h pkgmgrinfo_appinfo = NULL;
440 char *pkg_id_dup = NULL;
442 if (pkgmgrinfo_appinfo_get_appinfo(appid, &pkgmgrinfo_appinfo) != PMINFO_R_OK)
445 if (pkgmgrinfo_appinfo_get_pkgname(pkgmgrinfo_appinfo, &pkg_id) != PMINFO_R_OK)
448 pkg_id_dup = strdup(pkg_id);
449 if (pkg_id_dup == NULL)
456 pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo);
461 static inline ail_cb_ret_e __appinfo_cb(const ail_appinfo_h appinfo, void *user_data)
464 ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
466 ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
469 (* (char **) user_data) = strdup(package);
470 ret = AIL_CB_RET_CANCEL;
476 static char *__get_app_info_from_db_by_apppath(const char *apppath, uid_t uid)
478 char *caller_appid = NULL;
486 ret = ail_filter_new(&filter);
487 if (ret != AIL_ERROR_OK) {
491 ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_EXE_PATH, apppath);
492 if (ret != AIL_ERROR_OK) {
493 ail_filter_destroy(filter);
497 if(uid != GLOBAL_USER)
498 ret = ail_filter_count_usr_appinfo(filter, &count, uid);
500 ret = ail_filter_count_appinfo(filter, &count);
502 if (ret != AIL_ERROR_OK) {
503 ail_filter_destroy(filter);
507 ail_filter_destroy(filter);
510 if(uid != GLOBAL_USER)
511 ail_filter_list_usr_appinfo_foreach(filter, __appinfo_cb, &caller_appid,uid);
513 ail_filter_list_appinfo_foreach(filter, __appinfo_cb, &caller_appid);
515 ail_filter_destroy(filter);
520 static inline int __read_proc(const char *path, char *buf, int size)
525 if (buf == NULL || path == NULL)
528 fd = open(path, O_RDONLY);
532 ret = read(fd, buf, size - 1);
544 char *__proc_get_cmdline_bypid(int pid)
546 char buf[PKG_STRING_LEN_MAX] = {'\0', };
549 snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
550 ret = __read_proc(buf, buf, sizeof(buf));
554 /* support app launched by shell script*/
555 if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0)
556 return strdup(&buf[BINSH_SIZE + 1]);
561 static int __get_appid_bypid(int pid, char *pkgname, int len, uid_t uid)
563 char *cmdline = NULL;
564 char *caller_appid = NULL;
566 cmdline = __proc_get_cmdline_bypid(pid);
570 caller_appid = __get_app_info_from_db_by_apppath(cmdline, uid);
571 snprintf(pkgname, len, "%s", caller_appid);
579 static char *__get_caller_pkgid(uid_t uid)
581 char *caller_appid[PKG_STRING_LEN_MAX] = {0, };
582 char *caller_pkgid = NULL;
584 if (__get_appid_bypid(getpid(), caller_appid, sizeof(caller_appid), uid) < 0) {
585 ERR("get appid fail!!!\n");
588 if (__get_pkgid_by_appid(caller_appid, &caller_pkgid) < 0){
589 ERR("get pkgid fail!!!\n");
596 static inline int __pkgmgr_read_proc(const char *path, char *buf, int size)
601 if (buf == NULL || path == NULL)
604 fd = open(path, O_RDONLY);
608 ret = read(fd, buf, size - 1);
620 static inline int __pkgmgr_find_pid_by_cmdline(const char *dname,
621 const char *cmdline, const char *apppath)
625 if (strncmp(cmdline, apppath, PKG_STRING_LEN_MAX-1) == 0) {
627 if (pid != getpgid(pid))
635 static int __pkgmgr_proc_iter_kill_cmdline(const char *apppath)
638 struct dirent *dentry;
641 char buf[PKG_STRING_LEN_MAX];
643 dp = opendir("/proc");
648 while ((dentry = readdir(dp)) != NULL) {
649 if (!isdigit(dentry->d_name[0]))
652 snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
653 ret = __pkgmgr_read_proc(buf, buf, sizeof(buf));
657 pid = __pkgmgr_find_pid_by_cmdline(dentry->d_name, buf, apppath);
668 if (killpg(pgid, SIGKILL) < 0) {
680 static int __app_list_cb (const pkgmgr_appinfo_h handle,
684 pkgmgr_appinfo_get_exec(handle, &exec);
686 __pkgmgr_proc_iter_kill_cmdline(exec);
691 static int __sync_process(char *req_key)
693 char info_file[PKG_STRING_LEN_MAX] = {'\0', };
697 snprintf(info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_TMP_PATH, req_key);
702 vconf_get_int(VCONFKEY_PKGMGR_STATUS, &result);
704 DBG("file is not generated yet.... wait\n");
705 usleep(10 * 1000); /* 10ms sleep*/
707 DBG("info_file file is generated, result = %d. \n", result);
711 if (check_cnt > 6000) { /* 60s time over*/
712 DBG("wait time over!!\n");
717 vconf_set_int(VCONFKEY_PKGMGR_STATUS, -1);
721 static int __csc_process(const char *csc_path, char *result_path)
728 char *pkgtype = NULL;
730 char buf[PKG_STRING_LEN_MAX] = {0,};
731 char type_buf[1024] = { 0 };
732 char des_buf[1024] = { 0 };
733 dictionary *csc = NULL;
736 csc = iniparser_load(csc_path);
737 retvm_if(csc == NULL, PKGMGR_R_EINVAL, "cannot open parse file [%s]", csc_path);
739 file = fopen(result_path, "w");
740 tryvm_if(file == NULL, ret = PKGMGR_R_EINVAL, "cannot open result file [%s]", result_path);
742 count = iniparser_getint(csc, "csc packages:count", -1);
743 tryvm_if(count == 0, ret = PKGMGR_R_ERROR, "csc [%s] dont have packages", csc_path);
745 snprintf(buf, PKG_STRING_LEN_MAX, "[result]\n");
746 fwrite(buf, 1, strlen(buf), file);
747 snprintf(buf, PKG_STRING_LEN_MAX, "count = %d\n", count);
748 fwrite(buf, 1, strlen(buf), file);
750 for(cnt = 1 ; cnt <= count ; cnt++)
752 snprintf(type_buf, PKG_STRING_LEN_MAX - 1, "csc packages:type_%03d", cnt);
753 snprintf(des_buf, PKG_STRING_LEN_MAX - 1, "csc packages:description_%03d", cnt);
755 pkgtype = iniparser_getstring(csc, type_buf, NULL);
756 des = iniparser_getstring(csc, des_buf, NULL);
759 if (pkgtype == NULL) {
761 snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get pkgtype\n", type_buf);
762 fwrite(buf, 1, strlen(buf), file);
764 } else if (des == NULL) {
766 snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get description\n", des_buf);
767 fwrite(buf, 1, strlen(buf), file);
771 snprintf(buf, PKG_STRING_LEN_MAX, "type_%03d = %s\n", cnt, pkgtype);
772 fwrite(buf, 1, strlen(buf), file);
773 snprintf(buf, PKG_STRING_LEN_MAX, "description_%03d = %s\n", cnt, des);
774 fwrite(buf, 1, strlen(buf), file);
776 if (strcmp(pkgtype, "tpk") == 0) {
777 const char *ospinstaller_argv[] = { "/usr/bin/osp-installer", "-c", des, NULL };
778 ret = __xsystem(ospinstaller_argv);
779 } else if (strcmp(pkgtype, "wgt")== 0) {
780 const char *wrtinstaller_argv[] = { "/usr/bin/wrt-installer", "-c", des, NULL };
781 ret = __xsystem(wrtinstaller_argv);
789 __error_to_string(ret, &errstr);
790 snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = fail[%s]\n", cnt, errstr);
793 snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = success\n", cnt);
795 fwrite(buf, 1, strlen(buf), file);
799 iniparser_freedict(csc);
809 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)
811 char *req_key = NULL;
813 char *pkgtype = "rpm";
814 char *argv[PKG_ARGC_MAX] = { NULL, };
820 char buf[128] = {'\0'};
822 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
823 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
825 req_key = __get_req_key(pkgid);
827 snprintf(buf, 128, "%d", get_type);
828 argv[argcnt++] = strdup(pkgid);
829 argv[argcnt++] = strdup(buf);
831 /*** add quote in all string for special charactor like '\n'*** FIX */
832 for (i = 0; i < argcnt; i++) {
833 temp = g_shell_quote(argv[i]);
834 len += (strlen(temp) + 1);
838 args = (char *)calloc(len, sizeof(char));
839 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
841 strncpy(args, argv[0], len - 1);
843 for (i = 1; i < argcnt; i++) {
844 strncat(args, " ", strlen(" "));
845 temp = g_shell_quote(argv[i]);
846 strncat(args, temp, strlen(temp));
849 DBG("[args] %s [len] %d\n", args, len);
852 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, uid, 1);
854 ERR("comm_client_request failed, ret=%d\n", ret);
856 ret = __sync_process(req_key);
858 ERR("get size failed, ret=%d\n", ret);
861 for (i = 0; i < argcnt; i++)
870 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)
872 char *req_key = NULL;
875 pkgmgrinfo_pkginfo_h handle;
876 char *pkgtype = NULL;
877 char *installer_path = NULL;
878 char *argv[PKG_ARGC_MAX] = { NULL, };
884 char buf[128] = {'\0'};
885 char info_file[PKG_STRING_LEN_MAX] = {'\0', };
887 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
888 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
890 if(uid != GLOBAL_USER)
891 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
893 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
894 retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
896 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
897 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
899 installer_path = _get_backend_path_with_type(pkgtype);
900 req_key = __get_req_key(pkgid);
901 req_id = _get_request_id();
904 snprintf(buf, 128, "%d", move_type);
905 /* argv[0] installer path */
906 argv[argcnt++] = installer_path;
908 argv[argcnt++] = strdup("-k");
910 argv[argcnt++] = req_key;
912 argv[argcnt++] = strdup("-m");
914 argv[argcnt++] = strdup(pkgid);
916 argv[argcnt++] = strdup("-t");
918 argv[argcnt++] = strdup(buf);
920 /*** add quote in all string for special charactor like '\n'*** FIX */
921 for (i = 0; i < argcnt; i++) {
922 temp = g_shell_quote(argv[i]);
923 len += (strlen(temp) + 1);
927 args = (char *)calloc(len, sizeof(char));
928 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
930 strncpy(args, argv[0], len - 1);
932 for (i = 1; i < argcnt; i++) {
933 strncat(args, " ", strlen(" "));
934 temp = g_shell_quote(argv[i]);
935 strncat(args, temp, strlen(temp));
938 DBG("[args] %s [len] %d\n", args, len);
941 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, uid, 1);
943 ERR("comm_client_request failed, ret=%d\n", ret);
945 snprintf(info_file, PKG_STRING_LEN_MAX, "app2sd_%s", pkgid);
946 ret = __sync_process(info_file);
948 ERR("move pkg failed, ret=%d\n", ret);
951 for (i = 0; i < argcnt; i++)
957 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
961 static int __check_app_process(pkgmgr_request_service_type service_type, pkgmgr_client * pc, const char *pkgid, uid_t uid, void *data)
966 pkgmgrinfo_pkginfo_h handle;
969 /* Check for NULL value of pc */
970 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
971 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
973 if (uid != GLOBAL_USER)
974 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
976 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
977 retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
979 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
980 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
982 /* 2. generate req_key */
983 req_key = __get_req_key(pkgid);
985 /* 3. request activate */
986 if (service_type == PM_REQUEST_KILL_APP)
987 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_KILL_APP, pkgtype, pkgid, NULL, uid, 1);
988 else if (service_type == PM_REQUEST_CHECK_APP)
989 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_CHECK_APP, pkgtype, pkgid, NULL, uid, 1);
992 ERR("request failed, ret=%d\n", ret);
994 pid = __sync_process(req_key);
995 * (int *) data = pid;
999 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
1005 static int __request_size_info(pkgmgr_client *pc, uid_t uid)
1007 char *req_key = NULL;
1009 char *pkgtype = "getsize";
1010 char *pkgid = "size_info";
1011 pkgmgr_getsize_type get_type = PM_GET_SIZE_INFO;
1013 char *argv[PKG_ARGC_MAX] = { NULL, };
1019 char buf[128] = {'\0'};
1021 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1022 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
1024 req_key = __get_req_key(pkgid);
1026 snprintf(buf, 128, "%d", get_type);
1027 argv[argcnt++] = strdup(pkgid);
1028 argv[argcnt++] = strdup(buf);
1029 argv[argcnt++] = strdup(buf);
1031 /*** add quote in all string for special charactor like '\n'*** FIX */
1032 for (i = 0; i < argcnt; i++) {
1033 temp = g_shell_quote(argv[i]);
1034 len += (strlen(temp) + 1);
1038 args = (char *)calloc(len, sizeof(char));
1039 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
1041 strncpy(args, argv[0], len - 1);
1043 for (i = 1; i < argcnt; i++) {
1044 strncat(args, " ", strlen(" "));
1045 temp = g_shell_quote(argv[i]);
1046 strncat(args, temp, strlen(temp));
1049 DBG("[args] %s [len] %d\n", args, len);
1052 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, uid, 1);
1054 ERR("COMM_REQ_GET_SIZE failed, ret=%d\n", ret);
1058 for (i = 0; i < argcnt; i++)
1067 static int __change_op_cb_for_getsize(pkgmgr_client *pc)
1071 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
1072 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1074 /* free listening head */
1075 req_cb_info *tmp = NULL;
1076 req_cb_info *prev = NULL;
1077 for (tmp = mpc->info.request.rhead; tmp;) {
1083 /* free dbus connection */
1084 ret = comm_client_free(mpc->info.request.cc);
1085 retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
1087 /* Manage pc for seperated event */
1088 mpc->ctype = PC_REQUEST;
1089 mpc->status_type = PKGMGR_CLIENT_STATUS_GET_SIZE;
1092 mpc->info.request.cc = comm_client_new();
1093 retvm_if(mpc->info.request.cc == NULL, PKGMGR_R_ERROR, "client creation failed");
1095 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_GET_SIZE, mpc->info.request.cc, __operation_callback, pc);
1096 retvm_if(ret < 0, PKGMGR_R_ERROR, "set_status_callback() failed - %d", ret);
1101 static int __get_package_size_info(pkgmgr_client_t *mpc, char *req_key, const char *pkgid, pkgmgr_getsize_type get_type, uid_t uid)
1103 char *argv[PKG_ARGC_MAX] = { NULL, };
1106 char *pkgtype = "getsize"; //unused
1107 char buf[128] = { 0, };
1113 snprintf(buf, 128, "%d", get_type);
1114 argv[argcnt++] = strdup(pkgid);
1115 argv[argcnt++] = strdup(buf);
1116 argv[argcnt++] = strdup("-k");
1117 argv[argcnt++] = req_key;
1119 /*** add quote in all string for special charactor like '\n'*** FIX */
1120 for (i = 0; i < argcnt; i++) {
1121 temp = g_shell_quote(argv[i]);
1122 len += (strlen(temp) + 1);
1126 args = (char *)calloc(len, sizeof(char));
1127 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
1129 strncpy(args, argv[0], len - 1);
1131 for (i = 1; i < argcnt; i++) {
1132 strncat(args, " ", strlen(" "));
1133 temp = g_shell_quote(argv[i]);
1134 strncat(args, temp, strlen(temp));
1137 DBG("[args] %s [len] %d\n", args, len);
1140 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, uid, 1);
1142 ERR("COMM_REQ_GET_SIZE failed, ret=%d\n", ret);
1145 for (i = 0; i < argcnt; i++)
1154 static int __get_pkg_size_info_cb(uid_t target_uid, int req_id, const char *req_type,
1155 const char *pkgid, const char *key,
1156 const char *value, const void *pc, void *user_data)
1159 DBG("target_uid: %u, reqid: %d, req type: %s, pkgid: %s, unused key: %s, size info: %s",
1160 target_uid, req_id, req_type, pkgid, key, value);
1162 pkg_size_info_t *size_info = (pkg_size_info_t *)malloc(sizeof(pkg_size_info_t));
1163 retvm_if(size_info == NULL, -1, "The memory is insufficient.");
1165 char *save_ptr = NULL;
1166 char *token = strtok_r((char*)value, ":", &save_ptr);
1167 size_info->data_size = atoll(token);
1168 token = strtok_r(NULL, ":", &save_ptr);
1169 size_info->cache_size = atoll(token);
1170 token = strtok_r(NULL, ":", &save_ptr);
1171 size_info->app_size = atoll(token);
1172 token = strtok_r(NULL, ":", &save_ptr);
1173 size_info->ext_data_size = atoll(token);
1174 token = strtok_r(NULL, ":", &save_ptr);
1175 size_info->ext_cache_size = atoll(token);
1176 token = strtok_r(NULL, ":", &save_ptr);
1177 size_info->ext_app_size = atoll(token);
1179 DBG("data: %lld, cache: %lld, app: %lld, ext_data: %lld, ext_cache: %lld, ext_app: %lld",
1180 size_info->data_size, size_info->cache_size, size_info->app_size,
1181 size_info->ext_data_size, size_info->ext_cache_size, size_info->ext_app_size);
1183 pkgmgr_client_t *pmc = (pkgmgr_client_t *)pc;
1184 tryvm_if(pmc == NULL, ret = -1, "pkgmgr_client instance is null.");
1186 if (strcmp(pkgid, PKG_SIZE_INFO_TOTAL) == 0)
1187 { // total package size info
1188 pkgmgr_total_pkg_size_info_receive_cb callback = (pkgmgr_total_pkg_size_info_receive_cb)(pmc->new_event_cb);
1189 callback((pkgmgr_client *)pc, size_info, user_data);
1193 pkgmgr_pkg_size_info_receive_cb callback = (pkgmgr_pkg_size_info_receive_cb)(pmc->new_event_cb);
1194 callback((pkgmgr_client *)pc, pkgid, size_info, user_data);
1206 API pkgmgr_client *pkgmgr_client_new(client_type ctype)
1208 pkgmgr_client_t *pc = NULL;
1211 retvm_if(ctype != PC_REQUEST && ctype != PC_LISTENING && ctype != PC_BROADCAST, NULL, "ctype is not client_type");
1213 /* Allocate memory for ADT:pkgmgr_client */
1214 pc = calloc(1, sizeof(pkgmgr_client_t));
1215 retvm_if(pc == NULL, NULL, "No memory");
1219 pc->status_type = PKGMGR_CLIENT_STATUS_ALL;
1221 if (pc->ctype == PC_REQUEST) {
1222 pc->info.request.cc = comm_client_new();
1223 trym_if(pc->info.request.cc == NULL, "client creation failed");
1225 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.request.cc, __operation_callback, pc);
1226 trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
1227 } else if (pc->ctype == PC_LISTENING) {
1228 pc->info.listening.cc = comm_client_new();
1229 trym_if(pc->info.listening.cc == NULL, "client creation failed");
1231 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_ALL, pc->info.listening.cc, __status_callback, pc);
1232 trym_if(ret < 0L, "comm_client_set_status_callback() failed - %d", ret);
1233 } else if (pc->ctype == PC_BROADCAST) {
1234 pc->info.broadcast.bc = comm_status_broadcast_server_connect(COMM_STATUS_BROADCAST_ALL);
1235 trym_if(pc->info.broadcast.bc == NULL, "client creation failed");
1238 return (pkgmgr_client *) pc;
1246 API int pkgmgr_client_free(pkgmgr_client *pc)
1249 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1250 retvm_if(mpc == NULL, PKGMGR_R_EINVAL, "Invalid argument");
1252 if (mpc->ctype == PC_REQUEST) {
1255 for (tmp = mpc->info.request.rhead; tmp;) {
1261 ret = comm_client_free(mpc->info.request.cc);
1262 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
1263 } else if (mpc->ctype == PC_LISTENING) {
1264 listen_cb_info *tmp;
1265 listen_cb_info *prev;
1266 for (tmp = mpc->info.listening.lhead; tmp;) {
1272 ret = comm_client_free(mpc->info.listening.cc);
1273 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "comm_client_free() failed");
1274 } else if (mpc->ctype == PC_BROADCAST) {
1275 comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
1278 ERR("Invalid client type\n");
1279 return PKGMGR_R_EINVAL;
1291 return PKGMGR_R_ERROR;
1295 API int pkgmgr_client_usr_install(pkgmgr_client * pc, const char *pkg_type,
1296 const char *descriptor_path, const char *pkg_path,
1297 const char *optional_file, pkgmgr_mode mode,
1298 pkgmgr_handler event_cb, void *data, uid_t uid)
1300 char *pkgtype = NULL;
1301 char *installer_path = NULL;
1302 char *req_key = NULL;
1305 char *argv[PKG_ARGC_MAX] = { NULL, };
1311 char *caller_pkgid = NULL;
1313 caller_pkgid = __get_caller_pkgid(uid);
1314 if (caller_pkgid == NULL)
1315 ERR("caller dont have pkgid..\n");
1317 /* Check for NULL value of pc */
1318 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL");
1320 /* 0. check the pc type */
1321 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1322 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
1324 /* 1. check argument */
1325 if (descriptor_path) {
1326 retvm_if(strlen(descriptor_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "descriptor_path over PKG_STRING_LEN_MAX");
1327 retvm_if(access(descriptor_path, F_OK) != 0, PKGMGR_R_EINVAL, "descriptor_path access fail");
1330 retvm_if(pkg_path == NULL, PKGMGR_R_EINVAL, "pkg_path is NULL");
1331 retvm_if(strlen(pkg_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkg_path over PKG_STRING_LEN_MAX");
1332 retvm_if(access(pkg_path, F_OK) != 0, PKGMGR_R_EINVAL, "pkg_path access fail");
1335 retvm_if(strlen(optional_file) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
1337 /* 2. get installer path using pkg_path */
1339 installer_path = _get_backend_path_with_type(pkg_type);
1340 pkgtype = strdup(pkg_type);
1342 installer_path = _get_backend_path(pkg_path);
1343 pkgtype = __get_type_from_path(pkg_path);
1345 if (installer_path == NULL) {
1347 ERR("installer_path is NULL\n");
1348 return PKGMGR_R_EINVAL;
1351 /* 3. generate req_key */
1352 req_key = __get_req_key(pkg_path);
1354 /* 4. add callback info - add callback info to pkgmgr_client */
1355 req_id = _get_request_id();
1356 __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
1358 /* 5. generate argv */
1360 /* argv[0] installer path */
1361 argv[argcnt++] = installer_path;
1363 argv[argcnt++] = strdup("-k");
1365 argv[argcnt++] = req_key;
1367 argv[argcnt++] = strdup("-i");
1368 /* argv[(4)] if exists */
1369 if (descriptor_path)
1370 argv[argcnt++] = strdup(descriptor_path);
1372 argv[argcnt++] = strdup(pkg_path);
1373 /* argv[(5)] if exists */
1375 argv[argcnt++] = strdup("-o");
1376 argv[argcnt++] = strdup(optional_file);
1379 argv[argcnt++] = strdup("-p");
1380 argv[argcnt++] = strdup(caller_pkgid);
1383 /*** add quote in all string for special charactor like '\n'*** FIX */
1384 for (i = 0; i < argcnt; i++) {
1385 temp = g_shell_quote(argv[i]);
1386 len += (strlen(temp) + 1);
1390 args = (char *)calloc(len, sizeof(char));
1391 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1393 strncpy(args, argv[0], len - 1);
1395 for (i = 1; i < argcnt; i++) {
1396 strncat(args, " ", strlen(" "));
1397 temp = g_shell_quote(argv[i]);
1398 strncat(args, temp, strlen(temp));
1401 DBG("[args] %s [len] %d\n", args, len);
1403 /******************* end of quote ************************/
1405 /* 6. request install */
1406 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkg_path, args, uid, 1);
1407 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
1412 for (i = 0; i < argcnt; i++)
1425 API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
1426 const char *descriptor_path, const char *pkg_path,
1427 const char *optional_file, pkgmgr_mode mode,
1428 pkgmgr_handler event_cb, void *data)
1432 return pkgmgr_client_usr_install(pc, pkg_type,
1433 descriptor_path, pkg_path, optional_file, mode, event_cb,data, GLOBAL_USER);
1436 API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
1437 const char *optional_file, pkgmgr_mode mode,
1438 pkgmgr_handler event_cb, void *data)
1440 return pkgmgr_client_usr_reinstall(pc, pkg_type, pkgid, optional_file, mode, event_cb, data,GLOBAL_USER);
1443 API int pkgmgr_client_usr_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
1444 const char *optional_file, pkgmgr_mode mode,
1445 pkgmgr_handler event_cb, void *data, uid_t uid)
1447 char *pkgtype = NULL;
1448 char *installer_path = NULL;
1449 char *req_key = NULL;
1452 char *argv[PKG_ARGC_MAX] = { NULL, };
1459 /* Check for NULL value of pc */
1460 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1462 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1464 /* 0. check the pc type */
1465 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1468 /* 1. check argument */
1469 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1470 retv_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL);
1471 if (optional_file) {
1472 if (strlen(optional_file) >= PKG_STRING_LEN_MAX)
1473 return PKGMGR_R_EINVAL;
1476 /* 2. get installer path using pkg_path */
1477 installer_path = _get_backend_path_with_type(pkg_type);
1478 pkgtype = strdup(pkg_type);
1479 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path is null");
1481 /* 3. generate req_key */
1482 req_key = __get_req_key(pkgid);
1484 /* 4. add callback info - add callback info to pkgmgr_client */
1485 req_id = _get_request_id();
1486 __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
1488 /* 5. generate argv */
1490 /* argv[0] installer path */
1491 argv[argcnt++] = installer_path;
1493 argv[argcnt++] = strdup("-k");
1495 argv[argcnt++] = req_key;
1497 argv[argcnt++] = strdup("-r");
1499 argv[argcnt++] = strdup(pkgid);
1500 /* argv[(5)] if exists */
1502 argv[argcnt++] = strdup("-o");
1503 argv[argcnt++] = strdup(optional_file);
1506 /*** add quote in all string for special charactor like '\n'*** FIX */
1507 for (i = 0; i < argcnt; i++) {
1508 temp = g_shell_quote(argv[i]);
1509 len += (strlen(temp) + 1);
1513 args = (char *)calloc(len, sizeof(char));
1514 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1516 strncpy(args, argv[0], len - 1);
1518 for (i = 1; i < argcnt; i++) {
1519 strncat(args, " ", strlen(" "));
1520 temp = g_shell_quote(argv[i]);
1521 strncat(args, temp, strlen(temp));
1524 DBG("[args] %s [len] %d\n", args, len);
1526 /******************* end of quote ************************/
1528 /* 6. request install */
1529 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, uid, 1);
1530 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed");
1535 for (i = 0; i < argcnt; i++)
1546 API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
1547 const char *pkgid, pkgmgr_mode mode,
1548 pkgmgr_handler event_cb, void *data)
1550 return pkgmgr_client_usr_uninstall(pc, pkg_type,pkgid, mode, event_cb, data, GLOBAL_USER);
1552 API int pkgmgr_client_usr_uninstall(pkgmgr_client *pc, const char *pkg_type,
1553 const char *pkgid, pkgmgr_mode mode,
1554 pkgmgr_handler event_cb, void *data, uid_t uid)
1557 char *installer_path;
1561 char *argv[PKG_ARGC_MAX] = { NULL, };
1567 bool removable = false;
1568 char *caller_pkgid = NULL;
1570 caller_pkgid = __get_caller_pkgid(uid);
1571 if (caller_pkgid == NULL)
1572 DBG("caller dont have pkgid..\n");
1574 /* Check for NULL value of pc */
1575 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1577 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1579 /* 0. check the pc type */
1580 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1582 /* 1. check argument */
1583 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1585 pkgmgr_pkginfo_h handle;
1586 ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1588 /*check package id */
1589 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
1590 tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
1592 if (uid != GLOBAL_USER) {
1593 /*check running app , terminate app if it is running*/
1594 ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, __app_list_cb, NULL, uid);
1595 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1597 /*check running app , terminate app if it is running*/
1598 ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, __app_list_cb, NULL, uid);
1599 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1601 /*check running app , terminate app if it is running*/
1602 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
1603 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1605 /*check running app , terminate app if it is running*/
1606 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
1607 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1610 ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
1611 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
1612 tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
1614 /*check removable, execpt "rpm" type */
1615 if (strcmp(pkgtype, "rpm")) {
1616 pkgmgr_pkginfo_is_removable(handle, &removable);
1617 tryvm_if(removable == false, ret = PKGMGR_R_ERROR, "Pkgid(%s) can not be removed, This is non-removalbe package...\n", pkgid);
1620 /*check pkgid length */
1621 tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
1623 /* 2. get installer path using pkgtype */
1624 installer_path = _get_backend_path_with_type(pkgtype);
1625 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
1627 /* 3. generate req_key */
1628 req_key = __get_req_key(pkgid);
1630 /* 4. add callback info - add callback info to pkgmgr_client */
1631 req_id = _get_request_id();
1632 __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
1634 /* 5. generate argv */
1636 /* argv[0] installer path */
1637 argv[argcnt++] = installer_path;
1639 argv[argcnt++] = strdup("-k");
1641 argv[argcnt++] = req_key;
1643 argv[argcnt++] = strdup("-d");
1645 argv[argcnt++] = strdup(pkgid);
1647 argv[argcnt++] = strdup("-p");
1648 argv[argcnt++] = caller_pkgid;
1651 /*** add quote in all string for special charactor like '\n'*** FIX */
1652 for (i = 0; i < argcnt; i++) {
1653 temp = g_shell_quote(argv[i]);
1654 len += (strlen(temp) + 1);
1658 args = (char *)calloc(len, sizeof(char));
1659 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1661 strncpy(args, argv[0], len - 1);
1663 for (i = 1; i < argcnt; i++) {
1664 strncat(args, " ", strlen(" "));
1665 temp = g_shell_quote(argv[i]);
1666 strncat(args, temp, strlen(temp));
1669 DBG("[args] %s [len] %d\n", args, len);
1671 /******************* end of quote ************************/
1673 /* 6. request install */
1674 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, uid, 1);
1675 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
1680 for (i = 0; i < argcnt; i++)
1686 pkgmgr_pkginfo_destroy_pkginfo(handle);
1690 API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkg_type,
1691 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode)
1693 return pkgmgr_client_usr_move( pc,pkg_type, pkgid, move_type, mode, GLOBAL_USER);
1695 API int pkgmgr_client_usr_move(pkgmgr_client *pc, const char *pkg_type,
1696 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode, uid_t uid)
1698 const char *pkgtype = NULL;
1699 char *installer_path = NULL;
1700 char *req_key = NULL;
1702 char *argv[PKG_ARGC_MAX] = { NULL, };
1709 char buf[128] = {'\0'};
1711 /* Check for NULL value of pc */
1713 DBG("package manager client handle is NULL\n");
1714 return PKGMGR_R_EINVAL;
1716 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1717 /*check the pc type */
1718 if (mpc->ctype != PC_REQUEST)
1719 return PKGMGR_R_EINVAL;
1723 return PKGMGR_R_EINVAL;
1725 if (pkg_type == NULL) {
1726 pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid);
1727 if (pkgtype == NULL)
1728 return PKGMGR_R_EINVAL;
1732 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1733 return PKGMGR_R_EINVAL;
1735 if ((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD))
1736 return PKGMGR_R_EINVAL;
1738 /* get installer path using pkg_path */
1739 installer_path = _get_backend_path_with_type(pkgtype);
1740 if (installer_path == NULL)
1741 return PKGMGR_R_EINVAL;
1743 /* generate req_key */
1744 req_key = __get_req_key(pkgid);
1745 req_id = _get_request_id();
1748 snprintf(buf, 128, "%d", move_type);
1749 /* argv[0] installer path */
1750 argv[argcnt++] = installer_path;
1752 argv[argcnt++] = strdup("-k");
1754 argv[argcnt++] = req_key;
1756 argv[argcnt++] = strdup("-m");
1758 argv[argcnt++] = strdup(pkgid);
1760 argv[argcnt++] = strdup("-t");
1762 argv[argcnt++] = strdup(buf);
1764 /*** add quote in all string for special charactor like '\n'*** FIX */
1765 for (i = 0; i < argcnt; i++) {
1766 temp = g_shell_quote(argv[i]);
1767 len += (strlen(temp) + 1);
1771 args = (char *)calloc(len, sizeof(char));
1773 DBG("calloc failed");
1775 for (i = 0; i < argcnt; i++)
1778 return PKGMGR_R_ERROR;
1780 strncpy(args, argv[0], len - 1);
1782 for (i = 1; i < argcnt; i++) {
1783 strncat(args, " ", strlen(" "));
1784 temp = g_shell_quote(argv[i]);
1785 strncat(args, temp, strlen(temp));
1788 DBG("[args] %s [len] %d\n", args, len);
1789 /******************* end of quote ************************/
1791 /* 6. request install */
1792 ret = comm_client_request(mpc->info.request.cc, req_key,
1793 COMM_REQ_TO_MOVER, pkgtype, pkgid,
1796 ERR("request failed, ret=%d\n", ret);
1798 for (i = 0; i < argcnt; i++)
1802 return PKGMGR_R_ECOMM;
1805 for (i = 0; i < argcnt; i++)
1814 API int pkgmgr_client_move_pkg(pkgmgr_client *pc, const char *pkg_type,
1815 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode,
1816 pkgmgr_handler event_cb, void *data)
1818 return pkgmgr_client_move_usr_pkg(pc, pkg_type, pkgid, GLOBAL_USER, move_type, mode, event_cb, data);
1821 API int pkgmgr_client_move_usr_pkg(pkgmgr_client *pc, const char *pkg_type,
1822 const char *pkgid, uid_t uid, pkgmgr_move_type move_type, pkgmgr_mode mode,
1823 pkgmgr_handler event_cb, void *data)
1826 char *installer_path;
1830 char *argv[PKG_ARGC_MAX] = { NULL, };
1836 char buf[128] = {'\0'};
1838 /* Check for NULL value of pc */
1839 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1841 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1843 /* 0. check the pc type */
1844 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1846 /* 1. check argument */
1847 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1849 pkgmgr_pkginfo_h handle;
1850 if (uid != GLOBAL_USER)
1851 ret = pkgmgr_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
1853 ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
1855 /*check package id */
1856 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
1857 tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
1859 if (uid != GLOBAL_USER) {
1860 /*check running app , terminate app if it is running*/
1861 ret = pkgmgr_appinfo_get_usr_list(handle, PM_UI_APP, __app_list_cb, NULL, uid);
1862 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1864 /*check running app , terminate app if it is running*/
1865 ret = pkgmgr_appinfo_get_usr_list(handle, PM_SVC_APP, __app_list_cb, NULL, uid);
1866 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1869 /*check running app , terminate app if it is running*/
1870 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
1871 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1872 /*check running app , terminate app if it is running*/
1873 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
1874 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1877 ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
1878 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
1879 tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
1881 /*check pkgid length */
1882 tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
1884 /*check move_type */
1885 tryvm_if((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "move_type is not supported");
1887 /* 2. get installer path using pkgtype */
1888 installer_path = _get_backend_path_with_type(pkgtype);
1889 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
1891 /* 3. generate req_key */
1892 req_key = __get_req_key(pkgid);
1894 /* 4. add callback info - add callback info to pkgmgr_client */
1895 req_id = _get_request_id();
1896 __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
1898 /* 5. generate argv */
1899 snprintf(buf, 128, "%d", move_type);
1900 /* argv[0] installer path */
1901 argv[argcnt++] = installer_path;
1903 argv[argcnt++] = strdup("-k");
1905 argv[argcnt++] = req_key;
1907 argv[argcnt++] = strdup("-m");
1909 argv[argcnt++] = strdup(pkgid);
1911 argv[argcnt++] = strdup("-t");
1913 argv[argcnt++] = strdup(buf);
1915 /*** add quote in all string for special charactor like '\n'*** FIX */
1916 for (i = 0; i < argcnt; i++) {
1917 temp = g_shell_quote(argv[i]);
1918 len += (strlen(temp) + 1);
1922 args = (char *)calloc(len, sizeof(char));
1923 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1925 strncpy(args, argv[0], len - 1);
1927 for (i = 1; i < argcnt; i++) {
1928 strncat(args, " ", strlen(" "));
1929 temp = g_shell_quote(argv[i]);
1930 strncat(args, temp, strlen(temp));
1933 DBG("[args] %s [len] %d\n", args, len);
1935 /******************* end of quote ************************/
1937 /* 6. request install */
1938 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, uid, 1);
1939 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
1944 for (i = 0; i < argcnt; i++)
1950 pkgmgr_pkginfo_destroy_pkginfo(handle);
1954 API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type,
1957 return pkgmgr_client_usr_activate(pc, pkg_type, pkgid, GLOBAL_USER);
1960 API int pkgmgr_client_usr_activate(pkgmgr_client * pc, const char *pkg_type,
1961 const char *pkgid, uid_t uid)
1963 const char *pkgtype;
1966 /* Check for NULL value of pc */
1967 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1969 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1971 /* 0. check the pc type */
1972 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
1974 /* 1. check argument */
1975 retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
1976 retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
1978 if (pkg_type == NULL) {
1979 pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid);
1980 retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
1984 /* 2. generate req_key */
1985 req_key = __get_req_key(pkgid);
1986 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
1988 /* 3. request activate */
1989 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "1 PKG", uid, 1);
1990 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
1999 API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
2002 return pkgmgr_client_usr_deactivate(pc, pkg_type, pkgid, GLOBAL_USER);
2005 API int pkgmgr_client_usr_deactivate(pkgmgr_client *pc, const char *pkg_type,
2006 const char *pkgid, uid_t uid)
2008 const char *pkgtype;
2011 /* Check for NULL value of pc */
2012 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
2014 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2016 /* 0. check the pc type */
2017 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
2019 /* 1. check argument */
2020 retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
2021 retvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
2023 if (pkg_type == NULL) {
2024 pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid);
2025 if (pkgtype == NULL)
2026 return PKGMGR_R_EINVAL;
2030 /* 2. generate req_key */
2031 req_key = __get_req_key(pkgid);
2032 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
2034 /* 3. request activate */
2035 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, pkgid, "0 PKG", uid, 1);
2036 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
2045 API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
2047 return pkgmgr_client_usr_activate_app(pc,appid, GLOBAL_USER);
2050 API int pkgmgr_client_usr_activate_app(pkgmgr_client * pc, const char *appid, uid_t uid)
2052 const char *pkgtype;
2055 /* Check for NULL value of pc */
2056 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
2058 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2060 /* 0. check the pc type */
2061 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
2063 /* 1. check argument */
2064 retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
2065 retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
2067 pkgtype = _get_pkg_type_from_desktop_file(appid, uid);
2068 retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
2070 /* 2. generate req_key */
2071 req_key = __get_req_key(appid);
2072 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
2074 /* 3. request activate */
2075 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "1 APP", uid, 1);
2076 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
2085 API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[])
2087 return pkgmgr_client_usr_activate_appv(pc, appid, argv, GLOBAL_USER);
2090 API int pkgmgr_client_usr_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[], uid_t uid)
2092 const char *pkgtype;
2101 /* Check for NULL value of pc */
2102 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
2104 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2106 /* 0. check the pc type */
2107 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
2109 /* 1. check argument */
2110 retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
2111 retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
2113 pkgtype = _get_pkg_type_from_desktop_file(appid, uid);
2114 retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
2116 /* 2. generate req_key */
2117 req_key = __get_req_key(appid);
2118 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
2120 /*** add quote in all string for special charactor like '\n'*** FIX */
2122 for (i = 0; argv[i]; i++) {
2123 temp = g_shell_quote(argv[i]);
2124 len += (strlen(temp) + 1);
2130 args = (char *)calloc(len, sizeof(char));
2131 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
2132 strncpy(args, argv[0], len - 1);
2134 for (i = 1; i < argcnt; i++) {
2135 strncat(args, " ", strlen(" "));
2136 temp = g_shell_quote(argv[i]);
2137 strncat(args, temp, strlen(temp));
2143 argsr = (char *)calloc(strlen("1 APP")+2+len, sizeof(char));
2144 tryvm_if(argsr == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
2146 strncpy(argsr, "1 APP", strlen("1 APP"));
2148 strncat(argsr, " ", strlen(" "));
2149 strncat(argsr, args, strlen(args));
2152 DBG("argsr [%s]\n", argsr);
2153 /******************* end of quote ************************/
2155 /* 3. request activate */
2156 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, argsr, uid, 1);
2157 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
2171 API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
2173 return pkgmgr_client_usr_deactivate_app(pc, appid, GLOBAL_USER);
2176 API int pkgmgr_client_usr_deactivate_app(pkgmgr_client *pc, const char *appid, uid_t uid)
2178 const char *pkgtype;
2181 /* Check for NULL value of pc */
2182 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
2184 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2186 /* 0. check the pc type */
2187 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
2189 /* 1. check argument */
2190 retvm_if(appid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL");
2191 retvm_if(strlen(appid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkgid length over PKG_STRING_LEN_MAX ");
2193 pkgtype = _get_pkg_type_from_desktop_file(appid, uid);
2194 retvm_if(pkgtype == NULL, PKGMGR_R_EINVAL, "pkgtype is NULL");
2196 /* 2. generate req_key */
2197 req_key = __get_req_key(appid);
2198 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
2200 /* 3. request activate */
2201 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_ACTIVATOR, pkgtype, appid, "0 APP", uid, 1);
2202 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
2211 API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
2212 const char *appid, pkgmgr_mode mode)
2214 return pkgmgr_client_usr_clear_user_data(pc, pkg_type, appid,mode, GLOBAL_USER);
2216 API int pkgmgr_client_usr_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
2217 const char *appid, pkgmgr_mode mode, uid_t uid)
2219 const char *pkgtype;
2220 char *installer_path;
2223 char *argv[PKG_ARGC_MAX] = { NULL, };
2230 /* Check for NULL value of pc */
2232 DBG("package manager client handle is NULL\n");
2233 return PKGMGR_R_EINVAL;
2235 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2237 /* 0. check the pc type */
2238 if (mpc->ctype != PC_REQUEST)
2239 return PKGMGR_R_EINVAL;
2241 /* 1. check argument */
2243 return PKGMGR_R_EINVAL;
2246 if (pkg_type == NULL) {
2247 pkgtype = _get_pkg_type_from_desktop_file(appid, uid);
2248 if (pkgtype == NULL)
2249 return PKGMGR_R_EINVAL;
2253 if (strlen(appid) >= PKG_STRING_LEN_MAX)
2254 return PKGMGR_R_EINVAL;
2256 /* 2. get installer path using pkg_path */
2257 installer_path = _get_backend_path_with_type(pkgtype);
2258 if (installer_path == NULL)
2259 return PKGMGR_R_EINVAL;
2261 /* 3. generate req_key */
2262 req_key = __get_req_key(appid);
2264 /* 4. generate argv */
2266 /* argv[0] installer path */
2267 argv[argcnt++] = installer_path;
2269 argv[argcnt++] = strdup("-k");
2271 argv[argcnt++] = req_key;
2273 argv[argcnt++] = strdup("-c");
2275 argv[argcnt++] = strdup(appid);
2277 /*** add quote in all string for special charactor like '\n'*** FIX */
2278 for (i = 0; i < argcnt; i++) {
2279 temp = g_shell_quote(argv[i]);
2280 len += (strlen(temp) + 1);
2284 args = (char *)calloc(len, sizeof(char));
2286 DBG("calloc failed");
2288 for (i = 0; i < argcnt; i++)
2291 return PKGMGR_R_ERROR;
2293 strncpy(args, argv[0], len - 1);
2295 for (i = 1; i < argcnt; i++) {
2296 strncat(args, " ", strlen(" "));
2297 temp = g_shell_quote(argv[i]);
2298 strncat(args, temp, strlen(temp));
2301 DBG("[args] %s [len] %d\n", args, len);
2302 /******************* end of quote ************************/
2304 /* 6. request clear */
2305 ret = comm_client_request(mpc->info.request.cc, req_key,
2306 COMM_REQ_TO_CLEARER, pkgtype, appid,
2309 ERR("request failed, ret=%d\n", ret);
2311 for (i = 0; i < argcnt; i++)
2315 return PKGMGR_R_ECOMM;
2318 for (i = 0; i < argcnt; i++)
2327 API int pkgmgr_client_set_status_type(pkgmgr_client *pc, int status_type)
2331 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
2332 retvm_if(status_type == PKGMGR_CLIENT_STATUS_ALL, PKGMGR_R_OK, "status_type is PKGMGR_CLIENT_STATUS_ALL");
2333 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2335 /* free listening head */
2336 listen_cb_info *tmp = NULL;
2337 listen_cb_info *prev = NULL;
2338 for (tmp = mpc->info.listening.lhead; tmp;) {
2344 /* free dbus connection */
2345 ret = comm_client_free(mpc->info.listening.cc);
2346 retvm_if(ret < 0, PKGMGR_R_ERROR, "comm_client_free() failed - %d", ret);
2348 /* Manage pc for seperated event */
2349 mpc->ctype = PC_LISTENING;
2350 mpc->status_type = status_type;
2352 mpc->info.listening.cc = comm_client_new();
2353 retvm_if(mpc->info.listening.cc == NULL, PKGMGR_R_EINVAL, "client creation failed");
2355 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_INSTALL) == PKGMGR_CLIENT_STATUS_INSTALL) {
2356 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_INSTALL, mpc->info.listening.cc, __status_callback, pc);
2357 retvm_if(ret < 0, PKGMGR_R_ECOMM, "PKGMGR_CLIENT_STATUS_INSTALL failed - %d", ret);
2360 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_UNINSTALL) == PKGMGR_CLIENT_STATUS_UNINSTALL) {
2361 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_UNINSTALL, mpc->info.listening.cc, __status_callback, pc);
2362 retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_UNINSTALL failed - %d", ret);
2365 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_MOVE) == PKGMGR_CLIENT_STATUS_MOVE) {
2366 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_MOVE, mpc->info.listening.cc, __status_callback, pc);
2367 retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_MOVE failed - %d", ret);
2370 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS) == PKGMGR_CLIENT_STATUS_INSTALL_PROGRESS) {
2371 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_INSTALL_PROGRESS, mpc->info.listening.cc, __status_callback, pc);
2372 retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_INSTALL_PROGRESS failed - %d", ret);
2375 if ((mpc->status_type & PKGMGR_CLIENT_STATUS_UPGRADE) == PKGMGR_CLIENT_STATUS_UPGRADE) {
2376 ret = comm_client_set_status_callback(COMM_STATUS_BROADCAST_UPGRADE, mpc->info.listening.cc, __status_callback, pc);
2377 retvm_if(ret < 0, PKGMGR_R_ECOMM, "COMM_STATUS_BROADCAST_UPGRADE failed - %d", ret);
2383 API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
2387 /* Check for NULL value of pc */
2388 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client pc is NULL");
2389 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2391 /* 0. check input */
2392 retvm_if(mpc->ctype != PC_LISTENING, PKGMGR_R_EINVAL, "ctype is not PC_LISTENING");
2393 retvm_if(event_cb == NULL, PKGMGR_R_EINVAL, "event_cb is NULL");
2396 req_id = _get_request_id();
2398 /* 2. add callback info to pkgmgr_client */
2399 __add_stat_cbinfo(mpc, req_id, event_cb, data);
2403 API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
2404 const char *pkgid, const char *key,
2407 /* Check for NULL value of pc */
2409 DBG("package manager client handle is NULL\n");
2410 return PKGMGR_R_EINVAL;
2412 /* Check for valid arguments. NULL parameter causes DBUS to abort */
2413 if (pkgid == NULL || pkg_type == NULL || key == NULL || val == NULL) {
2414 DBG("Argument supplied is NULL\n");
2415 return PKGMGR_R_EINVAL;
2417 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2419 /* 0. check the pc type */
2420 if (mpc->ctype != PC_BROADCAST)
2421 return PKGMGR_R_EINVAL;
2423 comm_status_broadcast_server_send_signal(COMM_STATUS_BROADCAST_ALL, mpc->info.broadcast.bc,
2424 getuid(), PKG_STATUS,
2425 pkg_type, pkgid, key, val);
2430 API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
2432 return pkgmgr_info_new_from_file(NULL, pkg_path);
2435 API int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info)
2437 if (pkg_info == NULL)
2438 return PKGMGR_R_EINVAL;
2440 package_manager_pkg_detail_info_t *info = (package_manager_pkg_detail_info_t *)pkg_info;
2443 free(info->icon_buf);
2451 API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, int service_mode,
2452 pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
2453 const char *custom_info, pkgmgr_handler event_cb, void *data)
2455 return pkgmgr_client_usr_request_service(service_type, service_mode, pc, pkg_type, pkgid, GLOBAL_USER, custom_info, event_cb, data);
2458 API int pkgmgr_client_usr_request_service(pkgmgr_request_service_type service_type, int service_mode,
2459 pkgmgr_client * pc, const char *pkg_type, const char *pkgid, uid_t uid,
2460 const char *custom_info, pkgmgr_handler event_cb, void *data)
2464 /* Check for NULL value of service type */
2465 retvm_if(service_type > PM_REQUEST_MAX, PKGMGR_R_EINVAL, "service type is not defined\n");
2466 retvm_if(service_type < 0, PKGMGR_R_EINVAL, "service type is error\n");
2467 vconf_set_int(VCONFKEY_PKGMGR_STATUS, -1);
2469 switch (service_type) {
2470 case PM_REQUEST_CSC:
2471 tryvm_if(custom_info == NULL, ret = PKGMGR_R_EINVAL, "custom_info is NULL\n");
2472 tryvm_if(strlen(custom_info) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
2473 tryvm_if(data == NULL, ret = PKGMGR_R_EINVAL, "data is NULL\n");
2475 ret = __csc_process(custom_info, (char *)data);
2477 ERR("__csc_process fail \n");
2483 case PM_REQUEST_MOVE:
2484 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2485 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2486 tryvm_if((service_mode < PM_MOVE_TO_INTERNAL) || (service_mode > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "service_mode is wrong\n");
2488 ret = __move_pkg_process(pc, pkgid, uid, (pkgmgr_move_type)service_mode, event_cb, data);
2491 case PM_REQUEST_GET_SIZE:
2492 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2493 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2494 tryvm_if((service_mode < PM_GET_TOTAL_SIZE) || (service_mode >= PM_GET_MAX), ret = PKGMGR_R_EINVAL, "service_mode is wrong\n");
2496 ret = __get_size_process(pc, pkgid, uid, (pkgmgr_getsize_type)service_mode, event_cb, data);
2499 case PM_REQUEST_KILL_APP:
2500 case PM_REQUEST_CHECK_APP:
2501 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2502 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2504 ret = __check_app_process(service_type, pc, pkgid, uid, data);
2506 ERR("__check_app_process fail \n");
2513 ERR("Wrong Request\n");
2524 API int pkgmgr_client_usr_request_size_info(uid_t uid)
2527 pkgmgr_client *pc = NULL;
2529 pc = pkgmgr_client_new(PC_REQUEST);
2530 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "request pc is null\n");
2532 ret = __request_size_info(pc, uid);
2534 ERR("__request_size_info fail \n");
2537 pkgmgr_client_free(pc);
2541 API int pkgmgr_client_request_size_info(void) // get all package size (data, total)
2543 return pkgmgr_client_usr_request_size_info(GLOBAL_USER);
2546 API int pkgmgr_client_usr_clear_cache_dir(const char *pkgid, uid_t uid)
2548 retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "package id is null\n");
2551 pkgmgr_client_t *pc = NULL;
2552 char *pkg_type = NULL;
2553 int is_type_malloced = 0;
2555 pkgmgrinfo_pkginfo_h handle = NULL;
2557 pc = pkgmgr_client_new(PC_REQUEST);
2558 retvm_if(pc == NULL, PKGMGR_R_ESYSTEM, "request pc is null\n");
2560 if (strcmp(pkgid, PKG_CLEAR_ALL_CACHE) != 0)
2562 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &handle);
2563 tryvm_if(ret < 0, ret = PKGMGR_R_ENOPKG, "pkgmgr_pkginfo_get_pkginfo failed");
2565 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkg_type);
2566 tryvm_if(ret < 0, ret = PKGMGR_R_ESYSTEM, "pkgmgr_pkginfo_get_type failed");
2570 pkg_type = (char *)malloc(strlen("rpm") + 1);
2571 strcpy(pkg_type, "rpm");
2572 is_type_malloced = 1;
2575 ret = comm_client_request(pc->info.request.cc, NULL, COMM_REQ_CLEAR_CACHE_DIR, pkg_type, pkgid, NULL, uid, 0);
2576 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "COMM_REQ_CLEAR_CACHE_DIR failed, ret=%d\n", ret);
2581 pkgmgr_client_free(pc);
2583 if(is_type_malloced)
2586 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2591 API int pkgmgr_client_clear_cache_dir(const char *pkgid)
2593 return pkgmgr_client_usr_clear_cache_dir(pkgid, GLOBAL_USER);
2596 API int pkgmgr_client_clear_usr_all_cache_dir(uid_t uid)
2598 return pkgmgr_client_usr_clear_cache_dir(PKG_CLEAR_ALL_CACHE, uid);
2601 API int pkgmgr_client_clear_all_cache_dir(void)
2604 ret = pkgmgr_client_usr_clear_cache_dir(PKG_CLEAR_ALL_CACHE, GLOBAL_USER);
2608 API int pkgmgr_client_get_size(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data)
2610 return pkgmgr_client_usr_get_size(pc, pkgid, get_type, event_cb, data, GLOBAL_USER);
2613 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)
2615 char *req_key = NULL;
2617 char *pkgtype = "rpm";
2618 char *argv[PKG_ARGC_MAX] = { NULL, };
2624 char buf[128] = {'\0'};
2627 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2628 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
2629 retvm_if(event_cb == NULL, PKGMGR_R_EINVAL, "event_cb is NULL\n");
2630 retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "pkgid is NULL\n");
2632 req_key = __get_req_key(pkgid);
2633 retvm_if(req_key == NULL, PKGMGR_R_EINVAL, "req_key is NULL");
2635 req_id = _get_request_id();
2636 __add_op_cbinfo(mpc, req_id, req_key, event_cb, NULL, data);
2638 snprintf(buf, 128, "%d", get_type);
2639 argv[argcnt++] = strdup(pkgid);
2640 argv[argcnt++] = strdup(buf);
2641 argv[argcnt++] = strdup("-k");
2642 argv[argcnt++] = req_key;
2644 /*** add quote in all string for special charactor like '\n'*** FIX */
2645 for (i = 0; i < argcnt; i++) {
2646 temp = g_shell_quote(argv[i]);
2647 len += (strlen(temp) + 1);
2651 args = (char *)calloc(len, sizeof(char));
2652 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
2654 strncpy(args, argv[0], len - 1);
2656 for (i = 1; i < argcnt; i++) {
2657 strncat(args, " ", strlen(" "));
2658 temp = g_shell_quote(argv[i]);
2659 strncat(args, temp, strlen(temp));
2662 DBG("[args] %s [len] %d\n", args, len);
2665 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, uid, 1);
2667 ERR("comm_client_request failed, ret=%d\n", ret);
2670 for (i = 0; i < argcnt; i++)
2679 API int pkgmgr_client_usr_get_package_size_info(pkgmgr_client *pc, const char *pkgid, pkgmgr_pkg_size_info_receive_cb event_cb, void *user_data, uid_t uid)
2681 pkgmgrinfo_pkginfo_h pkginfo = NULL;
2682 char *req_key = NULL;
2685 int type = PM_GET_PKG_SIZE_INFO;
2687 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "The specified pc is NULL.");
2688 retvm_if(pkgid == NULL, PKGMGR_R_EINVAL, "The package id is NULL.");
2690 if (strcmp(pkgid, PKG_SIZE_INFO_TOTAL) == 0)
2691 { // total package size info
2692 type = PM_GET_TOTAL_PKG_SIZE_INFO;
2696 res = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, &pkginfo);
2697 retvm_if(res != 0, PKGMGR_R_ENOPKG, "The package id is not installed.");
2700 pkgmgrinfo_pkginfo_destroy_pkginfo(pkginfo);
2704 pkgmgr_client_t *mpc = (pkgmgr_client_t *)pc;
2705 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
2707 res = __change_op_cb_for_getsize(mpc);
2708 retvm_if(res < 0 , PKGMGR_R_ESYSTEM, "__change_op_cb_for_getsize is fail");
2710 req_key = __get_req_key(pkgid);
2711 retvm_if(req_key == NULL, PKGMGR_R_ESYSTEM, "req_key is NULL");
2713 req_id = _get_request_id();
2714 __add_op_cbinfo(mpc, req_id, req_key, __get_pkg_size_info_cb, event_cb, user_data);
2716 res = __get_package_size_info(mpc, req_key, pkgid, type, uid);
2721 API int pkgmgr_client_get_package_size_info(pkgmgr_client *pc, const char *pkgid, pkgmgr_pkg_size_info_receive_cb event_cb, void *user_data)
2723 return pkgmgr_client_usr_get_package_size_info(pc, pkgid, event_cb, user_data, GLOBAL_USER);
2726 API int pkgmgr_client_usr_get_total_package_size_info(pkgmgr_client *pc, pkgmgr_total_pkg_size_info_receive_cb event_cb, void *user_data, uid_t uid)
2727 { // total package size info
2728 return pkgmgr_client_usr_get_package_size_info(pc, PKG_SIZE_INFO_TOTAL, (pkgmgr_pkg_size_info_receive_cb)event_cb, user_data, uid);
2731 API int pkgmgr_client_get_total_package_size_info(pkgmgr_client *pc, pkgmgr_total_pkg_size_info_receive_cb event_cb, void *user_data)
2733 return pkgmgr_client_usr_get_package_size_info(pc, PKG_SIZE_INFO_TOTAL, event_cb, user_data, GLOBAL_USER);
2736 #define __START_OF_OLD_API
2737 ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
2743 iter_data *udata = (iter_data *) user_data;
2745 ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PACKAGETYPE_STR, &type);
2748 ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
2749 if (package == NULL)
2751 ail_appinfo_get_str(appinfo, AIL_PROP_VERSION_STR, &version);
2752 if (version == NULL)
2755 if (udata->iter_fn(type, package, version, udata->data) != 0)
2756 return AIL_CB_RET_CANCEL;
2758 return AIL_CB_RET_CONTINUE;
2761 API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data, uid_t uid)
2764 ail_filter_h filter;
2767 if (iter_fn == NULL)
2768 return PKGMGR_R_EINVAL;
2770 ret = ail_filter_new(&filter);
2771 if (ret != AIL_ERROR_OK) {
2772 return PKGMGR_R_ERROR;
2775 ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
2776 if (ret != AIL_ERROR_OK) {
2777 ail_filter_destroy(filter);
2778 return PKGMGR_R_ERROR;
2781 ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
2782 if (ret != AIL_ERROR_OK) {
2783 ail_filter_destroy(filter);
2784 return PKGMGR_R_ERROR;
2787 if(uid != GLOBAL_USER)
2788 ret = ail_filter_count_usr_appinfo(filter, &cnt, uid);
2790 ret = ail_filter_count_appinfo(filter, &cnt);
2791 if (ret != AIL_ERROR_OK) {
2792 ail_filter_destroy(filter);
2793 return PKGMGR_R_ERROR;
2796 iter_data *udata = calloc(1, sizeof(iter_data));
2797 if (udata == NULL) {
2798 ERR("calloc failed");
2799 ail_filter_destroy(filter);
2801 return PKGMGR_R_ERROR;
2803 udata->iter_fn = iter_fn;
2806 if(uid != GLOBAL_USER)
2807 ail_filter_list_usr_appinfo_foreach(filter, __appinfo_func, udata, uid);
2809 ail_filter_list_appinfo_foreach(filter, __appinfo_func, udata);
2812 ret = ail_filter_destroy(filter);
2813 if (ret != AIL_ERROR_OK) {
2814 return PKGMGR_R_ERROR;
2820 API pkgmgr_info *pkgmgr_info_new(const char *pkg_type, const char *pkgid)
2822 return pkgmgr_info_usr_new(pkg_type, pkgid, GLOBAL_USER);
2824 API pkgmgr_info *pkgmgr_info_usr_new(const char *pkg_type, const char *pkgid, uid_t uid)
2826 const char *pkgtype;
2827 pkg_plugin_set *plugin_set = NULL;
2828 package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
2830 /* 1. check argument */
2834 if (pkg_type == NULL) {
2835 pkgtype = _get_pkg_type_from_desktop_file(pkgid, uid);
2836 if (pkgtype == NULL)
2841 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
2844 pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
2845 if (pkg_detail_info == NULL) {
2846 ERR("*** Failed to alloc package_handler_info.\n");
2850 plugin_set = _package_manager_load_library(pkgtype);
2851 if (plugin_set == NULL) {
2852 ERR("*** Failed to load library");
2853 free(pkg_detail_info);
2857 if (plugin_set->pkg_is_installed) {
2858 if (plugin_set->pkg_is_installed(pkgid) != 0) {
2859 ERR("*** Failed to call pkg_is_installed()");
2860 free(pkg_detail_info);
2864 if (plugin_set->get_pkg_detail_info) {
2865 if (plugin_set->get_pkg_detail_info(pkgid,
2866 pkg_detail_info) != 0) {
2867 ERR("*** Failed to call get_pkg_detail_info()");
2868 free(pkg_detail_info);
2874 return (pkgmgr_info *) pkg_detail_info;
2877 API char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key)
2879 package_manager_pkg_detail_info_t *pkg_detail_info;
2881 if (pkg_info == NULL)
2886 pkg_detail_info = (package_manager_pkg_detail_info_t *) pkg_info;
2888 return _get_info_string(key, pkg_detail_info);
2891 API pkgmgr_info *pkgmgr_info_new_from_file(const char *pkg_type,
2892 const char *pkg_path)
2894 pkg_plugin_set *plugin_set = NULL;
2895 package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
2897 if (pkg_path == NULL) {
2898 ERR("pkg_path is NULL\n");
2902 if (strlen(pkg_path) > PKG_URL_STRING_LEN_MAX) {
2903 ERR("length of pkg_path is too long - %d.\n",
2908 pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
2909 if (pkg_detail_info == NULL) {
2910 ERR("*** Failed to alloc package_handler_info.\n");
2914 if (pkg_type == NULL)
2915 pkgtype = __get_type_from_path(pkg_path);
2917 pkgtype = strdup(pkg_type);
2919 plugin_set = _package_manager_load_library(pkgtype);
2920 if (plugin_set == NULL) {
2921 free(pkg_detail_info);
2926 if (plugin_set->get_pkg_detail_info_from_package) {
2927 if (plugin_set->get_pkg_detail_info_from_package(pkg_path,
2928 pkg_detail_info) != 0) {
2929 free(pkg_detail_info);
2936 return (pkgmgr_info *) pkg_detail_info;
2939 API int pkgmgr_info_free(pkgmgr_info * pkg_info)
2941 if (pkg_info == NULL)
2942 return PKGMGR_R_EINVAL;
2950 #define __END_OF_OLD_API
2952 API int pkgmgr_pkginfo_get_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data)
2955 ret = pkgmgrinfo_pkginfo_get_list(pkg_list_cb, user_data);
2959 API int pkgmgr_pkginfo_get_usr_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
2962 ret = pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data, uid);
2967 API int pkgmgr_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid, pkgmgr_pkginfo_h *handle)
2970 ret = pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, uid, handle);
2975 API int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle)
2978 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, handle);
2984 API int pkgmgr_pkginfo_get_pkgname(pkgmgr_pkginfo_h handle, char **pkg_name)
2987 ret = pkgmgrinfo_pkginfo_get_pkgname(handle, pkg_name);
2992 API int pkgmgr_pkginfo_get_pkgid(pkgmgr_pkginfo_h handle, char **pkgid)
2995 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, pkgid);
2999 API int pkgmgr_pkginfo_get_type(pkgmgr_pkginfo_h handle, char **type)
3002 ret = pkgmgrinfo_pkginfo_get_type(handle, type);
3006 API int pkgmgr_pkginfo_get_version(pkgmgr_pkginfo_h handle, char **version)
3009 ret = pkgmgrinfo_pkginfo_get_version(handle, version);
3013 API int pkgmgr_pkginfo_get_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location)
3016 pkgmgrinfo_install_location loc;
3017 ret = pkgmgrinfo_pkginfo_get_install_location(handle, &loc);
3022 API int pkgmgr_pkginfo_get_package_size(pkgmgr_pkginfo_h handle, int *size)
3025 ret = pkgmgrinfo_pkginfo_get_package_size(handle, size);
3029 API int pkgmgr_pkginfo_get_icon(pkgmgr_pkginfo_h handle, char **icon)
3032 ret = pkgmgrinfo_pkginfo_get_icon(handle, icon);
3036 API int pkgmgr_pkginfo_get_label(pkgmgr_pkginfo_h handle, char **label)
3039 ret = pkgmgrinfo_pkginfo_get_label(handle, label);
3043 API int pkgmgr_pkginfo_get_description(pkgmgr_pkginfo_h handle, char **description)
3046 ret = pkgmgrinfo_pkginfo_get_description(handle, description);
3050 API int pkgmgr_pkginfo_get_author_name(pkgmgr_pkginfo_h handle, char **author_name)
3053 ret = pkgmgrinfo_pkginfo_get_author_name(handle, author_name);
3057 API int pkgmgr_pkginfo_get_author_email(pkgmgr_pkginfo_h handle, char **author_email)
3060 ret = pkgmgrinfo_pkginfo_get_author_email(handle, author_email);
3064 API int pkgmgr_pkginfo_get_author_href(pkgmgr_pkginfo_h handle, char **author_href)
3067 ret = pkgmgrinfo_pkginfo_get_author_href(handle, author_href);
3071 API int pkgmgr_pkginfo_is_removable(pkgmgr_pkginfo_h handle, bool *removable)
3074 ret = pkgmgrinfo_pkginfo_is_removable(handle, removable);
3078 API int pkgmgr_pkginfo_is_preload(pkgmgr_pkginfo_h handle, bool *preload)
3081 ret = pkgmgrinfo_pkginfo_is_preload(handle, preload);
3085 API int pkgmgr_pkginfo_is_readonly(pkgmgr_pkginfo_h handle, bool *readonly)
3088 ret = pkgmgrinfo_pkginfo_is_readonly(handle, readonly);
3092 API int pkgmgr_pkginfo_is_for_all_users(pkgmgr_pkginfo_h handle, bool *for_all_users)
3095 ret = pkgmgrinfo_pkginfo_is_for_all_users(handle, for_all_users);
3099 API int pkgmgr_pkginfo_is_accessible(pkgmgr_pkginfo_h handle, bool *accessible)
3102 ret = pkgmgrinfo_pkginfo_is_accessible(handle, accessible);
3106 API int pkgmgr_pkginfo_destroy_pkginfo(pkgmgr_pkginfo_h handle)
3109 ret = pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
3113 API int pkgmgr_pkginfo_get_installed_storage(pkgmgr_pkginfo_h handle, pkgmgr_installed_storage *storage)
3116 pkgmgrinfo_installed_storage sto;
3117 ret = pkgmgrinfo_pkginfo_get_installed_storage(handle, &sto);
3122 API int pkgmgr_pkginfo_get_installed_time(pkgmgr_pkginfo_h handle, int *installed_time)
3125 ret = pkgmgrinfo_pkginfo_get_installed_time(handle, installed_time);
3129 API int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
3130 pkgmgr_info_app_list_cb app_func, void *user_data)
3133 ret = pkgmgrinfo_appinfo_get_list(handle, component, app_func, user_data);
3137 API int pkgmgr_appinfo_get_usr_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
3138 pkgmgr_info_app_list_cb app_func, void *user_data, uid_t uid)
3141 ret = pkgmgrinfo_appinfo_get_usr_list(handle, component, app_func, user_data, uid);
3145 API int pkgmgr_appinfo_foreach_category(pkgmgr_appinfo_h handle, pkgmgr_info_app_category_list_cb category_func,
3149 ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, user_data);
3153 API int pkgmgr_appinfo_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle)
3156 ret = pkgmgrinfo_appinfo_get_appinfo(appid, handle);
3160 API int pkgmgr_appinfo_get_appid(pkgmgr_appinfo_h handle, char **appid)
3163 ret = pkgmgrinfo_appinfo_get_appid(handle, appid);
3167 API int pkgmgr_appinfo_get_pkgname(pkgmgr_appinfo_h handle, char **pkg_name)
3170 ret = pkgmgrinfo_appinfo_get_pkgname(handle, pkg_name);
3174 API int pkgmgr_appinfo_get_pkgid(pkgmgr_appinfo_h handle, char **pkgid)
3177 ret = pkgmgrinfo_appinfo_get_pkgid(handle, pkgid);
3181 API int pkgmgr_appinfo_get_icon(pkgmgr_appinfo_h handle, char **icon)
3184 ret = pkgmgrinfo_appinfo_get_icon(handle, icon);
3188 API int pkgmgr_appinfo_get_label(pkgmgr_appinfo_h handle, char **label)
3191 ret = pkgmgrinfo_appinfo_get_label(handle, label);
3195 API int pkgmgr_appinfo_get_exec(pkgmgr_appinfo_h handle, char **exec)
3198 ret = pkgmgrinfo_appinfo_get_exec(handle, exec);
3202 API int pkgmgr_appinfo_get_component(pkgmgr_appinfo_h handle, pkgmgr_app_component *component)
3205 pkgmgrinfo_app_component comp;
3206 ret = pkgmgrinfo_appinfo_get_component(handle, &comp);
3211 API int pkgmgr_appinfo_get_apptype(pkgmgr_appinfo_h handle, char **app_type)
3214 ret = pkgmgrinfo_appinfo_get_apptype(handle, app_type);
3218 API int pkgmgr_appinfo_is_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay)
3221 ret = pkgmgrinfo_appinfo_is_nodisplay(handle, nodisplay);
3225 API int pkgmgr_appinfo_is_multiple(pkgmgr_appinfo_h handle, bool *multiple)
3228 ret = pkgmgrinfo_appinfo_is_multiple(handle, multiple);
3232 API int pkgmgr_appinfo_is_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage)
3235 ret = pkgmgrinfo_appinfo_is_taskmanage(handle, taskmanage);
3239 API int pkgmgr_appinfo_get_hwacceleration(pkgmgr_appinfo_h handle, pkgmgr_hwacceleration_type *hwacceleration)
3242 pkgmgrinfo_app_hwacceleration hwacc;
3243 ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
3244 *hwacceleration = hwacc;
3248 API int pkgmgr_appinfo_is_onboot(pkgmgr_appinfo_h handle, bool *onboot)
3251 ret = pkgmgrinfo_appinfo_is_onboot(handle, onboot);
3255 API int pkgmgr_appinfo_is_autorestart(pkgmgr_appinfo_h handle, bool *autorestart)
3258 ret = pkgmgrinfo_appinfo_is_autorestart(handle, autorestart);
3262 API int pkgmgr_appinfo_destroy_appinfo(pkgmgr_appinfo_h handle)
3265 ret = pkgmgrinfo_appinfo_destroy_appinfo(handle);
3269 API int pkgmgr_pkginfo_create_certinfo(pkgmgr_certinfo_h *handle)
3272 ret = pkgmgrinfo_pkginfo_create_certinfo(handle);
3276 API int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle, uid_t uid)
3279 ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle, uid);
3283 API int pkgmgr_pkginfo_get_cert_value(pkgmgr_certinfo_h handle, pkgmgr_cert_type cert_type, const char **cert_value)
3286 ret = pkgmgrinfo_pkginfo_get_cert_value(handle, cert_type, cert_value);
3290 API int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle)
3293 ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
3297 API int pkgmgr_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
3300 ret = pkgmgrinfo_datacontrol_get_info(providerid, type, appid, access);