2 * Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 #include "anbox/application/database.h"
19 #include "anbox/application/launcher_storage.h"
20 #include "anbox/system_configuration.h"
21 #include "anbox/logger.h"
24 namespace application {
25 const Database::Item Database::Unknown{};
27 Database::Database() :
28 storage_(std::make_shared<LauncherStorage>(SystemConfiguration::instance().application_item_dir())) {}
30 Database::~Database() {}
32 void Database::store_or_update(const Item &item) {
37 storage_->add_or_update(item);
38 items_[item.package] = item;
40 // We don't need to store the icon data anymore at this point as the
41 // launcher is already stored it on the disk.
42 items_[item.package].icon.clear();
45 void Database::remove(const Item &item) {
46 auto iter = items_.find(item.package);
47 if (iter == items_.end())
49 storage_->remove(item);
53 const Database::Item& Database::find_by_package(const std::string &package) const {
54 auto iter = items_.find(package);
55 if (iter == items_.end())
59 } // namespace application