6fe9dd0d04c251e4bbd39b1f8059f7a7623572b1
[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
29 static void usage(const char *name)
30 {
31         fprintf(stderr, "\n");
32         fprintf(stderr, "  Usage: %s\n", name);
33         fprintf(stderr, "\n");
34 }
35
36
37 ail_cb_ret_e appinfo_list_appid_namefunc(const ail_appinfo_h appinfo,  void *user_data)
38 {
39         char* package_str_name = NULL;
40     char* package_str_appid = NULL;
41     char* package_str_x_slp_exe = NULL;
42         ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_APPID_STR, &package_str_appid);
43         ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &package_str_name);
44         ail_appinfo_get_str(appinfo, AIL_PROP_X_SLP_EXE_PATH, &package_str_x_slp_exe);
45                 
46         printf("'%s' '%s' '%s'\n",package_str_appid, package_str_name, package_str_x_slp_exe);
47         return 0;
48 }
49
50
51
52 int main(int argc, char *argv[])
53 {
54         int o;
55         bool err;
56         if(getuid() == 0) {
57                 printf("Please use it as non root user\n");
58                 return;
59         } 
60         
61         printf("Application List for user %lu\n", (long)getuid());
62         printf("User's Application \n");
63         printf("APPID    NAME   EXEPATH \n");
64         ail_filter_list_usr_appinfo_foreach(NULL, appinfo_list_appid_namefunc, NULL, getuid());
65         printf("Global's / Common Applications \n");
66         printf("APPID    NAME   EXEPATH \n");
67         ail_filter_list_appinfo_foreach(NULL, appinfo_list_appid_namefunc, NULL);
68         printf("=================================================\n");
69         return 0;
70 }