Fix codes for setting certificate
[platform/core/appfw/pkgmgr-info.git] / src / pkgmgrinfo_plugininfo.c
1 /*
2  * pkgmgr-info
3  *
4  * Copyright (c) 2000 - 2019 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Junghyun Yeon <jungh.yeon@samsung.com>, Sangyoon Jang <jeremy.jang@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21
22 #define _GNU_SOURCE
23
24 #include <stdlib.h>
25 #include <stdbool.h>
26 #include <sqlite3.h>
27
28 #include "manager/pkginfo_manager.h"
29 #include "pkgmgrinfo_private.h"
30 #include "pkgmgrinfo_debug.h"
31 #include "pkgmgr-info.h"
32
33 API int pkgmgrinfo_plugininfo_foreach_plugininfo(const char *pkgid,
34                 const char *plugin_type, const char *plugin_name,
35                 pkgmgrinfo_plugin_list_cb plugin_list_cb, void *user_data)
36 {
37         int ret;
38         const char *appid;
39         GList *appid_list = NULL;
40         GList *tmp_list;
41
42         if (!pkgid || !plugin_type || !plugin_name || !plugin_list_cb) {
43                 _LOGE("Invalid parameter");
44                 return PMINFO_R_EINVAL;
45         }
46
47         ret = _plugininfo_get_appids(pkgid, plugin_type, plugin_name, &appid_list);
48         if (ret != PMINFO_R_OK) {
49                 _LOGE("Fail to get plugininfo");
50                 return ret;
51         }
52
53         for (tmp_list = appid_list; tmp_list != NULL; tmp_list = tmp_list->next) {
54                 appid = (char *)tmp_list->data;
55                 if (!appid)
56                         continue;
57                 ret = plugin_list_cb(pkgid, appid, plugin_type,
58                                                          plugin_name, user_data);
59                 if (ret != 0)
60                         break;
61         }
62
63         g_list_free_full(appid_list, free);
64
65         return ret;
66
67 }