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.
29 #include <sys/types.h>
32 #include <package_manager.h>
36 static void _print_help(const char *cmd)
38 fprintf(stderr, "Usage:\n");
39 fprintf(stderr, "\n");
40 fprintf(stderr, "[Get packageinfo value]\n");
41 fprintf(stderr, " %s <package>\n", cmd);
42 fprintf(stderr, "\n");
43 fprintf(stderr, "Ex) %s org.tizen.memo\n", cmd);
44 fprintf(stderr, "\n");
48 static bool _cert_info_cb(package_info_h handle, package_cert_type_e cert_type,
49 const char *cert_value, void *user_data)
51 fprintf(stderr, "cert_info[%d] \t= [%s]\n", cert_type, cert_value);
56 static int _get_packageinfo(const char *package)
58 package_info_h package_info;
65 package_info_installed_storage_type_e storage;
71 ret = package_manager_get_package_info(package, &package_info);
72 if (ret != PACKAGE_MANAGER_ERROR_NONE)
73 return PACKAGE_MANAGER_ERROR_INVALID_PARAMETER;
75 package_info_get_package(package_info, &pkg);
76 package_info_get_label(package_info, &label);
77 package_info_get_icon(package_info, &icon);
78 package_info_get_version(package_info, &version);
79 package_info_get_type(package_info, &type);
80 package_info_get_installed_storage(package_info, &storage);
81 package_info_is_system_package(package_info, &system);
82 package_info_is_removable_package(package_info, &removable);
83 package_info_is_preload_package(package_info, &preload);
85 fprintf(stderr, "pkg \t= [%s]\n", pkg);
86 fprintf(stderr, "label \t= [%s]\n", label);
87 fprintf(stderr, "icon \t= [%s]\n", icon);
88 fprintf(stderr, "version \t= [%s]\n", version);
89 fprintf(stderr, "type \t= [%s]\n", type);
90 fprintf(stderr, "storage \t= [%d]\n", storage);
91 fprintf(stderr, "system \t= [%d]\n", system);
92 fprintf(stderr, "removable \t= [%d]\n", removable);
93 fprintf(stderr, "preload \t= [%d]\n", preload);
95 package_info_foreach_cert_info(package_info, _cert_info_cb, NULL);
103 ret = package_info_destroy(package_info);
104 if (ret != PACKAGE_MANAGER_ERROR_NONE)
105 return PACKAGE_MANAGER_ERROR_INVALID_PARAMETER;
107 return PACKAGE_MANAGER_ERROR_NONE;
110 static int _get_appinfo(const char *appid)
112 char *package_id = NULL;
113 package_manager_get_package_id_by_app_id(appid, &package_id);
115 fprintf(stderr, "app_id \t= [%s]\n", appid);
116 fprintf(stderr, "package_id \t= [%s]\n", package_id);
118 return PACKAGE_MANAGER_ERROR_NONE;
121 int main(int argc, char **argv)
123 int ret = PACKAGE_MANAGER_ERROR_NONE;
126 fprintf(stderr, "mising operand\n");
128 } else if (2 == argc) {
129 ret = _get_packageinfo(argv[1]);
130 } else if (3 == argc) {
131 ret = _get_appinfo(argv[1]);
135 _print_help(argv[0]);
139 if (ret != PACKAGE_MANAGER_ERROR_NONE) {
140 fprintf(stderr, "There are some problems\n");