2 * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "db_handle_provider.hh"
18 #include "pkg_set_db_handler.hh"
22 #include "pkgmgrinfo_debug.h"
23 #include "pkgmgrinfo_internal.h"
25 namespace pkgmgr_common {
28 PkgSetDBHandler::PkgSetDBHandler(uid_t uid, int pid)
29 : AbstractDBHandler(uid, pid), uid_(uid) {}
31 PkgSetDBHandler::~PkgSetDBHandler() {}
33 void PkgSetDBHandler::SetPkgInfo(package_x* package) { package_ = package; }
34 void PkgSetDBHandler::SetPkgID(std::string pkgid) { pkgid = std::move(pkgid); }
35 void PkgSetDBHandler::SetWriteType(WriteType write_type) { write_type_ = write_type; }
37 std::vector<std::vector<std::string>>&& PkgSetDBHandler::GetResult() {
38 return std::move(result_);
41 int PkgSetDBHandler::Execute() {
42 SetOpType(OPERATION_TYPE_WRITE);
43 SetDBType(DB_TYPE_FILE_PKGDB);
48 //result_[0].emplace_back("FAIL");
49 return PMINFO_R_ERROR;
54 DBHandleProvider::GetInst(uid_).SetMemoryMode(GetPID(), true);
55 std::vector<sqlite3*> conn_list = GetConnection();
56 sqlite3* conn = conn_list.front();
57 if (write_type_ == Insert) {
58 ret = pkgmgr_parser_insert_pkg_info(conn, package_, uid_);
59 } else if (write_type_ == Update) {
60 ret = pkgmgr_parser_update_pkg_info(conn, package_, uid_);
61 } else if (write_type_ == Delete) {
62 ret = pkgmgr_parser_delete_pkg_info(conn, package_->package, uid_);
64 _LOGE("Unknown db write type");
67 if (ret != PM_PARSER_R_OK) {
68 //result_[0].emplace_back("FAIL");
72 //result_[0].emplace_back("SUCCESS");
77 } // namespace database
78 } // namespace pkgmgr_common