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>, Jaeho Lee <jaeho81.lee@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
28 #include "ail_private.h"
36 static void usage(const char *name)
38 fprintf(stderr, "\n");
39 fprintf(stderr, " Usage: %s -c command [options]\n", name);
40 fprintf(stderr, " command:\n");
41 fprintf(stderr, " c : count appinfos by option\n");
42 fprintf(stderr, " f : filter appinfos by option\n");
43 fprintf(stderr, "\n");
44 fprintf(stderr, " option:\n");
45 fprintf(stderr, " --package=<pacakge name>\n");
46 fprintf(stderr, " --exec=<exec file>\n");
47 fprintf(stderr, " --name=<title name>\n");
48 fprintf(stderr, " --type=<type>\n");
49 fprintf(stderr, " --icon=<icon file>\n");
50 fprintf(stderr, " --category=<category>\n");
51 fprintf(stderr, " --version=<version>\n");
52 fprintf(stderr, " --mimetype=<mimetype>\n");
53 fprintf(stderr, " --nodisplay=<{0|1}>\n");
54 fprintf(stderr, " --service=<service>\n");
55 fprintf(stderr, " --packagetype=<package type>\n");
56 fprintf(stderr, " --packagecategories=<package category>\n");
57 fprintf(stderr, " --packageid=<package id>\n");
58 fprintf(stderr, " --svc=<action:scheme:mime>\n");
59 fprintf(stderr, " --taskmanage=<{true|false}>\n");
60 fprintf(stderr, " --multiple=<{true|false}>\n");
61 fprintf(stderr, " --removable=<{true|false}>\n");
62 fprintf(stderr, "\n");
63 fprintf(stderr, " Example:\n");
64 fprintf(stderr, " %s -n menu-screen -r 1\n", name);
65 fprintf(stderr, "\n");
73 static struct _ail_map_t prop_map[] = {
74 {E_AIL_PROP_PACKAGE_STR, AIL_PROP_PACKAGE_STR},
75 {E_AIL_PROP_EXEC_STR, AIL_PROP_EXEC_STR},
76 {E_AIL_PROP_NAME_STR, AIL_PROP_NAME_STR},
77 {E_AIL_PROP_TYPE_STR, AIL_PROP_TYPE_STR},
78 {E_AIL_PROP_ICON_STR, AIL_PROP_ICON_STR},
79 {E_AIL_PROP_CATEGORIES_STR, AIL_PROP_CATEGORIES_STR},
80 {E_AIL_PROP_VERSION_STR, AIL_PROP_VERSION_STR},
81 {E_AIL_PROP_MIMETYPE_STR, AIL_PROP_MIMETYPE_STR},
82 {E_AIL_PROP_X_SLP_SERVICE_STR, AIL_PROP_X_SLP_SERVICE_STR},
83 {E_AIL_PROP_X_SLP_PACKAGETYPE_STR, AIL_PROP_X_SLP_PACKAGETYPE_STR},
84 {E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR, AIL_PROP_X_SLP_PACKAGECATEGORIES_STR},
85 {E_AIL_PROP_X_SLP_PACKAGEID_STR, AIL_PROP_X_SLP_PACKAGEID_STR},
86 {E_AIL_PROP_X_SLP_SVC_STR, AIL_PROP_X_SLP_SVC_STR},
87 {E_AIL_PROP_X_SLP_EXE_PATH, AIL_PROP_X_SLP_EXE_PATH},
88 {E_AIL_PROP_NODISPLAY_BOOL, AIL_PROP_NODISPLAY_BOOL},
89 {E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_NODISPLAY_BOOL},
90 {E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
91 {E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
92 {E_AIL_PROP_X_SLP_APPID_STR, AIL_PROP_X_SLP_APPID_STR},
93 {E_AIL_PROP_X_SLP_PKGID_STR, AIL_PROP_X_SLP_PKGID_STR},
94 {E_AIL_PROP_X_SLP_DOMAIN_STR, AIL_PROP_X_SLP_DOMAIN_STR},
95 {E_AIL_PROP_X_SLP_SUBMODEMAINID_STR, AIL_PROP_X_SLP_SUBMODEMAINID_STR},
96 {E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR, AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR},
97 {E_AIL_PROP_X_SLP_TEMP_INT, AIL_PROP_X_SLP_TEMP_INT},
98 {E_AIL_PROP_X_SLP_INSTALLEDTIME_INT, AIL_PROP_X_SLP_INSTALLEDTIME_INT},
99 {E_AIL_PROP_NODISPLAY_BOOL, AIL_PROP_NODISPLAY_BOOL},
100 {E_AIL_PROP_X_SLP_TASKMANAGE_BOOL, AIL_PROP_X_SLP_TASKMANAGE_BOOL},
101 {E_AIL_PROP_X_SLP_MULTIPLE_BOOL, AIL_PROP_X_SLP_MULTIPLE_BOOL},
102 {E_AIL_PROP_X_SLP_REMOVABLE_BOOL, AIL_PROP_X_SLP_REMOVABLE_BOOL},
103 {E_AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL, AIL_PROP_X_SLP_ISHORIZONTALSCALE_BOOL},
104 {E_AIL_PROP_X_SLP_ENABLED_BOOL, AIL_PROP_X_SLP_ENABLED_BOOL},
105 {E_AIL_PROP_X_SLP_SUBMODE_BOOL, AIL_PROP_X_SLP_SUBMODE_BOOL}
108 static const char *_ail_convert_to_property(int prop)
112 if (prop < E_AIL_PROP_STR_MIN || prop > E_AIL_PROP_BOOL_MAX)
115 for (i=0 ; i < (E_AIL_PROP_BOOL_MAX + 1) ; i++) {
116 if (prop == prop_map[i].prop) {
117 return prop_map[i].property;
126 static int _get_cmd(const char *arg)
153 ail_cb_ret_e appinfo_list_func(const ail_appinfo_h appinfo, void *user_data)
162 ail_error_e error = AIL_ERROR_OK;
163 ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
167 ret = AIL_CB_RET_CONTINUE;
168 for(i = 0; i< E_AIL_PROP_BOOL_MAX+1 && err==false; i ++) {
173 error = ail_appinfo_get_bool(appinfo, _ail_convert_to_property(i), &b);
174 if (error) ret = AIL_CB_RET_CANCEL;
175 printf("%s|",b?"true":"false");
178 ail_appinfo_get_int(appinfo, _ail_convert_to_property(i), &n);
179 if (error) ret = AIL_CB_RET_CANCEL;
183 ail_appinfo_get_str(appinfo, _ail_convert_to_property(i), &rs);
184 if (error) ret = AIL_CB_RET_CANCEL;
188 fprintf(stderr, "$$$\n");
199 int main(int argc, char *argv[])
206 static struct element e;
213 static const struct option longopts[] = {
214 { "help", 0, NULL, 'h' },
215 { "command", 1, NULL, 'c' },
216 { "package", 1, &(e.prop), E_AIL_PROP_PACKAGE_STR},
217 { "name", 1, &(e.prop), E_AIL_PROP_NAME_STR },
218 { "mimetype", 1, &(e.prop), E_AIL_PROP_MIMETYPE_STR},
219 { "removable", 1, &(e.prop), E_AIL_PROP_X_SLP_REMOVABLE_BOOL },
220 { "exec", 1, &(e.prop), E_AIL_PROP_EXEC_STR},
221 { "type", 1, &(e.prop), E_AIL_PROP_TYPE_STR},
222 { "icon", 1, &(e.prop), E_AIL_PROP_ICON_STR},
223 { "categories", 1, &(e.prop), E_AIL_PROP_CATEGORIES_STR},
224 { "version", 1, &(e.prop), E_AIL_PROP_VERSION_STR},
225 { "mimetype", 1, &(e.prop), E_AIL_PROP_MIMETYPE_STR},
226 { "nodisplay", 1, &(e.prop), E_AIL_PROP_NODISPLAY_BOOL},
227 { "service", 1, &(e.prop), E_AIL_PROP_X_SLP_SERVICE_STR},
228 { "packagetype", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGETYPE_STR},
229 { "packagecategories", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGECATEGORIES_STR},
230 { "packageid", 1, &(e.prop), E_AIL_PROP_X_SLP_PACKAGEID_STR},
231 { "svc", 1, &(e.prop), E_AIL_PROP_X_SLP_SVC_STR},
232 { "taskmanage", 1, &(e.prop), E_AIL_PROP_X_SLP_TASKMANAGE_BOOL},
233 { "multiple", 1, &(e.prop), E_AIL_PROP_X_SLP_MULTIPLE_BOOL},
234 { "removable", 1, &(e.prop), E_AIL_PROP_X_SLP_REMOVABLE_BOOL},
235 { "appid", 1, &(e.prop), E_AIL_PROP_X_SLP_APPID_STR},
236 { "pkgid", 1, &(e.prop), E_AIL_PROP_X_SLP_PKGID_STR},
237 { "submode", 1, &(e.prop), E_AIL_PROP_X_SLP_SUBMODE_BOOL},
238 { "submodemainid", 1, &(e.prop), E_AIL_PROP_X_SLP_SUBMODEMAINID_STR},
239 { "installedstorage", 1, &(e.prop), E_AIL_PROP_X_SLP_INSTALLEDSTORAGE_STR},
240 { "domain", 1, &(e.prop), E_AIL_PROP_X_SLP_DOMAIN_STR},
244 if (ail_filter_new(&f) != AIL_ERROR_OK)
249 while (!err && (o = getopt_long(argc, argv, "c:", longopts, &oi)) >= 0) {
251 struct element *p = &e;
257 c = _get_cmd(optarg);
262 if(!strcasecmp(optarg, "true") || !strcasecmp(optarg, "1"))
264 else if (!strcasecmp(optarg, "false") || !strcasecmp(optarg, "0"))
270 if (ail_filter_add_bool(f, _ail_convert_to_property(e.prop), b) != AIL_ERROR_OK)
275 if (ail_filter_add_int(f, _ail_convert_to_property(e.prop), atoi(optarg)) != AIL_ERROR_OK)
280 if (ail_filter_add_str(f, _ail_convert_to_property(e.prop), optarg) != AIL_ERROR_OK)
302 if (ail_filter_count_appinfo(f, &n) != AIL_ERROR_OK){
303 fprintf(stderr, "Error: failed to count appinfo\n");
306 fprintf(stderr, "count=%d\n", n);
309 ail_filter_list_appinfo_foreach(f, appinfo_list_func, NULL);
317 ail_filter_destroy(f);