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>
38 #include <pkgmgr-info.h>
39 #include <iniparser.h>
41 #include "package-manager.h"
42 #include "pkgmgr-internal.h"
43 #include "pkgmgr-api.h"
44 #include "comm_client.h"
45 #include "comm_status_broadcast_server.h"
48 static int _get_request_id()
50 static int internal_req_id = 1;
52 return internal_req_id++;
55 typedef struct _req_cb_info {
58 pkgmgr_handler event_cb;
60 struct _req_cb_info *next;
63 typedef struct _listen_cb_info {
65 pkgmgr_handler event_cb;
67 struct _listen_cb_info *next;
70 typedef struct _pkgmgr_client_t {
79 listen_cb_info *lhead;
87 typedef struct _iter_data {
88 pkgmgr_iter_fn iter_fn;
92 typedef struct _csc_info {
93 int count ; /** Number of csc packages */
94 char ** type ; /** package type */
95 char ** description ; /** description */
98 static int __xsystem(const char *argv[])
105 perror("fork failed");
109 execvp(argv[0], (char *const *)argv);
115 if (waitpid(pid, &status, 0) == -1) {
116 perror("waitpid failed");
119 if (WIFSIGNALED(status)) {
123 if (!WIFEXITED(status)) {
124 /* shouldn't happen */
125 perror("should not happen");
128 return WEXITSTATUS(status);
131 static int __csc_process(const char *csc_path, const char *result_path)
138 char *pkgtype = NULL;
140 char buf[PKG_STRING_LEN_MAX] = {0,};
141 char type_buf[1024] = { 0 };
142 char des_buf[1024] = { 0 };
143 csc_info *csc = NULL;
146 csc = iniparser_load(csc_path);
147 retvm_if(csc == NULL, PKGMGR_R_EINVAL, "cannot open parse file [%s]", csc_path);
149 file = fopen(result_path, "w");
150 retvm_if(file == NULL, PKGMGR_R_EINVAL, "cannot open result file [%s]", result_path);
152 count = iniparser_getint(csc, "csc packages:count", -1);
153 retvm_if(count == 0, PKGMGR_R_ERROR, "csc [%s] dont have packages", csc_path);
155 snprintf(buf, PKG_STRING_LEN_MAX, "[csc %d packages]\n", count);
156 fwrite(buf, 1, strlen(buf), file);
158 for(cnt = 1 ; cnt <= count ; cnt++)
160 snprintf(type_buf, PKG_STRING_LEN_MAX - 1, "csc packages:type_%03d", cnt);
161 snprintf(des_buf, PKG_STRING_LEN_MAX - 1, "csc packages:description_%03d", cnt);
163 pkgtype = iniparser_getstr(csc, type_buf);
164 des = iniparser_getstr(csc, des_buf);
167 if (pkgtype == NULL) {
169 snprintf(buf, PKG_STRING_LEN_MAX, "[%03d]Fail to get information[%s]\n", cnt, type_buf);
170 fwrite(buf, 1, strlen(buf), file);
172 } else if (des == NULL) {
174 snprintf(buf, PKG_STRING_LEN_MAX, "[%03d]Fail to get information[%s]\n", cnt, des_buf);
175 fwrite(buf, 1, strlen(buf), file);
179 if (strcmp(pkgtype, "tpk") == 0) {
180 const char *ospinstaller_argv[] = { "/usr/bin/osp-installer", "-c", des, NULL };
181 ret = __xsystem(ospinstaller_argv);
182 } else if (strcmp(pkgtype, "wgt")== 0) {
183 const char *wrtinstaller_argv[] = { "/usr/bin/wrt-installer", "-c", des, NULL };
184 ret = __xsystem(wrtinstaller_argv);
191 snprintf(buf, PKG_STRING_LEN_MAX, "[%03d][%s] csc result : Fail\n", cnt, pkgtype);
193 snprintf(buf, PKG_STRING_LEN_MAX, "[%03d][%s] csc result : Sucess\n", cnt, pkgtype);
195 fwrite(buf, 1, strlen(buf), file);
199 ret = PKGMGR_R_ERROR;
200 snprintf(buf, PKG_STRING_LEN_MAX, "[csc result] total : [%d], sucess : [%d]packages, fail : [%d]packages\n", count, count-csc_fail, csc_fail);
204 snprintf(buf, PKG_STRING_LEN_MAX, "[csc result] total : [%d], sucess : all packages\n", count);
207 fwrite(buf, 1, strlen(buf), file);
209 iniparser_freedict(csc);
218 static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
219 const char *req_key, pkgmgr_handler event_cb,
222 req_cb_info *cb_info;
223 req_cb_info *current;
226 cb_info = (req_cb_info *) calloc(1, sizeof(req_cb_info));
227 if (cb_info == NULL) {
228 _LOGD("calloc failed");
231 cb_info->request_id = request_id;
232 cb_info->req_key = strdup(req_key);
233 cb_info->event_cb = event_cb;
234 cb_info->data = data;
235 cb_info->next = NULL;
237 if (pc->info.request.rhead == NULL)
238 pc->info.request.rhead = cb_info;
240 current = prev = pc->info.request.rhead;
243 current = current->next;
246 prev->next = cb_info;
250 static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
254 tmp = pc->info.request.rhead;
257 _LOGE("tmp is NULL");
261 _LOGD("tmp->req_key %s, req_key %s", tmp->req_key, req_key);
264 if (strncmp(tmp->req_key, req_key, strlen(tmp->req_key)) == 0)
271 static void __remove_op_cbinfo(pkgmgr_client_t *pc, req_cb_info *info)
275 if (pc == NULL || pc->info.request.rhead == NULL || info == NULL)
278 tmp = pc->info.request.rhead;
280 if (tmp->next == info) {
281 tmp->next = info->next;
290 static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
291 pkgmgr_handler event_cb, void *data)
293 listen_cb_info *cb_info;
294 listen_cb_info *current;
295 listen_cb_info *prev;
297 cb_info = (listen_cb_info *) calloc(1, sizeof(listen_cb_info));
298 if (cb_info == NULL) {
299 _LOGD("calloc failed");
302 cb_info->request_id = request_id;
303 cb_info->event_cb = event_cb;
304 cb_info->data = data;
305 cb_info->next = NULL;
307 /* TODO - check the order of callback - FIFO or LIFO => Should be changed to LIFO */
308 if (pc->info.listening.lhead == NULL)
309 pc->info.listening.lhead = cb_info;
311 current = prev = pc->info.listening.lhead;
314 current = current->next;
317 prev->next = cb_info;
321 static void __operation_callback(void *cb_data, const char *req_id,
322 const char *pkg_type, const char *pkgid,
323 const char *key, const char *val)
326 req_cb_info *cb_info;
328 _LOGD("__operation_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
329 "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
331 pc = (pkgmgr_client_t *) cb_data;
333 /* find callback info */
334 cb_info = __find_op_cbinfo(pc, req_id);
338 _LOGD("__find_op_cbinfo");
341 if (cb_info->event_cb) {
342 cb_info->event_cb(cb_info->request_id, pkg_type, pkgid, key,
343 val, NULL, cb_info->data);
344 _LOGD("event_cb is called");
347 /*remove callback for last call
348 if (strcmp(key, "end") == 0) {
349 __remove_op_cbinfo(pc, cb_info);
350 _LOGD("__remove_op_cbinfo");
357 static void __status_callback(void *cb_data, const char *req_id,
358 const char *pkg_type, const char *pkgid,
359 const char *key, const char *val)
364 _LOGD("__status_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
365 "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
367 pc = (pkgmgr_client_t *) cb_data;
369 tmp = pc->info.listening.lhead;
371 if (tmp->event_cb(tmp->request_id, pkg_type, pkgid, key, val,
372 NULL, tmp->data) != 0)
380 API pkgmgr_client *pkgmgr_client_new(client_type ctype)
382 pkgmgr_client_t *pc = NULL;
385 if (ctype != PC_REQUEST && ctype != PC_LISTENING
386 && ctype != PC_BROADCAST)
389 /* Allocate memory for ADT:pkgmgr_client */
390 pc = calloc(1, sizeof(pkgmgr_client_t));
399 if (pc->ctype == PC_REQUEST) {
400 pc->info.request.cc = comm_client_new();
401 if (pc->info.request.cc == NULL) {
402 _LOGE("client creation failed");
405 ret = comm_client_set_status_callback(pc->info.request.cc,
406 __operation_callback, pc);
408 _LOGE("comm_client_set_status_callback() failed - %d",
412 } else if (pc->ctype == PC_LISTENING) {
413 pc->info.listening.cc = comm_client_new();
414 if (pc->info.listening.cc == NULL) {
415 _LOGE("client creation failed");
418 ret = comm_client_set_status_callback(pc->info.request.cc,
419 __status_callback, pc);
421 _LOGE("comm_client_set_status_callback() failed - %d",
425 } else if (pc->ctype == PC_BROADCAST) {
426 pc->info.broadcast.bc = comm_status_broadcast_server_connect();
427 if (pc->info.broadcast.bc == NULL) {
428 _LOGE("client creation failed");
434 return (pkgmgr_client *) pc;
442 API int pkgmgr_client_free(pkgmgr_client *pc)
445 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
448 _LOGE("Invalid argument");
449 return PKGMGR_R_EINVAL;
452 if (mpc->ctype == PC_REQUEST) {
455 for (tmp = mpc->info.request.rhead; tmp;) {
461 ret = comm_client_free(mpc->info.request.cc);
463 _LOGE("comm_client_free() failed - %d", ret);
466 } else if (mpc->ctype == PC_LISTENING) {
468 listen_cb_info *prev;
469 for (tmp = mpc->info.listening.lhead; tmp;) {
475 ret = comm_client_free(mpc->info.listening.cc);
477 _LOGE("comm_client_free() failed - %d", ret);
480 } else if (mpc->ctype == PC_BROADCAST) {
481 comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
484 _LOGE("Invalid client type\n");
485 return PKGMGR_R_EINVAL;
497 return PKGMGR_R_ERROR;
500 static char *__get_req_key(const char *pkg_path)
504 char timestr[PKG_STRING_LEN_MAX];
508 gettimeofday(&tv, NULL);
509 curtime = tv.tv_sec * 1000000 + tv.tv_usec;
510 snprintf(timestr, sizeof(timestr), "%ld", curtime);
512 size = strlen(pkg_path) + strlen(timestr) + 2;
513 str_req_key = (char *)calloc(size, sizeof(char));
514 if (str_req_key == NULL) {
515 _LOGD("calloc failed");
518 snprintf(str_req_key, size, "%s_%s", pkg_path, timestr);
523 static char *__get_type_from_path(const char *pkg_path)
526 char mimetype[255] = { '\0', };
527 char extlist[256] = { '\0', };
530 ret = _get_mime_from_file(pkg_path, mimetype, sizeof(mimetype));
532 _LOGE("_get_mime_from_file() failed - error code[%d]\n",
537 ret = _get_mime_extension(mimetype, extlist, sizeof(extlist));
539 _LOGE("_get_mime_extension() failed - error code[%d]\n",
544 if (strlen(extlist) == 0)
547 if (strchr(extlist, ',')) {
548 extlist[strlen(extlist) - strlen(strchr(extlist, ','))] = '\0';
550 pkg_type = strchr(extlist, '.') + 1;
551 return strdup(pkg_type);
554 API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
555 const char *descriptor_path, const char *pkg_path,
556 const char *optional_file, pkgmgr_mode mode,
557 pkgmgr_handler event_cb, void *data)
560 char *installer_path;
564 char *argv[PKG_ARGC_MAX] = { NULL, };
572 /* Check for NULL value of pc */
574 _LOGD("package manager client handle is NULL\n");
575 return PKGMGR_R_EINVAL;
577 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
579 /* 0. check the pc type */
580 if (mpc->ctype != PC_REQUEST)
581 return PKGMGR_R_EINVAL;
583 /* 1. check argument */
584 if (descriptor_path) {
585 if (strlen(descriptor_path) >= PKG_STRING_LEN_MAX)
586 return PKGMGR_R_EINVAL;
588 if (access(descriptor_path, F_OK) != 0)
589 return PKGMGR_R_EINVAL;
592 if (pkg_path == NULL)
593 return PKGMGR_R_EINVAL;
595 if (strlen(pkg_path) >= PKG_STRING_LEN_MAX)
596 return PKGMGR_R_EINVAL;
598 if (access(pkg_path, F_OK) != 0)
599 return PKGMGR_R_EINVAL;
603 if (strlen(optional_file) >= PKG_STRING_LEN_MAX)
604 return PKGMGR_R_EINVAL;
607 /* 2. get installer path using pkg_path */
609 installer_path = _get_backend_path_with_type(pkg_type);
610 pkgtype = strdup(pkg_type);
612 installer_path = _get_backend_path(pkg_path);
613 pkgtype = __get_type_from_path(pkg_path);
616 if (installer_path == NULL) {
618 return PKGMGR_R_EINVAL;
621 /* 3. generate req_key */
622 req_key = __get_req_key(pkg_path);
624 /* 4. add callback info - add callback info to pkgmgr_client */
625 req_id = _get_request_id();
626 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
628 /* 5. generate argv */
630 /* argv[0] installer path */
631 argv[argcnt++] = installer_path;
633 argv[argcnt++] = strdup("-k");
635 argv[argcnt++] = req_key;
637 argv[argcnt++] = strdup("-i");
638 /* argv[(4)] if exists */
640 argv[argcnt++] = strdup(descriptor_path);
642 argv[argcnt++] = strdup(pkg_path);
643 /* argv[(5)] if exists */
645 argv[argcnt++] = strdup("-o");
646 argv[argcnt++] = strdup(optional_file);
648 /* argv[6] -q option should be located at the end of command !! */
649 if (mode == PM_QUIET)
650 argv[argcnt++] = strdup("-q");
652 /*** add quote in all string for special charactor like '\n'*** FIX */
653 for (i = 0; i < argcnt; i++) {
654 temp = g_shell_quote(argv[i]);
655 len += (strlen(temp) + 1);
659 args = (char *)calloc(len, sizeof(char));
661 _LOGD("calloc failed");
663 for (i = 0; i < argcnt; i++)
667 return PKGMGR_R_ERROR;
669 strncpy(args, argv[0], len - 1);
671 for (i = 1; i < argcnt; i++) {
672 strncat(args, " ", strlen(" "));
673 temp = g_shell_quote(argv[i]);
674 strncat(args, temp, strlen(temp));
677 _LOGD("[args] %s [len] %d\n", args, len);
678 /******************* end of quote ************************/
680 /* 6. request install */
681 ret = comm_client_request(mpc->info.request.cc, req_key,
682 COMM_REQ_TO_INSTALLER, pkgtype, pkg_path,
685 _LOGE("request failed, ret=%d\n", ret);
687 for (i = 0; i < argcnt; i++)
691 return PKGMGR_R_ECOMM;
694 for (i = 0; i < argcnt; i++)
703 API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
704 const char *optional_file, pkgmgr_mode mode,
705 pkgmgr_handler event_cb, void *data)
707 char *pkgtype = NULL;
708 char *installer_path = NULL;
709 char *req_key = NULL;
712 char *argv[PKG_ARGC_MAX] = { NULL, };
720 /* Check for NULL value of pc */
721 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
723 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
725 /* 0. check the pc type */
726 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
729 /* 1. check argument */
730 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
731 retv_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL);
733 if (strlen(optional_file) >= PKG_STRING_LEN_MAX)
734 return PKGMGR_R_EINVAL;
737 /* 2. get installer path using pkg_path */
738 installer_path = _get_backend_path_with_type(pkg_type);
739 pkgtype = strdup(pkg_type);
740 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path is null");
742 /* 3. generate req_key */
743 req_key = __get_req_key(pkgid);
745 /* 4. add callback info - add callback info to pkgmgr_client */
746 req_id = _get_request_id();
747 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
749 /* 5. generate argv */
751 /* argv[0] installer path */
752 argv[argcnt++] = installer_path;
754 argv[argcnt++] = strdup("-k");
756 argv[argcnt++] = req_key;
758 argv[argcnt++] = strdup("-r");
760 argv[argcnt++] = strdup(pkgid);
761 /* argv[(5)] if exists */
763 argv[argcnt++] = strdup("-o");
764 argv[argcnt++] = strdup(optional_file);
767 /* argv[5] -q option should be located at the end of command !! */
768 if (mode == PM_QUIET)
769 argv[argcnt++] = strdup("-q");
771 /*** add quote in all string for special charactor like '\n'*** FIX */
772 for (i = 0; i < argcnt; i++) {
773 temp = g_shell_quote(argv[i]);
774 len += (strlen(temp) + 1);
778 args = (char *)calloc(len, sizeof(char));
779 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
781 strncpy(args, argv[0], len - 1);
783 for (i = 1; i < argcnt; i++) {
784 strncat(args, " ", strlen(" "));
785 temp = g_shell_quote(argv[i]);
786 strncat(args, temp, strlen(temp));
789 _LOGD("[args] %s [len] %d\n", args, len);
790 /******************* end of quote ************************/
792 /* 6. request install */
793 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, 1);
794 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed");
799 for (i = 0; i < argcnt; i++)
808 static inline int __pkgmgr_read_proc(const char *path, char *buf, int size)
813 if (buf == NULL || path == NULL)
816 fd = open(path, O_RDONLY);
820 ret = read(fd, buf, size - 1);
832 static inline int __pkgmgr_find_pid_by_cmdline(const char *dname,
833 const char *cmdline, const char *apppath)
837 if (strncmp(cmdline, apppath, PKG_STRING_LEN_MAX-1) == 0) {
839 if (pid != getpgid(pid))
847 static int __pkgmgr_proc_iter_kill_cmdline(const char *apppath)
850 struct dirent *dentry;
853 char buf[PKG_STRING_LEN_MAX];
855 dp = opendir("/proc");
860 while ((dentry = readdir(dp)) != NULL) {
861 if (!isdigit(dentry->d_name[0]))
864 snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
865 ret = __pkgmgr_read_proc(buf, buf, sizeof(buf));
869 pid = __pkgmgr_find_pid_by_cmdline(dentry->d_name, buf, apppath);
880 if (killpg(pgid, SIGKILL) < 0) {
892 static int __app_list_cb (const pkgmgr_appinfo_h handle,
896 pkgmgr_appinfo_get_exec(handle, &exec);
898 __pkgmgr_proc_iter_kill_cmdline(exec);
904 API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
905 const char *pkgid, pkgmgr_mode mode,
906 pkgmgr_handler event_cb, void *data)
909 char *installer_path;
913 char *argv[PKG_ARGC_MAX] = { NULL, };
921 /* Check for NULL value of pc */
922 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
924 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
926 /* 0. check the pc type */
927 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
929 /* 1. check argument */
930 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
932 pkgmgr_pkginfo_h handle;
933 ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
935 /*check package id */
936 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
937 tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
939 /*check running app , terminate app if it is running*/
940 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
941 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
943 /*check running app , terminate app if it is running*/
944 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
945 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
948 ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
949 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
950 tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
952 /*check pkgid length */
953 tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
955 /* 2. get installer path using pkgtype */
956 installer_path = _get_backend_path_with_type(pkgtype);
957 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
959 /* 3. generate req_key */
960 req_key = __get_req_key(pkgid);
962 /* 4. add callback info - add callback info to pkgmgr_client */
963 req_id = _get_request_id();
964 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
966 /* 5. generate argv */
968 /* argv[0] installer path */
969 argv[argcnt++] = installer_path;
971 argv[argcnt++] = strdup("-k");
973 argv[argcnt++] = req_key;
975 argv[argcnt++] = strdup("-d");
977 argv[argcnt++] = strdup(pkgid);
978 /* argv[5] -q option should be located at the end of command !! */
979 if (mode == PM_QUIET)
980 argv[argcnt++] = strdup("-q");
982 /*** add quote in all string for special charactor like '\n'*** FIX */
983 for (i = 0; i < argcnt; i++) {
984 temp = g_shell_quote(argv[i]);
985 len += (strlen(temp) + 1);
989 args = (char *)calloc(len, sizeof(char));
990 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
992 strncpy(args, argv[0], len - 1);
994 for (i = 1; i < argcnt; i++) {
995 strncat(args, " ", strlen(" "));
996 temp = g_shell_quote(argv[i]);
997 strncat(args, temp, strlen(temp));
1000 _LOGD("[args] %s [len] %d\n", args, len);
1001 /******************* end of quote ************************/
1003 /* 6. request install */
1004 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, 1);
1005 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
1007 for (i = 0; i < argcnt; i++)
1012 pkgmgr_pkginfo_destroy_pkginfo(handle);
1016 for (i = 0; i < argcnt; i++)
1022 pkgmgr_pkginfo_destroy_pkginfo(handle);
1027 API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkg_type,
1028 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode)
1030 const char *pkgtype = NULL;
1031 char *installer_path = NULL;
1032 char *req_key = NULL;
1034 char *argv[PKG_ARGC_MAX] = { NULL, };
1041 char *cookie = NULL;
1042 char buf[128] = {'\0'};
1044 /* Check for NULL value of pc */
1046 _LOGD("package manager client handle is NULL\n");
1047 return PKGMGR_R_EINVAL;
1049 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1050 /*check the pc type */
1051 if (mpc->ctype != PC_REQUEST)
1052 return PKGMGR_R_EINVAL;
1056 return PKGMGR_R_EINVAL;
1058 if (pkg_type == NULL) {
1059 pkgtype = _get_pkg_type_from_desktop_file(pkgid);
1060 if (pkgtype == NULL)
1061 return PKGMGR_R_EINVAL;
1065 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1066 return PKGMGR_R_EINVAL;
1068 if ((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD))
1069 return PKGMGR_R_EINVAL;
1071 /* get installer path using pkg_path */
1072 installer_path = _get_backend_path_with_type(pkgtype);
1073 if (installer_path == NULL)
1074 return PKGMGR_R_EINVAL;
1076 /* generate req_key */
1077 req_key = __get_req_key(pkgid);
1078 req_id = _get_request_id();
1081 snprintf(buf, 128, "%d", move_type);
1082 /* argv[0] installer path */
1083 argv[argcnt++] = installer_path;
1085 argv[argcnt++] = strdup("-k");
1087 argv[argcnt++] = req_key;
1089 argv[argcnt++] = strdup("-m");
1091 argv[argcnt++] = strdup(pkgid);
1093 argv[argcnt++] = strdup("-t");
1095 argv[argcnt++] = strdup(buf);
1096 /* argv[7] -q option should be located at the end of command !! */
1097 if (mode == PM_QUIET)
1098 argv[argcnt++] = strdup("-q");
1100 /*** add quote in all string for special charactor like '\n'*** FIX */
1101 for (i = 0; i < argcnt; i++) {
1102 temp = g_shell_quote(argv[i]);
1103 len += (strlen(temp) + 1);
1107 args = (char *)calloc(len, sizeof(char));
1109 _LOGD("calloc failed");
1111 for (i = 0; i < argcnt; i++)
1114 return PKGMGR_R_ERROR;
1116 strncpy(args, argv[0], len - 1);
1118 for (i = 1; i < argcnt; i++) {
1119 strncat(args, " ", strlen(" "));
1120 temp = g_shell_quote(argv[i]);
1121 strncat(args, temp, strlen(temp));
1124 _LOGD("[args] %s [len] %d\n", args, len);
1125 /******************* end of quote ************************/
1127 /* 6. request install */
1128 ret = comm_client_request(mpc->info.request.cc, req_key,
1129 COMM_REQ_TO_MOVER, pkgtype, pkgid,
1132 _LOGE("request failed, ret=%d\n", ret);
1134 for (i = 0; i < argcnt; i++)
1138 return PKGMGR_R_ECOMM;
1141 for (i = 0; i < argcnt; i++)
1149 API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type,
1152 const char *pkgtype;
1154 char *cookie = NULL;
1156 /* Check for NULL value of pc */
1158 _LOGD("package manager client handle is NULL\n");
1159 return PKGMGR_R_EINVAL;
1161 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1163 /* 0. check the pc type */
1164 if (mpc->ctype != PC_REQUEST)
1165 return PKGMGR_R_EINVAL;
1167 /* 1. check argument */
1169 return PKGMGR_R_EINVAL;
1171 if (pkg_type == NULL) {
1172 pkgtype = _get_pkg_type_from_desktop_file(pkgid);
1173 if (pkgtype == NULL)
1174 return PKGMGR_R_EINVAL;
1178 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1179 return PKGMGR_R_EINVAL;
1181 /* 2. generate req_key */
1182 req_key = __get_req_key(pkgid);
1184 /* 3. request activate */
1185 ret = comm_client_request(mpc->info.request.cc, req_key,
1186 COMM_REQ_TO_ACTIVATOR, pkgtype,
1187 pkgid, "1 PKG", cookie, 1);
1189 _LOGE("request failed, ret=%d\n", ret);
1191 return PKGMGR_R_ECOMM;
1199 API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
1202 const char *pkgtype;
1204 char *cookie = NULL;
1206 /* Check for NULL value of pc */
1208 _LOGD("package manager client handle is NULL\n");
1209 return PKGMGR_R_EINVAL;
1211 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1213 /* 0. check the pc type */
1214 if (mpc->ctype != PC_REQUEST)
1215 return PKGMGR_R_EINVAL;
1217 /* 1. check argument */
1219 return PKGMGR_R_EINVAL;
1221 if (pkg_type == NULL) {
1222 pkgtype = _get_pkg_type_from_desktop_file(pkgid);
1223 if (pkgtype == NULL)
1224 return PKGMGR_R_EINVAL;
1228 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1229 return PKGMGR_R_EINVAL;
1231 /* 2. generate req_key */
1232 req_key = __get_req_key(pkgid);
1234 /* 3. request activate */
1235 ret = comm_client_request(mpc->info.request.cc, req_key,
1236 COMM_REQ_TO_ACTIVATOR, pkgtype,
1237 pkgid, "0 PKG", cookie, 1);
1239 _LOGE("request failed, ret=%d\n", ret);
1241 return PKGMGR_R_ECOMM;
1249 API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
1251 const char *pkgtype;
1253 char *cookie = NULL;
1255 /* Check for NULL value of pc */
1257 _LOGD("package manager client handle is NULL\n");
1258 return PKGMGR_R_EINVAL;
1260 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1262 /* 0. check the pc type */
1263 if (mpc->ctype != PC_REQUEST)
1264 return PKGMGR_R_EINVAL;
1266 /* 1. check argument */
1268 return PKGMGR_R_EINVAL;
1270 if (strlen(appid) >= PKG_STRING_LEN_MAX)
1271 return PKGMGR_R_EINVAL;
1273 pkgtype = _get_pkg_type_from_desktop_file(appid);
1275 /* 2. generate req_key */
1276 req_key = __get_req_key(appid);
1278 /* 3. request activate */
1279 ret = comm_client_request(mpc->info.request.cc, req_key,
1280 COMM_REQ_TO_ACTIVATOR, pkgtype,
1281 appid, "1 APP", cookie, 1);
1283 _LOGE("request failed, ret=%d\n", ret);
1285 return PKGMGR_R_ECOMM;
1293 API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[])
1295 const char *pkgtype;
1297 char *cookie = NULL;
1305 /* Check for NULL value of pc */
1307 _LOGD("package manager client handle is NULL\n");
1308 return PKGMGR_R_EINVAL;
1310 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1312 /* 0. check the pc type */
1313 if (mpc->ctype != PC_REQUEST)
1314 return PKGMGR_R_EINVAL;
1316 /* 1. check argument */
1318 return PKGMGR_R_EINVAL;
1320 if (strlen(appid) >= PKG_STRING_LEN_MAX)
1321 return PKGMGR_R_EINVAL;
1323 pkgtype = _get_pkg_type_from_desktop_file(appid);
1325 /* 2. generate req_key */
1326 req_key = __get_req_key(appid);
1328 /*** add quote in all string for special charactor like '\n'*** FIX */
1330 for (i = 0; argv[i]; i++) {
1331 temp = g_shell_quote(argv[i]);
1332 len += (strlen(temp) + 1);
1338 args = (char *)calloc(len, sizeof(char));
1340 _LOGE("calloc failed");
1342 return PKGMGR_R_ERROR;
1344 strncpy(args, argv[0], len - 1);
1346 for (i = 1; i < argcnt; i++) {
1347 strncat(args, " ", strlen(" "));
1348 temp = g_shell_quote(argv[i]);
1349 strncat(args, temp, strlen(temp));
1355 argsr = (char *)calloc(strlen("1 APP")+2+len, sizeof(char));
1356 if (argsr == NULL) {
1357 _LOGE("calloc failed");
1360 return PKGMGR_R_ERROR;
1362 strncpy(argsr, "1 APP", strlen("1 APP"));
1364 strncat(argsr, " ", strlen(" "));
1365 strncat(argsr, args, strlen(args));
1368 _LOGD("argsr [%s]\n", argsr);
1369 /******************* end of quote ************************/
1371 /* 3. request activate */
1372 ret = comm_client_request(mpc->info.request.cc, req_key,
1373 COMM_REQ_TO_ACTIVATOR, pkgtype,
1374 appid, argsr, cookie, 1);
1376 _LOGE("request failed, ret=%d\n", ret);
1380 return PKGMGR_R_ECOMM;
1390 API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
1392 const char *pkgtype;
1394 char *cookie = NULL;
1396 /* Check for NULL value of pc */
1398 _LOGD("package manager client handle is NULL\n");
1399 return PKGMGR_R_EINVAL;
1401 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1403 /* 0. check the pc type */
1404 if (mpc->ctype != PC_REQUEST)
1405 return PKGMGR_R_EINVAL;
1407 /* 1. check argument */
1409 return PKGMGR_R_EINVAL;
1411 if (strlen(appid) >= PKG_STRING_LEN_MAX)
1412 return PKGMGR_R_EINVAL;
1414 pkgtype = _get_pkg_type_from_desktop_file(appid);
1416 /* 2. generate req_key */
1417 req_key = __get_req_key(appid);
1419 /* 3. request activate */
1420 ret = comm_client_request(mpc->info.request.cc, req_key,
1421 COMM_REQ_TO_ACTIVATOR, pkgtype,
1422 appid, "0 APP", cookie, 1);
1424 _LOGE("request failed, ret=%d\n", ret);
1426 return PKGMGR_R_ECOMM;
1435 API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
1436 const char *appid, pkgmgr_mode mode)
1438 const char *pkgtype;
1439 char *installer_path;
1442 char *argv[PKG_ARGC_MAX] = { NULL, };
1448 char *cookie = NULL;
1450 /* Check for NULL value of pc */
1452 _LOGD("package manager client handle is NULL\n");
1453 return PKGMGR_R_EINVAL;
1455 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1457 /* 0. check the pc type */
1458 if (mpc->ctype != PC_REQUEST)
1459 return PKGMGR_R_EINVAL;
1461 /* 1. check argument */
1463 return PKGMGR_R_EINVAL;
1466 if (pkg_type == NULL) {
1467 pkgtype = _get_pkg_type_from_desktop_file(appid);
1468 if (pkgtype == NULL)
1469 return PKGMGR_R_EINVAL;
1473 if (strlen(appid) >= PKG_STRING_LEN_MAX)
1474 return PKGMGR_R_EINVAL;
1476 /* 2. get installer path using pkg_path */
1477 installer_path = _get_backend_path_with_type(pkgtype);
1478 if (installer_path == NULL)
1479 return PKGMGR_R_EINVAL;
1481 /* 3. generate req_key */
1482 req_key = __get_req_key(appid);
1484 /* 4. generate argv */
1486 /* argv[0] installer path */
1487 argv[argcnt++] = installer_path;
1489 argv[argcnt++] = strdup("-k");
1491 argv[argcnt++] = req_key;
1493 argv[argcnt++] = strdup("-c");
1495 argv[argcnt++] = strdup(appid);
1496 /* argv[5] -q option should be located at the end of command !! */
1497 if (mode == PM_QUIET)
1498 argv[argcnt++] = strdup("-q");
1500 /*** add quote in all string for special charactor like '\n'*** FIX */
1501 for (i = 0; i < argcnt; i++) {
1502 temp = g_shell_quote(argv[i]);
1503 len += (strlen(temp) + 1);
1507 args = (char *)calloc(len, sizeof(char));
1509 _LOGD("calloc failed");
1511 for (i = 0; i < argcnt; i++)
1514 return PKGMGR_R_ERROR;
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 _LOGD("[args] %s [len] %d\n", args, len);
1525 /******************* end of quote ************************/
1527 /* 6. request clear */
1528 ret = comm_client_request(mpc->info.request.cc, req_key,
1529 COMM_REQ_TO_CLEARER, pkgtype, appid,
1532 _LOGE("request failed, ret=%d\n", ret);
1534 for (i = 0; i < argcnt; i++)
1538 return PKGMGR_R_ECOMM;
1541 for (i = 0; i < argcnt; i++)
1549 API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
1553 /* Check for NULL value of pc */
1555 _LOGD("package manager client handle is NULL\n");
1556 return PKGMGR_R_EINVAL;
1558 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1560 /* 0. check the pc type */
1561 if (mpc->ctype != PC_LISTENING)
1562 return PKGMGR_R_EINVAL;
1564 /* 1. check argument */
1565 if (event_cb == NULL)
1566 return PKGMGR_R_EINVAL;
1568 /* 2. add callback info to pkgmgr_client */
1569 req_id = _get_request_id();
1570 __add_stat_cbinfo(mpc, req_id, event_cb, data);
1575 API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
1576 const char *pkgid, const char *key,
1579 /* Check for NULL value of pc */
1581 _LOGD("package manager client handle is NULL\n");
1582 return PKGMGR_R_EINVAL;
1584 /* Check for valid arguments. NULL parameter causes DBUS to abort */
1585 if (pkgid == NULL || pkg_type == NULL || key == NULL || val == NULL) {
1586 _LOGD("Argument supplied is NULL\n");
1587 return PKGMGR_R_EINVAL;
1589 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1591 /* 0. check the pc type */
1592 if (mpc->ctype != PC_BROADCAST)
1593 return PKGMGR_R_EINVAL;
1595 comm_status_broadcast_server_send_signal(mpc->info.broadcast.bc,
1596 PKG_STATUS, pkg_type,
1602 API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
1604 return pkgmgr_info_new_from_file(NULL, pkg_path);
1607 API int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info)
1609 if (pkg_info == NULL)
1610 return PKGMGR_R_EINVAL;
1612 package_manager_pkg_detail_info_t *info = (package_manager_pkg_detail_info_t *)pkg_info;
1615 free(info->icon_buf);
1617 if (info->privilege_list)
1618 g_list_free(info->privilege_list);
1626 API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type,
1627 pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
1628 const char *optional_file, void *optional_mode,
1629 pkgmgr_handler event_cb, void *data)
1631 char *installer_path;
1636 /* Check for NULL value of service type */
1637 retvm_if(service_type > PM_REQUEST_MAX, PKGMGR_R_EINVAL, "service type is not defined\n");
1639 /* check optional_file length */
1641 retvm_if(strlen(optional_file) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
1643 /* add callback info - add callback info to pkgmgr_client if there is pc and pkgid */
1645 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1646 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1647 req_key = __get_req_key(pkgid);
1648 req_id = _get_request_id();
1649 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1652 switch (service_type) {
1653 case PM_REQUEST_CSC:
1654 ret = __csc_process(optional_file, (char *)data);
1656 _LOGE("__csc_process fail \n");
1659 case PM_REQUEST_MOVE:
1663 case PM_REQUEST_GET_SIZE:
1668 printf("Wrong Request\n");
1677 #define __START_OF_OLD_API
1678 ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
1684 iter_data *udata = (iter_data *) user_data;
1686 ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PACKAGETYPE_STR, &type);
1689 ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
1690 if (package == NULL)
1692 ail_appinfo_get_str(appinfo, AIL_PROP_VERSION_STR, &version);
1693 if (version == NULL)
1696 if (udata->iter_fn(type, package, version, udata->data) != 0)
1697 return AIL_CB_RET_CANCEL;
1699 return AIL_CB_RET_CONTINUE;
1702 API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data)
1705 ail_filter_h filter;
1708 if (iter_fn == NULL)
1709 return PKGMGR_R_EINVAL;
1711 ret = ail_filter_new(&filter);
1712 if (ret != AIL_ERROR_OK) {
1713 return PKGMGR_R_ERROR;
1716 ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
1717 if (ret != AIL_ERROR_OK) {
1718 ail_filter_destroy(filter);
1719 return PKGMGR_R_ERROR;
1722 ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
1723 if (ret != AIL_ERROR_OK) {
1724 ail_filter_destroy(filter);
1725 return PKGMGR_R_ERROR;
1728 ret = ail_filter_count_appinfo(filter, &cnt);
1729 if (ret != AIL_ERROR_OK) {
1730 ail_filter_destroy(filter);
1731 return PKGMGR_R_ERROR;
1734 iter_data *udata = calloc(1, sizeof(iter_data));
1735 if (udata == NULL) {
1736 _LOGE("calloc failed");
1737 ail_filter_destroy(filter);
1739 return PKGMGR_R_ERROR;
1741 udata->iter_fn = iter_fn;
1744 ail_filter_list_appinfo_foreach(filter, __appinfo_func, udata);
1748 ret = ail_filter_destroy(filter);
1749 if (ret != AIL_ERROR_OK) {
1750 return PKGMGR_R_ERROR;
1756 API pkgmgr_info *pkgmgr_info_new(const char *pkg_type, const char *pkgid)
1758 const char *pkgtype;
1759 pkg_plugin_set *plugin_set = NULL;
1760 package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
1762 /* 1. check argument */
1766 if (pkg_type == NULL) {
1767 pkgtype = _get_pkg_type_from_desktop_file(pkgid);
1768 if (pkgtype == NULL)
1773 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1776 pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
1777 if (pkg_detail_info == NULL) {
1778 _LOGE("*** Failed to alloc package_handler_info.\n");
1782 plugin_set = _package_manager_load_library(pkgtype);
1783 if (plugin_set == NULL) {
1784 _LOGE("*** Failed to load library");
1785 free(pkg_detail_info);
1789 if (plugin_set->pkg_is_installed) {
1790 if (plugin_set->pkg_is_installed(pkgid) != 0) {
1791 _LOGE("*** Failed to call pkg_is_installed()");
1792 free(pkg_detail_info);
1796 if (plugin_set->get_pkg_detail_info) {
1797 if (plugin_set->get_pkg_detail_info(pkgid,
1798 pkg_detail_info) != 0) {
1799 _LOGE("*** Failed to call get_pkg_detail_info()");
1800 free(pkg_detail_info);
1806 return (pkgmgr_info *) pkg_detail_info;
1809 API char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key)
1811 package_manager_pkg_detail_info_t *pkg_detail_info;
1813 if (pkg_info == NULL)
1818 pkg_detail_info = (package_manager_pkg_detail_info_t *) pkg_info;
1820 return _get_info_string(key, pkg_detail_info);
1823 API pkgmgr_info *pkgmgr_info_new_from_file(const char *pkg_type,
1824 const char *pkg_path)
1826 pkg_plugin_set *plugin_set = NULL;
1827 package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
1829 if (pkg_path == NULL) {
1830 _LOGE("pkg_path is NULL\n");
1834 if (strlen(pkg_path) > PKG_URL_STRING_LEN_MAX) {
1835 _LOGE("length of pkg_path is too long - %d.\n",
1840 pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
1841 if (pkg_detail_info == NULL) {
1842 _LOGE("*** Failed to alloc package_handler_info.\n");
1846 if (pkg_type == NULL)
1847 pkgtype = __get_type_from_path(pkg_path);
1849 pkgtype = strdup(pkg_type);
1851 plugin_set = _package_manager_load_library(pkgtype);
1852 if (plugin_set == NULL) {
1853 free(pkg_detail_info);
1858 if (plugin_set->get_pkg_detail_info_from_package) {
1859 if (plugin_set->get_pkg_detail_info_from_package(pkg_path,
1860 pkg_detail_info) != 0) {
1861 free(pkg_detail_info);
1868 return (pkgmgr_info *) pkg_detail_info;
1871 API int pkgmgr_info_free(pkgmgr_info * pkg_info)
1873 if (pkg_info == NULL)
1874 return PKGMGR_R_EINVAL;
1882 #define __END_OF_OLD_API
1884 API int pkgmgr_pkginfo_get_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data)
1887 ret = pkgmgrinfo_pkginfo_get_list(pkg_list_cb, user_data);
1891 API int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle)
1894 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, handle);
1898 API int pkgmgr_pkginfo_get_pkgname(pkgmgr_pkginfo_h handle, char **pkg_name)
1901 ret = pkgmgrinfo_pkginfo_get_pkgname(handle, pkg_name);
1906 API int pkgmgr_pkginfo_get_pkgid(pkgmgr_pkginfo_h handle, char **pkgid)
1909 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, pkgid);
1913 API int pkgmgr_pkginfo_get_type(pkgmgr_pkginfo_h handle, char **type)
1916 ret = pkgmgrinfo_pkginfo_get_type(handle, type);
1920 API int pkgmgr_pkginfo_get_version(pkgmgr_pkginfo_h handle, char **version)
1923 ret = pkgmgrinfo_pkginfo_get_version(handle, version);
1927 API int pkgmgr_pkginfo_get_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location)
1930 pkgmgrinfo_install_location loc;
1931 ret = pkgmgrinfo_pkginfo_get_install_location(handle, &loc);
1936 API int pkgmgr_pkginfo_get_package_size(pkgmgr_pkginfo_h handle, int *size)
1939 ret = pkgmgrinfo_pkginfo_get_package_size(handle, size);
1943 API int pkgmgr_pkginfo_get_icon(pkgmgr_pkginfo_h handle, char **icon)
1946 ret = pkgmgrinfo_pkginfo_get_icon(handle, icon);
1950 API int pkgmgr_pkginfo_get_label(pkgmgr_pkginfo_h handle, char **label)
1953 ret = pkgmgrinfo_pkginfo_get_label(handle, label);
1957 API int pkgmgr_pkginfo_get_description(pkgmgr_pkginfo_h handle, char **description)
1960 ret = pkgmgrinfo_pkginfo_get_description(handle, description);
1964 API int pkgmgr_pkginfo_get_author_name(pkgmgr_pkginfo_h handle, char **author_name)
1967 ret = pkgmgrinfo_pkginfo_get_author_name(handle, author_name);
1971 API int pkgmgr_pkginfo_get_author_email(pkgmgr_pkginfo_h handle, char **author_email)
1974 ret = pkgmgrinfo_pkginfo_get_author_email(handle, author_email);
1978 API int pkgmgr_pkginfo_get_author_href(pkgmgr_pkginfo_h handle, char **author_href)
1981 ret = pkgmgrinfo_pkginfo_get_author_href(handle, author_href);
1985 API int pkgmgr_pkginfo_is_removable(pkgmgr_pkginfo_h handle, bool *removable)
1988 ret = pkgmgrinfo_pkginfo_is_removable(handle, removable);
1992 API int pkgmgr_pkginfo_is_preload(pkgmgr_pkginfo_h handle, bool *preload)
1995 ret = pkgmgrinfo_pkginfo_is_preload(handle, preload);
1999 API int pkgmgr_pkginfo_is_readonly(pkgmgr_pkginfo_h handle, bool *readonly)
2002 ret = pkgmgrinfo_pkginfo_is_readonly(handle, readonly);
2006 API int pkgmgr_pkginfo_is_accessible(pkgmgr_pkginfo_h handle, bool *accessible)
2009 ret = pkgmgrinfo_pkginfo_is_accessible(handle, accessible);
2013 API int pkgmgr_pkginfo_destroy_pkginfo(pkgmgr_pkginfo_h handle)
2016 ret = pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2020 API int pkgmgr_pkginfo_get_installed_storage(pkgmgr_pkginfo_h handle, pkgmgr_installed_storage *storage)
2023 pkgmgrinfo_installed_storage sto;
2024 ret = pkgmgrinfo_pkginfo_get_installed_storage(handle, &sto);
2029 API int pkgmgr_pkginfo_get_installed_time(pkgmgr_pkginfo_h handle, int *installed_time)
2032 ret = pkgmgrinfo_pkginfo_get_installed_time(handle, installed_time);
2036 API int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
2037 pkgmgr_info_app_list_cb app_func, void *user_data)
2040 ret = pkgmgrinfo_appinfo_get_list(handle, component, app_func, user_data);
2044 API int pkgmgr_appinfo_foreach_category(pkgmgr_appinfo_h handle, pkgmgr_info_app_category_list_cb category_func,
2048 ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, user_data);
2052 API int pkgmgr_appinfo_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle)
2055 ret = pkgmgrinfo_appinfo_get_appinfo(appid, handle);
2059 API int pkgmgr_appinfo_get_appid(pkgmgr_appinfo_h handle, char **appid)
2062 ret = pkgmgrinfo_appinfo_get_appid(handle, appid);
2066 API int pkgmgr_appinfo_get_pkgname(pkgmgr_appinfo_h handle, char **pkg_name)
2069 ret = pkgmgrinfo_appinfo_get_pkgname(handle, pkg_name);
2073 API int pkgmgr_appinfo_get_pkgid(pkgmgr_appinfo_h handle, char **pkgid)
2076 ret = pkgmgrinfo_appinfo_get_pkgid(handle, pkgid);
2080 API int pkgmgr_appinfo_get_icon(pkgmgr_appinfo_h handle, char **icon)
2083 ret = pkgmgrinfo_appinfo_get_icon(handle, icon);
2087 API int pkgmgr_appinfo_get_label(pkgmgr_appinfo_h handle, char **label)
2090 ret = pkgmgrinfo_appinfo_get_label(handle, label);
2094 API int pkgmgr_appinfo_get_exec(pkgmgr_appinfo_h handle, char **exec)
2097 ret = pkgmgrinfo_appinfo_get_exec(handle, exec);
2101 API int pkgmgr_appinfo_get_component(pkgmgr_appinfo_h handle, pkgmgr_app_component *component)
2104 pkgmgrinfo_app_component comp;
2105 ret = pkgmgrinfo_appinfo_get_component(handle, &comp);
2110 API int pkgmgr_appinfo_get_apptype(pkgmgr_appinfo_h handle, char **app_type)
2113 ret = pkgmgrinfo_appinfo_get_apptype(handle, app_type);
2117 API int pkgmgr_appinfo_is_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay)
2120 ret = pkgmgrinfo_appinfo_is_nodisplay(handle, nodisplay);
2124 API int pkgmgr_appinfo_is_multiple(pkgmgr_appinfo_h handle, bool *multiple)
2127 ret = pkgmgrinfo_appinfo_is_multiple(handle, multiple);
2131 API int pkgmgr_appinfo_is_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage)
2134 ret = pkgmgrinfo_appinfo_is_taskmanage(handle, taskmanage);
2138 API int pkgmgr_appinfo_get_hwacceleration(pkgmgr_appinfo_h handle, pkgmgr_hwacceleration_type *hwacceleration)
2141 pkgmgrinfo_app_hwacceleration hwacc;
2142 ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
2143 *hwacceleration = hwacc;
2147 API int pkgmgr_appinfo_is_onboot(pkgmgr_appinfo_h handle, bool *onboot)
2150 ret = pkgmgrinfo_appinfo_is_onboot(handle, onboot);
2154 API int pkgmgr_appinfo_is_autorestart(pkgmgr_appinfo_h handle, bool *autorestart)
2157 ret = pkgmgrinfo_appinfo_is_autorestart(handle, autorestart);
2161 API int pkgmgr_appinfo_destroy_appinfo(pkgmgr_appinfo_h handle)
2164 ret = pkgmgrinfo_appinfo_destroy_appinfo(handle);
2168 API int pkgmgr_pkginfo_create_certinfo(pkgmgr_certinfo_h *handle)
2171 ret = pkgmgrinfo_pkginfo_create_certinfo(handle);
2175 API int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle)
2178 ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle);
2182 API int pkgmgr_pkginfo_get_cert_value(pkgmgr_certinfo_h handle, pkgmgr_cert_type cert_type, const char **cert_value)
2185 ret = pkgmgrinfo_pkginfo_get_cert_value(handle, cert_type, cert_value);
2189 API int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle)
2192 ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
2196 API int pkgmgr_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
2199 ret = pkgmgrinfo_datacontrol_get_info(providerid, type, appid, access);