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.
28 * @defgroup PackageManagerInfoGuide
31 @par Package Manager Information Library Programming Guide
33 <h1 class="pg"> Introduction</h1>
34 <h2 class="pg"> Purpose of this document</h2>
35 The purpose of this document is to describe how applications can use Package Manager Information APIs.\n
36 This document gives only programming guidelines to application developers.
38 <h2 class="pg"> Scope</h2>
39 The scope of this document is limited to Samsung platform Package Manager Info API usage.
41 <h1 class="pg"> Architecture</h1>
42 <h2 class="pg"> Architecture overview</h2>
43 Package Manager Information Library is responsible for getting/setting manifest file information from/to manifest DB.\n
45 The library provides APIs to parse the package's manifest file\n
46 It also provides APIs to insert/update/delete this parsed data from manifest DB.
49 <h2 class="pg"> Features</h2>
50 Package Manager Info Library has the following features:\n
52 - Get /Set Package Information in DB
53 - It provides API to get package manifest data from DB.
54 - It provides API to get package certificate data from DB.
55 - It provides API to set package manifest data in DB.
56 - It provides API to set package certificate data in DB.
58 @image html SLP_pkgmgr_info.png "High-Level Architure depicting get/set operation"
60 - Filter Package/Application Information
61 - It provides API to filter package information query result.
62 - It provides API to filter application information query result.
65 - It provides API to parse package manifest file.
66 - It provides API to insert/update/delete manifest data in DB.
68 @image html SLP_pkgmgr_parser.png "High-Level Architure depicting manifest parsing"
70 <h1 class="pg"> Package Manager API descriptions</h1>
71 <b> SEE API manual </b>
73 <h1 class="pg"> Package Manager Features with sample code</h1>
74 <h2 class="pg"> Get /Set Package Information in DB</h2>
77 - Get package version from manifest DB
80 #include <pkgmgr-info.h>
82 static int get_pkg_version(const char *pkgid)
86 pkgmgrinfo_pkginfo_h handle;
87 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
88 if (ret != PMINFO_R_OK)
90 ret = pkgmgrinfo_pkginfo_get_version(handle, &version);
91 if (ret != PMINFO_R_OK) {
92 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
95 printf("pkg version: %s\n", version);
96 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
101 - Get package author root certificate from manifest DB
104 static int get_cert_info(const char *pkgid)
107 pkgmgrinfo_certinfo_h handle;
108 char *auth_cert = NULL;
109 ret = pkgmgrinfo_pkginfo_create_certinfo(&handle);
110 if (ret != PMINFO_R_OK)
112 ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle);
113 if (ret != PMINFO_R_OK) {
114 pkgmgrinfo_pkginfo_destroy_certinfo(handle);
117 ret = pkgmgrinfo_pkginfo_get_cert_value(handle, PMINFO_AUTHOR_ROOT_CERT, &auth_cert);
118 if (ret != PMINFO_R_OK) {
119 pkgmgrinfo_pkginfo_destroy_certinfo(handle);
122 printf("Author root certificate: %s\n", auth_root);
123 pkgmgrinfo_pkginfo_destroy_certinfo(handle);
128 - Set package version in manifest DB
131 #include <pkgmgr-info.h>
133 static int set_pkg_version_in_db(const char *pkgid)
136 pkgmgrinfo_pkgdbinfo_h handle;
137 ret = pkgmgrinfo_create_pkgdbinfo(pkgid, &handle);
138 if (ret != PMINFO_R_OK)
140 ret = pkgmgrinfo_set_version_to_pkgdbinfo(handle, "0.0.1");
141 if (ret != PMINFO_R_OK) {
142 pkgmgrinfo_destroy_pkgdbinfo(handle);
145 ret = pkgmgrinfo_save_pkgdbinfo(handle);
146 if (ret != PMINFO_R_OK) {
147 pkgmgrinfo_destroy_pkgdbinfo(handle);
150 pkgmgrinfo_destroy_pkgdbinfo(handle);
155 - Set package author root certificate in manifest DB
158 static int set_cert_in_db(const char *pkgid)
161 pkgmgrinfo_instcertinfo_h handle;
162 ret = pkgmgrinfo_create_certinfo_set_handle(&handle);
163 if (ret != PMINFO_R_OK)
165 ret = pkgmgrinfo_set_cert_value(handle, PMINFO_SET_AUTHOR_ROOT_CERT, "author root certificate");
166 if (ret != PMINFO_R_OK) {
167 pkgmgrinfo_destroy_certinfo_set_handle(handle);
170 ret = pkgmgrinfo_save_pkgdbinfo(pkgid, handle);
171 if (ret != PMINFO_R_OK) {
172 pkgmgrinfo_destroy_certinfo_set_handle(handle);
175 pkgmgrinfo_destroy_certinfo_set_handle(handle);
181 <h2 class="pg"> Filter Package/Application Information </h2>
183 - Filter number of installed rpm packages out of total number of packages installed.
186 #include <pkgmgr-info.h>
187 int pkg_list_cb(pkgmgrinfo_pkginfo_h handle, void *user_data)
190 pkgmgrinfo_pkginfo_get_pkgname(handle, &pkgid);
191 printf("pkg id : %s\n", pkgid);
195 static int get_rpm_pkg_list()
198 pkgmgrinfo_pkginfo_filter_h handle;
199 ret = pkgmgrinfo_pkginfo_filter_create(&handle);
200 if (ret != PMINFO_R_OK)
202 ret = pkgmgrinfo_pkginfo_filter_add_string(handle, PMINFO_PKGINFO_PROP_PACKAGE_TYPE, "rpm");
203 if (ret != PMINFO_R_OK) {
204 pkgmgrinfo_pkginfo_filter_destroy(handle);
207 ret = pkgmgrinfo_pkginfo_filter_foreach_pkginfo(handle, pkg_list_cb, NULL);
208 if (ret != PMINFO_R_OK) {
209 pkgmgrinfo_pkginfo_filter_destroy(handle);
212 pkgmgrinfo_pkginfo_filter_destroy(handle);
217 - Filter number of installed applications which are of type "capp".
220 #include <pkgmgr-info.h>
222 static int get_capp_count()
226 pkgmgrinfo_appinfo_filter_h handle;
227 ret = pkgmgrinfo_appinfo_filter_create(&handle);
228 if (ret != PMINFO_R_OK)
230 ret = pkgmgrinfo_appinfo_filter_add_string(handle, PMINFO_APPINFO_PROP_APP_TYPE, "capp");
231 if (ret != PMINFO_R_OK) {
232 pkgmgrinfo_appinfo_filter_destroy(handle);
235 ret = pkgmgrinfo_appinfo_filter_count(handle, &count);
236 if (ret != PMINFO_R_OK) {
237 pkgmgrinfo_appinfo_filter_destroy(handle);
240 printf("No of capp: %d\n", count);
241 pkgmgrinfo_appinfo_filter_destroy(handle);
246 <h2 class="pg"> Manifest Parser </h2>
248 - Parse the package manifest file and insert the parsed data in manifest DB.
251 #include <pkgmgr-info.h>
253 static int parse_manifest_file_for_installation(const char *manifest)
256 ret = pkgmgr_parser_parse_manifest_for_installation(manifest, NULL);
264 - Parse the package manifest file and update the manifest DB with the parsed data.
267 #include <pkgmgr-info.h>
269 static int parse_manifest_file_for_upgrade(const char *manifest)
272 ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
279 - Parse the package manifest file and delete the parsed data from manifest DB.
282 #include <pkgmgr-info.h>
284 static int parse_manifest_file_for_uninstallation(const char *manifest)
287 ret = pkgmgr_parser_parse_manifest_for_uninstallation(manifest, NULL);