Refactor pkgmgr-info
[platform/core/appfw/pkgmgr-info.git] / src / server / pkgmgrinfo_internal.h
index b97ae13..5e5d315 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 
 #ifndef __PKGMGRINFO_INTERNAL_H__
 #define __PKGMGRINFO_INTERNAL_H__
 #include <stdbool.h>
 #include <unistd.h>
 #include <sys/types.h>
-
 #include <sqlite3.h>
 
+#include <string_view>
+
+#include <database.hpp>
 #include "pkgmgr_parser.h"
+#include "pkgmgrinfo_private.h"
 #include "pkgmgrinfo_type.h"
 #include "pkgmgr-info.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
 
-typedef struct {
-    int len;
-    GList *argument;
-} query_args;
 
-int pkginfo_internal_filter_get_list(sqlite3 *db, pkgmgrinfo_pkginfo_filter_h filter, uid_t uid, const char *locale, GHashTable *list);
-int appinfo_internal_filter_get_list(sqlite3 *db, pkgmgrinfo_appinfo_filter_h filter, uid_t db_uid, uid_t uid, const char *locale, GHashTable *list);
-int certinfo_internal_get(sqlite3 *db, const char *pkgid, uid_t uid, pkgmgrinfo_certinfo_h certinfo);
-int certinfo_internal_set(sqlite3 *db, const char *pkgid, pkgmgrinfo_instcertinfo_h handle, uid_t uid);
-int certinfo_internal_delete(sqlite3 *db, const char *pkgid);
-int get_query_result(sqlite3 *db, const char *query, GList *param, GList **list, int *row, int *col);
-int execute_write_queries(sqlite3 *db, GList *queries, GList *params_list);
-int pkginfo_internal_filter_get_depends_on(sqlite3 *db, const char *pkgid, GList **list);
+namespace pkgmgr_server::internal {
 
-void _save_column_int(sqlite3_stmt *stmt, int idx, int *i);
-void _save_column_str(sqlite3_stmt *stmt, int idx, char **str);
+void SetEnableUnitTest(bool enable);
+int CertInfoGet(const tizen_base::Database& db,
+    std::string_view pkgid, uid_t uid, pkgmgrinfo_certinfo_h certinfo);
+int CertInfoSet(const tizen_base::Database& db,
+    std::string_view pkgid, pkgmgrinfo_instcertinfo_h handle, uid_t uid);
+int InitializeDb(const tizen_base::Database& db, uid_t uid);
+int InsertPkgInfo(const tizen_base::Database& db, manifest_x* mfx, uid_t uid);
+int UpdatePkgInfo(const tizen_base::Database& db, manifest_x* mfx, uid_t uid);
+int DeletePkgInfo(const tizen_base::Database& db, const char* package, uid_t uid);
+bool CheckPackageStorageStatus(pkgmgrinfo_filter_x* tmp_filter);
+int ExecuteWriteQueries(const tizen_base::Database& db,
+    const std::vector<std::string>& queries,
+    const std::vector<std::vector<std::optional<std::string>>>& args_list);
+int GetQueryResult(const tizen_base::Database& db,
+    const std::string& query,
+    const std::vector<std::optional<std::string>>& param,
+    std::vector<std::vector<std::optional<std::string>>>& result);
+bool CheckAppStorageStatus(pkgmgrinfo_filter_x* tmp_filter);
+int GetAppInfo(const tizen_base::Database& db,
+    pkgmgrinfo_appinfo_filter_h filter, uid_t db_uid, uid_t uid,
+    const std::string& locale,
+    std::vector<std::shared_ptr<application_x>>& appinfo_list);
+int GetPkgInfo(const tizen_base::Database& db,
+    pkgmgrinfo_pkginfo_filter_h filter, uid_t uid,
+    const std::string& locale,
+    std::map<std::string, std::shared_ptr<package_x>>& pkginfo_list);
+int GetDependsOn(const tizen_base::Database& db, const std::string& pkgid,
+    std::vector<dependency_x*>& dep_list);
 
-int pkgmgr_parser_insert_pkg_info(sqlite3 *db, manifest_x *mfx, uid_t uid);
-int pkgmgr_parser_update_pkg_info(sqlite3 *db, manifest_x *mfx, uid_t uid);
-int pkgmgr_parser_delete_pkg_info(sqlite3 *db, const char *package, uid_t uid);
+}  // namespace pkgmgr_server::internal
 
-/** @} */
-#ifdef __cplusplus
-}
-#endif
 #endif                         /* __PKGMGRINFO_INTERNAL_H__ */
-/**
- * @}
- * @}
- */
-