Merge branch 'master' into fix_log
[platform/core/appfw/pkgmgr-info.git] / src / common / database / depinfo_db_handler.cc
1 /*
2  * Copyright (c) 2021 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 #include "depinfo_db_handler.hh"
18
19 #include "pkgmgrinfo_debug.h"
20 #include "pkgmgrinfo_internal.h"
21
22 namespace pkgmgr_common {
23 namespace database {
24
25 DepInfoGetDBHandler::DepInfoGetDBHandler(uid_t uid)
26     : AbstractDBHandler(uid), uid_(uid) {}
27
28 DepInfoGetDBHandler::~DepInfoGetDBHandler() {}
29
30 std::vector<dependency_x*> DepInfoGetDBHandler::GetDependencyList() {
31   return std::move(dependency_list_);
32 }
33
34 void DepInfoGetDBHandler::SetPkgID(const std::string& pkgid) {
35   pkgid_ = pkgid;
36 }
37
38 int DepInfoGetDBHandler::Execute() {
39   SetOpType(OPERATION_TYPE_READ);
40   SetDBType(DB_TYPE_FILE_PKGDB);
41
42   if (!Connect()) {
43     _LOGE("Failed to connect database");
44     return PMINFO_R_ERROR;
45   }
46   GList *list = nullptr;
47   int ret = pkginfo_internal_filter_get_depends_on(
48       GetConnection(), pkgid_.c_str(), &list);
49
50   return ret;
51 }
52
53 }  // namespace database
54 }  // namespace pkgmgr_common