8304a2639ffe308883fe7cd54c947f781afe732e
[platform/core/appfw/ail.git] / tool / src / ail_list.c
1 /*
2  * ail_list.c is based on ail_filter.c
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #include <stdio.h>
21 #include <getopt.h>
22 #include <unistd.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include "ail.h"
26 #include "ail_private.h"
27
28 static void usage(const char *name)
29 {
30         fprintf(stderr, "\n");
31         fprintf(stderr, "Usage: %s\n", name);
32         fprintf(stderr, "\n");
33 }
34
35 ail_cb_ret_e appinfo_list_appid_namefunc(const ail_appinfo_h appinfo, void *user_data)
36 {
37         char *package_str_name = NULL;
38         char *package_str_appid = NULL;
39         char *package_str_x_slp_exe = NULL;
40
41         ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_APPID_STR, &package_str_appid);
42         ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &package_str_name);
43         ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_EXE_PATH, &package_str_x_slp_exe);
44
45         printf("'%s' '%s' '%s'\n",package_str_appid, package_str_name, package_str_x_slp_exe);
46
47         free(package_str_appid);
48         free(package_str_name);
49         free(package_str_x_slp_exe);
50
51         return AIL_CB_RET_CONTINUE;
52 }
53
54 int main(int argc, char *argv[])
55 {
56         int o;
57         bool err;
58
59         if (getuid() == 0) {
60                 printf("Please use it as non root user\n");
61                 return;
62         }
63
64         printf("Application List for user %lu\n", (long)getuid());
65         printf("User's Application \n");
66         printf("APPID    NAME   EXEPATH \n");
67
68         ail_filter_list_usr_appinfo_foreach(NULL, appinfo_list_appid_namefunc, NULL, getuid());
69
70         printf("Global's / Common Applications \n");
71         printf("APPID    NAME   EXEPATH \n");
72
73         ail_filter_list_appinfo_foreach(NULL, appinfo_list_appid_namefunc, NULL);
74
75         printf("=================================================\n");
76
77         return 0;
78 }