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 "appinfo_db_handler.hh"
19 #include "pkgmgrinfo_internal.h"
23 void _move(gpointer key, gpointer value, gpointer user_data) {
24 application_x* appinfo = static_cast<application_x*>(value);
25 std::vector<application_x*>* app_list =
26 static_cast<std::vector<application_x*>*>(user_data);
27 app_list->emplace_back(appinfo);
32 namespace pkgmgr_common {
35 AppInfoDBHandler::AppInfoDBHandler(uid_t uid)
36 : AbstractDBHandler(uid), uid_(uid) {}
38 AppInfoDBHandler::~AppInfoDBHandler() {}
40 std::vector<application_x*> AppInfoDBHandler::GetAppHandle() {
41 return std::move(handle_list_);
44 void AppInfoDBHandler::SetFilter(pkgmgrinfo_filter_x* filter) {
48 bool AppInfoDBHandler::Execute() {
49 SetOpType(OPERATION_TYPE_READ);
50 SetDBType(DB_TYPE_FILE_PKGDB);
51 if (!Connect()) return false;
54 int ret = appinfo_internal_filter_get_list(GetConnection(), filter_, uid_,
55 GetLocale().c_str(), &list);
56 if (ret != PMINFO_R_OK) {
61 g_hash_table_foreach(list, _move, &handle_list_);
62 g_hash_table_destroy(list);
66 } // namespace database
67 } // namespace pkgmgr_common