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>
40 #include <security-server.h>
42 #include "package-manager.h"
43 #include "pkgmgr-internal.h"
44 #include "pkgmgr-debug.h"
45 #include "pkgmgr-api.h"
46 #include "comm_client.h"
47 #include "comm_status_broadcast_server.h"
51 #define LOG_TAG "PKGMGR"
54 #define PKG_TMP_PATH "/opt/usr/apps/tmp"
56 static int _get_request_id()
58 static int internal_req_id = 1;
60 return internal_req_id++;
63 typedef struct _req_cb_info {
66 pkgmgr_handler event_cb;
68 struct _req_cb_info *next;
71 typedef struct _listen_cb_info {
73 pkgmgr_handler event_cb;
75 struct _listen_cb_info *next;
78 typedef struct _pkgmgr_client_t {
87 listen_cb_info *lhead;
95 typedef struct _iter_data {
96 pkgmgr_iter_fn iter_fn;
100 static char *__get_cookie_from_security_server(void)
103 size_t cookie_size = 0;
104 char *e_cookie = NULL;
106 //calculage cookie size
107 cookie_size = security_server_get_cookie_size();
108 retvm_if(cookie_size <= 0, NULL, "security_server_get_cookie_size : cookie_size is %d", cookie_size);
110 //get cookie from security server
111 char cookie[cookie_size];
113 ret = security_server_request_cookie(cookie, cookie_size);
114 retvm_if(ret < 0, NULL, "security_server_request_cookie fail (%d)", ret);
117 e_cookie = g_base64_encode((const guchar *)cookie, cookie_size);
118 retvm_if(e_cookie == NULL, NULL, "g_base64_encode e_cookie is NULL");
123 static int __xsystem(const char *argv[])
130 perror("fork failed");
134 execvp(argv[0], (char *const *)argv);
140 if (waitpid(pid, &status, 0) == -1) {
141 perror("waitpid failed");
144 if (WIFSIGNALED(status)) {
148 if (!WIFEXITED(status)) {
149 /* shouldn't happen */
150 perror("should not happen");
153 return WEXITSTATUS(status);
156 static void __error_to_string(int errnumber, char **errstr)
161 case PKGCMD_ERR_PACKAGE_NOT_FOUND:
162 *errstr = PKGCMD_ERR_PACKAGE_NOT_FOUND_STR;
164 case PKGCMD_ERR_PACKAGE_INVALID:
165 *errstr = PKGCMD_ERR_PACKAGE_INVALID_STR;
167 case PKGCMD_ERR_PACKAGE_LOWER_VERSION:
168 *errstr = PKGCMD_ERR_PACKAGE_LOWER_VERSION_STR;
170 case PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND:
171 *errstr = PKGCMD_ERR_PACKAGE_EXECUTABLE_NOT_FOUND_STR;
173 case PKGCMD_ERR_MANIFEST_INVALID:
174 *errstr = PKGCMD_ERR_MANIFEST_INVALID_STR;
176 case PKGCMD_ERR_CONFIG_NOT_FOUND:
177 *errstr = PKGCMD_ERR_CONFIG_NOT_FOUND_STR;
179 case PKGCMD_ERR_CONFIG_INVALID:
180 *errstr = PKGCMD_ERR_CONFIG_INVALID_STR;
182 case PKGCMD_ERR_SIGNATURE_NOT_FOUND:
183 *errstr = PKGCMD_ERR_SIGNATURE_NOT_FOUND_STR;
185 case PKGCMD_ERR_SIGNATURE_INVALID:
186 *errstr = PKGCMD_ERR_SIGNATURE_INVALID_STR;
188 case PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED:
189 *errstr = PKGCMD_ERR_SIGNATURE_VERIFICATION_FAILED_STR;
191 case PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND:
192 *errstr = PKGCMD_ERR_ROOT_CERTIFICATE_NOT_FOUND_STR;
194 case PKGCMD_ERR_CERTIFICATE_INVALID:
195 *errstr = PKGCMD_ERR_CERTIFICATE_INVALID_STR;
197 case PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED:
198 *errstr = PKGCMD_ERR_CERTIFICATE_CHAIN_VERIFICATION_FAILED_STR;
200 case PKGCMD_ERR_CERTIFICATE_EXPIRED:
201 *errstr = PKGCMD_ERR_CERTIFICATE_EXPIRED_STR;
203 case PKGCMD_ERR_INVALID_PRIVILEGE:
204 *errstr = PKGCMD_ERR_INVALID_PRIVILEGE_STR;
206 case PKGCMD_ERR_MENU_ICON_NOT_FOUND:
207 *errstr = PKGCMD_ERR_MENU_ICON_NOT_FOUND_STR;
209 case PKGCMD_ERR_FATAL_ERROR:
210 *errstr = PKGCMD_ERR_FATAL_ERROR_STR;
212 case PKGCMD_ERR_OUT_OF_STORAGE:
213 *errstr = PKGCMD_ERR_OUT_OF_STORAGE_STR;
215 case PKGCMD_ERR_OUT_OF_MEMORY:
216 *errstr = PKGCMD_ERR_OUT_OF_MEMORY_STR;
218 case PKGCMD_ERR_ARGUMENT_INVALID:
219 *errstr = PKGCMD_ERR_ARGUMENT_INVALID_STR;
222 *errstr = PKGCMD_ERR_UNKNOWN_STR;
227 static void __add_op_cbinfo(pkgmgr_client_t * pc, int request_id,
228 const char *req_key, pkgmgr_handler event_cb,
231 req_cb_info *cb_info;
232 req_cb_info *current;
235 cb_info = (req_cb_info *) calloc(1, sizeof(req_cb_info));
236 if (cb_info == NULL) {
237 _LOGD("calloc failed");
240 cb_info->request_id = request_id;
241 cb_info->req_key = strdup(req_key);
242 cb_info->event_cb = event_cb;
243 cb_info->data = data;
244 cb_info->next = NULL;
246 if (pc->info.request.rhead == NULL)
247 pc->info.request.rhead = cb_info;
249 current = prev = pc->info.request.rhead;
252 current = current->next;
255 prev->next = cb_info;
259 static req_cb_info *__find_op_cbinfo(pkgmgr_client_t *pc, const char *req_key)
263 tmp = pc->info.request.rhead;
266 _LOGE("tmp is NULL");
270 _LOGD("tmp->req_key %s, req_key %s", tmp->req_key, req_key);
273 if (strncmp(tmp->req_key, req_key, strlen(tmp->req_key)) == 0)
280 static void __remove_op_cbinfo(pkgmgr_client_t *pc, req_cb_info *info)
284 if (pc == NULL || pc->info.request.rhead == NULL || info == NULL)
287 tmp = pc->info.request.rhead;
289 if (tmp->next == info) {
290 tmp->next = info->next;
299 static void __add_stat_cbinfo(pkgmgr_client_t *pc, int request_id,
300 pkgmgr_handler event_cb, void *data)
302 listen_cb_info *cb_info;
303 listen_cb_info *current;
304 listen_cb_info *prev;
306 cb_info = (listen_cb_info *) calloc(1, sizeof(listen_cb_info));
307 if (cb_info == NULL) {
308 _LOGD("calloc failed");
311 cb_info->request_id = request_id;
312 cb_info->event_cb = event_cb;
313 cb_info->data = data;
314 cb_info->next = NULL;
316 /* TODO - check the order of callback - FIFO or LIFO => Should be changed to LIFO */
317 if (pc->info.listening.lhead == NULL)
318 pc->info.listening.lhead = cb_info;
320 current = prev = pc->info.listening.lhead;
323 current = current->next;
326 prev->next = cb_info;
330 static void __operation_callback(void *cb_data, const char *req_id,
331 const char *pkg_type, const char *pkgid,
332 const char *key, const char *val)
335 req_cb_info *cb_info;
337 _LOGD("__operation_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
338 "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
340 pc = (pkgmgr_client_t *) cb_data;
342 /* find callback info */
343 cb_info = __find_op_cbinfo(pc, req_id);
347 _LOGD("__find_op_cbinfo");
350 if (cb_info->event_cb) {
351 cb_info->event_cb(cb_info->request_id, pkg_type, pkgid, key,
352 val, NULL, cb_info->data);
353 _LOGD("event_cb is called");
356 /*remove callback for last call
357 if (strcmp(key, "end") == 0) {
358 __remove_op_cbinfo(pc, cb_info);
359 _LOGD("__remove_op_cbinfo");
366 static void __status_callback(void *cb_data, const char *req_id,
367 const char *pkg_type, const char *pkgid,
368 const char *key, const char *val)
373 _LOGD("__status_callback() req_id[%s] pkg_type[%s] pkgid[%s]"
374 "key[%s] val[%s]\n", req_id, pkg_type, pkgid, key, val);
376 pc = (pkgmgr_client_t *) cb_data;
378 tmp = pc->info.listening.lhead;
380 if (tmp->event_cb(tmp->request_id, pkg_type, pkgid, key, val,
381 NULL, tmp->data) != 0)
389 static char *__get_req_key(const char *pkg_path)
393 char timestr[PKG_STRING_LEN_MAX];
397 gettimeofday(&tv, NULL);
398 curtime = tv.tv_sec * 1000000 + tv.tv_usec;
399 snprintf(timestr, sizeof(timestr), "%ld", curtime);
401 size = strlen(pkg_path) + strlen(timestr) + 2;
402 str_req_key = (char *)calloc(size, sizeof(char));
403 if (str_req_key == NULL) {
404 _LOGD("calloc failed");
407 snprintf(str_req_key, size, "%s_%s", pkg_path, timestr);
412 static char *__get_type_from_path(const char *pkg_path)
415 char mimetype[255] = { '\0', };
416 char extlist[256] = { '\0', };
419 ret = _get_mime_from_file(pkg_path, mimetype, sizeof(mimetype));
421 _LOGE("_get_mime_from_file() failed - error code[%d]\n",
426 ret = _get_mime_extension(mimetype, extlist, sizeof(extlist));
428 _LOGE("_get_mime_extension() failed - error code[%d]\n",
433 if (strlen(extlist) == 0)
436 if (strchr(extlist, ',')) {
437 extlist[strlen(extlist) - strlen(strchr(extlist, ','))] = '\0';
439 pkg_type = strchr(extlist, '.') + 1;
440 return strdup(pkg_type);
443 static inline int __pkgmgr_read_proc(const char *path, char *buf, int size)
448 if (buf == NULL || path == NULL)
451 fd = open(path, O_RDONLY);
455 ret = read(fd, buf, size - 1);
467 static inline int __pkgmgr_find_pid_by_cmdline(const char *dname,
468 const char *cmdline, const char *apppath)
472 if (strncmp(cmdline, apppath, PKG_STRING_LEN_MAX-1) == 0) {
474 if (pid != getpgid(pid))
482 static int __pkgmgr_proc_iter_kill_cmdline(const char *apppath)
485 struct dirent *dentry;
488 char buf[PKG_STRING_LEN_MAX];
490 dp = opendir("/proc");
495 while ((dentry = readdir(dp)) != NULL) {
496 if (!isdigit(dentry->d_name[0]))
499 snprintf(buf, sizeof(buf), "/proc/%s/cmdline", dentry->d_name);
500 ret = __pkgmgr_read_proc(buf, buf, sizeof(buf));
504 pid = __pkgmgr_find_pid_by_cmdline(dentry->d_name, buf, apppath);
515 if (killpg(pgid, SIGKILL) < 0) {
527 static int __app_list_cb (const pkgmgr_appinfo_h handle,
531 pkgmgr_appinfo_get_exec(handle, &exec);
533 __pkgmgr_proc_iter_kill_cmdline(exec);
538 static int __sync_process(char *req_key)
541 char info_file[PKG_STRING_LEN_MAX] = {'\0', };
545 char buffer[PKG_ARGC_MAX] = {'\0', };
547 snprintf(info_file, PKG_STRING_LEN_MAX, "%s/%s", PKG_TMP_PATH, req_key);
552 vconf_get_int(VCONFKEY_PKGMGR_STATUS, &result);
554 _LOGD("file is not generated yet.... wait\n");
555 usleep(10 * 1000); /* 10ms sleep*/
557 _LOGD("info_file file is generated, result = %d. \n", result);
561 if (check_cnt > 500) { /* 5s time over*/
562 _LOGD("wait time over!!\n");
567 vconf_set_int(VCONFKEY_PKGMGR_STATUS, -1);
571 static int __csc_process(const char *csc_path, char *result_path)
578 char *pkgtype = NULL;
580 char buf[PKG_STRING_LEN_MAX] = {0,};
581 char type_buf[1024] = { 0 };
582 char des_buf[1024] = { 0 };
583 dictionary *csc = NULL;
586 csc = iniparser_load(csc_path);
587 retvm_if(csc == NULL, PKGMGR_R_EINVAL, "cannot open parse file [%s]", csc_path);
589 file = fopen(result_path, "w");
590 tryvm_if(file == NULL, ret = PKGMGR_R_EINVAL, "cannot open result file [%s]", result_path);
592 count = iniparser_getint(csc, "csc packages:count", -1);
593 tryvm_if(count == 0, ret = PKGMGR_R_ERROR, "csc [%s] dont have packages", csc_path);
595 snprintf(buf, PKG_STRING_LEN_MAX, "[result]\n");
596 fwrite(buf, 1, strlen(buf), file);
597 snprintf(buf, PKG_STRING_LEN_MAX, "count = %d\n", count);
598 fwrite(buf, 1, strlen(buf), file);
600 for(cnt = 1 ; cnt <= count ; cnt++)
602 snprintf(type_buf, PKG_STRING_LEN_MAX - 1, "csc packages:type_%03d", cnt);
603 snprintf(des_buf, PKG_STRING_LEN_MAX - 1, "csc packages:description_%03d", cnt);
605 pkgtype = iniparser_getstr(csc, type_buf);
606 des = iniparser_getstr(csc, des_buf);
609 if (pkgtype == NULL) {
611 snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get pkgtype\n", type_buf);
612 fwrite(buf, 1, strlen(buf), file);
614 } else if (des == NULL) {
616 snprintf(buf, PKG_STRING_LEN_MAX, "%s = Fail to get description\n", des_buf);
617 fwrite(buf, 1, strlen(buf), file);
621 snprintf(buf, PKG_STRING_LEN_MAX, "type_%03d = %s\n", cnt, pkgtype);
622 fwrite(buf, 1, strlen(buf), file);
623 snprintf(buf, PKG_STRING_LEN_MAX, "description_%03d = %s\n", cnt, des);
624 fwrite(buf, 1, strlen(buf), file);
626 if (strcmp(pkgtype, "tpk") == 0) {
627 const char *ospinstaller_argv[] = { "/usr/bin/osp-installer", "-c", des, NULL };
628 ret = __xsystem(ospinstaller_argv);
629 } else if (strcmp(pkgtype, "wgt")== 0) {
630 const char *wrtinstaller_argv[] = { "/usr/bin/wrt-installer", "-c", des, NULL };
631 ret = __xsystem(wrtinstaller_argv);
639 __error_to_string(ret, &errstr);
640 snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = fail[%s]\n", cnt, errstr);
643 snprintf(buf, PKG_STRING_LEN_MAX, "result_%03d = success\n", cnt);
645 fwrite(buf, 1, strlen(buf), file);
649 iniparser_freedict(csc);
659 static int __get_size_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_getsize_type get_type, pkgmgr_handler event_cb, void *data)
661 char *req_key = NULL;
664 pkgmgrinfo_pkginfo_h handle;
665 char *pkgtype = NULL;
666 char *installer_path = NULL;
667 char *argv[PKG_ARGC_MAX] = { NULL, };
673 char buf[128] = {'\0'};
676 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
677 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
679 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
680 retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
682 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
683 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
685 installer_path = _get_backend_path_with_type(pkgtype);
686 req_key = __get_req_key(pkgid);
687 req_id = _get_request_id();
689 snprintf(buf, 128, "%d", get_type);
690 argv[argcnt++] = installer_path;
692 argv[argcnt++] = strdup("-k");
694 argv[argcnt++] = req_key;
696 argv[argcnt++] = strdup("-d");
698 argv[argcnt++] = strdup(pkgid);
700 argv[argcnt++] = strdup("-t");
702 argv[argcnt++] = strdup(buf);
704 /*** add quote in all string for special charactor like '\n'*** FIX */
705 for (i = 0; i < argcnt; i++) {
706 temp = g_shell_quote(argv[i]);
707 len += (strlen(temp) + 1);
711 args = (char *)calloc(len, sizeof(char));
712 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
714 strncpy(args, argv[0], len - 1);
716 for (i = 1; i < argcnt; i++) {
717 strncat(args, " ", strlen(" "));
718 temp = g_shell_quote(argv[i]);
719 strncat(args, temp, strlen(temp));
722 _LOGD("[args] %s [len] %d\n", args, len);
724 /* get cookie from security-server */
725 cookie = __get_cookie_from_security_server();
726 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
729 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_GET_SIZE, pkgtype, pkgid, args, cookie, 1);
731 _LOGE("comm_client_request failed, ret=%d\n", ret);
733 ret = __sync_process(req_key);
735 _LOGE("get size failed, ret=%d\n", ret);
738 for (i = 0; i < argcnt; i++)
746 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
750 static int __move_pkg_process(pkgmgr_client * pc, const char *pkgid, pkgmgr_move_type move_type, pkgmgr_handler event_cb, void *data)
752 char *req_key = NULL;
755 pkgmgrinfo_pkginfo_h handle;
756 char *pkgtype = NULL;
757 char *installer_path = NULL;
758 char *argv[PKG_ARGC_MAX] = { NULL, };
764 char buf[128] = {'\0'};
765 char info_file[PKG_STRING_LEN_MAX] = {'\0', };
768 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
769 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
771 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
772 retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
774 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
775 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
777 installer_path = _get_backend_path_with_type(pkgtype);
778 req_key = __get_req_key(pkgid);
779 req_id = _get_request_id();
782 snprintf(buf, 128, "%d", move_type);
783 /* argv[0] installer path */
784 argv[argcnt++] = installer_path;
786 argv[argcnt++] = strdup("-k");
788 argv[argcnt++] = req_key;
790 argv[argcnt++] = strdup("-m");
792 argv[argcnt++] = strdup(pkgid);
794 argv[argcnt++] = strdup("-t");
796 argv[argcnt++] = strdup(buf);
798 argv[argcnt++] = strdup("-q");
800 /*** add quote in all string for special charactor like '\n'*** FIX */
801 for (i = 0; i < argcnt; i++) {
802 temp = g_shell_quote(argv[i]);
803 len += (strlen(temp) + 1);
807 args = (char *)calloc(len, sizeof(char));
808 tryvm_if(args == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
810 strncpy(args, argv[0], len - 1);
812 for (i = 1; i < argcnt; i++) {
813 strncat(args, " ", strlen(" "));
814 temp = g_shell_quote(argv[i]);
815 strncat(args, temp, strlen(temp));
818 _LOGD("[args] %s [len] %d\n", args, len);
820 /* get cookie from security-server */
821 cookie = __get_cookie_from_security_server();
822 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
825 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie, 1);
827 _LOGE("comm_client_request failed, ret=%d\n", ret);
829 snprintf(info_file, PKG_STRING_LEN_MAX, "app2sd_%s", pkgid);
830 ret = __sync_process(info_file);
832 _LOGE("move pkg failed, ret=%d\n", ret);
835 for (i = 0; i < argcnt; i++)
843 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
847 static int __kill_app_process(pkgmgr_client * pc, const char *pkgid)
853 pkgmgrinfo_pkginfo_h handle;
855 /* Check for NULL value of pc */
856 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
857 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST\n");
859 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
860 retvm_if(ret < 0, PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_pkginfo failed");
862 ret = pkgmgrinfo_pkginfo_get_type(handle, &pkgtype);
863 tryvm_if(ret < 0, ret = PKGMGR_R_ERROR, "pkgmgr_pkginfo_get_type failed");
865 /* 2. generate req_key */
866 req_key = __get_req_key(pkgid);
868 /* 3. request activate */
869 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_KILL_APP, pkgtype, pkgid, NULL, NULL, 1);
871 _LOGE("request failed, ret=%d\n", ret);
875 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
881 API pkgmgr_client *pkgmgr_client_new(client_type ctype)
883 pkgmgr_client_t *pc = NULL;
886 if (ctype != PC_REQUEST && ctype != PC_LISTENING
887 && ctype != PC_BROADCAST)
890 /* Allocate memory for ADT:pkgmgr_client */
891 pc = calloc(1, sizeof(pkgmgr_client_t));
900 if (pc->ctype == PC_REQUEST) {
901 pc->info.request.cc = comm_client_new();
902 if (pc->info.request.cc == NULL) {
903 _LOGE("client creation failed");
906 ret = comm_client_set_status_callback(pc->info.request.cc,
907 __operation_callback, pc);
909 _LOGE("comm_client_set_status_callback() failed - %d",
913 } else if (pc->ctype == PC_LISTENING) {
914 pc->info.listening.cc = comm_client_new();
915 if (pc->info.listening.cc == NULL) {
916 _LOGE("client creation failed");
919 ret = comm_client_set_status_callback(pc->info.listening.cc,
920 __status_callback, pc);
922 _LOGE("comm_client_set_status_callback() failed - %d",
926 } else if (pc->ctype == PC_BROADCAST) {
927 pc->info.broadcast.bc = comm_status_broadcast_server_connect();
928 if (pc->info.broadcast.bc == NULL) {
929 _LOGE("client creation failed");
935 return (pkgmgr_client *) pc;
943 API int pkgmgr_client_free(pkgmgr_client *pc)
946 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
949 _LOGE("Invalid argument");
950 return PKGMGR_R_EINVAL;
953 if (mpc->ctype == PC_REQUEST) {
956 for (tmp = mpc->info.request.rhead; tmp;) {
962 ret = comm_client_free(mpc->info.request.cc);
964 _LOGE("comm_client_free() failed - %d", ret);
967 } else if (mpc->ctype == PC_LISTENING) {
969 listen_cb_info *prev;
970 for (tmp = mpc->info.listening.lhead; tmp;) {
976 ret = comm_client_free(mpc->info.listening.cc);
978 _LOGE("comm_client_free() failed - %d", ret);
981 } else if (mpc->ctype == PC_BROADCAST) {
982 comm_status_broadcast_server_disconnect(mpc->info.broadcast.bc);
985 _LOGE("Invalid client type\n");
986 return PKGMGR_R_EINVAL;
998 return PKGMGR_R_ERROR;
1001 API int pkgmgr_client_install(pkgmgr_client * pc, const char *pkg_type,
1002 const char *descriptor_path, const char *pkg_path,
1003 const char *optional_file, pkgmgr_mode mode,
1004 pkgmgr_handler event_cb, void *data)
1006 char *pkgtype = NULL;
1007 char *installer_path = NULL;
1008 char *req_key = NULL;
1011 char *argv[PKG_ARGC_MAX] = { NULL, };
1017 char *cookie = NULL;
1019 /* Check for NULL value of pc */
1020 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL");
1022 /* 0. check the pc type */
1023 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1024 retvm_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL, "mpc->ctype is not PC_REQUEST");
1026 /* 1. check argument */
1027 if (descriptor_path) {
1028 retvm_if(strlen(descriptor_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "descriptor_path over PKG_STRING_LEN_MAX");
1029 retvm_if(access(descriptor_path, F_OK) != 0, PKGMGR_R_EINVAL, "descriptor_path access fail");
1032 retvm_if(pkg_path == NULL, PKGMGR_R_EINVAL, "pkg_path is NULL");
1033 retvm_if(strlen(pkg_path) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "pkg_path over PKG_STRING_LEN_MAX");
1034 retvm_if(access(pkg_path, F_OK) != 0, PKGMGR_R_EINVAL, "pkg_path access fail");
1037 retvm_if(strlen(optional_file) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
1039 /* 2. get installer path using pkg_path */
1041 installer_path = _get_backend_path_with_type(pkg_type);
1042 pkgtype = strdup(pkg_type);
1044 installer_path = _get_backend_path(pkg_path);
1045 pkgtype = __get_type_from_path(pkg_path);
1047 if (installer_path == NULL) {
1049 _LOGE("installer_path is NULL\n");
1050 return PKGMGR_R_EINVAL;
1053 /* 3. generate req_key */
1054 req_key = __get_req_key(pkg_path);
1056 /* 4. add callback info - add callback info to pkgmgr_client */
1057 req_id = _get_request_id();
1058 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1060 /* 5. generate argv */
1062 /* argv[0] installer path */
1063 argv[argcnt++] = installer_path;
1065 argv[argcnt++] = strdup("-k");
1067 argv[argcnt++] = req_key;
1069 argv[argcnt++] = strdup("-i");
1070 /* argv[(4)] if exists */
1071 if (descriptor_path)
1072 argv[argcnt++] = strdup(descriptor_path);
1074 argv[argcnt++] = strdup(pkg_path);
1075 /* argv[(5)] if exists */
1077 argv[argcnt++] = strdup("-o");
1078 argv[argcnt++] = strdup(optional_file);
1080 /* argv[6] -q option should be located at the end of command !! */
1081 if (mode == PM_QUIET)
1082 argv[argcnt++] = strdup("-q");
1084 /*** add quote in all string for special charactor like '\n'*** FIX */
1085 for (i = 0; i < argcnt; i++) {
1086 temp = g_shell_quote(argv[i]);
1087 len += (strlen(temp) + 1);
1091 args = (char *)calloc(len, sizeof(char));
1092 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1094 strncpy(args, argv[0], len - 1);
1096 for (i = 1; i < argcnt; i++) {
1097 strncat(args, " ", strlen(" "));
1098 temp = g_shell_quote(argv[i]);
1099 strncat(args, temp, strlen(temp));
1102 _LOGD("[args] %s [len] %d\n", args, len);
1104 /* get cookie from security-server */
1105 cookie = __get_cookie_from_security_server();
1106 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
1107 /******************* end of quote ************************/
1109 /* 6. request install */
1110 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkg_path, args, cookie, 1);
1111 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed, ret=%d", ret);
1116 for (i = 0; i < argcnt; i++)
1129 API int pkgmgr_client_reinstall(pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
1130 const char *optional_file, pkgmgr_mode mode,
1131 pkgmgr_handler event_cb, void *data)
1133 char *pkgtype = NULL;
1134 char *installer_path = NULL;
1135 char *req_key = NULL;
1138 char *argv[PKG_ARGC_MAX] = { NULL, };
1144 char *cookie = NULL;
1146 /* Check for NULL value of pc */
1147 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1149 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1151 /* 0. check the pc type */
1152 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1155 /* 1. check argument */
1156 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1157 retv_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, PKGMGR_R_EINVAL);
1158 if (optional_file) {
1159 if (strlen(optional_file) >= PKG_STRING_LEN_MAX)
1160 return PKGMGR_R_EINVAL;
1163 /* 2. get installer path using pkg_path */
1164 installer_path = _get_backend_path_with_type(pkg_type);
1165 pkgtype = strdup(pkg_type);
1166 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path is null");
1168 /* 3. generate req_key */
1169 req_key = __get_req_key(pkgid);
1171 /* 4. add callback info - add callback info to pkgmgr_client */
1172 req_id = _get_request_id();
1173 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1175 /* 5. generate argv */
1177 /* argv[0] installer path */
1178 argv[argcnt++] = installer_path;
1180 argv[argcnt++] = strdup("-k");
1182 argv[argcnt++] = req_key;
1184 argv[argcnt++] = strdup("-r");
1186 argv[argcnt++] = strdup(pkgid);
1187 /* argv[(5)] if exists */
1189 argv[argcnt++] = strdup("-o");
1190 argv[argcnt++] = strdup(optional_file);
1193 /* argv[5] -q option should be located at the end of command !! */
1194 if (mode == PM_QUIET)
1195 argv[argcnt++] = strdup("-q");
1197 /*** add quote in all string for special charactor like '\n'*** FIX */
1198 for (i = 0; i < argcnt; i++) {
1199 temp = g_shell_quote(argv[i]);
1200 len += (strlen(temp) + 1);
1204 args = (char *)calloc(len, sizeof(char));
1205 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1207 strncpy(args, argv[0], len - 1);
1209 for (i = 1; i < argcnt; i++) {
1210 strncat(args, " ", strlen(" "));
1211 temp = g_shell_quote(argv[i]);
1212 strncat(args, temp, strlen(temp));
1215 _LOGD("[args] %s [len] %d\n", args, len);
1217 /* get cookie from security-server */
1218 cookie = __get_cookie_from_security_server();
1219 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
1220 /******************* end of quote ************************/
1222 /* 6. request install */
1223 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, 1);
1224 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "request failed");
1229 for (i = 0; i < argcnt; i++)
1242 API int pkgmgr_client_uninstall(pkgmgr_client *pc, const char *pkg_type,
1243 const char *pkgid, pkgmgr_mode mode,
1244 pkgmgr_handler event_cb, void *data)
1247 char *installer_path;
1251 char *argv[PKG_ARGC_MAX] = { NULL, };
1257 char *cookie = NULL;
1259 /* Check for NULL value of pc */
1260 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1262 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1264 /* 0. check the pc type */
1265 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1267 /* 1. check argument */
1268 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1270 pkgmgr_pkginfo_h handle;
1271 ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
1273 /*check package id */
1274 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
1275 tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
1277 /*check running app , terminate app if it is running*/
1278 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
1279 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1281 /*check running app , terminate app if it is running*/
1282 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
1283 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1286 ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
1287 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
1288 tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
1290 /*check pkgid length */
1291 tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
1293 /* 2. get installer path using pkgtype */
1294 installer_path = _get_backend_path_with_type(pkgtype);
1295 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
1297 /* 3. generate req_key */
1298 req_key = __get_req_key(pkgid);
1300 /* 4. add callback info - add callback info to pkgmgr_client */
1301 req_id = _get_request_id();
1302 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1304 /* 5. generate argv */
1306 /* argv[0] installer path */
1307 argv[argcnt++] = installer_path;
1309 argv[argcnt++] = strdup("-k");
1311 argv[argcnt++] = req_key;
1313 argv[argcnt++] = strdup("-d");
1315 argv[argcnt++] = strdup(pkgid);
1316 /* argv[5] -q option should be located at the end of command !! */
1317 if (mode == PM_QUIET)
1318 argv[argcnt++] = strdup("-q");
1320 /*** add quote in all string for special charactor like '\n'*** FIX */
1321 for (i = 0; i < argcnt; i++) {
1322 temp = g_shell_quote(argv[i]);
1323 len += (strlen(temp) + 1);
1327 args = (char *)calloc(len, sizeof(char));
1328 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1330 strncpy(args, argv[0], len - 1);
1332 for (i = 1; i < argcnt; i++) {
1333 strncat(args, " ", strlen(" "));
1334 temp = g_shell_quote(argv[i]);
1335 strncat(args, temp, strlen(temp));
1338 _LOGD("[args] %s [len] %d\n", args, len);
1340 /* get cookie from security-server */
1341 cookie = __get_cookie_from_security_server();
1342 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
1343 /******************* end of quote ************************/
1345 /* 6. request install */
1346 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_INSTALLER, pkgtype, pkgid, args, cookie, 1);
1347 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
1352 for (i = 0; i < argcnt; i++)
1360 pkgmgr_pkginfo_destroy_pkginfo(handle);
1365 API int pkgmgr_client_move(pkgmgr_client *pc, const char *pkg_type,
1366 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode)
1368 const char *pkgtype = NULL;
1369 char *installer_path = NULL;
1370 char *req_key = NULL;
1372 char *argv[PKG_ARGC_MAX] = { NULL, };
1379 char *cookie = NULL;
1380 char buf[128] = {'\0'};
1382 /* Check for NULL value of pc */
1384 _LOGD("package manager client handle is NULL\n");
1385 return PKGMGR_R_EINVAL;
1387 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1388 /*check the pc type */
1389 if (mpc->ctype != PC_REQUEST)
1390 return PKGMGR_R_EINVAL;
1394 return PKGMGR_R_EINVAL;
1396 if (pkg_type == NULL) {
1397 pkgtype = _get_pkg_type_from_desktop_file(pkgid);
1398 if (pkgtype == NULL)
1399 return PKGMGR_R_EINVAL;
1403 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1404 return PKGMGR_R_EINVAL;
1406 if ((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD))
1407 return PKGMGR_R_EINVAL;
1409 /* get installer path using pkg_path */
1410 installer_path = _get_backend_path_with_type(pkgtype);
1411 if (installer_path == NULL)
1412 return PKGMGR_R_EINVAL;
1414 /* generate req_key */
1415 req_key = __get_req_key(pkgid);
1416 req_id = _get_request_id();
1419 snprintf(buf, 128, "%d", move_type);
1420 /* argv[0] installer path */
1421 argv[argcnt++] = installer_path;
1423 argv[argcnt++] = strdup("-k");
1425 argv[argcnt++] = req_key;
1427 argv[argcnt++] = strdup("-m");
1429 argv[argcnt++] = strdup(pkgid);
1431 argv[argcnt++] = strdup("-t");
1433 argv[argcnt++] = strdup(buf);
1434 /* argv[7] -q option should be located at the end of command !! */
1435 if (mode == PM_QUIET)
1436 argv[argcnt++] = strdup("-q");
1438 /*** add quote in all string for special charactor like '\n'*** FIX */
1439 for (i = 0; i < argcnt; i++) {
1440 temp = g_shell_quote(argv[i]);
1441 len += (strlen(temp) + 1);
1445 args = (char *)calloc(len, sizeof(char));
1447 _LOGD("calloc failed");
1449 for (i = 0; i < argcnt; i++)
1452 return PKGMGR_R_ERROR;
1454 strncpy(args, argv[0], len - 1);
1456 for (i = 1; i < argcnt; i++) {
1457 strncat(args, " ", strlen(" "));
1458 temp = g_shell_quote(argv[i]);
1459 strncat(args, temp, strlen(temp));
1462 _LOGD("[args] %s [len] %d\n", args, len);
1463 /******************* end of quote ************************/
1465 /* 6. request install */
1466 ret = comm_client_request(mpc->info.request.cc, req_key,
1467 COMM_REQ_TO_MOVER, pkgtype, pkgid,
1470 _LOGE("request failed, ret=%d\n", ret);
1472 for (i = 0; i < argcnt; i++)
1476 return PKGMGR_R_ECOMM;
1479 for (i = 0; i < argcnt; i++)
1488 API int pkgmgr_client_move_pkg(pkgmgr_client *pc, const char *pkg_type,
1489 const char *pkgid, pkgmgr_move_type move_type, pkgmgr_mode mode,
1490 pkgmgr_handler event_cb, void *data)
1493 char *installer_path;
1497 char *argv[PKG_ARGC_MAX] = { NULL, };
1503 char *cookie = NULL;
1504 char buf[128] = {'\0'};
1506 /* Check for NULL value of pc */
1507 retvm_if(pc == NULL, PKGMGR_R_EINVAL, "package manager client handle is NULL\n");
1509 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1511 /* 0. check the pc type */
1512 retv_if(mpc->ctype != PC_REQUEST, PKGMGR_R_EINVAL);
1514 /* 1. check argument */
1515 retv_if(pkgid == NULL, PKGMGR_R_EINVAL);
1517 pkgmgr_pkginfo_h handle;
1518 ret = pkgmgr_pkginfo_get_pkginfo(pkgid, &handle);
1520 /*check package id */
1521 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_pkginfo fail");
1522 tryvm_if(handle == NULL, ret = PKGMGR_R_EINVAL, "Pkgid(%s) can not find in installed pkg DB! \n", pkgid);
1524 /*check running app , terminate app if it is running*/
1525 ret = pkgmgr_appinfo_get_list(handle, PM_UI_APP, __app_list_cb, NULL);
1526 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_UI_APP fail");
1528 /*check running app , terminate app if it is running*/
1529 ret = pkgmgr_appinfo_get_list(handle, PM_SVC_APP, __app_list_cb, NULL);
1530 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_appinfo_get_list : PM_SVC_APP fail");
1533 ret = pkgmgr_pkginfo_get_type(handle, &pkgtype);
1534 tryvm_if(ret < 0, ret = PKGMGR_R_EINVAL, "pkgmgr_pkginfo_get_type fail");
1535 tryvm_if(pkgtype == NULL, ret = PKGMGR_R_ERROR, "pkgtype is NULL");
1537 /*check pkgid length */
1538 tryvm_if(strlen(pkgid) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "pkgid is too long");
1540 /*check move_type */
1541 tryvm_if((move_type < PM_MOVE_TO_INTERNAL) || (move_type > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "move_type is not supported");
1543 /* 2. get installer path using pkgtype */
1544 installer_path = _get_backend_path_with_type(pkgtype);
1545 tryvm_if(installer_path == NULL, ret = PKGMGR_R_EINVAL, "installer_path fail");
1547 /* 3. generate req_key */
1548 req_key = __get_req_key(pkgid);
1550 /* 4. add callback info - add callback info to pkgmgr_client */
1551 req_id = _get_request_id();
1552 __add_op_cbinfo(mpc, req_id, req_key, event_cb, data);
1554 /* 5. generate argv */
1555 snprintf(buf, 128, "%d", move_type);
1556 /* argv[0] installer path */
1557 argv[argcnt++] = installer_path;
1559 argv[argcnt++] = strdup("-k");
1561 argv[argcnt++] = req_key;
1563 argv[argcnt++] = strdup("-m");
1565 argv[argcnt++] = strdup(pkgid);
1567 argv[argcnt++] = strdup("-t");
1569 argv[argcnt++] = strdup(buf);
1570 /* argv[5] -q option should be located at the end of command !! */
1571 if (mode == PM_QUIET)
1572 argv[argcnt++] = strdup("-q");
1574 /*** add quote in all string for special charactor like '\n'*** FIX */
1575 for (i = 0; i < argcnt; i++) {
1576 temp = g_shell_quote(argv[i]);
1577 len += (strlen(temp) + 1);
1581 args = (char *)calloc(len, sizeof(char));
1582 tryvm_if(args == NULL, ret = PKGMGR_R_ERROR, "calloc failed");
1584 strncpy(args, argv[0], len - 1);
1586 for (i = 1; i < argcnt; i++) {
1587 strncat(args, " ", strlen(" "));
1588 temp = g_shell_quote(argv[i]);
1589 strncat(args, temp, strlen(temp));
1592 _LOGD("[args] %s [len] %d\n", args, len);
1594 /* get cookie from security-server */
1595 cookie = __get_cookie_from_security_server();
1596 tryvm_if(cookie == NULL, ret = PKGMGR_R_ERROR, "__get_cookie_from_security_server is NULL");
1597 /******************* end of quote ************************/
1599 /* 6. request install */
1600 ret = comm_client_request(mpc->info.request.cc, req_key, COMM_REQ_TO_MOVER, pkgtype, pkgid, args, cookie, 1);
1601 tryvm_if(ret < 0, ret = PKGMGR_R_ECOMM, "calloc failed");
1606 for (i = 0; i < argcnt; i++)
1614 pkgmgr_pkginfo_destroy_pkginfo(handle);
1619 API int pkgmgr_client_activate(pkgmgr_client * pc, const char *pkg_type,
1622 const char *pkgtype;
1624 char *cookie = NULL;
1626 /* Check for NULL value of pc */
1628 _LOGD("package manager client handle is NULL\n");
1629 return PKGMGR_R_EINVAL;
1631 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1633 /* 0. check the pc type */
1634 if (mpc->ctype != PC_REQUEST)
1635 return PKGMGR_R_EINVAL;
1637 /* 1. check argument */
1639 return PKGMGR_R_EINVAL;
1641 if (pkg_type == NULL) {
1642 pkgtype = _get_pkg_type_from_desktop_file(pkgid);
1643 if (pkgtype == NULL)
1644 return PKGMGR_R_EINVAL;
1648 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1649 return PKGMGR_R_EINVAL;
1651 /* 2. generate req_key */
1652 req_key = __get_req_key(pkgid);
1654 /* 3. request activate */
1655 ret = comm_client_request(mpc->info.request.cc, req_key,
1656 COMM_REQ_TO_ACTIVATOR, pkgtype,
1657 pkgid, "1 PKG", cookie, 1);
1659 _LOGE("request failed, ret=%d\n", ret);
1661 return PKGMGR_R_ECOMM;
1669 API int pkgmgr_client_deactivate(pkgmgr_client *pc, const char *pkg_type,
1672 const char *pkgtype;
1674 char *cookie = NULL;
1676 /* Check for NULL value of pc */
1678 _LOGD("package manager client handle is NULL\n");
1679 return PKGMGR_R_EINVAL;
1681 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1683 /* 0. check the pc type */
1684 if (mpc->ctype != PC_REQUEST)
1685 return PKGMGR_R_EINVAL;
1687 /* 1. check argument */
1689 return PKGMGR_R_EINVAL;
1691 if (pkg_type == NULL) {
1692 pkgtype = _get_pkg_type_from_desktop_file(pkgid);
1693 if (pkgtype == NULL)
1694 return PKGMGR_R_EINVAL;
1698 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
1699 return PKGMGR_R_EINVAL;
1701 /* 2. generate req_key */
1702 req_key = __get_req_key(pkgid);
1704 /* 3. request activate */
1705 ret = comm_client_request(mpc->info.request.cc, req_key,
1706 COMM_REQ_TO_ACTIVATOR, pkgtype,
1707 pkgid, "0 PKG", cookie, 1);
1709 _LOGE("request failed, ret=%d\n", ret);
1711 return PKGMGR_R_ECOMM;
1719 API int pkgmgr_client_activate_app(pkgmgr_client * pc, const char *appid)
1721 const char *pkgtype;
1723 char *cookie = NULL;
1725 /* Check for NULL value of pc */
1727 _LOGD("package manager client handle is NULL\n");
1728 return PKGMGR_R_EINVAL;
1730 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1732 /* 0. check the pc type */
1733 if (mpc->ctype != PC_REQUEST)
1734 return PKGMGR_R_EINVAL;
1736 /* 1. check argument */
1738 return PKGMGR_R_EINVAL;
1740 if (strlen(appid) >= PKG_STRING_LEN_MAX)
1741 return PKGMGR_R_EINVAL;
1743 pkgtype = _get_pkg_type_from_desktop_file(appid);
1745 /* 2. generate req_key */
1746 req_key = __get_req_key(appid);
1748 /* 3. request activate */
1749 ret = comm_client_request(mpc->info.request.cc, req_key,
1750 COMM_REQ_TO_ACTIVATOR, pkgtype,
1751 appid, "1 APP", cookie, 1);
1753 _LOGE("request failed, ret=%d\n", ret);
1755 return PKGMGR_R_ECOMM;
1763 API int pkgmgr_client_activate_appv(pkgmgr_client * pc, const char *appid, char *const argv[])
1765 const char *pkgtype;
1767 char *cookie = NULL;
1775 /* Check for NULL value of pc */
1777 _LOGD("package manager client handle is NULL\n");
1778 return PKGMGR_R_EINVAL;
1780 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1782 /* 0. check the pc type */
1783 if (mpc->ctype != PC_REQUEST)
1784 return PKGMGR_R_EINVAL;
1786 /* 1. check argument */
1788 return PKGMGR_R_EINVAL;
1790 if (strlen(appid) >= PKG_STRING_LEN_MAX)
1791 return PKGMGR_R_EINVAL;
1793 pkgtype = _get_pkg_type_from_desktop_file(appid);
1795 /* 2. generate req_key */
1796 req_key = __get_req_key(appid);
1798 /*** add quote in all string for special charactor like '\n'*** FIX */
1800 for (i = 0; argv[i]; i++) {
1801 temp = g_shell_quote(argv[i]);
1802 len += (strlen(temp) + 1);
1808 args = (char *)calloc(len, sizeof(char));
1810 _LOGE("calloc failed");
1812 return PKGMGR_R_ERROR;
1814 strncpy(args, argv[0], len - 1);
1816 for (i = 1; i < argcnt; i++) {
1817 strncat(args, " ", strlen(" "));
1818 temp = g_shell_quote(argv[i]);
1819 strncat(args, temp, strlen(temp));
1825 argsr = (char *)calloc(strlen("1 APP")+2+len, sizeof(char));
1826 if (argsr == NULL) {
1827 _LOGE("calloc failed");
1830 return PKGMGR_R_ERROR;
1832 strncpy(argsr, "1 APP", strlen("1 APP"));
1834 strncat(argsr, " ", strlen(" "));
1835 strncat(argsr, args, strlen(args));
1838 _LOGD("argsr [%s]\n", argsr);
1839 /******************* end of quote ************************/
1841 /* 3. request activate */
1842 ret = comm_client_request(mpc->info.request.cc, req_key,
1843 COMM_REQ_TO_ACTIVATOR, pkgtype,
1844 appid, argsr, cookie, 1);
1846 _LOGE("request failed, ret=%d\n", ret);
1850 return PKGMGR_R_ECOMM;
1860 API int pkgmgr_client_deactivate_app(pkgmgr_client *pc, const char *appid)
1862 const char *pkgtype;
1864 char *cookie = NULL;
1866 /* Check for NULL value of pc */
1868 _LOGD("package manager client handle is NULL\n");
1869 return PKGMGR_R_EINVAL;
1871 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1873 /* 0. check the pc type */
1874 if (mpc->ctype != PC_REQUEST)
1875 return PKGMGR_R_EINVAL;
1877 /* 1. check argument */
1879 return PKGMGR_R_EINVAL;
1881 if (strlen(appid) >= PKG_STRING_LEN_MAX)
1882 return PKGMGR_R_EINVAL;
1884 pkgtype = _get_pkg_type_from_desktop_file(appid);
1886 /* 2. generate req_key */
1887 req_key = __get_req_key(appid);
1889 /* 3. request activate */
1890 ret = comm_client_request(mpc->info.request.cc, req_key,
1891 COMM_REQ_TO_ACTIVATOR, pkgtype,
1892 appid, "0 APP", cookie, 1);
1894 _LOGE("request failed, ret=%d\n", ret);
1896 return PKGMGR_R_ECOMM;
1905 API int pkgmgr_client_clear_user_data(pkgmgr_client *pc, const char *pkg_type,
1906 const char *appid, pkgmgr_mode mode)
1908 const char *pkgtype;
1909 char *installer_path;
1912 char *argv[PKG_ARGC_MAX] = { NULL, };
1918 char *cookie = NULL;
1920 /* Check for NULL value of pc */
1922 _LOGD("package manager client handle is NULL\n");
1923 return PKGMGR_R_EINVAL;
1925 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
1927 /* 0. check the pc type */
1928 if (mpc->ctype != PC_REQUEST)
1929 return PKGMGR_R_EINVAL;
1931 /* 1. check argument */
1933 return PKGMGR_R_EINVAL;
1936 if (pkg_type == NULL) {
1937 pkgtype = _get_pkg_type_from_desktop_file(appid);
1938 if (pkgtype == NULL)
1939 return PKGMGR_R_EINVAL;
1943 if (strlen(appid) >= PKG_STRING_LEN_MAX)
1944 return PKGMGR_R_EINVAL;
1946 /* 2. get installer path using pkg_path */
1947 installer_path = _get_backend_path_with_type(pkgtype);
1948 if (installer_path == NULL)
1949 return PKGMGR_R_EINVAL;
1951 /* 3. generate req_key */
1952 req_key = __get_req_key(appid);
1954 /* 4. generate argv */
1956 /* argv[0] installer path */
1957 argv[argcnt++] = installer_path;
1959 argv[argcnt++] = strdup("-k");
1961 argv[argcnt++] = req_key;
1963 argv[argcnt++] = strdup("-c");
1965 argv[argcnt++] = strdup(appid);
1966 /* argv[5] -q option should be located at the end of command !! */
1967 if (mode == PM_QUIET)
1968 argv[argcnt++] = strdup("-q");
1970 /*** add quote in all string for special charactor like '\n'*** FIX */
1971 for (i = 0; i < argcnt; i++) {
1972 temp = g_shell_quote(argv[i]);
1973 len += (strlen(temp) + 1);
1977 args = (char *)calloc(len, sizeof(char));
1979 _LOGD("calloc failed");
1981 for (i = 0; i < argcnt; i++)
1984 return PKGMGR_R_ERROR;
1986 strncpy(args, argv[0], len - 1);
1988 for (i = 1; i < argcnt; i++) {
1989 strncat(args, " ", strlen(" "));
1990 temp = g_shell_quote(argv[i]);
1991 strncat(args, temp, strlen(temp));
1994 _LOGD("[args] %s [len] %d\n", args, len);
1995 /******************* end of quote ************************/
1997 /* 6. request clear */
1998 ret = comm_client_request(mpc->info.request.cc, req_key,
1999 COMM_REQ_TO_CLEARER, pkgtype, appid,
2002 _LOGE("request failed, ret=%d\n", ret);
2004 for (i = 0; i < argcnt; i++)
2008 return PKGMGR_R_ECOMM;
2011 for (i = 0; i < argcnt; i++)
2019 API int pkgmgr_client_listen_status(pkgmgr_client *pc, pkgmgr_handler event_cb,
2023 /* Check for NULL value of pc */
2025 _LOGD("package manager client handle is NULL\n");
2026 return PKGMGR_R_EINVAL;
2028 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2030 /* 0. check the pc type */
2031 if (mpc->ctype != PC_LISTENING)
2032 return PKGMGR_R_EINVAL;
2034 /* 1. check argument */
2035 if (event_cb == NULL)
2036 return PKGMGR_R_EINVAL;
2038 /* 2. add callback info to pkgmgr_client */
2039 req_id = _get_request_id();
2040 __add_stat_cbinfo(mpc, req_id, event_cb, data);
2045 API int pkgmgr_client_broadcast_status(pkgmgr_client *pc, const char *pkg_type,
2046 const char *pkgid, const char *key,
2049 /* Check for NULL value of pc */
2051 _LOGD("package manager client handle is NULL\n");
2052 return PKGMGR_R_EINVAL;
2054 /* Check for valid arguments. NULL parameter causes DBUS to abort */
2055 if (pkgid == NULL || pkg_type == NULL || key == NULL || val == NULL) {
2056 _LOGD("Argument supplied is NULL\n");
2057 return PKGMGR_R_EINVAL;
2059 pkgmgr_client_t *mpc = (pkgmgr_client_t *) pc;
2061 /* 0. check the pc type */
2062 if (mpc->ctype != PC_BROADCAST)
2063 return PKGMGR_R_EINVAL;
2065 comm_status_broadcast_server_send_signal(mpc->info.broadcast.bc,
2066 PKG_STATUS, pkg_type,
2072 API pkgmgr_info *pkgmgr_client_check_pkginfo_from_file(const char *pkg_path)
2074 return pkgmgr_info_new_from_file(NULL, pkg_path);
2077 API int pkgmgr_client_free_pkginfo(pkgmgr_info * pkg_info)
2079 if (pkg_info == NULL)
2080 return PKGMGR_R_EINVAL;
2082 package_manager_pkg_detail_info_t *info = (package_manager_pkg_detail_info_t *)pkg_info;
2085 free(info->icon_buf);
2093 API int pkgmgr_client_request_service(pkgmgr_request_service_type service_type, int service_mode,
2094 pkgmgr_client * pc, const char *pkg_type, const char *pkgid,
2095 const char *custom_info, pkgmgr_handler event_cb, void *data)
2099 /* Check for NULL value of service type */
2100 retvm_if(service_type > PM_REQUEST_MAX, PKGMGR_R_EINVAL, "service type is not defined\n");
2101 retvm_if(service_type < 0, PKGMGR_R_EINVAL, "service type is error\n");
2102 vconf_set_int(VCONFKEY_PKGMGR_STATUS, -1);
2104 switch (service_type) {
2105 case PM_REQUEST_CSC:
2106 tryvm_if(custom_info == NULL, ret = PKGMGR_R_EINVAL, "custom_info is NULL\n");
2107 tryvm_if(strlen(custom_info) >= PKG_STRING_LEN_MAX, ret = PKGMGR_R_EINVAL, "optional_file over PKG_STRING_LEN_MAX");
2108 tryvm_if(data == NULL, ret = PKGMGR_R_EINVAL, "data is NULL\n");
2110 ret = __csc_process(custom_info, (char *)data);
2112 _LOGE("__csc_process fail \n");
2118 case PM_REQUEST_MOVE:
2119 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2120 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2121 tryvm_if((service_mode < PM_MOVE_TO_INTERNAL) || (service_mode > PM_MOVE_TO_SDCARD), ret = PKGMGR_R_EINVAL, "service_mode is wrong\n");
2123 ret = __move_pkg_process(pc, pkgid, (pkgmgr_move_type)service_mode, event_cb, data);
2126 case PM_REQUEST_GET_SIZE:
2127 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2128 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2129 tryvm_if((service_mode < PM_GET_TOTAL_SIZE) || (service_mode > PM_GET_DATA_SIZE), ret = PKGMGR_R_EINVAL, "service_mode is wrong\n");
2131 ret = __get_size_process(pc, pkgid, (pkgmgr_getsize_type)service_mode, event_cb, data);
2134 case PM_REQUEST_KILL_APP:
2135 tryvm_if(pkgid == NULL, ret = PKGMGR_R_EINVAL, "pkgid is NULL\n");
2136 tryvm_if(pc == NULL, ret = PKGMGR_R_EINVAL, "pc is NULL\n");
2138 ret = __kill_app_process(pc, pkgid);
2140 _LOGE("__kill_app_process fail \n");
2147 _LOGE("Wrong Request\n");
2158 #define __START_OF_OLD_API
2159 ail_cb_ret_e __appinfo_func(const ail_appinfo_h appinfo, void *user_data)
2165 iter_data *udata = (iter_data *) user_data;
2167 ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_PACKAGETYPE_STR, &type);
2170 ail_appinfo_get_str(appinfo, AIL_PROP_PACKAGE_STR, &package);
2171 if (package == NULL)
2173 ail_appinfo_get_str(appinfo, AIL_PROP_VERSION_STR, &version);
2174 if (version == NULL)
2177 if (udata->iter_fn(type, package, version, udata->data) != 0)
2178 return AIL_CB_RET_CANCEL;
2180 return AIL_CB_RET_CONTINUE;
2183 API int pkgmgr_get_pkg_list(pkgmgr_iter_fn iter_fn, void *data)
2186 ail_filter_h filter;
2189 if (iter_fn == NULL)
2190 return PKGMGR_R_EINVAL;
2192 ret = ail_filter_new(&filter);
2193 if (ret != AIL_ERROR_OK) {
2194 return PKGMGR_R_ERROR;
2197 ret = ail_filter_add_str(filter, AIL_PROP_TYPE_STR, "Application");
2198 if (ret != AIL_ERROR_OK) {
2199 ail_filter_destroy(filter);
2200 return PKGMGR_R_ERROR;
2203 ret = ail_filter_add_bool(filter, AIL_PROP_X_SLP_REMOVABLE_BOOL, true);
2204 if (ret != AIL_ERROR_OK) {
2205 ail_filter_destroy(filter);
2206 return PKGMGR_R_ERROR;
2209 ret = ail_filter_count_appinfo(filter, &cnt);
2210 if (ret != AIL_ERROR_OK) {
2211 ail_filter_destroy(filter);
2212 return PKGMGR_R_ERROR;
2215 iter_data *udata = calloc(1, sizeof(iter_data));
2216 if (udata == NULL) {
2217 _LOGE("calloc failed");
2218 ail_filter_destroy(filter);
2220 return PKGMGR_R_ERROR;
2222 udata->iter_fn = iter_fn;
2225 ail_filter_list_appinfo_foreach(filter, __appinfo_func, udata);
2229 ret = ail_filter_destroy(filter);
2230 if (ret != AIL_ERROR_OK) {
2231 return PKGMGR_R_ERROR;
2237 API pkgmgr_info *pkgmgr_info_new(const char *pkg_type, const char *pkgid)
2239 const char *pkgtype;
2240 pkg_plugin_set *plugin_set = NULL;
2241 package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
2243 /* 1. check argument */
2247 if (pkg_type == NULL) {
2248 pkgtype = _get_pkg_type_from_desktop_file(pkgid);
2249 if (pkgtype == NULL)
2254 if (strlen(pkgid) >= PKG_STRING_LEN_MAX)
2257 pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
2258 if (pkg_detail_info == NULL) {
2259 _LOGE("*** Failed to alloc package_handler_info.\n");
2263 plugin_set = _package_manager_load_library(pkgtype);
2264 if (plugin_set == NULL) {
2265 _LOGE("*** Failed to load library");
2266 free(pkg_detail_info);
2270 if (plugin_set->pkg_is_installed) {
2271 if (plugin_set->pkg_is_installed(pkgid) != 0) {
2272 _LOGE("*** Failed to call pkg_is_installed()");
2273 free(pkg_detail_info);
2277 if (plugin_set->get_pkg_detail_info) {
2278 if (plugin_set->get_pkg_detail_info(pkgid,
2279 pkg_detail_info) != 0) {
2280 _LOGE("*** Failed to call get_pkg_detail_info()");
2281 free(pkg_detail_info);
2287 return (pkgmgr_info *) pkg_detail_info;
2290 API char * pkgmgr_info_get_string(pkgmgr_info * pkg_info, const char *key)
2292 package_manager_pkg_detail_info_t *pkg_detail_info;
2294 if (pkg_info == NULL)
2299 pkg_detail_info = (package_manager_pkg_detail_info_t *) pkg_info;
2301 return _get_info_string(key, pkg_detail_info);
2304 API pkgmgr_info *pkgmgr_info_new_from_file(const char *pkg_type,
2305 const char *pkg_path)
2307 pkg_plugin_set *plugin_set = NULL;
2308 package_manager_pkg_detail_info_t *pkg_detail_info = NULL;
2310 if (pkg_path == NULL) {
2311 _LOGE("pkg_path is NULL\n");
2315 if (strlen(pkg_path) > PKG_URL_STRING_LEN_MAX) {
2316 _LOGE("length of pkg_path is too long - %d.\n",
2321 pkg_detail_info = calloc(1, sizeof(package_manager_pkg_detail_info_t));
2322 if (pkg_detail_info == NULL) {
2323 _LOGE("*** Failed to alloc package_handler_info.\n");
2327 if (pkg_type == NULL)
2328 pkgtype = __get_type_from_path(pkg_path);
2330 pkgtype = strdup(pkg_type);
2332 plugin_set = _package_manager_load_library(pkgtype);
2333 if (plugin_set == NULL) {
2334 free(pkg_detail_info);
2339 if (plugin_set->get_pkg_detail_info_from_package) {
2340 if (plugin_set->get_pkg_detail_info_from_package(pkg_path,
2341 pkg_detail_info) != 0) {
2342 free(pkg_detail_info);
2349 return (pkgmgr_info *) pkg_detail_info;
2352 API int pkgmgr_info_free(pkgmgr_info * pkg_info)
2354 if (pkg_info == NULL)
2355 return PKGMGR_R_EINVAL;
2363 #define __END_OF_OLD_API
2365 API int pkgmgr_pkginfo_get_list(pkgmgr_info_pkg_list_cb pkg_list_cb, void *user_data)
2368 ret = pkgmgrinfo_pkginfo_get_list(pkg_list_cb, user_data);
2372 API int pkgmgr_pkginfo_get_pkginfo(const char *pkgid, pkgmgr_pkginfo_h *handle)
2375 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, handle);
2379 API int pkgmgr_pkginfo_get_pkgname(pkgmgr_pkginfo_h handle, char **pkg_name)
2382 ret = pkgmgrinfo_pkginfo_get_pkgname(handle, pkg_name);
2387 API int pkgmgr_pkginfo_get_pkgid(pkgmgr_pkginfo_h handle, char **pkgid)
2390 ret = pkgmgrinfo_pkginfo_get_pkgid(handle, pkgid);
2394 API int pkgmgr_pkginfo_get_type(pkgmgr_pkginfo_h handle, char **type)
2397 ret = pkgmgrinfo_pkginfo_get_type(handle, type);
2401 API int pkgmgr_pkginfo_get_version(pkgmgr_pkginfo_h handle, char **version)
2404 ret = pkgmgrinfo_pkginfo_get_version(handle, version);
2408 API int pkgmgr_pkginfo_get_install_location(pkgmgr_pkginfo_h handle, pkgmgr_install_location *location)
2411 pkgmgrinfo_install_location loc;
2412 ret = pkgmgrinfo_pkginfo_get_install_location(handle, &loc);
2417 API int pkgmgr_pkginfo_get_package_size(pkgmgr_pkginfo_h handle, int *size)
2420 ret = pkgmgrinfo_pkginfo_get_package_size(handle, size);
2424 API int pkgmgr_pkginfo_get_icon(pkgmgr_pkginfo_h handle, char **icon)
2427 ret = pkgmgrinfo_pkginfo_get_icon(handle, icon);
2431 API int pkgmgr_pkginfo_get_label(pkgmgr_pkginfo_h handle, char **label)
2434 ret = pkgmgrinfo_pkginfo_get_label(handle, label);
2438 API int pkgmgr_pkginfo_get_description(pkgmgr_pkginfo_h handle, char **description)
2441 ret = pkgmgrinfo_pkginfo_get_description(handle, description);
2445 API int pkgmgr_pkginfo_get_author_name(pkgmgr_pkginfo_h handle, char **author_name)
2448 ret = pkgmgrinfo_pkginfo_get_author_name(handle, author_name);
2452 API int pkgmgr_pkginfo_get_author_email(pkgmgr_pkginfo_h handle, char **author_email)
2455 ret = pkgmgrinfo_pkginfo_get_author_email(handle, author_email);
2459 API int pkgmgr_pkginfo_get_author_href(pkgmgr_pkginfo_h handle, char **author_href)
2462 ret = pkgmgrinfo_pkginfo_get_author_href(handle, author_href);
2466 API int pkgmgr_pkginfo_is_removable(pkgmgr_pkginfo_h handle, bool *removable)
2469 ret = pkgmgrinfo_pkginfo_is_removable(handle, removable);
2473 API int pkgmgr_pkginfo_is_preload(pkgmgr_pkginfo_h handle, bool *preload)
2476 ret = pkgmgrinfo_pkginfo_is_preload(handle, preload);
2480 API int pkgmgr_pkginfo_is_readonly(pkgmgr_pkginfo_h handle, bool *readonly)
2483 ret = pkgmgrinfo_pkginfo_is_readonly(handle, readonly);
2487 API int pkgmgr_pkginfo_is_accessible(pkgmgr_pkginfo_h handle, bool *accessible)
2490 ret = pkgmgrinfo_pkginfo_is_accessible(handle, accessible);
2494 API int pkgmgr_pkginfo_destroy_pkginfo(pkgmgr_pkginfo_h handle)
2497 ret = pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
2501 API int pkgmgr_pkginfo_get_installed_storage(pkgmgr_pkginfo_h handle, pkgmgr_installed_storage *storage)
2504 pkgmgrinfo_installed_storage sto;
2505 ret = pkgmgrinfo_pkginfo_get_installed_storage(handle, &sto);
2510 API int pkgmgr_pkginfo_get_installed_time(pkgmgr_pkginfo_h handle, int *installed_time)
2513 ret = pkgmgrinfo_pkginfo_get_installed_time(handle, installed_time);
2517 API int pkgmgr_appinfo_get_list(pkgmgr_pkginfo_h handle, pkgmgr_app_component component,
2518 pkgmgr_info_app_list_cb app_func, void *user_data)
2521 ret = pkgmgrinfo_appinfo_get_list(handle, component, app_func, user_data);
2525 API int pkgmgr_appinfo_foreach_category(pkgmgr_appinfo_h handle, pkgmgr_info_app_category_list_cb category_func,
2529 ret = pkgmgrinfo_appinfo_foreach_category(handle, category_func, user_data);
2533 API int pkgmgr_appinfo_get_appinfo(const char *appid, pkgmgr_appinfo_h *handle)
2536 ret = pkgmgrinfo_appinfo_get_appinfo(appid, handle);
2540 API int pkgmgr_appinfo_get_appid(pkgmgr_appinfo_h handle, char **appid)
2543 ret = pkgmgrinfo_appinfo_get_appid(handle, appid);
2547 API int pkgmgr_appinfo_get_pkgname(pkgmgr_appinfo_h handle, char **pkg_name)
2550 ret = pkgmgrinfo_appinfo_get_pkgname(handle, pkg_name);
2554 API int pkgmgr_appinfo_get_pkgid(pkgmgr_appinfo_h handle, char **pkgid)
2557 ret = pkgmgrinfo_appinfo_get_pkgid(handle, pkgid);
2561 API int pkgmgr_appinfo_get_icon(pkgmgr_appinfo_h handle, char **icon)
2564 ret = pkgmgrinfo_appinfo_get_icon(handle, icon);
2568 API int pkgmgr_appinfo_get_label(pkgmgr_appinfo_h handle, char **label)
2571 ret = pkgmgrinfo_appinfo_get_label(handle, label);
2575 API int pkgmgr_appinfo_get_exec(pkgmgr_appinfo_h handle, char **exec)
2578 ret = pkgmgrinfo_appinfo_get_exec(handle, exec);
2582 API int pkgmgr_appinfo_get_component(pkgmgr_appinfo_h handle, pkgmgr_app_component *component)
2585 pkgmgrinfo_app_component comp;
2586 ret = pkgmgrinfo_appinfo_get_component(handle, &comp);
2591 API int pkgmgr_appinfo_get_apptype(pkgmgr_appinfo_h handle, char **app_type)
2594 ret = pkgmgrinfo_appinfo_get_apptype(handle, app_type);
2598 API int pkgmgr_appinfo_is_nodisplay(pkgmgr_appinfo_h handle, bool *nodisplay)
2601 ret = pkgmgrinfo_appinfo_is_nodisplay(handle, nodisplay);
2605 API int pkgmgr_appinfo_is_multiple(pkgmgr_appinfo_h handle, bool *multiple)
2608 ret = pkgmgrinfo_appinfo_is_multiple(handle, multiple);
2612 API int pkgmgr_appinfo_is_taskmanage(pkgmgr_appinfo_h handle, bool *taskmanage)
2615 ret = pkgmgrinfo_appinfo_is_taskmanage(handle, taskmanage);
2619 API int pkgmgr_appinfo_get_hwacceleration(pkgmgr_appinfo_h handle, pkgmgr_hwacceleration_type *hwacceleration)
2622 pkgmgrinfo_app_hwacceleration hwacc;
2623 ret = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
2624 *hwacceleration = hwacc;
2628 API int pkgmgr_appinfo_is_onboot(pkgmgr_appinfo_h handle, bool *onboot)
2631 ret = pkgmgrinfo_appinfo_is_onboot(handle, onboot);
2635 API int pkgmgr_appinfo_is_autorestart(pkgmgr_appinfo_h handle, bool *autorestart)
2638 ret = pkgmgrinfo_appinfo_is_autorestart(handle, autorestart);
2642 API int pkgmgr_appinfo_destroy_appinfo(pkgmgr_appinfo_h handle)
2645 ret = pkgmgrinfo_appinfo_destroy_appinfo(handle);
2649 API int pkgmgr_pkginfo_create_certinfo(pkgmgr_certinfo_h *handle)
2652 ret = pkgmgrinfo_pkginfo_create_certinfo(handle);
2656 API int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle)
2659 ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle);
2663 API int pkgmgr_pkginfo_get_cert_value(pkgmgr_certinfo_h handle, pkgmgr_cert_type cert_type, const char **cert_value)
2666 ret = pkgmgrinfo_pkginfo_get_cert_value(handle, cert_type, cert_value);
2670 API int pkgmgr_pkginfo_destroy_certinfo(pkgmgr_certinfo_h handle)
2673 ret = pkgmgrinfo_pkginfo_destroy_certinfo(handle);
2677 API int pkgmgr_datacontrol_get_info(const char *providerid, const char * type, char **appid, char **access)
2680 ret = pkgmgrinfo_datacontrol_get_info(providerid, type, appid, access);