Refactor pkgmgr-info
[platform/core/appfw/pkgmgr-info.git] / src / server / pkgmgrinfo_internal.h
1 /*
2 * Copyright (c) 2022 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 #ifndef __PKGMGRINFO_INTERNAL_H__
18 #define __PKGMGRINFO_INTERNAL_H__
19
20 #include <errno.h>
21 #include <stdbool.h>
22 #include <unistd.h>
23 #include <sys/types.h>
24 #include <sqlite3.h>
25
26 #include <string_view>
27
28 #include <database.hpp>
29 #include "pkgmgr_parser.h"
30 #include "pkgmgrinfo_private.h"
31 #include "pkgmgrinfo_type.h"
32 #include "pkgmgr-info.h"
33
34
35 namespace pkgmgr_server::internal {
36
37 void SetEnableUnitTest(bool enable);
38 int CertInfoGet(const tizen_base::Database& db,
39     std::string_view pkgid, uid_t uid, pkgmgrinfo_certinfo_h certinfo);
40 int CertInfoSet(const tizen_base::Database& db,
41     std::string_view pkgid, pkgmgrinfo_instcertinfo_h handle, uid_t uid);
42 int InitializeDb(const tizen_base::Database& db, uid_t uid);
43 int InsertPkgInfo(const tizen_base::Database& db, manifest_x* mfx, uid_t uid);
44 int UpdatePkgInfo(const tizen_base::Database& db, manifest_x* mfx, uid_t uid);
45 int DeletePkgInfo(const tizen_base::Database& db, const char* package, uid_t uid);
46 bool CheckPackageStorageStatus(pkgmgrinfo_filter_x* tmp_filter);
47 int ExecuteWriteQueries(const tizen_base::Database& db,
48     const std::vector<std::string>& queries,
49     const std::vector<std::vector<std::optional<std::string>>>& args_list);
50 int GetQueryResult(const tizen_base::Database& db,
51     const std::string& query,
52     const std::vector<std::optional<std::string>>& param,
53     std::vector<std::vector<std::optional<std::string>>>& result);
54 bool CheckAppStorageStatus(pkgmgrinfo_filter_x* tmp_filter);
55 int GetAppInfo(const tizen_base::Database& db,
56     pkgmgrinfo_appinfo_filter_h filter, uid_t db_uid, uid_t uid,
57     const std::string& locale,
58     std::vector<std::shared_ptr<application_x>>& appinfo_list);
59 int GetPkgInfo(const tizen_base::Database& db,
60     pkgmgrinfo_pkginfo_filter_h filter, uid_t uid,
61     const std::string& locale,
62     std::map<std::string, std::shared_ptr<package_x>>& pkginfo_list);
63 int GetDependsOn(const tizen_base::Database& db, const std::string& pkgid,
64     std::vector<dependency_x*>& dep_list);
65
66 }  // namespace pkgmgr_server::internal
67
68 #endif                          /* __PKGMGRINFO_INTERNAL_H__ */