Add new elements for component-based application
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_compinfo.c
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #define _GNU_SOURCE
18 #include <stdio.h>
19
20 #include "pkgmgr-info.h"
21 #include "pkgmgrinfo_debug.h"
22 #include "pkgmgrinfo_private.h"
23
24 API int pkgmgrinfo_compinfo_get_appid(pkgmgrinfo_compinfo_h handle,
25                 const char **appid)
26 {
27         retvm_if(handle == NULL, PMINFO_R_EINVAL, "compinfo handle is NULL");
28         retvm_if(appid == NULL, PMINFO_R_EINVAL, "appid is NULL");
29         pkgmgr_compinfo_x *info = (pkgmgr_compinfo_x *)handle;
30
31         if (info->comp_info == NULL || info->appid == NULL)
32                 return PMINFO_R_ERROR;
33
34         *appid = info->appid;
35
36         return PMINFO_R_OK;
37 }
38
39 API int pkgmgrinfo_compinfo_get_compid(pkgmgrinfo_compinfo_h handle,
40                 const char **compid)
41 {
42         retvm_if(handle == NULL, PMINFO_R_EINVAL, "compinfo handle is NULL");
43         retvm_if(compid == NULL, PMINFO_R_EINVAL, "compid is NULL");
44         pkgmgr_compinfo_x *info = (pkgmgr_compinfo_x *)handle;
45
46         if (info->comp_info == NULL || info->comp_info->id == NULL)
47                 return PMINFO_R_ERROR;
48
49         *compid = info->comp_info->id;
50
51         return PMINFO_R_OK;
52 }
53
54 API int pkgmgrinfo_compinfo_get_type(pkgmgrinfo_compinfo_h handle,
55                 const char **type)
56 {
57         retvm_if(handle == NULL, PMINFO_R_EINVAL, "compinfo handle is NULL");
58         retvm_if(type == NULL, PMINFO_R_EINVAL, "type is NULL");
59         pkgmgr_compinfo_x *info = (pkgmgr_compinfo_x *)handle;
60
61         if (info->comp_info == NULL || info->comp_info->type == NULL)
62                 return PMINFO_R_ERROR;
63
64         *type = info->comp_info->type;
65
66         return PMINFO_R_OK;
67 }
68
69 API int pkgmgrinfo_compinfo_get_launch_mode(pkgmgrinfo_compinfo_h handle,
70                 const char **launch_mode)
71 {
72         retvm_if(handle == NULL, PMINFO_R_EINVAL, "compinfo handle is NULL");
73         retvm_if(launch_mode == NULL, PMINFO_R_EINVAL, "type is NULL");
74         pkgmgr_compinfo_x *info = (pkgmgr_compinfo_x *)handle;
75
76         if (info->comp_info == NULL || info->comp_info->launch_mode == NULL)
77                 return PMINFO_R_ERROR;
78
79         *launch_mode = info->comp_info->launch_mode;
80
81         return PMINFO_R_OK;
82 }