Release version 0.13.7
[platform/core/api/app-manager.git] / tool / main.c
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  * PROPRIETARY/CONFIDENTIAL
4  * This software is the confidential and proprietary information of
5  * SAMSUNG ELECTRONICS ("Confidential Information"). You agree and acknowledge that
6  * this software is owned by Samsung and you
7  * shall not disclose such Confidential Information and shall
8  * use it only in accordance with the terms of the license agreement
9  * you entered into with SAMSUNG ELECTRONICS.  SAMSUNG make no
10  * representations or warranties about the suitability
11  * of the software, either express or implied, including but not
12  * limited to the implied warranties of merchantability, fitness for
13  * a particular purpose, or non-infringement.
14  * SAMSUNG shall not be liable for any damages suffered by licensee arising out of or
15  * related to this software.
16  */
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <unistd.h>
22 #include <sys/stat.h>
23 #include <sys/types.h>
24 #include <fcntl.h>
25
26 #include <app_manager.h>
27
28 static void _print_help(const char *cmd)
29 {
30         fprintf(stderr, "Usage:\n");
31         fprintf(stderr, "\n");
32         fprintf(stderr, "[Get appinfo value]\n");
33         fprintf(stderr, "    %s <app_id>\n", cmd);
34         fprintf(stderr, "\n");
35         fprintf(stderr, "Ex) %s com.samsung.memo\n", cmd);
36         fprintf(stderr, "\n");
37 }
38
39 static int _get_appinfo(const char *app_id)
40 {
41         app_info_h app_info;
42         int ret;
43         char *appid = NULL;
44         char *label = NULL;
45         char *icon = NULL;
46         char *package = NULL;
47         char *type = NULL;
48
49         ret = app_manager_get_app_info(app_id, &app_info);
50         if (ret != APP_MANAGER_ERROR_NONE) {
51                 fprintf(stderr, "No corresponding app_id for [%s]\n", app_id);
52                 return ret;
53         }
54
55         ret = app_info_get_app_id(app_info, &appid);
56         if (ret != APP_MANAGER_ERROR_NONE) {
57                 fprintf(stderr, "Failed to get app_id. error(%d)\n", ret);
58                 goto end;
59         }
60
61         ret = app_info_get_label(app_info, &label);
62         if (ret != APP_MANAGER_ERROR_NONE) {
63                 fprintf(stderr, "Failed to get label. error(%d)\n", ret);
64                 goto end;
65         }
66
67         ret = app_info_get_icon(app_info, &icon);
68         if (ret != APP_MANAGER_ERROR_NONE) {
69                 fprintf(stderr, "Failed to get icon. error(%d)\n", ret);
70                 goto end;
71         }
72
73         ret = app_info_get_package(app_info, &package);
74         if (ret != APP_MANAGER_ERROR_NONE) {
75                 fprintf(stderr, "Failed to get package. error(%d)\n", ret);
76                 goto end;
77         }
78
79         ret = app_info_get_type(app_info, &type);
80         if (ret != APP_MANAGER_ERROR_NONE) {
81                 fprintf(stderr, "Failed to get type. error(%d)\n", ret);
82                 goto end;
83         }
84
85         fprintf(stderr, "appid   = [%s]\n", appid);
86         fprintf(stderr, "label   = [%s]\n", label);
87         fprintf(stderr, "icon    = [%s]\n", icon);
88         fprintf(stderr, "package = [%s]\n", package);
89         fprintf(stderr, "type    = [%s]\n", type);
90
91 end:
92         free(appid);
93         free(label);
94         free(icon);
95         free(package);
96         free(type);
97
98         app_info_destroy(app_info);
99
100         return ret;
101 }
102
103 int main(int argc, char **argv)
104 {
105         int ret = APP_MANAGER_ERROR_NONE;
106
107         if (argc == 2) {
108                 ret = _get_appinfo(argv[1]);
109         } else {
110                 _print_help(argv[0]);
111                 return EXIT_FAILURE;
112         }
113
114         if (ret != APP_MANAGER_ERROR_NONE)
115                 fprintf(stderr, "There are some problems\n");
116
117         return EXIT_SUCCESS;
118 }
119