-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(pkgmgr-info)
${CMAKE_SOURCE_DIR}/src/common
${CMAKE_SOURCE_DIR}/src/common/socket
${CMAKE_SOURCE_DIR}/src/common/parcel
- ${CMAKE_SOURCE_DIR}/src/common/shared_memory
- ${CMAKE_SOURCE_DIR}/src/common/filter_checker
${CMAKE_SOURCE_DIR}/src/server
${CMAKE_SOURCE_DIR}/src/server/cynara_checker
+ ${CMAKE_SOURCE_DIR}/src/server/filter_checker
${CMAKE_SOURCE_DIR}/src/server/database
${CMAKE_SOURCE_DIR}/src/server/request_handler
- ${CMAKE_SOURCE_DIR}/src/server/shared_memory
)
### Required packages
#ifndef __PKGMGRINFO_EXTENSION_H__
#define __PKGMGRINFO_EXTENSION_H__
-#include <parcel.h>
-#include "pkgmgrinfo_type.h"
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <parcel.h>
+
+#include "pkgmgrinfo_type.h"
+
int pkgmgrinfo_pkginfo_to_parcel(pkgmgrinfo_pkginfo_h handle, parcel_h* parcel);
int pkgmgrinfo_appinfo_to_parcel(pkgmgrinfo_appinfo_h handle, parcel_h* parcel);
int pkgmgrinfo_pkginfo_from_parcel(parcel_h parcel, pkgmgrinfo_pkginfo_h* handle);
Name: pkgmgr-info
Summary: Packager Manager infomation api for package
-Version: 0.31.2
+Version: 0.30.0
Release: 1
Group: Application Framework/Package Management
License: Apache-2.0
# Communication modules for pkg-mgr client lib and server process
# By Youmin Ha <youmin.ha@samsung.com>
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 2.6)
#set(CMAKE_SKIP_BUILD_RPATH true)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/manager MANAGER_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common/socket SOCKET_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common/parcel PARCEL_SRCS)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common/shared_memory SHARED_MEMORY_SRCS)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common/filter_checker FILTER_CHECKER_SRCS)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common/filter_checker/pkg_filter_checker PKG_FILTER_CHECKER_SRCS)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/common/filter_checker/app_filter_checker APP_FILTER_CHECKER_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/utils UTIL_SRCS)
ADD_LIBRARY(pkgmgr-info SHARED
${COMMON_SRCS}
${SOCKET_SRCS}
${PARCEL_SRCS}
- ${SHARED_MEMORY_SRCS}
${MANAGER_SRCS}
${UTIL_SRCS}
- ${FILTER_CHECKER_SRCS}
- ${PKG_FILTER_CHECKER_SRCS}
- ${APP_FILTER_CHECKER_SRCS}
)
## Compile flags
PATTERN "*.hh"
)
-INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/common/shared_memory/ DESTINATION include/pkgmgr-common
- FILES_MATCHING
- PATTERN "*.hh"
-)
-
ADD_SUBDIRECTORY(server)
PkgInfoClient::PkgInfoClient(
std::shared_ptr<pkgmgr_common::parcel::AbstractParcelable> parcel,
uid_t uid, pkgmgr_common::ReqType req_type)
- : parcel_(std::move(parcel)),
+ : parcel_(parcel),
result_parcel_(nullptr),
uid_(uid),
req_type_(req_type),
is_offline_(false) {
socket_ = std::make_unique<pkgmgr_common::socket::ClientSocket>(SOCK_PATH);
- if (req_type == pkgmgr_common::ReqType::GET_PKG_INFO
- || req_type == pkgmgr_common::ReqType::GET_APP_INFO)
- is_offline_ = true;
}
bool PkgInfoClient::SendRequest() {
p.WriteParcelable(*parcel_.get());
// CREATE_DB request type need to be executed directly by the caller
- // GET_PKG_INFO, GET_APP_INFO request type directly access shared memory or database
- if (req_type_ == pkgmgr_common::ReqType::CREATE_DB ||
- req_type_ == pkgmgr_common::ReqType::GET_PKG_INFO ||
- req_type_ == pkgmgr_common::ReqType::GET_APP_INFO) {
+ if (req_type_ == pkgmgr_common::ReqType::CREATE_DB) {
is_offline_ = true;
return RequestHandlerDirectAccess(&p);
}
+++ /dev/null
-/*
- * 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.
- */
-
-#include "app_disable_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-#include "utils/logging.hh"
-
-namespace pkgmgr_common {
-
-bool AppDisableAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- if (value == nullptr || app_info->GetIsDisabled() == nullptr)
- return false;
-
- if (strcasecmp(value, app_info->GetIsDisabled()) != 0) {
- if (strcasecmp(app_info->GetIsDisabled(), "true") == 0)
- LOG(WARNING) << "The application [" << app_info->GetAppId() << "] is disabled";
- return false;
- }
-
- return true;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef APP_DISABLE_APP_FILTER_CHECKER_HH_
-#define APP_DISABLE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class AppDisableAppFilterChecker: public IAppFilterChecker {
- public:
- AppDisableAppFilterChecker() = default;
- ~AppDisableAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // APP_DISABLE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "appid_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool AppIdAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetAppId() != nullptr &&
- strcmp(value, app_info->GetAppId()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef APPID_APP_FILTER_CHECKER_HH_
-#define APPID_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class AppIdAppFilterChecker: public IAppFilterChecker {
- public:
- AppIdAppFilterChecker() = default;
- ~AppIdAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // APPID_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "auto_restart_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool AutoRestartAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetAutoRestart() != nullptr &&
- strcasecmp(value, app_info->GetAutoRestart()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 AUTO_RESTART_APP_FILTER_CHECKER_HH_
-#define AUTO_RESTART_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class AutoRestartAppFilterChecker: public IAppFilterChecker {
- public:
- AutoRestartAppFilterChecker() = default;
- ~AutoRestartAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // AUTO_RESTART_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include <glib.h>
-
-#include "category_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool CategoryAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- for (const char* category : app_info->GetCategory()) {
- if (value != nullptr && category != nullptr && strcmp(value, category) == 0) return true;
- }
-
- return false;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef CATEGORY_APP_FILTER_CHECKER_HH_
-#define CATEGORY_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class CategoryAppFilterChecker: public IAppFilterChecker {
- public:
- CategoryAppFilterChecker() = default;
- ~CategoryAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // CATEGORY_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "check_storage_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool CheckStorageAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value == nullptr || strcasecmp(value, "true") != 0 ||
- __appinfo_check_installed_storage(app_info->GetInstalledStorage(),
- app_info->GetExternalPath()) == PMINFO_R_OK);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 CHECK_STORAGE_APP_FILTER_CHECKER_HH_
-#define CHECK_STORAGE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class CheckStorageAppFilterChecker: public IAppFilterChecker {
- public:
- CheckStorageAppFilterChecker() = default;
- ~CheckStorageAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // CHECK_STORAGE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "component_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool ComponentAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetComponent() != nullptr &&
- strcmp(value, app_info->GetComponent()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef COMPONENT_APP_FILTER_CHECKER_HH_
-#define COMPONENT_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class ComponentAppFilterChecker: public IAppFilterChecker {
- public:
- ComponentAppFilterChecker() = default;
- ~ComponentAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // COMPONENT_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "default_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool DefaultAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return true;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef DEFAULT_APP_FILTER_CHECKER_HH_
-#define DEFAULT_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class DefaultAppFilterChecker: public IAppFilterChecker {
- public:
- DefaultAppFilterChecker() = default;
- ~DefaultAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // DEFAULT_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "exec_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool ExecAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetExec() != nullptr &&
- strcmp(value, app_info->GetExec()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef EXEC_APP_FILTER_CHECKER_HH_
-#define EXEC_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class ExecAppFilterChecker: public IAppFilterChecker {
- public:
- ExecAppFilterChecker() = default;
- ~ExecAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // EXEC_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "hw_acceleration_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool HWAccelerationAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetHwAcceleration() != nullptr &&
- strcmp(value, app_info->GetHwAcceleration()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 HW_ACCELERATION_APP_FILTER_CHECKER_HH_
-#define HW_ACCELERATION_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class HWAccelerationAppFilterChecker: public IAppFilterChecker {
- public:
- HWAccelerationAppFilterChecker() = default;
- ~HWAccelerationAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // HW_ACCELERATION_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "icon_app_filter_checker.hh"
-
-#include <glib.h>
-#include <string.h>
-
-namespace pkgmgr_common {
-
-bool IconAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- if (value == nullptr)
- return false;
-
- for (const Icon& icon : app_info->GetIcon()) {
- if (icon.Text() != nullptr && strcmp(icon.Text(), value) == 0)
- return true;
- }
-
- return false;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 ICON_APP_FILTER_CHECKER_HH_
-#define ICON_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class IconAppFilterChecker: public IAppFilterChecker {
- public:
- IconAppFilterChecker() = default;
- ~IconAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // ICON_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "launch_condition_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool LaunchConditionAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetLaunchCondition() != nullptr &&
- strcmp(value, app_info->GetLaunchCondition()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 LAUNCH_CONDITION_APP_FILTER_CHECKER_HH_
-#define LAUNCH_CONDITION_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class LaunchConditionAppFilterChecker: public IAppFilterChecker {
- public:
- LaunchConditionAppFilterChecker() = default;
- ~LaunchConditionAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // LAUNCH_CONDITION_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "mime_app_filter_checker.hh"
-
-#include <glib.h>
-
-namespace pkgmgr_common {
-
-bool MimeAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- if (value == nullptr)
- return false;
- for (auto app_control : app_info->GetAppcontrol()) {
- if (app_control.Mime() != nullptr && strcmp(app_control.Mime(), value) == 0)
- return true;
- }
-
- return false;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 MIME_APP_FILTER_CHECKER_HH_
-#define MIME_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class MimeAppFilterChecker: public IAppFilterChecker {
- public:
- MimeAppFilterChecker() = default;
- ~MimeAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // MIME_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "multiple_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool MultipleAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetMultiple() != nullptr &&
- strcasecmp(value, app_info->GetMultiple()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 MULTIPLE_APP_FILTER_CHECKER_HH_
-#define MULTIPLE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class MultipleAppFilterChecker: public IAppFilterChecker {
- public:
- MultipleAppFilterChecker() = default;
- ~MultipleAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // MULTIPLE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "nodisplay_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool NoDisplayAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetNodisplay() != nullptr &&
- strcasecmp(value, app_info->GetNodisplay()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
-#define NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class NoDisplayAppFilterChecker: public IAppFilterChecker {
- public:
- NoDisplayAppFilterChecker() = default;
- ~NoDisplayAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "onboot_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool OnBootAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetOnboot() != nullptr &&
- strcasecmp(value, app_info->GetOnboot()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 ONBOOT_APP_FILTER_CHECKER_HH_
-#define ONBOOT_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class OnBootAppFilterChecker: public IAppFilterChecker {
- public:
- OnBootAppFilterChecker() = default;
- ~OnBootAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // ONBOOT_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "operation_app_filter_checker.hh"
-
-#include <glib.h>
-
-namespace pkgmgr_common {
-
-bool OperationAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- for (auto app_control : app_info->GetAppcontrol()) {
- if (app_control.Operation() != nullptr &&
- strcmp(app_control.Operation(), value) == 0)
- return true;
- }
-
- return false;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef OPERATION_APP_FILTER_CHECKER_HH_
-#define OPERATION_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class OperationAppFilterChecker: public IAppFilterChecker {
- public:
- OperationAppFilterChecker() = default;
- ~OperationAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // OPERATION_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "pkg_disable_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-#include "utils/logging.hh"
-
-namespace pkgmgr_common {
-
-bool PkgDisableAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- if (value == nullptr || !app_info || app_info->GetIsPackageDisabled() == nullptr)
- return false;
-
- if (strcasecmp(value, app_info->GetIsPackageDisabled()) != 0) {
- if (strcasecmp(app_info->GetIsPackageDisabled(), "true") == 0)
- LOG(WARNING) << "The pacakge [" << app_info->GetPackage()
- << "] to which the application ["
- << app_info->GetAppId() << "] belongs is disabled";
- return false;
- }
-
- return true;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef PKG_DISABLE_APP_FILTER_CHECKER_HH_
-#define PKG_DISABLE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class PkgDisableAppFilterChecker: public IAppFilterChecker {
- public:
- PkgDisableAppFilterChecker() = default;
- ~PkgDisableAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // PKG_DISABLE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "pkgid_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool PkgIdAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetPackage() != nullptr &&
- strcmp(value, app_info->GetPackage()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef PKGID_APP_FILTER_CHECKER_HH_
-#define PKGID_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class PkgIdAppFilterChecker: public IAppFilterChecker {
- public:
- PkgIdAppFilterChecker() = default;
- ~PkgIdAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // PKGID_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "screen_reader_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool ScreenReaderAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetScreenReader() != nullptr &&
- strcmp(value, app_info->GetScreenReader()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 SCREEN_READER_APP_FILTER_CHECKER_HH_
-#define SCREEN_READER_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class ScreenReaderAppFilterChecker: public IAppFilterChecker {
- public:
- ScreenReaderAppFilterChecker() = default;
- ~ScreenReaderAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // SCREEN_READER_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "storage_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool StorageAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetInstalledStorage() != nullptr &&
- strcasecmp(value, app_info->GetInstalledStorage()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef STORAGE_APP_FILTER_CHECKER_HH_
-#define STORAGE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class StorageAppFilterChecker: public IAppFilterChecker {
- public:
- StorageAppFilterChecker() = default;
- ~StorageAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // STORAGE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "support_disable_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool SupportDisableAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetSupportDisable() != nullptr &&
- strcasecmp(value, app_info->GetSupportDisable()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 SUPPORT_DISABLE_APP_FILTER_CHECKER_HH_
-#define SUPPORT_DISABLE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class SupportDisableAppFilterChecker: public IAppFilterChecker {
- public:
- SupportDisableAppFilterChecker() = default;
- ~SupportDisableAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // SUPPORT_DISABLE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "support_mode_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool SupportModeAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetSupportMode() != nullptr &&
- strcmp(value, app_info->GetSupportMode()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 SUPPORT_MODE_APP_FILTER_CHECKER_HH_
-#define SUPPORT_MODE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class SupportModeAppFilterChecker: public IAppFilterChecker {
- public:
- SupportModeAppFilterChecker() = default;
- ~SupportModeAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // SUPPORT_MODE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "task_manage_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool TaskManageAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetTaskManage() != nullptr &&
- strcasecmp(value, app_info->GetTaskManage()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 TASK_MANAGE_APP_FILTER_CHECKER_HH_
-#define TASK_MANAGE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class TaskManageAppFilterChecker: public IAppFilterChecker {
- public:
- TaskManageAppFilterChecker() = default;
- ~TaskManageAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // TASK_MANAGE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "type_app_filter_checker.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-bool TypeAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetType() != nullptr &&
- strcmp(value, app_info->GetType()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef TYPE_APP_FILTER_CHECKER_HH_
-#define TYPE_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class TypeAppFilterChecker: public IAppFilterChecker {
- public:
- TypeAppFilterChecker() = default;
- ~TypeAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // TYPE_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "ui_gadget_app_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool UIGadgetAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- return (value != nullptr && app_info->GetUiGadget() != nullptr &&
- strcmp(value, app_info->GetUiGadget()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 UI_GADGET_APP_FILTER_CHECKER_HH_
-#define UI_GADGET_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class UIGadgetAppFilterChecker: public IAppFilterChecker {
- public:
- UIGadgetAppFilterChecker() = default;
- ~UIGadgetAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // UI_GADGET_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "uri_app_filter_checker.hh"
-
-#include <glib.h>
-
-namespace pkgmgr_common {
-
-bool URIAppFilterChecker::CheckFilter(const char* value,
- const AppInfoHandle* app_info) {
- if (value == nullptr)
- return false;
-
- for (auto app_control : app_info->GetAppcontrol())
- if (app_control.Uri() != nullptr && strcmp(app_control.Uri(), value) == 0)
- return true;
-
- return false;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 URI_APP_FILTER_CHECKER_HH_
-#define URI_APP_FILTER_CHECKER_HH_
-
-#include "app_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class URIAppFilterChecker: public IAppFilterChecker {
- public:
- URIAppFilterChecker() = default;
- ~URIAppFilterChecker() = default;
- bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // URI_APP_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef APP_FILTER_CHECKER_BASE_HH_
-#define APP_FILTER_CHECKER_BASE_HH_
-
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class IAppFilterChecker {
- public:
- IAppFilterChecker() = default;
- virtual ~IAppFilterChecker() = default;
- virtual bool CheckFilter(const char* value,
- const AppInfoHandle* app_info) = 0;
-};
-
-} // namespace pkgmgr_common
-
-#endif // APP_FILTER_CHECKER_BASE_HH_
+++ /dev/null
-/*
- * Copyright (c) 2021 - 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 FILTER_CHECKER_LIST_HH_
-#define FILTER_CHECKER_LIST_HH_
-
-#include "app_filter_checker/app_disable_app_filter_checker.hh"
-#include "app_filter_checker/appid_app_filter_checker.hh"
-#include "app_filter_checker/auto_restart_app_filter_checker.hh"
-#include "app_filter_checker/category_app_filter_checker.hh"
-#include "app_filter_checker/check_storage_app_filter_checker.hh"
-#include "app_filter_checker/component_app_filter_checker.hh"
-#include "app_filter_checker/default_app_filter_checker.hh"
-#include "app_filter_checker/exec_app_filter_checker.hh"
-#include "app_filter_checker/hw_acceleration_app_filter_checker.hh"
-#include "app_filter_checker/icon_app_filter_checker.hh"
-#include "app_filter_checker/launch_condition_app_filter_checker.hh"
-#include "app_filter_checker/mime_app_filter_checker.hh"
-#include "app_filter_checker/multiple_app_filter_checker.hh"
-#include "app_filter_checker/nodisplay_app_filter_checker.hh"
-#include "app_filter_checker/onboot_app_filter_checker.hh"
-#include "app_filter_checker/operation_app_filter_checker.hh"
-#include "app_filter_checker/pkg_disable_app_filter_checker.hh"
-#include "app_filter_checker/pkgid_app_filter_checker.hh"
-#include "app_filter_checker/screen_reader_app_filter_checker.hh"
-#include "app_filter_checker/storage_app_filter_checker.hh"
-#include "app_filter_checker/support_disable_app_filter_checker.hh"
-#include "app_filter_checker/support_mode_app_filter_checker.hh"
-#include "app_filter_checker/task_manage_app_filter_checker.hh"
-#include "app_filter_checker/type_app_filter_checker.hh"
-#include "app_filter_checker/ui_gadget_app_filter_checker.hh"
-#include "app_filter_checker/uri_app_filter_checker.hh"
-
-#include "pkg_filter_checker/app_setting_pkg_filter_checker.hh"
-#include "pkg_filter_checker/author_email_pkg_filter_checker.hh"
-#include "pkg_filter_checker/author_href_pkg_filter_checker.hh"
-#include "pkg_filter_checker/author_name_pkg_filter_checker.hh"
-#include "pkg_filter_checker/check_storage_pkg_filter_checker.hh"
-#include "pkg_filter_checker/default_pkg_filter_checker.hh"
-#include "pkg_filter_checker/disable_pkg_filter_checker.hh"
-#include "pkg_filter_checker/install_location_pkg_filter_checker.hh"
-#include "pkg_filter_checker/installed_storage_pkg_filter_checker.hh"
-#include "pkg_filter_checker/nodisplay_pkg_filter_checker.hh"
-#include "pkg_filter_checker/pkg_size_pkg_filter_checker.hh"
-#include "pkg_filter_checker/pkgid_pkg_filter_checker.hh"
-#include "pkg_filter_checker/pkgtype_pkg_filter_checker.hh"
-#include "pkg_filter_checker/preload_pkg_filter_checker.hh"
-#include "pkg_filter_checker/privilege_pkg_filter_checker.hh"
-#include "pkg_filter_checker/read_only_pkg_filter_checker.hh"
-#include "pkg_filter_checker/removable_pkg_filter_checker.hh"
-#include "pkg_filter_checker/restype_pkg_filter_checker.hh"
-#include "pkg_filter_checker/support_disable_pkg_filter_checker.hh"
-#include "pkg_filter_checker/system_pkg_filter_checker.hh"
-#include "pkg_filter_checker/update_pkg_filter_checker.hh"
-#include "pkg_filter_checker/version_pkg_filter_checker.hh"
-
-#endif // FILTER_CHECKER_LIST_HH_
+++ /dev/null
-/*
- * Copyright (c) 2021 - 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.
- */
-
-#include "filter_checker_provider.hh"
-
-#include <memory>
-
-#include "filter_checker_list.hh"
-#include "pkgmgrinfo_debug.h"
-
-namespace pkgmgr_common {
-
-FilterCheckerProvider::FilterCheckerProvider() {
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_ID] =
- std::make_unique<PkgIdPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE] =
- std::make_unique<PkgTypePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION] =
- std::make_unique<VersionPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION] =
- std::make_unique<InstallLocationPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE] =
- std::make_unique<InstalledStorageFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME] =
- std::make_unique<AuthorNamePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL] =
- std::make_unique<AuthorEmailPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF] =
- std::make_unique<AuthorHrefPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE] =
- std::make_unique<PrivilegePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE] =
- std::make_unique<RemovablePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD] =
- std::make_unique<PreloadPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE] =
- std::make_unique<DisablePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE] =
- std::make_unique<ResTypePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE] =
- std::make_unique<CheckStoragePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE] =
- std::make_unique<PkgSizePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY] =
- std::make_unique<ReadOnlyPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE] =
- std::make_unique<UpdatePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING] =
- std::make_unique<AppSettingPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING] =
- std::make_unique<NoDisplayPkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE] =
- std::make_unique<SupportDisablePkgFilterChecker>();
- pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM] =
- std::make_unique<SystemPkgFilterChecker>();
-
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_ID] =
- std::make_unique<AppIdAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_COMPONENT] =
- std::make_unique<ComponentAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_EXEC] =
- std::make_unique<ExecAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_TYPE] =
- std::make_unique<TypeAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_OPERATION] =
- std::make_unique<OperationAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_CATEGORY] =
- std::make_unique<CategoryAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_PACKAGE] =
- std::make_unique<PkgIdAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE] =
- std::make_unique<StorageAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_NODISPLAY] =
- std::make_unique<NoDisplayAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_DISABLE] =
- std::make_unique<AppDisableAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_PKG_DISABLE] =
- std::make_unique<PkgDisableAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_ICON] =
- std::make_unique<IconAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_URI] =
- std::make_unique<URIAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_MIME] =
- std::make_unique<MimeAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_MULTIPLE] =
- std::make_unique<MultipleAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_ONBOOT] =
- std::make_unique<OnBootAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_AUTORESTART] =
- std::make_unique<AutoRestartAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_TASKMANAGE] =
- std::make_unique<TaskManageAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_HWACCELERATION] =
- std::make_unique<HWAccelerationAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_SCREENREADER] =
- std::make_unique<ScreenReaderAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION] =
- std::make_unique<LaunchConditionAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_UI_GADGET] =
- std::make_unique<UIGadgetAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE] =
- std::make_unique<SupportDisableAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE] =
- std::make_unique<SupportModeAppFilterChecker>();
- app_checker_map_[E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE] =
- std::make_unique<CheckStorageAppFilterChecker>();
-
- default_pkg_checker = std::make_unique<DefaultPkgFilterChecker>();
- default_app_checker = std::make_unique<DefaultAppFilterChecker>();
-}
-
-FilterCheckerProvider& FilterCheckerProvider::GetInst() {
- static FilterCheckerProvider inst;
- return inst;
-}
-
-IPkgFilterChecker* FilterCheckerProvider::GetPkgFilterChecker(int id) {
- auto it = pkg_checker_map_.find(id);
- if (it == pkg_checker_map_.end()) {
- _LOGE("Invalid filter id %d", id);
- return default_pkg_checker.get();
- }
- return it->second.get();
-}
-
-IAppFilterChecker* FilterCheckerProvider::GetAppFilterChecker(int id) {
- auto it = app_checker_map_.find(id);
- if (it == app_checker_map_.end()) {
- _LOGE("Invalid filter id %d", id);
- return default_app_checker.get();
- }
- return it->second.get();
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef FILTER_CHECKER_FACTORY_HH_
-#define FILTER_CHECKER_FACTORY_HH_
-
-#include <memory>
-#include <unordered_map>
-
-#include "pkg_filter_checker_base.hh"
-#include "app_filter_checker_base.hh"
-
-namespace pkgmgr_common {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-class EXPORT_API FilterCheckerProvider {
- public:
- static FilterCheckerProvider& GetInst();
- ~FilterCheckerProvider() = default;
- IPkgFilterChecker* GetPkgFilterChecker(int id);
- IAppFilterChecker* GetAppFilterChecker(int id);
-
- private:
- FilterCheckerProvider();
- std::unordered_map<int, std::unique_ptr<IPkgFilterChecker>> pkg_checker_map_;
- std::unordered_map<int, std::unique_ptr<IAppFilterChecker>> app_checker_map_;
-
- std::unique_ptr<IPkgFilterChecker> default_pkg_checker;
- std::unique_ptr<IAppFilterChecker> default_app_checker;
-};
-
-} // namespace pkgmgr_common
-
-#endif // FILTER_CHECKER_BASE_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "app_setting_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool AppSettingPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetAppSetting() != nullptr &&
- strcasecmp(value, info->GetAppSetting()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 APP_SETTING_PKG_FILTER_CHECKER_HH_
-#define APP_SETTING_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class AppSettingPkgFilterChecker : public IPkgFilterChecker {
- public:
- AppSettingPkgFilterChecker() = default;
- ~AppSettingPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // APP_SETTING_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "author_email_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool AuthorEmailPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- auto iter = info->GetAuthor();
- if (iter.begin() == iter.end())
- return false;
-
- Author author = *iter.begin();
- return (value != nullptr && author.Email() != nullptr &&
- strcmp(value, author.Email()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 AUTHOR_EMAIL_PKG_FILTER_CHECKER_HH_
-#define AUTHOR_EMAIL_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class AuthorEmailPkgFilterChecker : public IPkgFilterChecker {
- public:
- AuthorEmailPkgFilterChecker() = default;
- ~AuthorEmailPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // AUTHOR_EMAIL_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "author_href_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool AuthorHrefPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- auto iter = info->GetAuthor();
- if (iter.begin() == iter.end())
- return false;
-
- Author author(*iter.begin());
- return (value != nullptr && author.Href() != nullptr &&
- strcmp(value, author.Href()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 AUTHOR_HREF_PKG_FILTER_CHECKER_HH_
-#define AUTHOR_HREF_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class AuthorHrefPkgFilterChecker : public IPkgFilterChecker {
- public:
- AuthorHrefPkgFilterChecker() = default;
- ~AuthorHrefPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // AUTHOR_HREF_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "author_name_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool AuthorNamePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- auto iter = info->GetAuthor();
- if (iter.begin() == iter.end())
- return false;
-
- Author author(*iter.begin());
- return (value != nullptr && author.Text() != nullptr &&
- strcmp(value, author.Text()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 AUTHOR_NAME_PKG_FILTER_CHECKER_HH_
-#define AUTHOR_NAME_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class AuthorNamePkgFilterChecker : public IPkgFilterChecker {
- public:
- AuthorNamePkgFilterChecker() = default;
- ~AuthorNamePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // AUTHOR_NAME_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "check_storage_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool CheckStoragePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value == nullptr || strcasecmp(value, "true") != 0 ||
- __pkginfo_check_installed_storage(info->GetPackage(),
- info->GetInstalledStorage(), info->GetExternalPath()) == PMINFO_R_OK);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
-#define CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class CheckStoragePkgFilterChecker : public IPkgFilterChecker {
- public:
- CheckStoragePkgFilterChecker() = default;
- ~CheckStoragePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "default_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool DefaultPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return true;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef DEFAULT_PKG_FILTER_CHECKER_HH_
-#define DEFAULT_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class DefaultPkgFilterChecker: public IPkgFilterChecker {
- public:
- DefaultPkgFilterChecker() = default;
- ~DefaultPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // DEFAULT_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "disable_pkg_filter_checker.hh"
-
-#include "utils/logging.hh"
-
-namespace pkgmgr_common {
-
-bool DisablePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- if (value == nullptr || info->GetIsDisabled() == nullptr)
- return false;
-
- if (strcasecmp(value, info->GetIsDisabled()) != 0) {
- if (strcasecmp(info->GetIsDisabled(), "true") == 0)
- LOG(WARNING) << "The package [" << info->GetPackage() << "] is disabled";
- return false;
- }
-
- return true;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef DISABLE_PKG_FILTER_CHECKER_HH_
-#define DISABLE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class DisablePkgFilterChecker: public IPkgFilterChecker {
- public:
- DisablePkgFilterChecker() = default;
- ~DisablePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // DISABLE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "install_location_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool InstallLocationPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetInstallLocation() != nullptr &&
- strcmp(value, info->GetInstallLocation()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 INSTALL_LOCATION_PKG_FILTER_CHECKER_HH_
-#define INSTALL_LOCATION_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class InstallLocationPkgFilterChecker : public IPkgFilterChecker {
- public:
- InstallLocationPkgFilterChecker() = default;
- ~InstallLocationPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // INSTALL_LOCATION_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "installed_storage_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool InstalledStorageFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetInstalledStorage() != nullptr &&
- strcmp(value, info->GetInstalledStorage()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 INSTALLED_STORAGE_PKG_FILTER_CHECKER_HH_
-#define INSTALLED_STORAGE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class InstalledStorageFilterChecker : public IPkgFilterChecker {
- public:
- InstalledStorageFilterChecker() = default;
- ~InstalledStorageFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // INSTALLED_STORAGE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "nodisplay_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool NoDisplayPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetNoDisplaySetting() != nullptr &&
- strcasecmp(value, info->GetNoDisplaySetting()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 NODISPLAY_PKG_FILTER_CHECKER_HH_
-#define NODISPLAY_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class NoDisplayPkgFilterChecker : public IPkgFilterChecker {
- public:
- NoDisplayPkgFilterChecker() = default;
- ~NoDisplayPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // NODISPLAY_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "pkg_size_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool PkgSizePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetPackageSize() != nullptr &&
- strcmp(value, info->GetPackageSize()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 PKG_SIZE_PKG_FILTER_CHECKER_HH_
-#define PKG_SIZE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class PkgSizePkgFilterChecker : public IPkgFilterChecker {
- public:
- PkgSizePkgFilterChecker() = default;
- ~PkgSizePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // PKG_SIZE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "pkgid_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool PkgIdPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetPackage() != nullptr &&
- strcmp(value, info->GetPackage()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef PKGID_PKG_FILTER_CHECKER_HH_
-#define PKGID_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class PkgIdPkgFilterChecker: public IPkgFilterChecker {
- public:
- PkgIdPkgFilterChecker() = default;
- ~PkgIdPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // PKGID_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "pkgtype_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool PkgTypePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetType() != nullptr &&
- strcasecmp(value, info->GetType()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 PKGYPTE_PKG_FILTER_CHECKER_HH_
-#define PKGYPTE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class PkgTypePkgFilterChecker : public IPkgFilterChecker {
- public:
- PkgTypePkgFilterChecker() = default;
- ~PkgTypePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // PKGYPTE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "preload_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool PreloadPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetPreload() != nullptr &&
- strcasecmp(value, info->GetPreload()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef PRELOAD_PKG_FILTER_CHECKER_HH_
-#define PRELOAD_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class PreloadPkgFilterChecker: public IPkgFilterChecker {
- public:
- PreloadPkgFilterChecker() = default;
- ~PreloadPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // PRELOAD_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "privilege_pkg_filter_checker.hh"
-
-#include <glib.h>
-
-namespace pkgmgr_common {
-
-bool PrivilegePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- for (auto priv : info->GetPrivileges())
- if (priv.Value() != nullptr && strcmp(priv.Value(), value) == 0)
- return true;
-
- return false;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef PRIVILEGE_PKG_FILTER_CHECKER_HH_
-#define PRIVILEGE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class PrivilegePkgFilterChecker: public IPkgFilterChecker {
- public:
- PrivilegePkgFilterChecker() = default;
- ~PrivilegePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // PRIVILEGE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "read_only_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool ReadOnlyPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetReadonly() != nullptr &&
- strcasecmp(value, info->GetReadonly()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 READ_ONLY_PKG_FILTER_CHECKER_HH_
-#define READ_ONLY_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class ReadOnlyPkgFilterChecker : public IPkgFilterChecker {
- public:
- ReadOnlyPkgFilterChecker() = default;
- ~ReadOnlyPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // READ_ONLY_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "removable_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool RemovablePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetRemovable() != nullptr &&
- strcasecmp(value, info->GetRemovable()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef REMOVABLE_PKG_FILTER_CHECKER_HH_
-#define REMOVABLE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class RemovablePkgFilterChecker: public IPkgFilterChecker {
- public:
- RemovablePkgFilterChecker() = default;
- ~RemovablePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // REMOVABLE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "restype_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool ResTypePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- if (!info->GetResType())
- return false;
-
- if (value == nullptr || strlen(value) == 0)
- return info->GetResType() != nullptr;
-
- return strcmp(value, info->GetResType()) == 0;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef RESTYPE_PKG_FILTER_CHECKER_HH_
-#define RESTYPE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class ResTypePkgFilterChecker: public IPkgFilterChecker {
- public:
- ResTypePkgFilterChecker() = default;
- ~ResTypePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // RESTYPE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "support_disable_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool SupportDisablePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetSupportDisable() != nullptr &&
- strcasecmp(value, info->GetSupportDisable()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 SUPPORT_DISABLE_PKG_FILTER_CHECKER_HH_
-#define SUPPORT_DISABLE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class SupportDisablePkgFilterChecker : public IPkgFilterChecker {
- public:
- SupportDisablePkgFilterChecker() = default;
- ~SupportDisablePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // SUPPORT_DISABLE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "system_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool SystemPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetSystem() != nullptr &&
- strcasecmp(value, info->GetSystem()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 SYSTEM_PKG_FILTER_CHECKER_HH_
-#define SYSTEM_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class SystemPkgFilterChecker : public IPkgFilterChecker {
- public:
- SystemPkgFilterChecker() = default;
- ~SystemPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // SYSTEM_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "update_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool UpdatePkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetUpdate() != nullptr &&
- strcasecmp(value, info->GetUpdate()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 UPDATE_PKG_FILTER_CHECKER_HH_
-#define UPDATE_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class UpdatePkgFilterChecker : public IPkgFilterChecker {
- public:
- UpdatePkgFilterChecker() = default;
- ~UpdatePkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // UPDATE_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "version_pkg_filter_checker.hh"
-
-namespace pkgmgr_common {
-
-bool VersionPkgFilterChecker::CheckFilter(const char* value,
- const PkgInfoHandle* info) {
- return (value != nullptr && info->GetVersion() != nullptr &&
- strcmp(value, info->GetVersion()) == 0);
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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 VERSION_PKG_FILTER_CHECKER_HH_
-#define VERSION_PKG_FILTER_CHECKER_HH_
-
-#include "pkg_filter_checker_base.hh"
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class VersionPkgFilterChecker : public IPkgFilterChecker {
- public:
- VersionPkgFilterChecker() = default;
- ~VersionPkgFilterChecker() = default;
- bool CheckFilter(const char* value, const PkgInfoHandle* info) override;
-};
-
-} // namespace pkgmgr_common
-
-#endif // VERSION_PKG_FILTER_CHECKER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef PKG_FILTER_CHECKER_BASE_HH_
-#define PKG_FILTER_CHECKER_BASE_HH_
-
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-
-class IPkgFilterChecker {
- public:
- IPkgFilterChecker() = default;
- virtual ~IPkgFilterChecker() = default;
- virtual bool CheckFilter(const char* value, const PkgInfoHandle* info) = 0;
-};
-
-} // namespace pkgmgr_common
-
-#endif // PKG_FILTER_CHECKER_BASE_HH_
return parcel->ReadInt32(val);
}
-bool AbstractParcelable::ReadBuffer(tizen_base::Parcel* parcel,
- void** buf, uint32_t* size) {
- uint32_t buf_size;
- if (parcel->ReadUInt32(&buf_size) != TIZEN_ERROR_NONE)
- return false;
-
- if (buf_size == 0)
- return false;
-
- void* ptr = malloc(buf_size);
- if (ptr == nullptr)
- return false;
-
- if (parcel->Read(ptr, buf_size) != TIZEN_ERROR_NONE) {
- free(ptr);
- return false;
- }
-
- *buf = ptr;
- *size = buf_size;
-
- return true;
-}
-
bool AbstractParcelable::ReadString(tizen_base::Parcel* parcel, char** val) {
bool is_null;
if (parcel->ReadBool(&is_null) != TIZEN_ERROR_NONE)
parcel->WriteInt32(i);
}
-void AbstractParcelable::WriteBuffer(tizen_base::Parcel* parcel,
- const void* buf, uint32_t size) const {
- parcel->WriteUInt32(size);
- parcel->Write(buf, size);
-}
-
void AbstractParcelable::WriteString(tizen_base::Parcel* parcel,
const char* str) const {
if (str == nullptr) {
Query,
Result,
Command,
- CreateDB,
- ROPkgInfo,
- ROAppInfo
+ CreateDB
};
class EXPORT_API AbstractParcelable : public tizen_base::Parcelable {
bool ReadString(tizen_base::Parcel* parcel, char** val);
std::optional<std::string> ReadString(tizen_base::Parcel* parcel);
bool ReadInt(tizen_base::Parcel* parcel, int* val);
- bool ReadBuffer(tizen_base::Parcel* parcel, void** buf, uint32_t* size);
void WriteString(tizen_base::Parcel* parcel, const char* str) const;
void WriteString(tizen_base::Parcel* parcel,
const std::optional<std::string>& str) const;
void WriteInt(tizen_base::Parcel* parcel, int i) const;
- void WriteBuffer(tizen_base::Parcel* parcel, const void* buf, uint32_t size) const;
private:
uid_t uid_;
#include <vector>
-#include "pkgmgrinfo_debug.h"
#include "pkgmgrinfo_private.h"
namespace pkgmgr_common {
for (int i = 0; i < size; ++i) {
label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- if (!label) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &label->lang);
ReadString(parcel, &label->name);
ReadString(parcel, &label->text);
for (int i = 0; i < size; ++i) {
icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
- if (!icon) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &icon->text);
ReadString(parcel, &icon->lang);
ReadString(parcel, &icon->section);
for (int i = 0; i < size; ++i) {
image_x* image = reinterpret_cast<image_x*>(calloc(1, sizeof(image_x)));
- if (!image) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &image->text);
ReadString(parcel, &image->lang);
ReadString(parcel, &image->section);
for (int i = 0; i < size; ++i) {
metadata_x* metadata =
reinterpret_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
- if (!metadata) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &metadata->key);
ReadString(parcel, &metadata->value);
for (int i = 0; i < size; ++i) {
datacontrol_x* datacontrol =
reinterpret_cast<datacontrol_x*>(calloc(1, sizeof(datacontrol_x)));
- if (!datacontrol) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &datacontrol->providerid);
ReadString(parcel, &datacontrol->access);
ReadString(parcel, &datacontrol->type);
for (int i = 0; i < size; ++i) {
appcontrol_x* appcontrol =
reinterpret_cast<appcontrol_x*>(calloc(1, sizeof(appcontrol_x)));
- if (!appcontrol) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &appcontrol->operation);
ReadString(parcel, &appcontrol->uri);
ReadString(parcel, &appcontrol->mime);
for (int i = 0; i < size; ++i) {
splashscreen_x* splashscreen =
reinterpret_cast<splashscreen_x*>(calloc(1, sizeof(splashscreen_x)));
- if (!splashscreen) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &splashscreen->src);
ReadString(parcel, &splashscreen->type);
ReadString(parcel, &splashscreen->dpi);
for (int i = 0; i < size; ++i) {
res_control_x* res_control =
reinterpret_cast<res_control_x*>(calloc(1, sizeof(res_control_x)));
- if (!res_control) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &res_control->res_type);
ReadString(parcel, &res_control->min_res_version);
ReadString(parcel, &res_control->max_res_version);
application_x* AppInfoParcelable::ReadApplication(tizen_base::Parcel* parcel) {
application_x* application =
reinterpret_cast<application_x*>(calloc(1, sizeof(application_x)));
- if (!application) {
- _LOGE("Out of memory");
- return nullptr;
- }
ReadString(parcel, &application->appid);
ReadString(parcel, &application->exec);
CertInfoParcelable::CertInfoParcelable(uid_t uid, std::string pkgid)
: AbstractParcelable(uid, ParcelableType::CertInfo),
cert_info_(nullptr),
- pkgid_(std::move(pkgid)),
+ pkgid_(pkgid),
auto_release_(true) {}
CertInfoParcelable::CertInfoParcelable(uid_t uid, pkgmgr_certinfo_x* cert_info,
std::string pkgid, bool auto_release)
: AbstractParcelable(uid, ParcelableType::CertInfo),
cert_info_(cert_info),
- pkgid_(std::move(pkgid)),
+ pkgid_(pkgid),
auto_release_(auto_release) {}
CertInfoParcelable::~CertInfoParcelable() {
#include <vector>
-#include "pkgmgrinfo_debug.h"
#include "pkgmgrinfo_private.h"
namespace pkgmgr_common {
dependency_x* DepInfoParcelable::ReadDependency(tizen_base::Parcel* parcel) {
dependency_x* dep =
reinterpret_cast<dependency_x*>(calloc(1, sizeof(dependency_x)));
- if (!dep) {
- _LOGE("Out of memory");
- return nullptr;
- }
ReadString(parcel, &dep->pkgid);
ReadString(parcel, &dep->depends_on);
ReadString(parcel, &dep->type);
#include <vector>
-#include "pkgmgrinfo_debug.h"
#include "pkgmgrinfo_private.h"
#include "pkgmgr-info.h"
#include "utils/logging.hh"
filter_ = reinterpret_cast<pkgmgrinfo_filter_x*>(
calloc(1, sizeof(pkgmgrinfo_filter_x)));
+
if (filter_ == nullptr) {
LOG(ERROR) << "out of memory";
return;
tizen_base::Parcel* parcel) {
pkgmgrinfo_node_x* node = reinterpret_cast<pkgmgrinfo_node_x*>(
calloc(1, sizeof(pkgmgrinfo_node_x)));
- if (!node) {
- _LOGE("Out of memory");
- return nullptr;
- }
ReadInt(parcel, &node->prop);
ReadString(parcel, &node->key);
ReadString(parcel, &node->value);
pkgmgrinfo_metadata_node_x* node =
reinterpret_cast<pkgmgrinfo_metadata_node_x*>(
calloc(1, sizeof(pkgmgrinfo_metadata_node_x)));
- if (!node) {
- _LOGE("Out of memory");
- return nullptr;
- }
ReadString(parcel, &node->key);
ReadString(parcel, &node->value);
#include "pkginfo_parcelable.hh"
#include "query_parcelable.hh"
#include "result_parcelable.hh"
-#include "ro_appinfo_parcelable.hh"
-#include "ro_pkginfo_parcelable.hh"
#include "command_parcelable.hh"
namespace pkgmgr_common {
res = std::make_unique<CreateDBParcelable>();
parcel.ReadParcelable(res.get());
break;
- case ParcelableType::ROPkgInfo:
- res = std::make_unique<ROPkgInfoParcelable>();
- parcel.ReadParcelable(res.get());
- break;
- case ParcelableType::ROAppInfo:
- res = std::make_unique<ROAppInfoParcelable>();
- parcel.ReadParcelable(res.get());
- break;
case ParcelableType::Unknown:
res = std::make_unique<AbstractParcelable>();
parcel.ReadParcelable(res.get());
#include "appinfo_parcelable.hh"
-#include "pkgmgrinfo_debug.h"
#include "pkgmgrinfo_private.h"
namespace pkgmgr_common {
for (int i = 0; i < size; ++i) {
icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
- if (!icon) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &icon->text);
ReadString(parcel, &icon->lang);
ReadString(parcel, &icon->section);
for (int i = 0; i < size; ++i) {
label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- if (!label) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &label->lang);
ReadString(parcel, &label->name);
ReadString(parcel, &label->text);
for (int i = 0; i < size; ++i) {
author_x* author = reinterpret_cast<author_x*>(
calloc(1, sizeof(author_x)));
- if (!author) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &author->email);
ReadString(parcel, &author->href);
ReadString(parcel, &author->text);
for (int i = 0; i < size; ++i) {
description_x* description =
reinterpret_cast<description_x*>(calloc(1, sizeof(description_x)));
- if (!description) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &description->name);
ReadString(parcel, &description->text);
ReadString(parcel, &description->lang);
for (int i = 0; i < size; ++i) {
privilege_x* privilege =
reinterpret_cast<privilege_x*>(calloc(1, sizeof(privilege_x)));
- if (!privilege) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &privilege->type);
ReadString(parcel, &privilege->value);
appdefined_privilege_x* appdefined_privilege =
reinterpret_cast<appdefined_privilege_x*>(
calloc(1, sizeof(appdefined_privilege_x)));
- if (!appdefined_privilege) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &appdefined_privilege->type);
ReadString(parcel, &appdefined_privilege->value);
ReadString(parcel, &appdefined_privilege->license);
appdefined_privilege_x* appdefined_privilege =
reinterpret_cast<appdefined_privilege_x*>(
calloc(1, sizeof(appdefined_privilege_x)));
- if (!appdefined_privilege) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &appdefined_privilege->type);
ReadString(parcel, &appdefined_privilege->value);
ReadString(parcel, &appdefined_privilege->license);
for (int i = 0; i < size; ++i) {
dependency_x* dependendy =
reinterpret_cast<dependency_x*>(calloc(1, sizeof(dependency_x)));
- if (!dependendy) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &dependendy->depends_on);
ReadString(parcel, &dependendy->type);
ReadString(parcel, &dependendy->required_version);
for (int i = 0; i < size; ++i) {
plugin_x* plugin = reinterpret_cast<plugin_x*>(
calloc(1, sizeof(plugin_x)));
- if (!plugin) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &plugin->pkgid);
ReadString(parcel, &plugin->appid);
ReadString(parcel, &plugin->plugin_type);
res_allowed_package_x* res_allowed_package =
reinterpret_cast<res_allowed_package_x*>(
calloc(1, sizeof(res_allowed_package_x)));
- if (!res_allowed_package) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &res_allowed_package->allowed_package);
int priv_len;
for (int i = 0; i < size; ++i) {
metadata_x* metadata =
reinterpret_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
- if (!metadata) {
- _LOGE("Out of memory");
- return;
- }
ReadString(parcel, &metadata->key);
ReadString(parcel, &metadata->value);
package_x* PkgInfoParcelable::ReadPackage(tizen_base::Parcel* parcel) {
package_x* package =
reinterpret_cast<package_x*>(calloc(1, sizeof(package_x)));
- if (!package) {
- _LOGE("Out of memory");
- return nullptr;
- }
ReadString(parcel, &package->for_all_users);
ReadString(parcel, &package->package);
write_type_(PkgWriteType::None), auto_release_(true) {}
PkgInfoParcelable::PkgInfoParcelable(
- uid_t uid, std::vector<std::shared_ptr<package_x>> pkg_list,
+ uid_t uid, std::vector<std::shared_ptr<package_x>>&& pkg_list,
PkgWriteType write_type, bool auto_release)
: AbstractParcelable(uid, ParcelableType::PkgInfo),
pkg_list_(std::move(pkg_list)), write_type_(write_type),
auto_release_(auto_release) {}
PkgInfoParcelable::PkgInfoParcelable(
- int ret, std::vector<std::shared_ptr<package_x>> pkg_list,
+ int ret, std::vector<std::shared_ptr<package_x>>&& pkg_list,
bool auto_release)
: AbstractParcelable(0, ParcelableType::PkgInfo, ret),
pkg_list_(std::move(pkg_list)), write_type_(PkgWriteType::None),
public:
PkgInfoParcelable();
PkgInfoParcelable(uid_t uid,
- std::vector<std::shared_ptr<package_x>> pkg_list,
+ std::vector<std::shared_ptr<package_x>>&& pkg_list,
PkgWriteType write_type, bool auto_release = true);
- PkgInfoParcelable(int ret, std::vector<std::shared_ptr<package_x>> pkg_list,
+ PkgInfoParcelable(int ret, std::vector<std::shared_ptr<package_x>>&& pkg_list,
bool auto_release = true);
~PkgInfoParcelable();
const std::vector<std::shared_ptr<package_x>>& GetPkgInfo();
+++ /dev/null
-/*
- * Copyright (c) 2024 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.
- */
-
-#include "ro_appinfo_parcelable.hh"
-
-#include <vector>
-
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-namespace parcel {
-
-ROAppInfoParcelable::ROAppInfoParcelable()
- : AbstractParcelable(0, ParcelableType::ROAppInfo) {}
-
-ROAppInfoParcelable::ROAppInfoParcelable(
- int ret, std::vector<AppInfoHandle> app_list)
- : AbstractParcelable(0, ParcelableType::ROAppInfo, ret),
- app_list_(std::move(app_list)) {}
-
-const std::vector<AppInfoHandle>& ROAppInfoParcelable::GetAppInfo() {
- return app_list_;
-}
-
-std::vector<AppInfoHandle> ROAppInfoParcelable::ExtractAppInfo() {
- return std::move(app_list_);
-}
-
-void ROAppInfoParcelable::WriteToParcel(tizen_base::Parcel* parcel) const {
- AbstractParcelable::WriteToParcel(parcel);
-
- WriteInt(parcel, app_list_.size());
-
- for (const auto& app : app_list_)
- WriteBuffer(parcel, app.GetData(), app.GetDataSize());
-}
-
-void ROAppInfoParcelable::ReadFromParcel(tizen_base::Parcel* parcel) {
- int len = 0;
-
- AbstractParcelable::ReadFromParcel(parcel);
-
- ReadInt(parcel, &len);
-
- for (int i = 0; i < len ; ++i) {
- uint32_t size;
- void* buf;
- if (!ReadBuffer(parcel, &buf, &size))
- continue;
-
- app_list_.emplace_back(std::make_unique<tizen_base::Parcel>(reinterpret_cast<uint8_t*>(buf), size, false));
- }
-}
-
-} // namespace parcel
-} // namespace pkgmgr_common
+++ /dev/null
-#ifndef RO_APPINFO_PARCELABLE_HH_
-#define RO_APPINFO_PARCELABLE_HH_
-
-#include "abstract_parcelable.hh"
-
-#include <vector>
-
-#include "pkgmgrinfo_basic.h"
-
-#include "pkg_write_type.hh"
-#include "pkgmgr_info_handle.hh"
-
-namespace pkgmgr_common {
-namespace parcel {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-class EXPORT_API ROAppInfoParcelable : public AbstractParcelable {
- public:
- ROAppInfoParcelable();
- ROAppInfoParcelable(int ret,
- std::vector<AppInfoHandle> app_list);
- const std::vector<AppInfoHandle>& GetAppInfo();
- std::vector<AppInfoHandle> ExtractAppInfo();
-
- void WriteToParcel(tizen_base::Parcel* parcel) const override;
- void ReadFromParcel(tizen_base::Parcel* parcel) override;
-
- private:
- std::vector<AppInfoHandle> app_list_;
-};
-
-} // namespace parcel
-} // namespace pkgmgr_common
-
-#endif // RO_APPINFO_PARCELABLE_HH_
+++ /dev/null
-/*
- * Copyright (c) 2024 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.
- */
-
-#include "ro_pkginfo_parcelable.hh"
-
-#include <vector>
-
-#include "pkgmgr_info_handle_writer.hh"
-
-#include "pkgmgrinfo_private.h"
-
-namespace pkgmgr_common {
-namespace parcel {
-
-ROPkgInfoParcelable::ROPkgInfoParcelable()
- : AbstractParcelable(0, ParcelableType::ROPkgInfo) {}
-
-ROPkgInfoParcelable::ROPkgInfoParcelable(
- int ret, std::vector<PkgInfoHandle> pkg_list)
- : AbstractParcelable(0, ParcelableType::ROPkgInfo, ret),
- pkg_list_(std::move(pkg_list)) {}
-
-const std::vector<PkgInfoHandle>& ROPkgInfoParcelable::GetPkgInfo() {
- return pkg_list_;
-}
-
-std::vector<PkgInfoHandle> ROPkgInfoParcelable::ExtractPkgInfo() {
- return std::move(pkg_list_);
-}
-
-void ROPkgInfoParcelable::WriteToParcel(tizen_base::Parcel* parcel) const {
- AbstractParcelable::WriteToParcel(parcel);
-
- WriteInt(parcel, pkg_list_.size());
-
- for (const auto& pkg : pkg_list_)
- WriteBuffer(parcel, pkg.GetData(), pkg.GetDataSize());
-}
-
-void ROPkgInfoParcelable::ReadFromParcel(tizen_base::Parcel* parcel) {
- int len = 0;
-
- AbstractParcelable::ReadFromParcel(parcel);
-
- ReadInt(parcel, &len);
-
- for (int i = 0; i < len ; ++i) {
- uint32_t size;
- void* buf;
- if (!ReadBuffer(parcel, &buf, &size))
- continue;
-
- pkg_list_.emplace_back(std::make_unique<tizen_base::Parcel>(reinterpret_cast<uint8_t*>(buf), size, false));
- }
-}
-
-} // namespace parcel
-} // namespace pkgmgr_common
+++ /dev/null
-#ifndef RO_PKGINFO_PARCELABLE_HH_
-#define RO_PKGINFO_PARCELABLE_HH_
-
-#include "abstract_parcelable.hh"
-
-#include <vector>
-
-#include "pkgmgrinfo_basic.h"
-
-#include "pkg_write_type.hh"
-#include "pkgmgr_info_handle.hh"
-
-namespace pkgmgr_common {
-namespace parcel {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-class EXPORT_API ROPkgInfoParcelable : public AbstractParcelable {
- public:
- ROPkgInfoParcelable();
- ROPkgInfoParcelable(int ret,
- std::vector<PkgInfoHandle> pkg_list);
- const std::vector<PkgInfoHandle>& GetPkgInfo();
- std::vector<PkgInfoHandle> ExtractPkgInfo();
-
- void WriteToParcel(tizen_base::Parcel* parcel) const override;
- void ReadFromParcel(tizen_base::Parcel* parcel) override;
-
- private:
- std::vector<PkgInfoHandle> pkg_list_;
-};
-
-} // namespace parcel
-} // namespace pkgmgr_common
-
-#endif // RO_PKGINFO_PARCELABLE_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "pkgmgr_info_handle.hh"
-
-#include <vector>
-#include <queue>
-
-#include "pkgmgrinfo_private.h"
-
-#include "utils/logging.hh"
-
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_INFO"
-
-#define GET_CSTRING(CLASS_NAME, FUNC_NAME, ELEMENT_NAME) \
- const char* CLASS_NAME::FUNC_NAME() const { \
- return GetCString(index_.ELEMENT_NAME); \
- }
-
-#define GET_LIST_ITERATOR(TYPE, FUNC_NAME, CLASS_NAME, ELEMENT_NAME) \
- Iterable<TYPE> CLASS_NAME::FUNC_NAME() const { \
- int index = index_.ELEMENT_NAME; \
- if (index < 0) \
- return Iterable<TYPE>(parcel_, -1); \
- return Iterable<TYPE>(parcel_, index); \
- }
-
-namespace pkgmgr_common {
-
-template<typename T>
-Iterable<T>::Iterable(const tizen_base::Parcel* parcel, int index)
- : SerializedBase(parcel) {
- if (index < 0 || static_cast<size_t>(index) >= parcel_->GetDataSize())
- return;
-
- int counts;
- if (!GetInt(index, &counts))
- return;
- index += sizeof(int32_t);
-
- std::vector<int> indexs;
- for (int i = 0; i < counts; ++i) {
- int ind;
- if (!GetInt(index, &ind))
- return;
-
- index += sizeof(int32_t);
- indexs.emplace_back(ind);
- }
-
- indexs_ = std::move(indexs);
-}
-
-SerializedBase::SerializedBase(const tizen_base::Parcel* parcel)
- : parcel_(parcel) {};
-
-SerializedBase& SerializedBase::operator=(SerializedBase&& h) noexcept {
- if (this != &h) {
- parcel_ = h.parcel_;
- }
- return *this;
-}
-
-const char* SerializedBase::GetCString(int index) const {
- if (index < -1)
- return nullptr;
-
- if ((size_t)index >= parcel_->GetDataSize())
- return nullptr;
-
- return reinterpret_cast<const char*>(parcel_->GetData() + index);
-}
-
-bool SerializedBase::GetInt(int index, int* result) const {
- if (index < 0 || result == nullptr)
- return false;
-
- int32_t tmp = -1;
-
- if (index + sizeof(tmp) > parcel_->GetDataSize())
- return false;
-
- auto* p = reinterpret_cast<uint8_t*>(&tmp);
- memcpy(p, parcel_->GetData() + index, sizeof(tmp));
-
- *result = tmp;
-
- return true;
-}
-
-bool SerializedBase::GetBuf(int index, void* buf, uint32_t size) const {
- if (index < 0 || index + size > parcel_->GetDataSize())
- return false;
-
- memcpy(buf, parcel_->GetData() + index, size);
-
- return true;
-}
-
-GET_CSTRING(Label, Name, name)
-GET_CSTRING(Label, Text, text)
-GET_CSTRING(Label, Lang, lang)
-
-GET_CSTRING(Icon, Text, text)
-GET_CSTRING(Icon, Lang, lang)
-GET_CSTRING(Icon, Section, section)
-GET_CSTRING(Icon, Size, size)
-GET_CSTRING(Icon, Resolution, resolution)
-GET_CSTRING(Icon, Dpi, dpi)
-
-GET_CSTRING(Image, Text, text)
-GET_CSTRING(Image, Lang, lang)
-GET_CSTRING(Image, Section, section)
-
-GET_CSTRING(Metadata, Key, key)
-GET_CSTRING(Metadata, Value, value)
-
-GET_CSTRING(DataControl, ProviderId, providerid)
-GET_CSTRING(DataControl, Access, access)
-GET_CSTRING(DataControl, Type, type)
-GET_CSTRING(DataControl, Trusted, trusted)
-GET_LIST_ITERATOR(const char*, Privileges, DataControl, privileges)
-
-GET_CSTRING(Appcontrol, Operation, operation)
-GET_CSTRING(Appcontrol, Uri, uri)
-GET_CSTRING(Appcontrol, Mime, mime)
-GET_CSTRING(Appcontrol, Visibility, visibility)
-GET_CSTRING(Appcontrol, Id, id)
-GET_LIST_ITERATOR(const char*, Privileges, Appcontrol, privileges)
-
-GET_CSTRING(ResControl, ResType, res_type)
-GET_CSTRING(ResControl, MinResVersion, min_res_version)
-GET_CSTRING(ResControl, MaxResVersion, max_res_version)
-GET_CSTRING(ResControl, AutoClose, auto_close)
-
-GET_CSTRING(SplashScreen, Src, src)
-GET_CSTRING(SplashScreen, Type, type)
-GET_CSTRING(SplashScreen, Dpi, dpi)
-GET_CSTRING(SplashScreen, Orientation, orientation)
-GET_CSTRING(SplashScreen, Indicatordisplay, indicatordisplay)
-GET_CSTRING(SplashScreen, Operation, operation)
-GET_CSTRING(SplashScreen, ColorDepth, color_depth)
-
-GET_CSTRING(Author, Email, email)
-GET_CSTRING(Author, Href, href)
-GET_CSTRING(Author, Text, text)
-GET_CSTRING(Author, Lang, lang)
-
-GET_CSTRING(License, Text, text)
-GET_CSTRING(License, Lang, lang)
-
-GET_CSTRING(Description, Name, name)
-GET_CSTRING(Description, Text, text)
-GET_CSTRING(Description, Lang, lang)
-
-GET_CSTRING(Privilege, Type, type)
-GET_CSTRING(Privilege, Value, value)
-
-GET_CSTRING(AppdefinedPrivilege, Type, type)
-GET_CSTRING(AppdefinedPrivilege, Value, value)
-GET_CSTRING(AppdefinedPrivilege, License, license)
-
-GET_CSTRING(Dependency, Pkgid, pkgid)
-GET_CSTRING(Dependency, DependsOn, depends_on)
-GET_CSTRING(Dependency, Type, type)
-GET_CSTRING(Dependency, RequiredVersion, required_version)
-
-GET_CSTRING(Plugin, Pkgid, pkgid)
-GET_CSTRING(Plugin, Appid, appid)
-GET_CSTRING(Plugin, PluginType, plugin_type)
-GET_CSTRING(Plugin, PluginName, plugin_name)
-
-GET_CSTRING(ResAllowedPackage, AllowedPackage, allowed_package)
-GET_LIST_ITERATOR(const char*, GetRequiredPrivileges, ResAllowedPackage, required_privileges)
-
-GET_CSTRING(Medatata, Key, key)
-GET_CSTRING(Medatata, Value, value)
-
-
-std::string PkgInfoHandle::ToString() const {
- std::string result = "";
- result += "[for_all_users]\n";
- result += std::string(GetForAllUsers() ? GetForAllUsers() : "nullptr") + "\n";
- result += "[package]\n";
- result += std::string(GetPackage() ? GetPackage() : "nullptr") + "\n";
- result += "[version]\n";
- result += std::string(GetVersion() ? GetVersion() : "nullptr") + "\n";
- result += "[installlocation]\n";
- result += std::string(GetInstallLocation() ? GetInstallLocation() : "nullptr") + "\n";
- result += "[ns]\n";
- result += std::string(GetNameSpace() ? GetNameSpace() : "nullptr") + "\n";
- result += "[removable]\n";
- result += std::string(GetRemovable() ? GetRemovable() : "nullptr") + "\n";
- result += "[preload]\n";
- result += std::string(GetPreload() ? GetPreload() : "nullptr") + "\n";
- result += "[readonly]\n";
- result += std::string(GetReadonly() ? GetReadonly() : "nullptr") + "\n";
- result += "[update]\n";
- result += std::string(GetUpdate() ? GetUpdate() : "nullptr") + "\n";
- result += "[appsetting]\n";
- result += std::string(GetAppSetting() ? GetAppSetting() : "nullptr") + "\n";
- result += "[system]\n";
- result += std::string(GetSystem() ? GetSystem() : "nullptr") + "\n";
- result += "[type]\n";
- result += std::string(GetType() ? GetType() : "nullptr") + "\n";
- result += "[package_size]\n";
- result += std::string(GetPackageSize() ? GetPackageSize() : "nullptr") + "\n";
- result += "[installed_time]\n";
- result += std::string(GetInstalledTime() ? GetInstalledTime() : "nullptr") + "\n";
- result += "[installed_storage]\n";
- result += std::string(GetInstalledStorage() ? GetInstalledStorage() : "nullptr") + "\n";
- result += "[storeclient_id]\n";
- result += std::string(GetStoreClientId() ? GetStoreClientId() : "nullptr") + "\n";
- result += "[mainapp_id]\n";
- result += std::string(GetMainAppId() ? GetMainAppId() : "nullptr") + "\n";
- result += "[package_url]\n";
- result += std::string(GetPackageUrl() ? GetPackageUrl() : "nullptr") + "\n";
- result += "[root_path]\n";
- result += std::string(GetRootPath() ? GetRootPath() : "nullptr") + "\n";
- result += "[csc_path]\n";
- result += std::string(GetCscPath() ? GetCscPath() : "nullptr") + "\n";
- result += "[nodisplay_setting]\n";
- result += std::string(GetNoDisplaySetting() ? GetNoDisplaySetting() : "nullptr") + "\n";
- result += "[support_mode]\n";
- result += std::string(GetSupportMode() ? GetSupportMode() : "nullptr") + "\n";
- result += "[support_disable]\n";
- result += std::string(GetSupportDisable() ? GetSupportDisable() : "nullptr") + "\n";
- result += "[api_version]\n";
- result += std::string(GetApiVersion() ? GetApiVersion() : "nullptr") + "\n";
- result += "[tep_name]\n";
- result += std::string(GetTepName() ? GetTepName() : "nullptr") + "\n";
- result += "[zip_mount_file]\n";
- result += std::string(GetZipMountFile() ? GetZipMountFile() : "nullptr") + "\n";
- result += "[backend_installer]\n";
- result += std::string(GetBackendInstaller() ? GetBackendInstaller() : "nullptr") + "\n";
- result += "[external_path]\n";
- result += std::string(GetExternalPath() ? GetExternalPath() : "nullptr") + "\n";
- result += "[use_system_certs]\n";
- result += std::string(GetUseSystemCerts() ? GetUseSystemCerts() : "nullptr") + "\n";
- result += "[locale]\n";
- result += std::string(GetLocale() ? GetLocale() : "nullptr") + "\n";
- result += "[res_type]\n";
- result += std::string(GetResType() ? GetResType() : "nullptr") + "\n";
- result += "[res_version]\n";
- result += std::string(GetResVersion() ? GetResVersion() : "nullptr") + "\n";
- result += "[lib]\n";
- result += std::string(GetLib() ? GetLib() : "nullptr") + "\n";
- result += "[is_disabled]\n";
- result += std::string(GetIsDisabled() ? GetIsDisabled() : "nullptr") + "\n";
- result += "[light_user_switch_mode]\n";
- result += std::string(GetLightUserSwitchMode() ? GetLightUserSwitchMode() : "nullptr") + "\n";
- result += "[icon]\n";
- for (Icon icon : GetIcon()) {
- result += std::string("") + "text : " + (icon.Text() ? icon.Text() : "nullptr") +
- " lang : " + (icon.Lang() ? icon.Lang() : "nullptr") +
- " section : " + (icon.Section() ? icon.Section() : "nullptr") +
- " size : " + (icon.Size() ? icon.Size() : "nullptr") +
- " resolution : " + (icon.Resolution() ? icon.Resolution() : "nullptr") +
- " dpi : " + (icon.Dpi() ? icon.Dpi() : "nullptr") +
- "\n";
- }
-
- result += "[label]\n";
- for (Label label : GetLabel()) {
- result += std::string("") +
- " name : " + (label.Name() ? label.Name() : "nullptr") +
- " text : " + (label.Text() ? label.Text() : "nullptr") +
- " lang : " + (label.Lang() ? label.Lang() : "nullptr") +
- "\n";
- }
-
- result += "[author]\n";
- for (Author author : GetAuthor()) {
- result += std::string("") +
- " email : " + (author.Email() ? author.Email() : "nullptr") +
- " href : " + (author.Href() ? author.Href() : "nullptr") +
- " text : " + (author.Text() ? author.Text() : "nullptr") +
- " lang : " + (author.Lang() ? author.Lang() : "nullptr") +
- "\n";
- }
- result += "[description]\n";
- for (Description description : GetDescription()) {
- result += std::string("") +
- " name : " + (description.Name() ? description.Name() : "nullptr") +
- " text : " + (description.Text() ? description.Text() : "nullptr") +
- " lang : " + (description.Lang() ? description.Lang() : "nullptr") +
- "\n";
- }
- result += "[privileges]\n";
- for (Privilege priv : GetPrivileges()) {
- result += std::string("") +
- " type : " + (priv.Type() ? priv.Type() : "nullptr") +
- " value : " + (priv.Value() ? priv.Value() : "nullptr") +
- "\n";
- }
- result += "[appdefined_privileges]\n";
- for (AppdefinedPrivilege priv : GetAppdefinedPrivileges()) {
- result += std::string("") +
- " type : " + (priv.Type() ? priv.Type() : "nullptr") +
- " value : " + (priv.Value() ? priv.Value() : "nullptr") +
- " license : " + (priv.License() ? priv.License() : "nullptr") +
- "\n";
- }
- result += "[provides_appdefined_privileges]\n";
- for (AppdefinedPrivilege priv : GetProvidesAppDefinedPrivileges()) {
- result += std::string("") +
- " type : " + (priv.Type() ? priv.Type() : "nullptr") +
- " value : " + (priv.Value() ? priv.Value() : "nullptr") +
- " license : " + (priv.License() ? priv.License() : "nullptr") +
- "\n";
- }
- result += "[dependencies]\n";
- for (Dependency dep : GetDependencies()) {
- result += std::string("") +
- " pkgid : " + (dep.Pkgid() ? dep.Pkgid() : "nullptr") +
- " depends_on : " + (dep.DependsOn() ? dep.DependsOn() : "nullptr") +
- " type : " + (dep.Type() ? dep.Type() : "nullptr") +
- " required_version : " + (dep.RequiredVersion() ? dep.RequiredVersion() : "nullptr") +
- "\n";
- }
- result += "[plugin]\n";
- for (Plugin plugin : GetPlugin()) {
- result += std::string("") +
- " pkgid : " + (plugin.Pkgid() ? plugin.Pkgid() : "nullptr") +
- " appid : " + (plugin.Appid() ? plugin.Appid() : "nullptr") +
- " plugin_type : " + (plugin.PluginType() ? plugin.PluginType() : "nullptr") +
- " plugin_name : " + (plugin.PluginName() ? plugin.PluginName() : "nullptr") +
- "\n";
- }
- result += "[res_allowed_packages]\n";
- for (ResAllowedPackage it : GetResAllowedPackages()) {
- result += std::string("") +
- " allowed_package : " + (it.AllowedPackage() ? it.AllowedPackage() : "nullptr") +
- " required_privileges : " + [&]() -> std::string {
- std::string result = "";
- for (const char* rp : it.GetRequiredPrivileges()) {
- result += (rp ? rp : "nullptr");
- result += " ";
- }
- return result;
- }() +
- "\n";
- }
- result += "[metadata]\n";
- for (Metadata metadata : GetMetadata()) {
- result += std::string("") +
- " key : " + (metadata.Key() ? metadata.Key() : "nullptr") +
- " value : " + (metadata.Value() ? metadata.Value() : "nullptr") +
- "\n";
- }
-
- return result;
-}
-
-std::string PkgInfoHandle::ToString(package_x* info) {
- std::string result = "";
- result += "[for_all_users]\n";
- result += std::string(info->for_all_users ? info->for_all_users : "nullptr") + "\n";
- result += "[package]\n";
- result += std::string(info->package ? info->package : "nullptr") + "\n";
- result += "[version]\n";
- result += std::string(info->version ? info->version : "nullptr") + "\n";
- result += "[installlocation]\n";
- result += std::string(info->installlocation ? info->installlocation : "nullptr") + "\n";
- result += "[ns]\n";
- result += std::string(info->ns ? info->ns : "nullptr") + "\n";
- result += "[removable]\n";
- result += std::string(info->removable ? info->removable : "nullptr") + "\n";
- result += "[preload]\n";
- result += std::string(info->preload ? info->preload : "nullptr") + "\n";
- result += "[readonly]\n";
- result += std::string(info->readonly ? info->readonly : "nullptr") + "\n";
- result += "[update]\n";
- result += std::string(info->update ? info->update : "nullptr") + "\n";
- result += "[appsetting]\n";
- result += std::string(info->appsetting ? info->appsetting : "nullptr") + "\n";
- result += "[system]\n";
- result += std::string(info->system ? info->system : "nullptr") + "\n";
- result += "[type]\n";
- result += std::string(info->type ? info->type : "nullptr") + "\n";
- result += "[package_size]\n";
- result += std::string(info->package_size ? info->package_size : "nullptr") + "\n";
- result += "[installed_time]\n";
- result += std::string(info->installed_time ? info->installed_time : "nullptr") + "\n";
- result += "[installed_storage]\n";
- result += std::string(info->installed_storage ? info->installed_storage : "nullptr") + "\n";
- result += "[storeclient_id]\n";
- result += std::string(info->storeclient_id ? info->storeclient_id : "nullptr") + "\n";
- result += "[mainapp_id]\n";
- result += std::string(info->mainapp_id ? info->mainapp_id : "nullptr") + "\n";
- result += "[package_url]\n";
- result += std::string(info->package_url ? info->package_url : "nullptr") + "\n";
- result += "[root_path]\n";
- result += std::string(info->root_path ? info->root_path : "nullptr") + "\n";
- result += "[csc_path]\n";
- result += std::string(info->csc_path ? info->csc_path : "nullptr") + "\n";
- result += "[nodisplay_setting]\n";
- result += std::string(info->nodisplay_setting ? info->nodisplay_setting : "nullptr") + "\n";
- result += "[support_mode]\n";
- result += std::string(info->support_mode ? info->support_mode : "nullptr") + "\n";
- result += "[support_disable]\n";
- result += std::string(info->support_disable ? info->support_disable : "nullptr") + "\n";
- result += "[api_version]\n";
- result += std::string(info->api_version ? info->api_version : "nullptr") + "\n";
- result += "[tep_name]\n";
- result += std::string(info->tep_name ? info->tep_name : "nullptr") + "\n";
- result += "[zip_mount_file]\n";
- result += std::string(info->zip_mount_file ? info->zip_mount_file : "nullptr") + "\n";
- result += "[backend_installer]\n";
- result += std::string(info->backend_installer ? info->backend_installer : "nullptr") + "\n";
- result += "[external_path]\n";
- result += std::string(info->external_path ? info->external_path : "nullptr") + "\n";
- result += "[use_system_certs]\n";
- result += std::string(info->use_system_certs ? info->use_system_certs : "nullptr") + "\n";
- result += "[locale]\n";
- result += std::string(info->locale ? info->locale : "nullptr") + "\n";
- result += "[res_type]\n";
- result += std::string(info->res_type ? info->res_type : "nullptr") + "\n";
- result += "[res_version]\n";
- result += std::string(info->res_version ? info->res_version : "nullptr") + "\n";
- result += "[lib]\n";
- result += std::string(info->lib ? info->lib : "nullptr") + "\n";
- result += "[is_disabled]\n";
- result += std::string(info->is_disabled ? info->is_disabled : "nullptr") + "\n";
- result += "[light_user_switch_mode]\n";
- result += std::string(info->light_user_switch_mode ? info->light_user_switch_mode : "nullptr") + "\n";
- result += "[icon]\n";
- if (!info->icon)
- result += "nullptr\n";
- else {
- icon_x* icon = (icon_x*)info->icon->data;
- result += std::string("") + "text : " + (icon->text ? icon->text : "nullptr") +
- " lang : " + (icon->lang ? icon->lang : "nullptr") +
- " section : " + (icon->section ? icon->section : "nullptr") +
- " size : " + (icon->size ? icon->size : "nullptr") +
- " resolution : " + (icon->resolution ? icon->resolution : "nullptr") +
- " dpi : " + (icon->dpi ? icon->dpi : "nullptr") +
- "\n";
- }
-
- result += "[label]\n";
- if (!info->label)
- result += "nullptr\n";
- else {
- label_x* label = (label_x*)info->label->data;
- result += std::string("") +
- " name : " + (label->name ? label->name : "nullptr") +
- " text : " + (label->text ? label->text : "nullptr") +
- " lang : " + (label->lang ? label->lang : "nullptr") +
- "\n";
- }
-
- result += "[author]\n";
- if (!info->author)
- result += "nullptr\n";
- else {
- author_x* author = (author_x*)info->author->data;
- result += std::string("") +
- " email : " + (author->email ? author->email : "nullptr") +
- " href : " + (author->href ? author->href : "nullptr") +
- " text : " + (author->text ? author->text : "nullptr") +
- " lang : " + (author->lang ? author->lang : "nullptr") +
- "\n";
- }
- result += "[description]\n";
- if (!info->description)
- result += "nullptr\n";
- else {
- description_x* description = (description_x*)info->description->data;
- result += std::string("") +
- " name : " + (description->name ? description->name : "nullptr") +
- " text : " + (description->text ? description->text : "nullptr") +
- " lang : " + (description->lang ? description->lang : "nullptr") +
- "\n";
- }
- result += "[privileges]\n";
- info->privileges = g_list_reverse(info->privileges);
- for (GList* it = info->privileges; it; it = it->next) {
- privilege_x* priv = (privilege_x*)it->data;
- result += std::string("") +
- " type : " + (priv->type ? priv->type : "nullptr") +
- " value : " + (priv->value ? priv->value : "nullptr") +
- "\n";
- }
- info->privileges = g_list_reverse(info->privileges);
- result += "[appdefined_privileges]\n";
-
- info->appdefined_privileges = g_list_reverse(info->appdefined_privileges);
- for (GList* it = info->appdefined_privileges; it; it = it->next) {
- appdefined_privilege_x* priv = (appdefined_privilege_x*)it->data;
- result += std::string("") +
- " type : " + (priv->type ? priv->type : "nullptr") +
- " value : " + (priv->value ? priv->value : "nullptr") +
- " license : " + (priv->license ? priv->license : "nullptr") +
- "\n";
- }
- info->appdefined_privileges = g_list_reverse(info->appdefined_privileges);
- result += "[provides_appdefined_privileges]\n";
- info->provides_appdefined_privileges = g_list_reverse(info->provides_appdefined_privileges);
- for (GList* it = info->provides_appdefined_privileges; it; it = it->next) {
- appdefined_privilege_x* priv = (appdefined_privilege_x*)it->data;
- result += std::string("") +
- " type : " + (priv->type ? priv->type : "nullptr") +
- " value : " + (priv->value ? priv->value : "nullptr") +
- " license : " + (priv->license ? priv->license : "nullptr") +
- "\n";
- }
- info->provides_appdefined_privileges = g_list_reverse(info->provides_appdefined_privileges);
- result += "[dependencies]\n";
- info->dependencies = g_list_reverse(info->dependencies);
- for (GList* it = info->dependencies; it; it = it->next) {
- dependency_x* dep = (dependency_x*)it->data;
- result += std::string("") +
- " pkgid : " + (dep->pkgid ? dep->pkgid : "nullptr") +
- " depends_on : " + (dep->depends_on ? dep->depends_on : "nullptr") +
- " type : " + (dep->type ? dep->type : "nullptr") +
- " required_version : " + (dep->required_version ? dep->required_version : "nullptr") +
- "\n";
- }
- info->dependencies = g_list_reverse(info->dependencies);
- result += "[plugin]\n";
- info->plugin = g_list_reverse(info->plugin);
- for (GList* it = info->plugin; it; it = it->next) {
- plugin_x* plugin = (plugin_x*)it->data;
- result += std::string("") +
- " pkgid : " + (plugin->pkgid ? plugin->pkgid : "nullptr") +
- " appid : " + (plugin->appid ? plugin->appid : "nullptr") +
- " plugin_type : " + (plugin->plugin_type ? plugin->plugin_type : "nullptr") +
- " plugin_name : " + (plugin->plugin_name ? plugin->plugin_name : "nullptr") +
- "\n";
- }
- info->plugin = g_list_reverse(info->plugin);
- result += "[res_allowed_packages]\n";
- info->res_allowed_packages = g_list_reverse(info->res_allowed_packages);
- for (GList* it = info->res_allowed_packages; it; it = it->next) {
- res_allowed_package_x* allowed_package = (res_allowed_package_x*)it->data;
- result += std::string("") +
- " allowed_package : " + (allowed_package->allowed_package ? allowed_package->allowed_package : "nullptr") +
- " required_privileges : " + [&]() -> std::string {
- std::string result = "";
- allowed_package->required_privileges = g_list_reverse(allowed_package->required_privileges);
- for (GList* it = allowed_package->required_privileges; it; it = it->next) {
- char* rp = (char*)it->data;
- result += (rp ? rp : "nullptr");
- result += " ";
- }
- allowed_package->required_privileges = g_list_reverse(allowed_package->required_privileges);
- return result;
- }() +
- "\n";
- }
- info->res_allowed_packages = g_list_reverse(info->res_allowed_packages);
- result += "[metadata]\n";
- info->metadata = g_list_reverse(info->metadata);
- for (GList* it = info->metadata; it; it = it->next) {
- metadata_x* metadata = (metadata_x*)it->data;
- result += std::string("") +
- " key : " + (metadata->key ? metadata->key : "nullptr") +
- " value : " + (metadata->value ? metadata->value : "nullptr") +
- "\n";
- }
- info->metadata = g_list_reverse(info->metadata);
-
- return result;
-}
-
-PkgInfoHandle::PkgInfoHandle(std::unique_ptr<tizen_base::Parcel> parcel)
- : Serialized<PkgInfoIndex>(parcel.get(), parcel->GetDataSize() - sizeof(index_)),
- base_parcel_(std::move(parcel)) {}
-
-PkgInfoHandle& PkgInfoHandle::operator=(PkgInfoHandle&& h) noexcept {
- if (this != &h) {
- Serialized<PkgInfoIndex>::operator=(std::move(h));
- base_parcel_ = std::move(h.base_parcel_);
- }
- return *this;
-}
-
-bool PkgInfoHandle::operator<(const PkgInfoHandle& h) {
- if (!GetPackage())
- return true;
-
- if (!h.GetPackage())
- return false;
-
- return strcmp(GetPackage(), h.GetPackage()) < 0;
-}
-
-const char* PkgInfoHandle::GetKey() const {
- return GetPackage();
-}
-
-GET_CSTRING(PkgInfoHandle, GetForAllUsers, for_all_users)
-GET_CSTRING(PkgInfoHandle, GetPackage, package)
-GET_CSTRING(PkgInfoHandle, GetVersion, version)
-GET_CSTRING(PkgInfoHandle, GetInstallLocation, installlocation)
-GET_CSTRING(PkgInfoHandle, GetNameSpace, ns)
-GET_CSTRING(PkgInfoHandle, GetRemovable, removable)
-GET_CSTRING(PkgInfoHandle, GetPreload, preload)
-GET_CSTRING(PkgInfoHandle, GetReadonly, readonly)
-GET_CSTRING(PkgInfoHandle, GetUpdate, update)
-GET_CSTRING(PkgInfoHandle, GetAppSetting, appsetting)
-GET_CSTRING(PkgInfoHandle, GetSystem, system)
-GET_CSTRING(PkgInfoHandle, GetType, type)
-GET_CSTRING(PkgInfoHandle, GetPackageSize, package_size)
-GET_CSTRING(PkgInfoHandle, GetInstalledTime, installed_time)
-GET_CSTRING(PkgInfoHandle, GetInstalledStorage, installed_storage)
-GET_CSTRING(PkgInfoHandle, GetStoreClientId, storeclient_id)
-GET_CSTRING(PkgInfoHandle, GetMainAppId, mainapp_id)
-GET_CSTRING(PkgInfoHandle, GetPackageUrl, package_url)
-GET_CSTRING(PkgInfoHandle, GetRootPath, root_path)
-GET_CSTRING(PkgInfoHandle, GetCscPath, csc_path)
-GET_CSTRING(PkgInfoHandle, GetNoDisplaySetting, nodisplay_setting)
-GET_CSTRING(PkgInfoHandle, GetSupportMode, support_mode)
-GET_CSTRING(PkgInfoHandle, GetSupportDisable, support_disable)
-GET_CSTRING(PkgInfoHandle, GetApiVersion, api_version)
-GET_CSTRING(PkgInfoHandle, GetTepName, tep_name)
-GET_CSTRING(PkgInfoHandle, GetZipMountFile, zip_mount_file)
-GET_CSTRING(PkgInfoHandle, GetBackendInstaller, backend_installer)
-GET_CSTRING(PkgInfoHandle, GetExternalPath, external_path)
-GET_CSTRING(PkgInfoHandle, GetUseSystemCerts, use_system_certs)
-GET_CSTRING(PkgInfoHandle, GetLocale, locale)
-GET_CSTRING(PkgInfoHandle, GetResType, res_type)
-GET_CSTRING(PkgInfoHandle, GetResVersion, res_version)
-GET_CSTRING(PkgInfoHandle, GetLib, lib)
-GET_CSTRING(PkgInfoHandle, GetIsDisabled, is_disabled)
-GET_CSTRING(PkgInfoHandle, GetLightUserSwitchMode, light_user_switch_mode)
-
-GET_LIST_ITERATOR(Icon, GetIcon, PkgInfoHandle, icon)
-GET_LIST_ITERATOR(Label, GetLabel, PkgInfoHandle, label)
-GET_LIST_ITERATOR(Author, GetAuthor, PkgInfoHandle, author)
-GET_LIST_ITERATOR(Description, GetDescription, PkgInfoHandle, description)
-GET_LIST_ITERATOR(Privilege, GetPrivileges, PkgInfoHandle, privileges)
-GET_LIST_ITERATOR(AppdefinedPrivilege, GetAppdefinedPrivileges, PkgInfoHandle, appdefined_privileges)
-GET_LIST_ITERATOR(AppdefinedPrivilege, GetProvidesAppDefinedPrivileges, PkgInfoHandle, provides_appdefined_privileges)
-GET_LIST_ITERATOR(Dependency, GetDependencies, PkgInfoHandle, dependencies)
-GET_LIST_ITERATOR(Plugin, GetPlugin, PkgInfoHandle, plugin)
-GET_LIST_ITERATOR(ResAllowedPackage, GetResAllowedPackages, PkgInfoHandle, res_allowed_packages)
-GET_LIST_ITERATOR(Metadata, GetMetadata, PkgInfoHandle, metadata)
-
-uint8_t* PkgInfoHandle::GetData() const {
- return base_parcel_->GetData();
-}
-
-uint32_t PkgInfoHandle::GetDataSize() const {
- return base_parcel_->GetDataSize();
-}
-
-PkgInfoHandle PkgInfoHandle::Clone() const {
- return PkgInfoHandle(std::make_unique<tizen_base::Parcel>(base_parcel_->GetData(), base_parcel_->GetDataSize(), true));
-}
-
-std::string AppInfoHandle::ToString() const {
- std::string result = "";
- result += "[appid]\n";
- result += std::string(GetAppId() ? GetAppId() : "nullptr") + "\n";
- result += "[exec]\n";
- result += std::string(GetExec() ? GetExec() : "nullptr") + "\n";
- result += "[nodisplay]\n";
- result += std::string(GetNodisplay() ? GetNodisplay() : "nullptr") + "\n";
- result += "[multiple]\n";
- result += std::string(GetMultiple() ? GetMultiple() : "nullptr") + "\n";
- result += "[taskmanage]\n";
- result += std::string(GetTaskManage() ? GetTaskManage() : "nullptr") + "\n";
- result += "[type]\n";
- result += std::string(GetType() ? GetType() : "nullptr") + "\n";
- result += "[categories]\n";
- result += std::string(GetCategories() ? GetCategories() : "nullptr") + "\n";
- result += "[extraid]\n";
- result += std::string(GetExtraid() ? GetExtraid() : "nullptr") + "\n";
- result += "[hwacceleration]\n";
- result += std::string(GetHwAcceleration() ? GetHwAcceleration() : "nullptr") + "\n";
- result += "[screenreader]\n";
- result += std::string(GetScreenReader() ? GetScreenReader() : "nullptr") + "\n";
- result += "[mainapp]\n";
- result += std::string(GetMainApp() ? GetMainApp() : "nullptr") + "\n";
- result += "[package]\n";
- result += std::string(GetPackage() ? GetPackage() : "nullptr") + "\n";
- result += "[recentimage]\n";
- result += std::string(GetRecentimage() ? GetRecentimage() : "nullptr") + "\n";
- result += "[launchcondition]\n";
- result += std::string(GetLaunchCondition() ? GetLaunchCondition() : "nullptr") + "\n";
- result += "[indicatordisplay]\n";
- result += std::string(GetIndicatorDisplay() ? GetIndicatorDisplay() : "nullptr") + "\n";
- result += "[portraitimg]\n";
- result += std::string(GetPortraitImg() ? GetPortraitImg() : "nullptr") + "\n";
- result += "[landscapeimg]\n";
- result += std::string(GetLandscapeImg() ? GetLandscapeImg() : "nullptr") + "\n";
- result += "[effectimage_type]\n";
- result += std::string(GetEffectImageType() ? GetEffectImageType() : "nullptr") + "\n";
- result += "[guestmode_visibility]\n";
- result += std::string(GetGuestModeVisibility() ? GetGuestModeVisibility() : "nullptr") + "\n";
- result += "[component]\n";
- result += std::string(GetComponent() ? GetComponent() : "nullptr") + "\n";
- result += "[permission_type]\n";
- result += std::string(GetPermissionType() ? GetPermissionType() : "nullptr") + "\n";
- result += "[component_type]\n";
- result += std::string(GetComponentType() ? GetComponentType() : "nullptr") + "\n";
- result += "[preload]\n";
- result += std::string(GetPreload() ? GetPreload() : "nullptr") + "\n";
- result += "[submode]\n";
- result += std::string(GetSubmode() ? GetSubmode() : "nullptr") + "\n";
- result += "[submode_mainid]\n";
- result += std::string(GetSubmodeMainId() ? GetSubmodeMainId() : "nullptr") + "\n";
- result += "[process_pool]\n";
- result += std::string(GetProcessPool() ? GetProcessPool() : "nullptr") + "\n";
- result += "[installed_storage]\n";
- result += std::string(GetInstalledStorage() ? GetInstalledStorage() : "nullptr") + "\n";
- result += "[autorestart]\n";
- result += std::string(GetAutoRestart() ? GetAutoRestart() : "nullptr") + "\n";
- result += "[onboot]\n";
- result += std::string(GetOnboot() ? GetOnboot() : "nullptr") + "\n";
- result += "[support_disable]\n";
- result += std::string(GetSupportDisable() ? GetSupportDisable() : "nullptr") + "\n";
- result += "[ui_gadget]\n";
- result += std::string(GetUiGadget() ? GetUiGadget() : "nullptr") + "\n";
- result += "[launch_mode]\n";
- result += std::string(GetLaunchMode() ? GetLaunchMode() : "nullptr") + "\n";
- result += "[support_ambient]\n";
- result += std::string(GetSupportAmbient() ? GetSupportAmbient() : "nullptr") + "\n";
- result += "[setup_appid]\n";
- result += std::string(GetSetupAppId() ? GetSetupAppId() : "nullptr") + "\n";
- result += "[alias_appid]\n";
- result += std::string(GetAliasAppid() ? GetAliasAppid() : "nullptr") + "\n";
- result += "[effective_appid]\n";
- result += std::string(GetEffectiveAppId() ? GetEffectiveAppId() : "nullptr") + "\n";
- result += "[package_type]\n";
- result += std::string(GetPackageType() ? GetPackageType() : "nullptr") + "\n";
- result += "[tep_name]\n";
- result += std::string(GetTepName() ? GetTepName() : "nullptr") + "\n";
- result += "[zip_mount_file]\n";
- result += std::string(GetZipMountFile() ? GetZipMountFile() : "nullptr") + "\n";
- result += "[root_path]\n";
- result += std::string(GetRootPath() ? GetRootPath() : "nullptr") + "\n";
- result += "[api_version]\n";
- result += std::string(GetApiVersion() ? GetApiVersion() : "nullptr") + "\n";
- result += "[for_all_users]\n";
- result += std::string(GetForAllUsers() ? GetForAllUsers() : "nullptr") + "\n";
- result += "[is_disabled]\n";
- result += std::string(GetIsDisabled() ? GetIsDisabled() : "nullptr") + "\n";
- result += "[splash_screen_display]\n";
- result += std::string(GetSplashScreenDisplay() ? GetSplashScreenDisplay() : "nullptr") + "\n";
- result += "[external_path]\n";
- result += std::string(GetExternalPath() ? GetExternalPath() : "nullptr") + "\n";
- result += "[package_system]\n";
- result += std::string(GetPackageSystem() ? GetPackageSystem() : "nullptr") + "\n";
- result += "[removable]\n";
- result += std::string(GetRemovable() ? GetRemovable() : "nullptr") + "\n";
- result += "[package_installed_time]\n";
- result += std::string(GetPackageInstalledTime() ? GetPackageInstalledTime() : "nullptr") + "\n";
- result += "[support_mode]\n";
- result += std::string(GetSupportMode() ? GetSupportMode() : "nullptr") + "\n";
- result += "[locale]\n";
- result += std::string(GetLocale() ? GetLocale() : "nullptr") + "\n";
- result += "[light_user_switch_mode]\n";
- result += std::string(GetLightUserSwitchMode() ? GetLightUserSwitchMode() : "nullptr") + "\n";
- result += "[label]\n";
- for (Label label : GetLabel()) {
- result += std::string("") +
- " name : " + (label.Name() ? label.Name() : "nullptr") +
- " text : " + (label.Text() ? label.Text() : "nullptr") +
- " lang : " + (label.Lang() ? label.Lang() : "nullptr") +
- "\n";
- }
-
- result += "[icon]\n";
- for (Icon icon : GetIcon()) {
- result += std::string("") + "text : " + (icon.Text() ? icon.Text() : "nullptr") +
- " lang : " + (icon.Lang() ? icon.Lang() : "nullptr") +
- " section : " + (icon.Section() ? icon.Section() : "nullptr") +
- " size : " + (icon.Size() ? icon.Size() : "nullptr") +
- " resolution : " + (icon.Resolution() ? icon.Resolution() : "nullptr") +
- " dpi : " + (icon.Dpi() ? icon.Dpi() : "nullptr") +
- "\n";
- }
-
- result += "[category]\n";
- for (const char* category : GetCategory()) {
- result += std::string("") +
- " category : " + (category ? category : "nullptr") +
- "\n";
- }
- result += "[metadata]\n";
- for (Metadata metadata : GetMetadata()) {
- result += std::string("") +
- " key : " + (metadata.Key() ? metadata.Key() : "nullptr") +
- " value : " + (metadata.Value() ? metadata.Value() : "nullptr") +
- "\n";
- }
- result += "[background_category]\n";
- for (const char* bg_category : GetBackgroundCategory()) {
- result += std::string("") +
- " bg_category : " + (bg_category ? bg_category : "nullptr") +
- "\n";
- }
- result += "[appcontrol]\n";
- for (Appcontrol appcontrol : GetAppcontrol()) {
- result += std::string("") +
- " operation : " + (appcontrol.Operation() ? appcontrol.Operation() : "nullptr") +
- " uri : " + (appcontrol.Uri() ? appcontrol.Uri() : "nullptr") +
- " mime : " + (appcontrol.Mime() ? appcontrol.Mime() : "nullptr") +
- " visibility : " + (appcontrol.Visibility() ? appcontrol.Visibility() : "nullptr") +
- " id : " + (appcontrol.Id() ? appcontrol.Id() : "nullptr") +
- "\n";
- }
- result += "[splashscreens]\n";
- for (SplashScreen ss : GetSplashscreens()) {
- result += std::string("") +
- " src : " + (ss.Src() ? ss.Src() : "nullptr") +
- " type : " + (ss.Type() ? ss.Type() : "nullptr") +
- " dpi : " + (ss.Dpi() ? ss.Dpi() : "nullptr") +
- " orientation : " + (ss.Orientation() ? ss.Orientation() : "nullptr") +
- " indicatordisplay : " + (ss.Indicatordisplay() ? ss.Indicatordisplay() : "nullptr") +
- " operation : " + (ss.Operation() ? ss.Operation() : "nullptr") +
- " color_depth : " + (ss.ColorDepth() ? ss.ColorDepth() : "nullptr") +
- "\n";
- }
- result += "[res_control]\n";
- for (ResControl res_control : GetResControl()) {
- result += std::string("") +
- " res_type : " + (res_control.ResType() ? res_control.ResType() : "nullptr") +
- " min_res_version : " + (res_control.MinResVersion() ? res_control.MinResVersion() : "nullptr") +
- " max_res_version : " + (res_control.MaxResVersion() ? res_control.MaxResVersion() : "nullptr") +
- " auto_close : " + (res_control.AutoClose() ? res_control.AutoClose() : "nullptr") +
- "\n";
- }
-
- return result;
-}
-
-std::string AppInfoHandle::ToString(application_x* handle) {
- std::string result = "";
- result += "[appid]\n";
- result += std::string(handle->appid ? handle->appid : "nullptr") + "\n";
- result += "[exec]\n";
- result += std::string(handle->exec ? handle->exec : "nullptr") + "\n";
- result += "[nodisplay]\n";
- result += std::string(handle->nodisplay ? handle->nodisplay : "nullptr") + "\n";
- result += "[multiple]\n";
- result += std::string(handle->multiple ? handle->multiple : "nullptr") + "\n";
- result += "[taskmanage]\n";
- result += std::string(handle->taskmanage ? handle->taskmanage : "nullptr") + "\n";
- result += "[type]\n";
- result += std::string(handle->type ? handle->type : "nullptr") + "\n";
- result += "[categories]\n";
- result += std::string(handle->categories ? handle->categories : "nullptr") + "\n";
- result += "[extraid]\n";
- result += std::string(handle->extraid ? handle->extraid : "nullptr") + "\n";
- result += "[hwacceleration]\n";
- result += std::string(handle->hwacceleration ? handle->hwacceleration : "nullptr") + "\n";
- result += "[screenreader]\n";
- result += std::string(handle->screenreader ? handle->screenreader : "nullptr") + "\n";
- result += "[mainapp]\n";
- result += std::string(handle->mainapp ? handle->mainapp : "nullptr") + "\n";
- result += "[package]\n";
- result += std::string(handle->package ? handle->package : "nullptr") + "\n";
- result += "[recentimage]\n";
- result += std::string(handle->recentimage ? handle->recentimage : "nullptr") + "\n";
- result += "[launchcondition]\n";
- result += std::string(handle->launchcondition ? handle->launchcondition : "nullptr") + "\n";
- result += "[indicatordisplay]\n";
- result += std::string(handle->indicatordisplay ? handle->indicatordisplay : "nullptr") + "\n";
- result += "[portraitimg]\n";
- result += std::string(handle->portraitimg ? handle->portraitimg : "nullptr") + "\n";
- result += "[landscapeimg]\n";
- result += std::string(handle->landscapeimg ? handle->landscapeimg : "nullptr") + "\n";
- result += "[effectimage_type]\n";
- result += std::string(handle->effectimage_type ? handle->effectimage_type : "nullptr") + "\n";
- result += "[guestmode_visibility]\n";
- result += std::string(handle->guestmode_visibility ? handle->guestmode_visibility : "nullptr") + "\n";
- result += "[component]\n";
- result += std::string(handle->component ? handle->component : "nullptr") + "\n";
- result += "[permission_type]\n";
- result += std::string(handle->permission_type ? handle->permission_type : "nullptr") + "\n";
- result += "[component_type]\n";
- result += std::string(handle->component_type ? handle->component_type : "nullptr") + "\n";
- result += "[preload]\n";
- result += std::string(handle->preload ? handle->preload : "nullptr") + "\n";
- result += "[submode]\n";
- result += std::string(handle->submode ? handle->submode : "nullptr") + "\n";
- result += "[submode_mainid]\n";
- result += std::string(handle->submode_mainid ? handle->submode_mainid : "nullptr") + "\n";
- result += "[process_pool]\n";
- result += std::string(handle->process_pool ? handle->process_pool : "nullptr") + "\n";
- result += "[installed_storage]\n";
- result += std::string(handle->installed_storage ? handle->installed_storage : "nullptr") + "\n";
- result += "[autorestart]\n";
- result += std::string(handle->autorestart ? handle->autorestart : "nullptr") + "\n";
- result += "[onboot]\n";
- result += std::string(handle->onboot ? handle->onboot : "nullptr") + "\n";
- result += "[support_disable]\n";
- result += std::string(handle->support_disable ? handle->support_disable : "nullptr") + "\n";
- result += "[ui_gadget]\n";
- result += std::string(handle->ui_gadget ? handle->ui_gadget : "nullptr") + "\n";
- result += "[launch_mode]\n";
- result += std::string(handle->launch_mode ? handle->launch_mode : "nullptr") + "\n";
- result += "[support_ambient]\n";
- result += std::string(handle->support_ambient ? handle->support_ambient : "nullptr") + "\n";
- result += "[setup_appid]\n";
- result += std::string(handle->setup_appid ? handle->setup_appid : "nullptr") + "\n";
- result += "[alias_appid]\n";
- result += std::string(handle->alias_appid ? handle->alias_appid : "nullptr") + "\n";
- result += "[effective_appid]\n";
- result += std::string(handle->effective_appid ? handle->effective_appid : "nullptr") + "\n";
- result += "[package_type]\n";
- result += std::string(handle->package_type ? handle->package_type : "nullptr") + "\n";
- result += "[tep_name]\n";
- result += std::string(handle->tep_name ? handle->tep_name : "nullptr") + "\n";
- result += "[zip_mount_file]\n";
- result += std::string(handle->zip_mount_file ? handle->zip_mount_file : "nullptr") + "\n";
- result += "[root_path]\n";
- result += std::string(handle->root_path ? handle->root_path : "nullptr") + "\n";
- result += "[api_version]\n";
- result += std::string(handle->api_version ? handle->api_version : "nullptr") + "\n";
- result += "[for_all_users]\n";
- result += std::string(handle->for_all_users ? handle->for_all_users : "nullptr") + "\n";
- result += "[is_disabled]\n";
- result += std::string(handle->is_disabled ? handle->is_disabled : "nullptr") + "\n";
- result += "[splash_screen_display]\n";
- result += std::string(handle->splash_screen_display ? handle->splash_screen_display : "nullptr") + "\n";
- result += "[external_path]\n";
- result += std::string(handle->external_path ? handle->external_path : "nullptr") + "\n";
- result += "[package_system]\n";
- result += std::string(handle->package_system ? handle->package_system : "nullptr") + "\n";
- result += "[removable]\n";
- result += std::string(handle->removable ? handle->removable : "nullptr") + "\n";
- result += "[package_installed_time]\n";
- result += std::string(handle->package_installed_time ? handle->package_installed_time : "nullptr") + "\n";
- result += "[support_mode]\n";
- result += std::string(handle->support_mode ? handle->support_mode : "nullptr") + "\n";
- result += "[locale]\n";
- result += std::string(handle->locale ? handle->locale : "nullptr") + "\n";
- result += "[light_user_switch_mode]\n";
- result += std::string(handle->light_user_switch_mode ? handle->light_user_switch_mode : "nullptr") + "\n";
- result += "[label]\n";
- if (!handle->label)
- result += "nullptr\n";
- else {
- label_x* label = (label_x*)handle->label->data;
- result += std::string("") +
- " name : " + (label->name ? label->name : "nullptr") +
- " text : " + (label->text ? label->text : "nullptr") +
- " lang : " + (label->lang ? label->lang : "nullptr") +
- "\n";
- }
-
- result += "[icon]\n";
- if (!handle->icon)
- result += "nullptr\n";
- else {
- icon_x* icon = (icon_x*)handle->icon->data;
- result += std::string("") + "text : " + (icon->text ? icon->text : "nullptr") +
- " lang : " + (icon->lang ? icon->lang : "nullptr") +
- " section : " + (icon->section ? icon->section : "nullptr") +
- " size : " + (icon->size ? icon->size : "nullptr") +
- " resolution : " + (icon->resolution ? icon->resolution : "nullptr") +
- " dpi : " + (icon->dpi ? icon->dpi : "nullptr") +
- "\n";
- }
-
- result += "[category]\n";
- handle->category = g_list_reverse(handle->category);
- for (GList* it = handle->category; it; it = it->next) {
- char* category = (char*)it->data;
- result += std::string("") +
- " category : " + (category ? category : "nullptr") +
- "\n";
- }
- handle->category = g_list_reverse(handle->category);
-
- result += "[metadata]\n";
- handle->metadata = g_list_reverse(handle->metadata);
- for (GList* it = handle->metadata; it; it = it->next) {
- metadata_x* metadata = (metadata_x*)it->data;
- result += std::string("") +
- " key : " + (metadata->key ? metadata->key : "nullptr") +
- " value : " + (metadata->value ? metadata->value : "nullptr") +
- "\n";
- }
- handle->metadata = g_list_reverse(handle->metadata);
- result += "[background_category]\n";
- handle->background_category = g_list_reverse(handle->background_category);
- for (GList* it = handle->background_category; it; it = it->next) {
- char* bg_category = (char*)it->data;
- result += std::string("") +
- " bg_category : " + (bg_category ? bg_category : "nullptr") +
- "\n";
- }
- handle->background_category = g_list_reverse(handle->background_category);
-
- result += "[appcontrol]\n";
- handle->appcontrol = g_list_reverse(handle->appcontrol);
- for (GList* it = handle->appcontrol; it; it = it->next) {
- appcontrol_x* appcontrol = (appcontrol_x*)it->data;
- result += std::string("") +
- " operation : " + (appcontrol->operation ? appcontrol->operation : "nullptr") +
- " uri : " + (appcontrol->uri ? appcontrol->uri : "nullptr") +
- " mime : " + (appcontrol->mime ? appcontrol->mime : "nullptr") +
- " visibility : " + (appcontrol->visibility ? appcontrol->visibility : "nullptr") +
- " id : " + (appcontrol->id ? appcontrol->id : "nullptr") +
- "\n";
- }
- handle->appcontrol = g_list_reverse(handle->appcontrol);
-
- result += "[splashscreens]\n";
- handle->splashscreens = g_list_reverse(handle->splashscreens);
- for (GList* it = handle->splashscreens; it; it = it->next) {
- splashscreen_x* ss = (splashscreen_x*)it->data;
- result += std::string("") +
- " src : " + (ss->src ? ss->src : "nullptr") +
- " type : " + (ss->type ? ss->type : "nullptr") +
- " dpi : " + (ss->dpi ? ss->dpi : "nullptr") +
- " orientation : " + (ss->orientation ? ss->orientation : "nullptr") +
- " indicatordisplay : " + (ss->indicatordisplay ? ss->indicatordisplay : "nullptr") +
- " operation : " + (ss->operation ? ss->operation : "nullptr") +
- " color_depth : " + (ss->color_depth ? ss->color_depth : "nullptr") +
- "\n";
- }
- handle->splashscreens = g_list_reverse(handle->splashscreens);
-
- result += "[res_control]\n";
- handle->res_control = g_list_reverse(handle->res_control);
- for (GList* it = handle->res_control; it; it = it->next) {
- res_control_x* res_control = (res_control_x*)it->data;
- result += std::string("") +
- " res_type : " + (res_control->res_type ? res_control->res_type : "nullptr") +
- " min_res_version : " + (res_control->min_res_version ? res_control->min_res_version : "nullptr") +
- " max_res_version : " + (res_control->max_res_version ? res_control->max_res_version : "nullptr") +
- " auto_close : " + (res_control->auto_close ? res_control->auto_close : "nullptr") +
- "\n";
- }
- handle->res_control = g_list_reverse(handle->res_control);
-
- return result;
-}
-
-AppInfoHandle::AppInfoHandle(std::unique_ptr<tizen_base::Parcel> parcel)
- : Serialized<AppInfoIndex>(parcel.get(), parcel->GetDataSize() - sizeof(index_)),
- base_parcel_(std::move(parcel)) {}
-
-AppInfoHandle& AppInfoHandle::operator=(AppInfoHandle&& h) noexcept {
- if (this != &h) {
- Serialized<AppInfoIndex>::operator=(std::move(h));
- base_parcel_ = std::move(h.base_parcel_);
- }
- return *this;
-}
-
-bool AppInfoHandle::operator<(const AppInfoHandle& h) {
- if (!GetAppId())
- return true;
-
- if (!h.GetAppId())
- return false;
-
- return strcmp(GetAppId(), h.GetAppId()) < 0;
-}
-
-GET_CSTRING(AppInfoHandle, GetAppId, appid)
-GET_CSTRING(AppInfoHandle, GetExec, exec)
-GET_CSTRING(AppInfoHandle, GetNodisplay, nodisplay)
-GET_CSTRING(AppInfoHandle, GetMultiple, multiple)
-GET_CSTRING(AppInfoHandle, GetTaskManage, taskmanage)
-GET_CSTRING(AppInfoHandle, GetType, type)
-GET_CSTRING(AppInfoHandle, GetCategories, categories)
-GET_CSTRING(AppInfoHandle, GetExtraid, extraid)
-GET_CSTRING(AppInfoHandle, GetHwAcceleration, hwacceleration)
-GET_CSTRING(AppInfoHandle, GetScreenReader, screenreader)
-GET_CSTRING(AppInfoHandle, GetMainApp, mainapp)
-GET_CSTRING(AppInfoHandle, GetPackage, package)
-GET_CSTRING(AppInfoHandle, GetRecentimage, recentimage)
-GET_CSTRING(AppInfoHandle, GetLaunchCondition, launchcondition)
-GET_CSTRING(AppInfoHandle, GetIndicatorDisplay, indicatordisplay)
-GET_CSTRING(AppInfoHandle, GetPortraitImg, portraitimg)
-GET_CSTRING(AppInfoHandle, GetLandscapeImg, landscapeimg)
-GET_CSTRING(AppInfoHandle, GetEffectImageType, effectimage_type)
-GET_CSTRING(AppInfoHandle, GetGuestModeVisibility, guestmode_visibility)
-GET_CSTRING(AppInfoHandle, GetComponent, component)
-GET_CSTRING(AppInfoHandle, GetPermissionType, permission_type)
-GET_CSTRING(AppInfoHandle, GetComponentType, component_type)
-GET_CSTRING(AppInfoHandle, GetPreload, preload)
-GET_CSTRING(AppInfoHandle, GetSubmode, submode)
-GET_CSTRING(AppInfoHandle, GetSubmodeMainId, submode_mainid)
-GET_CSTRING(AppInfoHandle, GetProcessPool, process_pool)
-GET_CSTRING(AppInfoHandle, GetInstalledStorage, installed_storage)
-GET_CSTRING(AppInfoHandle, GetAutoRestart, autorestart)
-GET_CSTRING(AppInfoHandle, GetOnboot, onboot)
-GET_CSTRING(AppInfoHandle, GetSupportDisable, support_disable)
-GET_CSTRING(AppInfoHandle, GetUiGadget, ui_gadget)
-GET_CSTRING(AppInfoHandle, GetLaunchMode, launch_mode)
-GET_CSTRING(AppInfoHandle, GetSupportAmbient, support_ambient)
-GET_CSTRING(AppInfoHandle, GetSetupAppId, setup_appid)
-GET_CSTRING(AppInfoHandle, GetAliasAppid, alias_appid)
-GET_CSTRING(AppInfoHandle, GetEffectiveAppId, effective_appid)
-GET_CSTRING(AppInfoHandle, GetPackageType, package_type)
-GET_CSTRING(AppInfoHandle, GetTepName, tep_name)
-GET_CSTRING(AppInfoHandle, GetZipMountFile, zip_mount_file)
-GET_CSTRING(AppInfoHandle, GetRootPath, root_path)
-GET_CSTRING(AppInfoHandle, GetApiVersion, api_version)
-GET_CSTRING(AppInfoHandle, GetForAllUsers, for_all_users)
-GET_CSTRING(AppInfoHandle, GetIsDisabled, is_disabled)
-GET_CSTRING(AppInfoHandle, GetSplashScreenDisplay, splash_screen_display)
-GET_CSTRING(AppInfoHandle, GetExternalPath, external_path)
-GET_CSTRING(AppInfoHandle, GetPackageSystem, package_system)
-GET_CSTRING(AppInfoHandle, GetRemovable, removable)
-GET_CSTRING(AppInfoHandle, GetPackageInstalledTime, package_installed_time)
-GET_CSTRING(AppInfoHandle, GetSupportMode, support_mode)
-GET_CSTRING(AppInfoHandle, GetLocale, locale)
-GET_CSTRING(AppInfoHandle, GetLightUserSwitchMode, light_user_switch_mode)
-GET_CSTRING(AppInfoHandle, GetIsPackageDisabled, is_package_disabled)
-
-GET_LIST_ITERATOR(Label, GetLabel, AppInfoHandle, label)
-GET_LIST_ITERATOR(Icon, GetIcon, AppInfoHandle, icon)
-GET_LIST_ITERATOR(Image, GetImage, AppInfoHandle, image)
-GET_LIST_ITERATOR(const char*, GetCategory, AppInfoHandle, category)
-GET_LIST_ITERATOR(Metadata, GetMetadata, AppInfoHandle, metadata)
-GET_LIST_ITERATOR(const char*, GetBackgroundCategory, AppInfoHandle, background_category)
-GET_LIST_ITERATOR(Appcontrol, GetAppcontrol, AppInfoHandle, appcontrol)
-GET_LIST_ITERATOR(SplashScreen, GetSplashscreens, AppInfoHandle, splashscreens)
-GET_LIST_ITERATOR(ResControl, GetResControl, AppInfoHandle, res_control)
-
-const char* AppInfoHandle::GetKey() const {
- return GetAppId();
-}
-
-uint8_t* AppInfoHandle::GetData() const {
- return base_parcel_->GetData();
-}
-
-uint32_t AppInfoHandle::GetDataSize() const {
- return base_parcel_->GetDataSize();
-}
-
-AppInfoHandle AppInfoHandle::Clone() const {
- return AppInfoHandle(std::make_unique<tizen_base::Parcel>(base_parcel_->GetData(), base_parcel_->GetDataSize(), true));
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-#ifndef COMMON_PKGMGR_INFO_HANDLE_HH_
-#define COMMON_PKGMGR_INFO_HANDLE_HH_
-
-#include <memory>
-#include <optional>
-#include <vector>
-
-#include "pkgmgrinfo_basic.h"
-
-#include <database.hpp>
-#include <parcel.hh>
-#include "pkg_write_type.hh"
-#include "pkgmgrinfo_debug.h"
-
-namespace pkgmgr_common {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-class EXPORT_API SerializedBase {
- public:
- SerializedBase(const tizen_base::Parcel* parcel);
- SerializedBase(const SerializedBase& h) = delete;
- SerializedBase(SerializedBase&& h) noexcept = default;
- SerializedBase& operator=(SerializedBase&& h) noexcept;
-
- const char* GetCString(int index) const;
- bool GetInt(int index, int* result) const;
- bool GetBuf(int index, void* buf, uint32_t size) const;
-
- protected:
- const tizen_base::Parcel* parcel_;
-};
-
-template<typename T>
-class EXPORT_API Serialized : public SerializedBase {
- public:
- Serialized(const tizen_base::Parcel* parcel, int data_index) : SerializedBase(parcel) {
- if (data_index < 0) {
- memset(&index_, -1, sizeof(index_));
- return;
- }
-
- if (!GetBuf(data_index, &index_, sizeof(index_)))
- memset(&index_, -1, sizeof(index_));
- }
-
- Serialized(const Serialized& h) = delete;
- Serialized(Serialized&& h) noexcept = default;
-
- Serialized& operator=(Serialized&& h) noexcept {
- if (this != &h) {
- SerializedBase::operator=(std::move(h));
- index_ = h.index_;
- memset(&h.index_, -1, sizeof(h.index_));
- }
- return *this;
- }
-
- protected:
- T index_;
-};
-
-template<typename T>
-class EXPORT_API Iterable : public SerializedBase {
- public:
- class EXPORT_API Iterator : public SerializedBase {
- public:
- explicit Iterator(const tizen_base::Parcel* parcel, std::vector<int>::const_iterator it) : SerializedBase(parcel), it_(std::move(it)) {}
-
- T operator*() {
- if constexpr (std::is_same_v<T, const char*>) {
- if (*it_ < 0)
- return nullptr;
-
- return GetCString(*it_);
- } else {
- return T(parcel_, *it_);
- }
- }
-
- bool operator!=(const Iterator& rhs) const {
- return it_ != rhs.it_;
- }
-
- bool operator==(const Iterator& rhs) const {
- return it_ == rhs.it_;
- }
-
- void operator++() {
- it_++;
- }
-
- private:
- std::vector<int>::const_iterator it_;
- };
-
- explicit Iterable(const tizen_base::Parcel* parcel, int index);
-
- Iterator begin() const {
- return Iterator(SerializedBase::parcel_, indexs_.begin());
- }
-
- Iterator end() const {
- return Iterator(SerializedBase::parcel_, indexs_.end());
- }
-
- private:
- std::vector<int> indexs_;
-};
-
-class EXPORT_API LabelIndex {
- public:
- int32_t name;
- int32_t text;
- int32_t lang;
-};
-
-class EXPORT_API Label : public Serialized<LabelIndex> {
- public:
- using Serialized<LabelIndex>::Serialized;
-
- const char* Name() const;
- const char* Text() const;
- const char* Lang() const;
-};
-
-class EXPORT_API IconIndex {
- public:
- int32_t text;
- int32_t lang;
- int32_t section;
- int32_t size;
- int32_t resolution;
- int32_t dpi;
-};
-
-class EXPORT_API Icon : public Serialized<IconIndex> {
- public:
- using Serialized<IconIndex>::Serialized;
-
- const char* Text() const;
- const char* Lang() const;
- const char* Section() const;
- const char* Size() const;
- const char* Resolution() const;
- const char* Dpi() const;
-};
-
-class EXPORT_API ImageIndex {
- public:
- int32_t text;
- int32_t lang;
- int32_t section;
-};
-
-class EXPORT_API Image : public Serialized<ImageIndex> {
- public:
- using Serialized<ImageIndex>::Serialized;
-
- const char* Text() const;
- const char* Lang() const;
- const char* Section() const;
-};
-
-class EXPORT_API MetadataIndex {
- public:
- int32_t key;
- int32_t value;
-};
-
-class EXPORT_API Metadata : public Serialized<MetadataIndex> {
- public:
- using Serialized<MetadataIndex>::Serialized;
-
- const char* Key() const;
- const char* Value() const;
-};
-
-class EXPORT_API DataControlIndex {
- public:
- int32_t providerid;
- int32_t access;
- int32_t type;
- int32_t trusted;
- int32_t privileges;
-};
-
-class EXPORT_API DataControl : public Serialized<DataControlIndex> {
- public:
- using Serialized<DataControlIndex>::Serialized;
-
- const char* ProviderId() const;
- const char* Access() const;
- const char* Type() const;
- const char* Trusted() const;
- Iterable<const char*> Privileges() const;
-};
-
-class EXPORT_API AppcontrolIndex {
- public:
- int32_t operation;
- int32_t uri;
- int32_t mime;
- int32_t visibility;
- int32_t id;
- int32_t privileges;
-};
-
-class EXPORT_API Appcontrol : public Serialized<AppcontrolIndex> {
- public:
- using Serialized<AppcontrolIndex>::Serialized;
-
- const char* Operation() const;
- const char* Uri() const;
- const char* Mime() const;
- const char* Visibility() const;
- const char* Id() const;
- Iterable<const char*> Privileges() const;
-};
-
-class EXPORT_API ResControlIndex {
- public:
- int32_t res_type;
- int32_t min_res_version;
- int32_t max_res_version;
- int32_t auto_close;
-};
-
-class EXPORT_API ResControl : public Serialized<ResControlIndex> {
- public:
- using Serialized<ResControlIndex>::Serialized;
-
- const char* ResType() const;
- const char* MinResVersion() const;
- const char* MaxResVersion() const;
- const char* AutoClose() const;
-};
-
-class EXPORT_API SplashScreenIndex {
- public:
- int32_t src;
- int32_t type;
- int32_t dpi;
- int32_t orientation;
- int32_t indicatordisplay;
- int32_t operation;
- int32_t color_depth;
-};
-
-class EXPORT_API SplashScreen : public Serialized<SplashScreenIndex> {
- public:
- using Serialized<SplashScreenIndex>::Serialized;
-
- const char* Src() const;
- const char* Type() const;
- const char* Dpi() const;
- const char* Orientation() const;
- const char* Indicatordisplay() const;
- const char* Operation() const;
- const char* ColorDepth() const;
-};
-
-class EXPORT_API AuthorIndex {
- public:
- int32_t email;
- int32_t href;
- int32_t text;
- int32_t lang;
-};
-
-class EXPORT_API Author : public Serialized<AuthorIndex> {
- public:
- using Serialized<AuthorIndex>::Serialized;
-
- const char* Email() const;
- const char* Href() const;
- const char* Text() const;
- const char* Lang() const;
-};
-
-class EXPORT_API LicenseIndex {
- public:
- int32_t text;
- int32_t lang;
-};
-
-class EXPORT_API License : public Serialized<LicenseIndex> {
- public:
- using Serialized<LicenseIndex>::Serialized;
-
- const char* Text() const;
- const char* Lang() const;
-};
-
-class EXPORT_API DescriptionIndex {
- public:
- int32_t name;
- int32_t text;
- int32_t lang;
-};
-
-class EXPORT_API Description : public Serialized<DescriptionIndex> {
- public:
- using Serialized<DescriptionIndex>::Serialized;
-
- const char* Name() const;
- const char* Text() const;
- const char* Lang() const;
-};
-
-class EXPORT_API PrivilegeIndex {
- public:
- int32_t type;
- int32_t value;
-};
-
-class EXPORT_API Privilege : public Serialized<PrivilegeIndex> {
- public:
- using Serialized<PrivilegeIndex>::Serialized;
-
- const char* Type() const;
- const char* Value() const;
-};
-
-class EXPORT_API AppdefinedPrivilegeIndex {
- public:
- int32_t type;
- int32_t value;
- int32_t license;
-};
-
-class EXPORT_API AppdefinedPrivilege : public Serialized<AppdefinedPrivilegeIndex> {
- public:
- using Serialized<AppdefinedPrivilegeIndex>::Serialized;
-
- const char* Type() const;
- const char* Value() const;
- const char* License() const;
-};
-
-class EXPORT_API DependencyIndex {
- public:
- int32_t pkgid;
- int32_t depends_on;
- int32_t type;
- int32_t required_version;
-};
-
-class EXPORT_API Dependency : public Serialized<DependencyIndex> {
- public:
- using Serialized<DependencyIndex>::Serialized;
-
- const char* Pkgid() const;
- const char* DependsOn() const;
- const char* Type() const;
- const char* RequiredVersion() const;
-};
-
-class EXPORT_API PluginIndex {
- public:
- int32_t pkgid;
- int32_t appid;
- int32_t plugin_type;
- int32_t plugin_name;
-};
-
-class EXPORT_API Plugin : public Serialized<PluginIndex> {
- public:
- using Serialized<PluginIndex>::Serialized;
-
- const char* Pkgid() const;
- const char* Appid() const;
- const char* PluginType() const;
- const char* PluginName() const;
-};
-
-class EXPORT_API ResAllowedPackageIndex {
- public:
- int32_t allowed_package;
- int32_t required_privileges;
-};
-
-class EXPORT_API ResAllowedPackage : public Serialized<ResAllowedPackageIndex> {
- public:
- using Serialized<ResAllowedPackageIndex>::Serialized;
-
- const char* AllowedPackage() const;
- Iterable<const char*> GetRequiredPrivileges() const;
-};
-
-class EXPORT_API MedatataIndex {
- public:
- int32_t key;
- int32_t value;
-};
-
-class EXPORT_API Medatata : public Serialized<MedatataIndex> {
- public:
- using Serialized<MedatataIndex>::Serialized;
-
- const char* Key() const;
- const char* Value() const;
-};
-
-class EXPORT_API PkgInfoIndex {
- public:
- int32_t for_all_users;
- int32_t package;
- int32_t version;
- int32_t installlocation;
- int32_t ns;
- int32_t removable;
- int32_t preload;
- int32_t readonly;
- int32_t update;
- int32_t appsetting;
- int32_t system;
- int32_t type;
- int32_t package_size;
- int32_t installed_time;
- int32_t installed_storage;
- int32_t storeclient_id;
- int32_t mainapp_id;
- int32_t package_url;
- int32_t root_path;
- int32_t csc_path;
- int32_t nodisplay_setting;
- int32_t support_mode;
- int32_t support_disable;
- int32_t api_version;
- int32_t tep_name;
- int32_t zip_mount_file;
- int32_t backend_installer;
- int32_t external_path;
- int32_t use_system_certs;
- int32_t locale;
- int32_t res_type;
- int32_t res_version;
- int32_t lib;
- int32_t is_disabled;
- int32_t light_user_switch_mode;
- int32_t icon;
- int32_t label;
- int32_t author;
- int32_t description;
- int32_t license;
- int32_t privileges;
- int32_t appdefined_privileges;
- int32_t provides_appdefined_privileges;
- int32_t application;
- int32_t compatibility;
- int32_t deviceprofile;
- int32_t dependencies;
- int32_t plugin;
- int32_t res_allowed_packages;
- int32_t metadata;
-};
-
-class EXPORT_API PkgInfoHandle : public Serialized<PkgInfoIndex> {
- public:
- PkgInfoHandle(std::unique_ptr<tizen_base::Parcel> parcel);
- PkgInfoHandle(const PkgInfoHandle& h) = delete;
- PkgInfoHandle(PkgInfoHandle&& h) noexcept = default;
- PkgInfoHandle& operator=(PkgInfoHandle&& h) noexcept;
- bool operator<(const PkgInfoHandle& h);
-
- const char* GetKey() const;
- const char* GetForAllUsers() const;
- const char* GetPackage() const;
- const char* GetVersion() const;
- const char* GetInstallLocation() const;
- const char* GetNameSpace() const;
- const char* GetRemovable() const;
- const char* GetPreload() const;
- const char* GetReadonly() const;
- const char* GetUpdate() const;
- const char* GetAppSetting() const;
- const char* GetSystem() const;
- const char* GetType() const;
- const char* GetPackageSize() const;
- const char* GetInstalledTime() const;
- const char* GetInstalledStorage() const;
- const char* GetStoreClientId() const;
- const char* GetMainAppId() const;
- const char* GetPackageUrl() const;
- const char* GetRootPath() const;
- const char* GetCscPath() const;
- const char* GetNoDisplaySetting() const;
- const char* GetSupportMode() const;
- const char* GetSupportDisable() const;
- const char* GetApiVersion() const;
- const char* GetTepName() const;
- const char* GetZipMountFile() const;
- const char* GetBackendInstaller() const;
- const char* GetExternalPath() const;
- const char* GetUseSystemCerts() const;
- const char* GetLocale() const;
- const char* GetResType() const;
- const char* GetResVersion() const;
- const char* GetLib() const;
- const char* GetIsDisabled() const;
- const char* GetLightUserSwitchMode() const;
- Iterable<Icon> GetIcon() const;
- Iterable<Label> GetLabel() const;
- Iterable<Author> GetAuthor() const;
- Iterable<Description> GetDescription() const;
- Iterable<Privilege> GetPrivileges() const;
- Iterable<AppdefinedPrivilege> GetAppdefinedPrivileges() const;
- Iterable<AppdefinedPrivilege> GetProvidesAppDefinedPrivileges() const;
- Iterable<Dependency> GetDependencies() const;
- Iterable<Plugin> GetPlugin() const;
- Iterable<ResAllowedPackage> GetResAllowedPackages() const;
- Iterable<Metadata> GetMetadata() const;
- uint8_t* GetData() const;
- uint32_t GetDataSize() const;
- PkgInfoHandle Clone() const;
-
- std::string ToString() const;
- static std::string ToString(package_x* info);
-
- private:
- std::unique_ptr<tizen_base::Parcel> base_parcel_;
-};
-
-class EXPORT_API AppInfoIndex {
- public:
- int32_t appid;
- int32_t exec;
- int32_t nodisplay;
- int32_t multiple;
- int32_t taskmanage;
- int32_t type;
- int32_t categories;
- int32_t extraid;
- int32_t hwacceleration;
- int32_t screenreader;
- int32_t mainapp;
- int32_t package;
- int32_t recentimage;
- int32_t launchcondition;
- int32_t indicatordisplay;
- int32_t portraitimg;
- int32_t landscapeimg;
- int32_t effectimage_type;
- int32_t guestmode_visibility;
- int32_t component;
- int32_t permission_type;
- int32_t component_type;
- int32_t preload;
- int32_t submode;
- int32_t submode_mainid;
- int32_t process_pool;
- int32_t installed_storage;
- int32_t autorestart;
- int32_t onboot;
- int32_t support_disable;
- int32_t ui_gadget;
- int32_t launch_mode;
- int32_t support_ambient;
- int32_t setup_appid;
- int32_t alias_appid;
- int32_t effective_appid;
- int32_t package_type;
- int32_t tep_name;
- int32_t zip_mount_file;
- int32_t root_path;
- int32_t api_version;
- int32_t for_all_users;
- int32_t is_disabled;
- int32_t splash_screen_display;
- int32_t external_path;
- int32_t package_system;
- int32_t removable;
- int32_t package_installed_time;
- int32_t support_mode;
- int32_t locale;
- int32_t light_user_switch_mode;
- int32_t is_package_disabled;
- int32_t label;
- int32_t icon;
- int32_t image;
- int32_t category;
- int32_t metadata;
- int32_t permission;
- int32_t launchconditions;
- int32_t notification;
- int32_t datashare;
- int32_t datacontrol;
- int32_t background_category;
- int32_t appcontrol;
- int32_t splashscreens;
- int32_t res_control;
- int32_t privileges;
-};
-
-class EXPORT_API AppInfoHandle : public Serialized<AppInfoIndex> {
- public:
- AppInfoHandle(std::unique_ptr<tizen_base::Parcel> parcel);
- AppInfoHandle(const AppInfoHandle& h) = delete;
- AppInfoHandle(AppInfoHandle&& h) noexcept = default;
- AppInfoHandle& operator=(AppInfoHandle&& h) noexcept;
- bool operator<(const AppInfoHandle& h);
-
- const char* GetKey() const;
- const char* GetAppId() const;
- const char* GetExec() const;
- const char* GetNodisplay() const;
- const char* GetMultiple() const;
- const char* GetTaskManage() const;
- const char* GetType() const;
- const char* GetCategories() const;
- const char* GetExtraid() const;
- const char* GetHwAcceleration() const;
- const char* GetScreenReader() const;
- const char* GetMainApp() const;
- const char* GetPackage() const;
- const char* GetRecentimage() const;
- const char* GetLaunchCondition() const;
- const char* GetIndicatorDisplay() const;
- const char* GetPortraitImg() const;
- const char* GetLandscapeImg() const;
- const char* GetEffectImageType() const;
- const char* GetGuestModeVisibility() const;
- const char* GetComponent() const;
- const char* GetPermissionType() const;
- const char* GetComponentType() const;
- const char* GetPreload() const;
- const char* GetSubmode() const;
- const char* GetSubmodeMainId() const;
- const char* GetProcessPool() const;
- const char* GetInstalledStorage() const;
- const char* GetAutoRestart() const;
- const char* GetOnboot() const;
- const char* GetSupportDisable() const;
- const char* GetUiGadget() const;
- const char* GetLaunchMode() const;
- const char* GetSupportAmbient() const;
- const char* GetSetupAppId() const;
- const char* GetAliasAppid() const;
- const char* GetEffectiveAppId() const;
- const char* GetPackageType() const;
- const char* GetTepName() const;
- const char* GetZipMountFile() const;
- const char* GetRootPath() const;
- const char* GetApiVersion() const;
- const char* GetForAllUsers() const;
- const char* GetIsDisabled() const;
- const char* GetSplashScreenDisplay() const;
- const char* GetExternalPath() const;
- const char* GetPackageSystem() const;
- const char* GetRemovable() const;
- const char* GetPackageInstalledTime() const;
- const char* GetSupportMode() const;
- const char* GetLocale() const;
- const char* GetLightUserSwitchMode() const;
- const char* GetIsPackageDisabled() const;
- Iterable<Label> GetLabel() const;
- Iterable<Icon> GetIcon() const;
- Iterable<Image> GetImage() const;
- Iterable<const char*> GetCategory() const;
- Iterable<Metadata> GetMetadata() const;
- Iterable<const char*> GetBackgroundCategory() const;
- Iterable<Appcontrol> GetAppcontrol() const;
- Iterable<SplashScreen> GetSplashscreens() const;
- Iterable<ResControl> GetResControl() const;
-
- uint8_t* GetData() const;
- uint32_t GetDataSize() const;
- AppInfoHandle Clone() const;
-
- std::string ToString() const;
- static std::string ToString(application_x* info);
-
- private:
- std::unique_ptr<tizen_base::Parcel> base_parcel_;
-};
-
-} // namespace pkgmgr_common
-
-#endif // COMMON_PKGMGR_INFO_HANDLE_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "pkgmgr_info_handle_writer.hh"
-
-#include <vector>
-#include <queue>
-
-#include "pkgmgr_info_handle.hh"
-#include "appinfo_parcelable.hh"
-#include "shared_memory/shm_config.hh"
-
-#include "pkgmgrinfo_private.h"
-
-#include "utils/logging.hh"
-
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_INFO"
-
-namespace {
-
-int GetIndex(const tizen_base::Parcel& parcel) {
- return (int)parcel.GetDataSize();
-}
-
-int WriteCString(tizen_base::Parcel& parcel, const char* str) {
- if (!str)
- return -1;
-
- int index = GetIndex(parcel);
- parcel.Write(str, strlen(str) + 1);
- return index;
-}
-
-int Write(tizen_base::Parcel& parcel, void* ptr, size_t len) {
- if (!ptr)
- return -1;
-
- int index = GetIndex(parcel);
- parcel.Write(ptr, len);
- return index;
-}
-
-}
-
-namespace pkgmgr_common {
-
-namespace ps = pkgmgr_common::shared_memory;
-
-IconWriter::IconWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-IconWriter& IconWriter::WriteText(const char* text) {
- index_.text = WriteCString(parcel_, text);
- return *this;
-}
-
-IconWriter& IconWriter::WriteLang(const char* lang) {
- index_.lang = WriteCString(parcel_, lang);
- return *this;
-}
-
-IconWriter& IconWriter::WriteSection(const char* section) {
- index_.section = WriteCString(parcel_, section);
- return *this;
-}
-
-IconWriter& IconWriter::WriteSize(const char* size) {
- index_.size = WriteCString(parcel_, size);
- return *this;
-}
-
-IconWriter& IconWriter::WriteResolution(const char* resolution) {
- index_.resolution = WriteCString(parcel_, resolution);
- return *this;
-}
-
-IconWriter& IconWriter::WriteDpi(const char* dpi) {
- index_.dpi = WriteCString(parcel_, dpi);
- return *this;
-}
-
-int IconWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-LabelWriter::LabelWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-LabelWriter& LabelWriter::WriteName(const char* name) {
- index_.name = WriteCString(parcel_, name);
- return *this;
-}
-
-LabelWriter& LabelWriter::WriteText(const char* text) {
- index_.text = WriteCString(parcel_, text);
- return *this;
-}
-
-LabelWriter& LabelWriter::WriteLang(const char* lang) {
- index_.lang = WriteCString(parcel_, lang);
- return *this;
-}
-
-int LabelWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-AuthorWriter::AuthorWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-AuthorWriter& AuthorWriter::WriteEmail(const char* email) {
- index_.email = WriteCString(parcel_, email);
- return *this;
-}
-
-AuthorWriter& AuthorWriter::WriteHref(const char* href) {
- index_.href = WriteCString(parcel_, href);
- return *this;
-}
-
-AuthorWriter& AuthorWriter::WriteText(const char* text) {
- index_.text = WriteCString(parcel_, text);
- return *this;
-}
-
-AuthorWriter& AuthorWriter::WriteLang(const char* lang) {
- index_.lang = WriteCString(parcel_, lang);
- return *this;
-}
-int AuthorWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-LicenseWriter::LicenseWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-LicenseWriter& LicenseWriter::WriteText(const char* text) {
- index_.text = WriteCString(parcel_, text);
- return *this;
-}
-
-LicenseWriter& LicenseWriter::WriteLang(const char* lang) {
- index_.lang = WriteCString(parcel_, lang);
- return *this;
-}
-
-int LicenseWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-DescriptionWriter::DescriptionWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-DescriptionWriter& DescriptionWriter::WriteName(const char* name) {
- index_.name = WriteCString(parcel_, name);
- return *this;
-}
-
-DescriptionWriter& DescriptionWriter::WriteText(const char* text) {
- index_.text = WriteCString(parcel_, text);
- return *this;
-}
-
-DescriptionWriter& DescriptionWriter::WriteLang(const char* lang) {
- index_.lang = WriteCString(parcel_, lang);
- return *this;
-}
-
-int DescriptionWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-PrivilegeWriter::PrivilegeWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-PrivilegeWriter& PrivilegeWriter::WriteType(const char* type) {
- index_.type = WriteCString(parcel_, type);
- return *this;
-}
-
-PrivilegeWriter& PrivilegeWriter::WriteValue(const char* value) {
- index_.value = WriteCString(parcel_, value);
- return *this;
-}
-
-int PrivilegeWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-AppdefinedPrivilegeWriter::AppdefinedPrivilegeWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-AppdefinedPrivilegeWriter& AppdefinedPrivilegeWriter::WriteType(const char* type) {
- index_.type = WriteCString(parcel_, type);
- return *this;
-}
-
-AppdefinedPrivilegeWriter& AppdefinedPrivilegeWriter::WriteValue(const char* value) {
- index_.value = WriteCString(parcel_, value);
- return *this;
-}
-
-AppdefinedPrivilegeWriter& AppdefinedPrivilegeWriter::WriteLicense(const char* license) {
- index_.license = WriteCString(parcel_, license);
- return *this;
-}
-
-int AppdefinedPrivilegeWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-DependencyWriter::DependencyWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-DependencyWriter& DependencyWriter::WritePkgid(const char* pkgid) {
- index_.pkgid = WriteCString(parcel_, pkgid);
- return *this;
-}
-
-DependencyWriter& DependencyWriter::WriteDependsOn(const char* depends_on) {
- index_.depends_on = WriteCString(parcel_, depends_on);
- return *this;
-}
-
-DependencyWriter& DependencyWriter::WriteType(const char* type) {
- index_.type = WriteCString(parcel_, type);
- return *this;
-}
-
-DependencyWriter& DependencyWriter::WriteRequiredVersion(const char* required_version) {
- index_.required_version = WriteCString(parcel_, required_version);
- return *this;
-}
-
-int DependencyWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-PluginWriter::PluginWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-PluginWriter& PluginWriter::WritePkgid(const char* pkgid) {
- index_.pkgid = WriteCString(parcel_, pkgid);
- return *this;
-}
-
-PluginWriter& PluginWriter::WriteAppid(const char* appid) {
- index_.appid = WriteCString(parcel_, appid);
- return *this;
-}
-
-PluginWriter& PluginWriter::WritePluginType(const char* plugin_type) {
- index_.plugin_type = WriteCString(parcel_, plugin_type);
- return *this;
-}
-
-PluginWriter& PluginWriter::WritePluginName(const char* plugin_name) {
- index_.plugin_name = WriteCString(parcel_, plugin_name);
- return *this;
-}
-
-int PluginWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-ResAllowedPackageWriter::ResAllowedPackageWriter(tizen_base::Parcel& parcel) :
- parcel_(parcel), required_privilege_list_writer_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-ResAllowedPackageWriter& ResAllowedPackageWriter::WriteAllowedPackage(const char* allowed_package) {
- index_.allowed_package = WriteCString(parcel_, allowed_package);
- return *this;
-}
-
-ListWriter<char*>& ResAllowedPackageWriter::GetRequiredPrivilegeWriter() {
- return required_privilege_list_writer_;
-}
-
-int ResAllowedPackageWriter::Commit() {
- index_.required_privileges = required_privilege_list_writer_.Commit();
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-MetadataWriter::MetadataWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-MetadataWriter& MetadataWriter::WriteKey(const char* key) {
- index_.key = WriteCString(parcel_, key);
- return *this;
-}
-
-MetadataWriter& MetadataWriter::WriteValue(const char* value) {
- index_.value = WriteCString(parcel_, value);
- return *this;
-}
-
-int MetadataWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-ImageWriter::ImageWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-ImageWriter& ImageWriter::WriteText(const char* text) {
- index_.text = WriteCString(parcel_, text);
- return *this;
-}
-
-ImageWriter& ImageWriter::WriteLang(const char* lang) {
- index_.lang = WriteCString(parcel_, lang);
- return *this;
-}
-
-ImageWriter& ImageWriter::WriteSection(const char* section) {
- index_.section = WriteCString(parcel_, section);
- return *this;
-}
-
-int ImageWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-DataControlWriter::DataControlWriter(tizen_base::Parcel& parcel) : parcel_(parcel), privilege_list_writer_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-DataControlWriter& DataControlWriter::WriteProviderId(const char* providerid) {
- index_.providerid = WriteCString(parcel_, providerid);
- return *this;
-}
-
-DataControlWriter& DataControlWriter::WriteAccess(const char* access) {
- index_.access = WriteCString(parcel_, access);
- return *this;
-}
-
-DataControlWriter& DataControlWriter::WriteType(const char* type) {
- index_.type = WriteCString(parcel_, type);
- return *this;
-}
-
-DataControlWriter& DataControlWriter::WriteTrusted(const char* trusted) {
- index_.trusted = WriteCString(parcel_, trusted);
- return *this;
-}
-
-ListWriter<char*>& DataControlWriter::GetPrivilegeListWriter() {
- return privilege_list_writer_;
-}
-
-int DataControlWriter::Commit() {
- index_.privileges = privilege_list_writer_.Commit();
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-AppcontrolWriter::AppcontrolWriter(tizen_base::Parcel& parcel) : parcel_(parcel), privilege_list_writer_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-AppcontrolWriter& AppcontrolWriter::WriteOperation(const char* operation) {
- index_.operation = WriteCString(parcel_, operation);
- return *this;
-}
-
-AppcontrolWriter& AppcontrolWriter::WriteUri(const char* uri) {
- index_.uri = WriteCString(parcel_, uri);
- return *this;
-}
-
-AppcontrolWriter& AppcontrolWriter::WriteMime(const char* mime) {
- index_.mime = WriteCString(parcel_, mime);
- return *this;
-}
-
-AppcontrolWriter& AppcontrolWriter::WriteVisibility(const char* visibility) {
- index_.visibility = WriteCString(parcel_, visibility);
- return *this;
-}
-
-AppcontrolWriter& AppcontrolWriter::WriteId(const char* id) {
- index_.id = WriteCString(parcel_, id);
- return *this;
-}
-
-ListWriter<char*>& AppcontrolWriter::GetPrivilegeListWriter() {
- return privilege_list_writer_;
-}
-
-int AppcontrolWriter::Commit() {
- index_.privileges = privilege_list_writer_.Commit();
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-SplashScreenWriter::SplashScreenWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-SplashScreenWriter& SplashScreenWriter::WriteSrc(const char* src) {
- index_.src = WriteCString(parcel_, src);
- return *this;
-}
-
-SplashScreenWriter& SplashScreenWriter::WriteType(const char* type) {
- index_.type = WriteCString(parcel_, type);
- return *this;
-}
-
-SplashScreenWriter& SplashScreenWriter::WriteDpi(const char* dpi) {
- index_.dpi = WriteCString(parcel_, dpi);
- return *this;
-}
-
-SplashScreenWriter& SplashScreenWriter::WriteOrientation(const char* orientation) {
- index_.orientation = WriteCString(parcel_, orientation);
- return *this;
-}
-
-SplashScreenWriter& SplashScreenWriter::WriteIndicatordisplay(const char* indicatordisplay) {
- index_.indicatordisplay = WriteCString(parcel_, indicatordisplay);
- return *this;
-}
-
-SplashScreenWriter& SplashScreenWriter::WriteOperation(const char* operation) {
- index_.operation = WriteCString(parcel_, operation);
- return *this;
-}
-
-SplashScreenWriter& SplashScreenWriter::WriteColorDepth(const char* color_depth) {
- index_.color_depth = WriteCString(parcel_, color_depth);
- return *this;
-}
-
-int SplashScreenWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-ResControlWriter::ResControlWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {
- memset(&index_, -1, sizeof(index_));
-}
-
-ResControlWriter& ResControlWriter::WriteResType(const char* res_type) {
- index_.res_type = WriteCString(parcel_, res_type);
- return *this;
-}
-
-ResControlWriter& ResControlWriter::WriteMinResVersion(const char* min_res_version) {
- index_.min_res_version = WriteCString(parcel_, min_res_version);
- return *this;
-}
-
-ResControlWriter& ResControlWriter::WriteMaxResVersion(const char* max_res_version) {
- index_.max_res_version = WriteCString(parcel_, max_res_version);
- return *this;
-}
-
-ResControlWriter& ResControlWriter::WriteAutoClose(const char* auto_close) {
- index_.auto_close = WriteCString(parcel_, auto_close);
- return *this;
-}
-
-int ResControlWriter::Commit() {
- return Write(parcel_, &index_, sizeof(index_));
-}
-
-PkgInfoHandleWriter::PkgInfoHandleWriter() :
- icon_list_writer_(parcel_),
- label_list_writer_(parcel_),
- author_list_writer_(parcel_),
- description_list_writer_(parcel_),
- privileges_list_writer_(parcel_),
- appdefined_privileges_list_writer_(parcel_),
- provides_appdefined_privileges_list_writer_(parcel_),
- dependencies_list_writer_(parcel_),
- plugin_list_writer_(parcel_),
- res_allowed_packages_list_writer_(parcel_),
- metadata_list_writer_(parcel_),
- deviceprofile_list_writer_(parcel_) {
- memset(&index_, -1, sizeof(index_));
-}
-
-void PkgInfoHandleWriter::WriteForAllUsers(const char* for_all_users) {
- index_.for_all_users = WriteCString(parcel_, for_all_users);
-}
-
-void PkgInfoHandleWriter::WritePackage(const char* package) {
- index_.package = WriteCString(parcel_, package);
-}
-
-void PkgInfoHandleWriter::WriteVersion(const char* version) {
- index_.version = WriteCString(parcel_, version);
-}
-
-void PkgInfoHandleWriter::WriteInstallLocation(const char* installlocation) {
- index_.installlocation = WriteCString(parcel_, installlocation);
-}
-
-void PkgInfoHandleWriter::WriteNameSpace(const char* ns) {
- index_.ns = WriteCString(parcel_, ns);
-}
-
-void PkgInfoHandleWriter::WriteRemovable(const char* removable) {
- index_.removable = WriteCString(parcel_, removable);
-}
-
-void PkgInfoHandleWriter::WritePreload(const char* preload) {
- index_.preload = WriteCString(parcel_, preload);
-}
-
-void PkgInfoHandleWriter::WriteReadonly(const char* readonly) {
- index_.readonly = WriteCString(parcel_, readonly);
-}
-
-void PkgInfoHandleWriter::WriteUpdate(const char* update) {
- index_.update = WriteCString(parcel_, update);
-}
-
-void PkgInfoHandleWriter::WriteAppSetting(const char* appsetting) {
- index_.appsetting = WriteCString(parcel_, appsetting);
-}
-
-void PkgInfoHandleWriter::WriteSystem(const char* system) {
- index_.system = WriteCString(parcel_, system);
-}
-
-void PkgInfoHandleWriter::WriteType(const char* type) {
- index_.type = WriteCString(parcel_, type);
-}
-
-void PkgInfoHandleWriter::WritePackageSize(const char* package_size) {
- index_.package_size = WriteCString(parcel_, package_size);
-}
-
-void PkgInfoHandleWriter::WriteInstalledTime(const char* installed_time) {
- index_.installed_time = WriteCString(parcel_, installed_time);
-}
-
-void PkgInfoHandleWriter::WriteInstalledStorage(const char* installed_storage) {
- index_.installed_storage = WriteCString(parcel_, installed_storage);
-}
-
-void PkgInfoHandleWriter::WriteStoreClientId(const char* storeclient_id) {
- index_.storeclient_id = WriteCString(parcel_, storeclient_id);
-}
-
-void PkgInfoHandleWriter::WriteMainAppId(const char* mainapp_id) {
- index_.mainapp_id = WriteCString(parcel_, mainapp_id);
-}
-
-void PkgInfoHandleWriter::WritePackageUrl(const char* package_url) {
- index_.package_url = WriteCString(parcel_, package_url);
-}
-
-void PkgInfoHandleWriter::WriteRootPath(const char* root_path) {
- index_.root_path = WriteCString(parcel_, root_path);
-}
-
-void PkgInfoHandleWriter::WriteCscPath(const char* csc_path) {
- index_.csc_path = WriteCString(parcel_, csc_path);
-}
-
-void PkgInfoHandleWriter::WriteNoDisplaySetting(const char* nodisplay_setting) {
- index_.nodisplay_setting = WriteCString(parcel_, nodisplay_setting);
-}
-
-void PkgInfoHandleWriter::WriteSupportMode(const char* support_mode) {
- index_.support_mode = WriteCString(parcel_, support_mode);
-}
-
-void PkgInfoHandleWriter::WriteSupportDisable(const char* support_disable) {
- index_.support_disable = WriteCString(parcel_, support_disable);
-}
-
-void PkgInfoHandleWriter::WriteApiVersion(const char* api_version) {
- index_.api_version = WriteCString(parcel_, api_version);
-}
-
-void PkgInfoHandleWriter::WriteTepName(const char* tep_name) {
- index_.tep_name = WriteCString(parcel_, tep_name);
-}
-
-void PkgInfoHandleWriter::WriteZipMountFile(const char* zip_mount_file) {
- index_.zip_mount_file = WriteCString(parcel_, zip_mount_file);
-}
-
-void PkgInfoHandleWriter::WriteBackendInstaller(const char* backend_installer) {
- index_.backend_installer = WriteCString(parcel_, backend_installer);
-}
-
-void PkgInfoHandleWriter::WriteExternalPath(const char* external_path) {
- index_.external_path = WriteCString(parcel_, external_path);
-}
-
-void PkgInfoHandleWriter::WriteUseSystemCerts(const char* use_system_certs) {
- index_.use_system_certs = WriteCString(parcel_, use_system_certs);
-}
-
-void PkgInfoHandleWriter::WriteLocale(const char* locale) {
- index_.locale = WriteCString(parcel_, locale);
-}
-
-void PkgInfoHandleWriter::WriteResType(const char* res_type) {
- index_.res_type = WriteCString(parcel_, res_type);
-}
-
-void PkgInfoHandleWriter::WriteResVersion(const char* res_version) {
- index_.res_version = WriteCString(parcel_, res_version);
-}
-
-void PkgInfoHandleWriter::WriteLib(const char* lib) {
- index_.lib = WriteCString(parcel_, lib);
-}
-
-void PkgInfoHandleWriter::WriteIsDisabled(const char* is_disabled) {
- index_.is_disabled = WriteCString(parcel_, is_disabled);
-}
-
-void PkgInfoHandleWriter::WriteLightUserSwitchMode(const char* light_user_switch_mode) {
- index_.light_user_switch_mode = WriteCString(parcel_, light_user_switch_mode);
-}
-
-ListWriter<IconWriter>& PkgInfoHandleWriter::GetIconListWriter() {
- return icon_list_writer_;
-}
-
-ListWriter<LabelWriter>& PkgInfoHandleWriter::GetLabelListWriter() {
- return label_list_writer_;
-}
-
-ListWriter<AuthorWriter>& PkgInfoHandleWriter::GetAuthorListWriter() {
- return author_list_writer_;
-}
-
-ListWriter<DescriptionWriter>& PkgInfoHandleWriter::GetDescriptionListWriter() {
- return description_list_writer_;
-}
-
-ListWriter<PrivilegeWriter>& PkgInfoHandleWriter::GetPrivilegesListWriter() {
- return privileges_list_writer_;
-}
-
-ListWriter<AppdefinedPrivilegeWriter>& PkgInfoHandleWriter::GetAppdefinedPrivilegesListWriter() {
- return appdefined_privileges_list_writer_;
-}
-
-ListWriter<AppdefinedPrivilegeWriter>& PkgInfoHandleWriter::GetProvidesAppDefinedPrivilegesListWriter() {
- return provides_appdefined_privileges_list_writer_;
-}
-
-ListWriter<DependencyWriter>& PkgInfoHandleWriter::GetDependenciesListWriter() {
- return dependencies_list_writer_;
-}
-
-ListWriter<PluginWriter>& PkgInfoHandleWriter::GetPluginListWriter() {
- return plugin_list_writer_;
-}
-
-ListWriter<ResAllowedPackageWriter>& PkgInfoHandleWriter::GetResAllowedPackagesListWriter() {
- return res_allowed_packages_list_writer_;
-}
-
-ListWriter<MetadataWriter>& PkgInfoHandleWriter::GetMetadataListWriter() {
- return metadata_list_writer_;
-}
-
-ListWriter<char*>& PkgInfoHandleWriter::GetDeviceprofileListWriter() {
- return deviceprofile_list_writer_;
-}
-
-PkgInfoHandle PkgInfoHandleWriter::FromPackageX(package_x* package) {
- PkgInfoHandleWriter writer;
- writer.WriteForAllUsers(package->for_all_users);
- writer.WritePackage(package->package);
- writer.WriteVersion(package->version);
- writer.WriteInstallLocation(package->installlocation);
- writer.WriteNameSpace(package->ns);
- writer.WriteRemovable(package->removable);
- writer.WritePreload(package->preload);
- writer.WriteReadonly(package->readonly);
- writer.WriteUpdate(package->update);
- writer.WriteAppSetting(package->appsetting);
- writer.WriteSystem(package->system);
- writer.WriteType(package->type);
- writer.WritePackageSize(package->package_size);
- writer.WriteInstalledTime(package->installed_time);
- writer.WriteInstalledStorage(package->installed_storage);
- writer.WriteStoreClientId(package->storeclient_id);
- writer.WriteMainAppId(package->mainapp_id);
- writer.WritePackageUrl(package->package_url);
- writer.WriteRootPath(package->root_path);
- writer.WriteCscPath(package->csc_path);
- writer.WriteNoDisplaySetting(package->nodisplay_setting);
- writer.WriteSupportMode(package->support_mode);
- writer.WriteSupportDisable(package->support_disable);
- writer.WriteApiVersion(package->api_version);
- writer.WriteTepName(package->tep_name);
- writer.WriteZipMountFile(package->zip_mount_file);
- writer.WriteBackendInstaller(package->backend_installer);
- writer.WriteExternalPath(package->external_path);
- writer.WriteUseSystemCerts(package->use_system_certs);
- writer.WriteLocale(package->locale);
- writer.WriteResType(package->res_type);
- writer.WriteResVersion(package->res_version);
- writer.WriteLib(package->lib);
- writer.WriteIsDisabled(package->is_disabled);
- writer.WriteLightUserSwitchMode(package->light_user_switch_mode);
-
- return writer.ExtractPkgInfo();
-}
-
-PkgInfoHandle PkgInfoHandleWriter::ExtractPkgInfo() {
- index_.icon = icon_list_writer_.Commit();
- index_.label = label_list_writer_.Commit();
- index_.author = author_list_writer_.Commit();
- index_.description = description_list_writer_.Commit();
- index_.privileges = privileges_list_writer_.Commit();
- index_.appdefined_privileges = appdefined_privileges_list_writer_.Commit();
- index_.provides_appdefined_privileges = provides_appdefined_privileges_list_writer_.Commit();
- index_.dependencies = dependencies_list_writer_.Commit();
- index_.plugin = plugin_list_writer_.Commit();
- index_.res_allowed_packages = res_allowed_packages_list_writer_.Commit();
- index_.metadata = metadata_list_writer_.Commit();
-
- parcel_.Write(&index_, sizeof(index_));
- parcel_.Pin();
-
- return PkgInfoHandle(std::make_unique<tizen_base::Parcel>(std::move(parcel_)));
-}
-
-AppInfoHandleWriter::AppInfoHandleWriter() :
- label_writer_(parcel_),
- icon_writer_(parcel_),
- image_writer_(parcel_),
- category_writer_(parcel_),
- metadata_writer_(parcel_),
- datacontrol_writer_(parcel_),
- background_category_writer_(parcel_),
- appcontrol_writer_(parcel_),
- splash_screens_writer_(parcel_),
- res_control_writer_(parcel_) {
- memset(&index_, -1, sizeof(index_));
-}
-
-void AppInfoHandleWriter::WriteAppId(const char* appid) {
- index_.appid = WriteCString(parcel_, appid);
-}
-
-void AppInfoHandleWriter::WriteExec(const char* exec) {
- index_.exec = WriteCString(parcel_, exec);
-}
-
-void AppInfoHandleWriter::WriteNodisplay(const char* nodisplay) {
- index_.nodisplay = WriteCString(parcel_, nodisplay);
-}
-
-void AppInfoHandleWriter::WriteMultiple(const char* multiple) {
- index_.multiple = WriteCString(parcel_, multiple);
-}
-
-void AppInfoHandleWriter::WriteTaskManage(const char* taskmanage) {
- index_.taskmanage = WriteCString(parcel_, taskmanage);
-}
-
-void AppInfoHandleWriter::WriteType(const char* type) {
- index_.type = WriteCString(parcel_, type);
-}
-
-void AppInfoHandleWriter::WriteCategories(const char* categories) {
- index_.categories = WriteCString(parcel_, categories);
-}
-
-void AppInfoHandleWriter::WriteExtraid(const char* extraid) {
- index_.extraid = WriteCString(parcel_, extraid);
-}
-
-void AppInfoHandleWriter::WriteHwAcceleration(const char* hwacceleration) {
- index_.hwacceleration = WriteCString(parcel_, hwacceleration);
-}
-
-void AppInfoHandleWriter::WriteScreenReader(const char* screenreader) {
- index_.screenreader = WriteCString(parcel_, screenreader);
-}
-
-void AppInfoHandleWriter::WriteMainApp(const char* mainapp) {
- index_.mainapp = WriteCString(parcel_, mainapp);
-}
-
-void AppInfoHandleWriter::WritePackage(const char* package) {
- index_.package = WriteCString(parcel_, package);
-}
-
-void AppInfoHandleWriter::WriteRecentimage(const char* recentimage) {
- index_.recentimage = WriteCString(parcel_, recentimage);
-}
-
-void AppInfoHandleWriter::WriteLaunchCondition(const char* launchcondition) {
- index_.launchcondition = WriteCString(parcel_, launchcondition);
-}
-
-void AppInfoHandleWriter::WriteIndicatorDisplay(const char* indicatordisplay) {
- index_.indicatordisplay = WriteCString(parcel_, indicatordisplay);
-}
-
-void AppInfoHandleWriter::WritePortraitImg(const char* portraitimg) {
- index_.portraitimg = WriteCString(parcel_, portraitimg);
-}
-
-void AppInfoHandleWriter::WriteLandscapeImg(const char* landscapeimg) {
- index_.landscapeimg = WriteCString(parcel_, landscapeimg);
-}
-
-void AppInfoHandleWriter::WriteEffecImageType(const char* effectimage_type) {
- index_.effectimage_type = WriteCString(parcel_, effectimage_type);
-}
-
-void AppInfoHandleWriter::WriteGuestModeVisibility(const char* guestmode_visibility) {
- index_.guestmode_visibility = WriteCString(parcel_, guestmode_visibility);
-}
-
-void AppInfoHandleWriter::WriteComponent(const char* component) {
- index_.component = WriteCString(parcel_, component);
-}
-
-void AppInfoHandleWriter::WritePermissionType(const char* permission_type) {
- index_.permission_type = WriteCString(parcel_, permission_type);
-}
-
-void AppInfoHandleWriter::WriteComponentType(const char* component_type) {
- index_.component_type = WriteCString(parcel_, component_type);
-}
-
-void AppInfoHandleWriter::WritePreload(const char* preload) {
- index_.preload = WriteCString(parcel_, preload);
-}
-
-void AppInfoHandleWriter::WriteSubmode(const char* submode) {
- index_.submode = WriteCString(parcel_, submode);
-}
-
-void AppInfoHandleWriter::WriteSubmodeMainId(const char* submode_mainid) {
- index_.submode_mainid = WriteCString(parcel_, submode_mainid);
-}
-
-void AppInfoHandleWriter::WriteProcessPool(const char* process_pool) {
- index_.process_pool = WriteCString(parcel_, process_pool);
-}
-
-void AppInfoHandleWriter::WriteInstalledStorage(const char* installed_storage) {
- index_.installed_storage = WriteCString(parcel_, installed_storage);
-}
-
-void AppInfoHandleWriter::WriteAutoRestart(const char* autorestart) {
- index_.autorestart = WriteCString(parcel_, autorestart);
-}
-
-void AppInfoHandleWriter::WriteOnboot(const char* onboot) {
- index_.onboot = WriteCString(parcel_, onboot);
-}
-
-void AppInfoHandleWriter::WriteSupportDisable(const char* support_disable) {
- index_.support_disable = WriteCString(parcel_, support_disable);
-}
-
-void AppInfoHandleWriter::WriteUiGadget(const char* ui_gadget) {
- index_.ui_gadget = WriteCString(parcel_, ui_gadget);
-}
-
-void AppInfoHandleWriter::WriteLaunchMode(const char* launch_mode) {
- index_.launch_mode = WriteCString(parcel_, launch_mode);
-}
-
-void AppInfoHandleWriter::WriteSupportAmbient(const char* support_ambient) {
- index_.support_ambient = WriteCString(parcel_, support_ambient);
-}
-
-void AppInfoHandleWriter::WriteSetupAppId(const char* setup_appid) {
- index_.setup_appid = WriteCString(parcel_, setup_appid);
-}
-
-void AppInfoHandleWriter::WriteAliasAppid(const char* alias_appid) {
- index_.alias_appid = WriteCString(parcel_, alias_appid);
-}
-
-void AppInfoHandleWriter::WriteEffectiveAppId(const char* effective_appid) {
- index_.effective_appid = WriteCString(parcel_, effective_appid);
-}
-
-void AppInfoHandleWriter::WritePackageType(const char* package_type) {
- index_.package_type = WriteCString(parcel_, package_type);
-}
-
-void AppInfoHandleWriter::WriteTepName(const char* tep_name) {
- index_.tep_name = WriteCString(parcel_, tep_name);
-}
-
-void AppInfoHandleWriter::WriteZipMountFile(const char* zip_mount_file) {
- index_.zip_mount_file = WriteCString(parcel_, zip_mount_file);
-}
-
-void AppInfoHandleWriter::WriteRootPath(const char* root_path) {
- index_.root_path = WriteCString(parcel_, root_path);
-}
-
-void AppInfoHandleWriter::WriteApiVersion(const char* api_version) {
- index_.api_version = WriteCString(parcel_, api_version);
-}
-
-void AppInfoHandleWriter::WriteForAllUsers(const char* for_all_users) {
- index_.for_all_users = WriteCString(parcel_, for_all_users);
-}
-
-void AppInfoHandleWriter::WriteIsDisabled(const char* is_disabled) {
- index_.is_disabled = WriteCString(parcel_, is_disabled);
-}
-
-void AppInfoHandleWriter::WriteSplashScreenDisplay(const char* splash_screen_display) {
- index_.splash_screen_display = WriteCString(parcel_, splash_screen_display);
-}
-
-void AppInfoHandleWriter::WriteExternalPath(const char* external_path) {
- index_.external_path = WriteCString(parcel_, external_path);
-}
-
-void AppInfoHandleWriter::WritePackageSystem(const char* package_system) {
- index_.package_system = WriteCString(parcel_, package_system);
-}
-
-void AppInfoHandleWriter::WriteRemovable(const char* removable) {
- index_.removable = WriteCString(parcel_, removable);
-}
-
-void AppInfoHandleWriter::WritePackageInstalledTime(const char* package_installed_time) {
- index_.package_installed_time = WriteCString(parcel_, package_installed_time);
-}
-
-void AppInfoHandleWriter::WriteSupportMode(const char* support_mode) {
- index_.support_mode = WriteCString(parcel_, support_mode);
-}
-
-void AppInfoHandleWriter::WriteLocale(const char* locale) {
- index_.locale = WriteCString(parcel_, locale);
-}
-
-void AppInfoHandleWriter::WriteLightUserSwitchMode(const char* light_user_switch_mode) {
- index_.light_user_switch_mode = WriteCString(parcel_, light_user_switch_mode);
-}
-
-void AppInfoHandleWriter::WriteIsPackageDisabled(const char* is_package_disabled) {
- index_.is_package_disabled = WriteCString(parcel_, is_package_disabled);
-}
-
-ListWriter<LabelWriter>& AppInfoHandleWriter::GetLabelListWriter() {
- return label_writer_;
-}
-
-ListWriter<IconWriter>& AppInfoHandleWriter::GetIconListWriter() {
- return icon_writer_;
-}
-
-ListWriter<ImageWriter>& AppInfoHandleWriter::GetImageListWriter() {
- return image_writer_;
-}
-
-ListWriter<char*>& AppInfoHandleWriter::GetCategoryListWriter() {
- return category_writer_;
-}
-
-ListWriter<MetadataWriter>& AppInfoHandleWriter::GetMetadataListWriter() {
- return metadata_writer_;
-}
-
-ListWriter<DataControlWriter>& AppInfoHandleWriter::GetDatacontrolListWriter() {
- return datacontrol_writer_;
-}
-
-ListWriter<char*>& AppInfoHandleWriter::GetBackgroundCategoryListWriter() {
- return background_category_writer_;
-}
-
-ListWriter<AppcontrolWriter>& AppInfoHandleWriter::GetAppcontrolListWriter() {
- return appcontrol_writer_;
-}
-
-ListWriter<SplashScreenWriter>& AppInfoHandleWriter::GetSplashscreensListWriter() {
- return splash_screens_writer_;
-}
-
-ListWriter<ResControlWriter>& AppInfoHandleWriter::GetResControlListWriter() {
- return res_control_writer_;
-}
-
-AppInfoHandle AppInfoHandleWriter::FromApplicationX(application_x* application) {
- AppInfoHandleWriter writer;
-
- writer.WriteAppId(application->appid);
- writer.WriteExec(application->exec);
- writer.WriteNodisplay(application->nodisplay);
- writer.WriteMultiple(application->multiple);
- writer.WriteTaskManage(application->taskmanage);
- writer.WriteType(application->type);
- writer.WriteCategories(application->categories);
- writer.WriteExtraid(application->extraid);
- writer.WriteHwAcceleration(application->hwacceleration);
- writer.WriteScreenReader(application->screenreader);
- writer.WriteMainApp(application->mainapp);
- writer.WritePackage(application->package);
- writer.WriteRecentimage(application->recentimage);
- writer.WriteLaunchCondition(application->launchcondition);
- writer.WriteIndicatorDisplay(application->indicatordisplay);
- writer.WritePortraitImg(application->portraitimg);
- writer.WriteLandscapeImg(application->landscapeimg);
- writer.WriteEffecImageType(application->effectimage_type);
- writer.WriteGuestModeVisibility(application->guestmode_visibility);
- writer.WriteComponent(application->component);
- writer.WritePermissionType(application->permission_type);
- writer.WriteComponentType(application->component_type);
- writer.WritePreload(application->preload);
- writer.WriteSubmode(application->submode);
- writer.WriteSubmodeMainId(application->submode_mainid);
- writer.WriteProcessPool(application->process_pool);
- writer.WriteInstalledStorage(application->installed_storage);
- writer.WriteAutoRestart(application->autorestart);
- writer.WriteOnboot(application->onboot);
- writer.WriteSupportDisable(application->support_disable);
- writer.WriteUiGadget(application->ui_gadget);
- writer.WriteLaunchMode(application->launch_mode);
- writer.WriteSupportAmbient(application->support_ambient);
- writer.WriteSetupAppId(application->setup_appid);
- writer.WriteAliasAppid(application->alias_appid);
- writer.WriteEffectiveAppId(application->effective_appid);
- writer.WritePackageType(application->package_type);
- writer.WriteTepName(application->tep_name);
- writer.WriteZipMountFile(application->zip_mount_file);
- writer.WriteRootPath(application->root_path);
- writer.WriteApiVersion(application->api_version);
- writer.WriteForAllUsers(application->for_all_users);
- writer.WriteIsDisabled(application->is_disabled);
- writer.WriteSplashScreenDisplay(application->splash_screen_display);
- writer.WriteExternalPath(application->external_path);
- writer.WritePackageSystem(application->package_system);
- writer.WriteRemovable(application->removable);
- writer.WritePackageInstalledTime(application->package_installed_time);
- writer.WriteSupportMode(application->support_mode);
- writer.WriteLocale(application->locale);
- writer.WriteLightUserSwitchMode(application->light_user_switch_mode);
-
- return writer.ExtractAppInfo();
-}
-
-AppInfoHandle AppInfoHandleWriter::ExtractAppInfo() {
- index_.label = label_writer_.Commit();
- index_.icon = icon_writer_.Commit();
- index_.image = image_writer_.Commit();
- index_.category = category_writer_.Commit();
- index_.metadata = metadata_writer_.Commit();
- index_.datacontrol = datacontrol_writer_.Commit();
- index_.background_category = background_category_writer_.Commit();
- index_.appcontrol = appcontrol_writer_.Commit();
- index_.splashscreens = splash_screens_writer_.Commit();
- index_.res_control = res_control_writer_.Commit();
-
- parcel_.Write(&index_, sizeof(index_));
- parcel_.Pin();
-
- return AppInfoHandle(std::make_unique<tizen_base::Parcel>(std::move(parcel_)));
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-#ifndef COMMON_PKGMGR_INFO_HANDLE_WRITER_HH_
-#define COMMON_PKGMGR_INFO_HANDLE_WRITER_HH_
-
-#include "abstract_parcelable.hh"
-
-#include <optional>
-#include <vector>
-
-#include "pkgmgrinfo_basic.h"
-
-#include <database.hpp>
-#include <parcel.hh>
-#include "pkgmgr_info_handle.hh"
-
-namespace pkgmgr_common {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-template<typename T>
-class ListWriter {
- public:
- ListWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {}
- ListWriter(const ListWriter&) = delete;
- ListWriter& operator=(const ListWriter&) = delete;
- ListWriter(ListWriter&&) noexcept = default;
- ListWriter& operator=(ListWriter&&) noexcept = default;
-
- T& AddItem() {
- items_.emplace_back(parcel_);
- return items_.back();
- }
-
- int Commit() {
- if (items_.size() == 0)
- return -1;
-
- std::vector<int> indexs;
- for (auto& item : items_)
- indexs.emplace_back(item.Commit());
-
- int result_index = parcel_.GetDataSize();
- parcel_.WriteInt32(items_.size());
- for (int index : indexs)
- parcel_.WriteInt32(index);
-
- return result_index;
- }
-
- private:
- tizen_base::Parcel& parcel_;
- std::vector<T> items_;
-};
-
-template<>
-class ListWriter<char*> {
- public:
- ListWriter(tizen_base::Parcel& parcel) : parcel_(parcel) {}
- ListWriter(const ListWriter&) = delete;
- ListWriter& operator=(const ListWriter&) = delete;
- ListWriter(ListWriter&&) noexcept = default;
- ListWriter& operator=(ListWriter&&) noexcept = default;
-
- ListWriter<char*>& Write(const char* ptr) {
- int index = parcel_.GetDataSize();
- parcel_.Write(ptr, strlen(ptr) + 1);
- indexs_.emplace_back(index);
-
- return *this;
- }
-
- int Commit() {
- int index = parcel_.GetDataSize();
- parcel_.WriteInt32(indexs_.size());
- for (int index : indexs_)
- parcel_.WriteInt32(index);
-
- return index;
- }
-
- private:
- tizen_base::Parcel& parcel_;
- std::vector<int> indexs_;
-};
-
-class EXPORT_API IconWriter {
- public:
- IconWriter(tizen_base::Parcel& parcel);
- IconWriter(const IconWriter&) = delete;
- IconWriter& operator=(const IconWriter&) = delete;
- IconWriter(IconWriter&&) noexcept = default;
- IconWriter& operator=(IconWriter&&) noexcept = default;
-
- IconWriter& WriteText(const char* text);
- IconWriter& WriteLang(const char* lang);
- IconWriter& WriteSection(const char* section);
- IconWriter& WriteSize(const char* size);
- IconWriter& WriteResolution(const char* resolution);
- IconWriter& WriteDpi(const char* dpi);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- IconIndex index_;
-};
-
-class EXPORT_API LabelWriter {
- public:
- LabelWriter(tizen_base::Parcel& parcel);
- LabelWriter(const LabelWriter&) = delete;
- LabelWriter& operator=(const LabelWriter&) = delete;
- LabelWriter(LabelWriter&&) noexcept = default;
- LabelWriter& operator=(LabelWriter&&) noexcept = default;
-
- LabelWriter& WriteName(const char* name);
- LabelWriter& WriteText(const char* text);
- LabelWriter& WriteLang(const char* lang);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- LabelIndex index_;
-};
-
-class EXPORT_API AuthorWriter {
- public:
- AuthorWriter(tizen_base::Parcel& parcel);
- AuthorWriter(const AuthorWriter&) = delete;
- AuthorWriter& operator=(const AuthorWriter&) = delete;
- AuthorWriter(AuthorWriter&&) noexcept = default;
- AuthorWriter& operator=(AuthorWriter&&) noexcept = default;
-
- AuthorWriter& WriteEmail(const char* email);
- AuthorWriter& WriteHref(const char* href);
- AuthorWriter& WriteText(const char* text);
- AuthorWriter& WriteLang(const char* lang);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- AuthorIndex index_;
-};
-
-class EXPORT_API LicenseWriter {
- public:
- LicenseWriter(tizen_base::Parcel& parcel);
- LicenseWriter(const LicenseWriter&) = delete;
- LicenseWriter& operator=(const LicenseWriter&) = delete;
- LicenseWriter(LicenseWriter&&) noexcept = default;
- LicenseWriter& operator=(LicenseWriter&&) noexcept = default;
-
- LicenseWriter& WriteText(const char* text);
- LicenseWriter& WriteLang(const char* lang);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- LicenseIndex index_;
-};
-
-class EXPORT_API DescriptionWriter {
- public:
- DescriptionWriter(tizen_base::Parcel& parcel);
- DescriptionWriter(const DescriptionWriter&) = delete;
- DescriptionWriter& operator=(const DescriptionWriter&) = delete;
- DescriptionWriter(DescriptionWriter&&) noexcept = default;
- DescriptionWriter& operator=(DescriptionWriter&&) noexcept = default;
-
- DescriptionWriter& WriteName(const char* name);
- DescriptionWriter& WriteText(const char* text);
- DescriptionWriter& WriteLang(const char* lang);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- DescriptionIndex index_;
-};
-
-class EXPORT_API PrivilegeWriter {
- public:
- PrivilegeWriter(tizen_base::Parcel& parcel);
- PrivilegeWriter(const PrivilegeWriter&) = delete;
- PrivilegeWriter& operator=(const PrivilegeWriter&) = delete;
- PrivilegeWriter(PrivilegeWriter&&) noexcept = default;
- PrivilegeWriter& operator=(PrivilegeWriter&&) noexcept = default;
-
- PrivilegeWriter& WriteType(const char* type);
- PrivilegeWriter& WriteValue(const char* value);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- PrivilegeIndex index_;
-};
-
-class EXPORT_API AppdefinedPrivilegeWriter {
- public:
- AppdefinedPrivilegeWriter(tizen_base::Parcel& parcel);
- AppdefinedPrivilegeWriter(const AppdefinedPrivilegeWriter&) = delete;
- AppdefinedPrivilegeWriter& operator=(const AppdefinedPrivilegeWriter&) = delete;
- AppdefinedPrivilegeWriter(AppdefinedPrivilegeWriter&&) noexcept = default;
- AppdefinedPrivilegeWriter& operator=(AppdefinedPrivilegeWriter&&) noexcept = default;
-
- AppdefinedPrivilegeWriter& WriteType(const char* type);
- AppdefinedPrivilegeWriter& WriteValue(const char* value);
- AppdefinedPrivilegeWriter& WriteLicense(const char* license);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- AppdefinedPrivilegeIndex index_;
-};
-
-class EXPORT_API DependencyWriter {
- public:
- DependencyWriter(tizen_base::Parcel& parcel);
- DependencyWriter(const DependencyWriter&) = delete;
- DependencyWriter& operator=(const DependencyWriter&) = delete;
- DependencyWriter(DependencyWriter&&) noexcept = default;
- DependencyWriter& operator=(DependencyWriter&&) noexcept = default;
-
- DependencyWriter& WritePkgid(const char* pkgid);
- DependencyWriter& WriteDependsOn(const char* depends_on);
- DependencyWriter& WriteType(const char* type);
- DependencyWriter& WriteRequiredVersion(const char* required_version);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- DependencyIndex index_;
-};
-
-class EXPORT_API PluginWriter {
- public:
- PluginWriter(tizen_base::Parcel& parcel);
- PluginWriter(const PluginWriter&) = delete;
- PluginWriter& operator=(const PluginWriter&) = delete;
- PluginWriter(PluginWriter&&) noexcept = default;
- PluginWriter& operator=(PluginWriter&&) noexcept = default;
-
- PluginWriter& WritePkgid(const char* pkgid);
- PluginWriter& WriteAppid(const char* appid);
- PluginWriter& WritePluginType(const char* plugin_type);
- PluginWriter& WritePluginName(const char* plugin_name);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- PluginIndex index_;
-};
-
-class EXPORT_API ResAllowedPackageWriter {
- public:
- ResAllowedPackageWriter(tizen_base::Parcel& parcel);
- ResAllowedPackageWriter(const ResAllowedPackageWriter&) = delete;
- ResAllowedPackageWriter& operator=(const ResAllowedPackageWriter&) = delete;
- ResAllowedPackageWriter(ResAllowedPackageWriter&&) noexcept = default;
- ResAllowedPackageWriter& operator=(ResAllowedPackageWriter&&) noexcept = default;
-
- ResAllowedPackageWriter& WriteAllowedPackage(const char* allowed_package);
- ListWriter<char*>& GetRequiredPrivilegeWriter();
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- ResAllowedPackageIndex index_;
-
- ListWriter<char*> required_privilege_list_writer_;
-};
-
-class EXPORT_API MetadataWriter {
- public:
- MetadataWriter(tizen_base::Parcel& parcel);
- MetadataWriter(const MetadataWriter&) = delete;
- MetadataWriter& operator=(const MetadataWriter&) = delete;
- MetadataWriter(MetadataWriter&&) noexcept = default;
- MetadataWriter& operator=(MetadataWriter&&) noexcept = default;
-
- MetadataWriter& WriteKey(const char* key);
- MetadataWriter& WriteValue(const char* value);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- MetadataIndex index_;
-};
-
-class EXPORT_API ImageWriter {
- public:
- ImageWriter(tizen_base::Parcel& parcel);
- ImageWriter(const ImageWriter&) = delete;
- ImageWriter& operator=(const ImageWriter&) = delete;
- ImageWriter(ImageWriter&&) noexcept = default;
- ImageWriter& operator=(ImageWriter&&) noexcept = default;
-
- ImageWriter& WriteText(const char* text);
- ImageWriter& WriteLang(const char* lang);
- ImageWriter& WriteSection(const char* section);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- ImageIndex index_;
-};
-
-class EXPORT_API DataControlWriter {
- public:
- DataControlWriter(tizen_base::Parcel& parcel);
- DataControlWriter(const DataControlWriter&) = delete;
- DataControlWriter& operator=(const DataControlWriter&) = delete;
- DataControlWriter(DataControlWriter&&) noexcept = default;
- DataControlWriter& operator=(DataControlWriter&&) noexcept = default;
-
- DataControlWriter& WriteProviderId(const char* providerid);
- DataControlWriter& WriteAccess(const char* access);
- DataControlWriter& WriteType(const char* type);
- DataControlWriter& WriteTrusted(const char* trusted);
- ListWriter<char*>& GetPrivilegeListWriter();
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- ListWriter<char*> privilege_list_writer_;
- DataControlIndex index_;
-};
-
-class EXPORT_API AppcontrolWriter {
- public:
- AppcontrolWriter(tizen_base::Parcel& parcel);
- AppcontrolWriter(const AppcontrolWriter&) = delete;
- AppcontrolWriter& operator=(const AppcontrolWriter&) = delete;
- AppcontrolWriter(AppcontrolWriter&&) noexcept = default;
- AppcontrolWriter& operator=(AppcontrolWriter&&) noexcept = default;
-
- AppcontrolWriter& WriteOperation(const char* operation);
- AppcontrolWriter& WriteUri(const char* uri);
- AppcontrolWriter& WriteMime(const char* mime);
- AppcontrolWriter& WriteVisibility(const char* visibility);
- AppcontrolWriter& WriteId(const char* id);
- ListWriter<char*>& GetPrivilegeListWriter();
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- ListWriter<char*> privilege_list_writer_;
- AppcontrolIndex index_;
-};
-
-class EXPORT_API SplashScreenWriter {
- public:
- SplashScreenWriter(tizen_base::Parcel& parcel);
- SplashScreenWriter(const SplashScreenWriter&) = delete;
- SplashScreenWriter& operator=(const SplashScreenWriter&) = delete;
- SplashScreenWriter(SplashScreenWriter&&) noexcept = default;
- SplashScreenWriter& operator=(SplashScreenWriter&&) noexcept = default;
-
- SplashScreenWriter& WriteSrc(const char* src);
- SplashScreenWriter& WriteType(const char* type);
- SplashScreenWriter& WriteDpi(const char* dpi);
- SplashScreenWriter& WriteOrientation(const char* orientation);
- SplashScreenWriter& WriteIndicatordisplay(const char* indicatordisplay);
- SplashScreenWriter& WriteOperation(const char* operation);
- SplashScreenWriter& WriteColorDepth(const char* color_depth);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- SplashScreenIndex index_;
-};
-
-class EXPORT_API ResControlWriter {
- public:
- ResControlWriter(tizen_base::Parcel& parcel);
- ResControlWriter(const ResControlWriter&) = delete;
- ResControlWriter& operator=(const ResControlWriter&) = delete;
- ResControlWriter(ResControlWriter&&) noexcept = default;
- ResControlWriter& operator=(ResControlWriter&&) noexcept = default;
-
- ResControlWriter& WriteResType(const char* res_type);
- ResControlWriter& WriteMinResVersion(const char* min_res_version);
- ResControlWriter& WriteMaxResVersion(const char* max_res_version);
- ResControlWriter& WriteAutoClose(const char* auto_close);
-
- int Commit();
-
- private:
- tizen_base::Parcel& parcel_;
- ResControlIndex index_;
-};
-
-class EXPORT_API PkgInfoHandleWriter {
- public:
- PkgInfoHandleWriter();
- void WriteForAllUsers(const char* for_all_users);
- void WritePackage(const char* package);
- void WriteVersion(const char* version);
- void WriteInstallLocation(const char* installlocation);
- void WriteNameSpace(const char* ns);
- void WriteRemovable(const char* removable);
- void WritePreload(const char* preload);
- void WriteReadonly(const char* readonly);
- void WriteUpdate(const char* update);
- void WriteAppSetting(const char* appsetting);
- void WriteSystem(const char* system);
- void WriteType(const char* type);
- void WritePackageSize(const char* package_size);
- void WriteInstalledTime(const char* installed_time);
- void WriteInstalledStorage(const char* installed_storage);
- void WriteStoreClientId(const char* storeclient_id);
- void WriteMainAppId(const char* mainapp_id);
- void WritePackageUrl(const char* package_url);
- void WriteRootPath(const char* root_path);
- void WriteCscPath(const char* csc_path);
- void WriteNoDisplaySetting(const char* nodisplay_setting);
- void WriteSupportMode(const char* support_mode);
- void WriteSupportDisable(const char* support_disable);
- void WriteApiVersion(const char* api_version);
- void WriteTepName(const char* tep_name);
- void WriteZipMountFile(const char* zip_mount_file);
- void WriteBackendInstaller(const char* backend_installer);
- void WriteExternalPath(const char* external_path);
- void WriteUseSystemCerts(const char* use_system_certs);
- void WriteLocale(const char* locale);
- void WriteResType(const char* res_type);
- void WriteResVersion(const char* res_version);
- void WriteLib(const char* lib);
- void WriteIsDisabled(const char* is_disabled);
- void WriteLightUserSwitchMode(const char* light_user_switch_mode);
- ListWriter<IconWriter>& GetIconListWriter();
- ListWriter<LabelWriter>& GetLabelListWriter();
- ListWriter<AuthorWriter>& GetAuthorListWriter();
- ListWriter<DescriptionWriter>& GetDescriptionListWriter();
- ListWriter<PrivilegeWriter>& GetPrivilegesListWriter();
- ListWriter<AppdefinedPrivilegeWriter>& GetAppdefinedPrivilegesListWriter();
- ListWriter<AppdefinedPrivilegeWriter>& GetProvidesAppDefinedPrivilegesListWriter();
- ListWriter<DependencyWriter>& GetDependenciesListWriter();
- ListWriter<PluginWriter>& GetPluginListWriter();
- ListWriter<ResAllowedPackageWriter>& GetResAllowedPackagesListWriter();
- ListWriter<MetadataWriter>& GetMetadataListWriter();
- ListWriter<char*>& GetDeviceprofileListWriter();
-
- static PkgInfoHandle FromPackageX(package_x* pkg);
- PkgInfoHandle ExtractPkgInfo();
-
- private:
- tizen_base::Parcel parcel_;
- PkgInfoIndex index_;
-
- ListWriter<IconWriter> icon_list_writer_;
- ListWriter<LabelWriter> label_list_writer_;
- ListWriter<AuthorWriter> author_list_writer_;
- ListWriter<DescriptionWriter> description_list_writer_;
- ListWriter<PrivilegeWriter> privileges_list_writer_;
- ListWriter<AppdefinedPrivilegeWriter> appdefined_privileges_list_writer_;
- ListWriter<AppdefinedPrivilegeWriter> provides_appdefined_privileges_list_writer_;
- ListWriter<DependencyWriter> dependencies_list_writer_;
- ListWriter<PluginWriter> plugin_list_writer_;
- ListWriter<ResAllowedPackageWriter> res_allowed_packages_list_writer_;
- ListWriter<MetadataWriter> metadata_list_writer_;
- ListWriter<char*> deviceprofile_list_writer_;
-};
-
-class EXPORT_API AppInfoHandleWriter {
- public:
- AppInfoHandleWriter();
- void WriteAppId(const char* appid);
- void WriteExec(const char* exec);
- void WriteNodisplay(const char* nodisplay);
- void WriteMultiple(const char* multiple);
- void WriteTaskManage(const char* taskmanage);
- void WriteType(const char* type);
- void WriteCategories(const char* categories);
- void WriteExtraid(const char* extraid);
- void WriteHwAcceleration(const char* hwacceleration);
- void WriteScreenReader(const char* screenreader);
- void WriteMainApp(const char* mainapp);
- void WritePackage(const char* package);
- void WriteRecentimage(const char* recentimage);
- void WriteLaunchCondition(const char* launchcondition);
- void WriteIndicatorDisplay(const char* indicatordisplay);
- void WritePortraitImg(const char* portraitimg);
- void WriteLandscapeImg(const char* landscapeimg);
- void WriteEffecImageType(const char* effectimage_type);
- void WriteGuestModeVisibility(const char* guestmode_visibility);
- void WriteComponent(const char* component);
- void WritePermissionType(const char* permission_type);
- void WriteComponentType(const char* component_type);
- void WritePreload(const char* preload);
- void WriteSubmode(const char* submode);
- void WriteSubmodeMainId(const char* submode_mainid);
- void WriteProcessPool(const char* process_pool);
- void WriteInstalledStorage(const char* installed_storage);
- void WriteAutoRestart(const char* autorestart);
- void WriteOnboot(const char* onboot);
- void WriteSupportDisable(const char* support_disable);
- void WriteUiGadget(const char* ui_gadget);
- void WriteLaunchMode(const char* launch_mode);
- void WriteSupportAmbient(const char* support_ambient);
- void WriteSetupAppId(const char* setup_appid);
- void WriteAliasAppid(const char* alias_appid);
- void WriteEffectiveAppId(const char* effective_appid);
- void WritePackageType(const char* package_type);
- void WriteTepName(const char* tep_name);
- void WriteZipMountFile(const char* zip_mount_file);
- void WriteRootPath(const char* root_path);
- void WriteApiVersion(const char* api_version);
- void WriteForAllUsers(const char* for_all_users);
- void WriteIsDisabled(const char* is_disabled);
- void WriteSplashScreenDisplay(const char* splash_screen_display);
- void WriteExternalPath(const char* external_path);
- void WritePackageSystem(const char* package_system);
- void WriteRemovable(const char* removable);
- void WritePackageInstalledTime(const char* package_installed_time);
- void WriteSupportMode(const char* support_mode);
- void WriteLocale(const char* locale);
- void WriteLightUserSwitchMode(const char* light_user_switch_mode);
- void WriteIsPackageDisabled(const char* is_package_disabled);
- ListWriter<LabelWriter>& GetLabelListWriter();
- ListWriter<IconWriter>& GetIconListWriter();
- ListWriter<ImageWriter>& GetImageListWriter();
- ListWriter<char*>& GetCategoryListWriter();
- ListWriter<MetadataWriter>& GetMetadataListWriter();
- ListWriter<DataControlWriter>& GetDatacontrolListWriter();
- ListWriter<char*>& GetBackgroundCategoryListWriter();
- ListWriter<AppcontrolWriter>& GetAppcontrolListWriter();
- ListWriter<SplashScreenWriter>& GetSplashscreensListWriter();
- ListWriter<ResControlWriter>& GetResControlListWriter();
-
- static AppInfoHandle FromApplicationX(application_x* application);
- AppInfoHandle ExtractAppInfo();
- AppInfoHandle GetAppInfo();
-
- private:
- tizen_base::Parcel parcel_;
- AppInfoIndex index_;
-
- ListWriter<LabelWriter> label_writer_;
- ListWriter<IconWriter> icon_writer_;
- ListWriter<ImageWriter> image_writer_;
- ListWriter<char*> category_writer_;
- ListWriter<MetadataWriter> metadata_writer_;
- ListWriter<DataControlWriter> datacontrol_writer_;
- ListWriter<char*> background_category_writer_;
- ListWriter<AppcontrolWriter> appcontrol_writer_;
- ListWriter<SplashScreenWriter> splash_screens_writer_;
- ListWriter<ResControlWriter> res_control_writer_;
-};
-
-} // namespace pkgmgr_common
-
-#endif // COMMON_PKGMGR_INFO_HANDLE_WRITER_HH_
+++ /dev/null
-/*
-* Copyright (c) 2023 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.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <sys/smack.h>
-#include <linux/limits.h>
-#include <sys/stat.h>
-
-#include <sqlite3.h>
-#include <glib.h>
-#include <system_info.h>
-
-#include <queue>
-#include <set>
-#include <string>
-#include <string_view>
-
-#include "pkgmgr_parser.h"
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_storage_status.h"
-#include "pkgmgrinfo_private.h"
-#include "pkgmgrinfo_debug.h"
-#include "pkgmgr-info.h"
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgr_info_handle_writer.hh"
-
-namespace pkgmgr_common {
-
-bool CheckPackageStorageStatus(pkgmgrinfo_filter_x* tmp_filter) {
- GSList* tmp_list = nullptr;
- pkgmgrinfo_node_x* tmp_node = nullptr;
- int property = -1;
-
- if (tmp_filter->cache_flag)
- return false;
-
- property = _pminfo_pkginfo_convert_to_prop_bool(
- PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE);
- for (tmp_list = tmp_filter->list; tmp_list != nullptr;
- tmp_list = g_slist_next(tmp_list)) {
- tmp_node = reinterpret_cast<pkgmgrinfo_node_x*>(tmp_list->data);
- if (property == tmp_node->prop) {
- if (strcmp(tmp_node->value, "true") == 0)
- return true;
- else
- return false;
- }
- }
- return true;
-}
-
-bool CheckAppStorageStatus(pkgmgrinfo_filter_x* tmp_filter) {
- GSList* tmp_list = nullptr;
- pkgmgrinfo_node_x* tmp_node = nullptr;
- int property = -1;
-
- if (tmp_filter == nullptr)
- return true;
-
- if (tmp_filter->cache_flag)
- return false;
-
- property = _pminfo_appinfo_convert_to_prop_bool(
- PMINFO_APPINFO_PROP_APP_CHECK_STORAGE);
- for (tmp_list = tmp_filter->list; tmp_list != nullptr;
- tmp_list = g_slist_next(tmp_list)) {
- tmp_node = (pkgmgrinfo_node_x *)tmp_list->data;
- if (property == tmp_node->prop) {
- if (strcmp(tmp_node->value, "true") == 0)
- return true;
- else
- return false;
- }
- }
-
- return true;
-}
-
-} // namespace pkgmgr_common
+++ /dev/null
-/*
-* 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_STORAGE_STATUS_H__
-#define __PKGMGRINFO_STORAGE_STATUS_H__
-
-#include <errno.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"
-
-#include "pkgmgr_info_handle.hh"
-
-namespace pkgmgr_common {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-EXPORT_API bool CheckPackageStorageStatus(pkgmgrinfo_filter_x* tmp_filter);
-EXPORT_API bool CheckAppStorageStatus(pkgmgrinfo_filter_x* tmp_filter);
-
-} // namespace pkgmgr_common
-
-#endif /* __PKGMGRINFO_STORAGE_STATUS_H__ */
+++ /dev/null
-/*
- * Copyright (c) 2025 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.
- */
-
-#include "shm_app_reader.hh"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include <unordered_set>
-
-#include "utils/logging.hh"
-
-#include "pkgmgrinfo_storage_status.h"
-#include "filter_checker/filter_checker_provider.hh"
-#include "manager/pkginfo_manager.h"
-#include "shm_pkg_reader.hh"
-
-#include <fstream>
-
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_INFO"
-
-namespace pkgmgr_common {
-namespace shared_memory {
-
-inline bool CheckPrivilegeFilters(const char* pkgid, uid_t uid,
- const std::unordered_set<std::string>& privilege_filters) {
- ShmPkgReader pkg_reader(uid);
-
- auto pkg_info = pkg_reader.GetHandle(pkgid);
- if (!pkg_info)
- return false;
-
- for (const auto priv : pkg_info->GetPrivileges()) {
- if (priv.Value() != nullptr && privilege_filters.count(priv.Value()))
- return true;
- }
-
- return false;
-}
-
-inline bool CheckMetadataFilter(const AppInfoHandle* info,
- const std::unordered_map<std::string, std::string>& metadata_map) {
- for (const auto& node : info->GetMetadata()) {
- if (node.Key() != nullptr) {
- auto metadata = metadata_map.find(node.Key());
- if (metadata == metadata_map.end())
- continue;
-
- if (metadata->second.empty() ||
- strcmp(node.Value() ? node.Value() : "", metadata->second.c_str()) == 0)
- return true;
- }
- }
- return false;
-}
-
-int ShmAppReader::GetHandles(pkgmgrinfo_filter_x* filter,
- std::map<std::string, AppInfoHandle>& list) {
- FilterChecker filter_checker(uid_);
- if (!filter_checker.Init(filter)) {
- LOG(ERROR) << "Failted to initialize filter checker";
- return PMINFO_R_ERROR;
- }
-
- if (filter_checker.AppIdFilterValue()) {
- for (auto& reader : readers_) {
- int result;
- auto handle = reader.GetHandle(filter_checker.AppIdFilterValue(), &result);
- if (!handle) {
- if (result == TIZEN_ERROR_NO_DATA)
- continue;
- else if (result != TIZEN_ERROR_NONE)
- return PMINFO_R_ERROR;
- } else {
- if (filter_checker.Check(*handle))
- list.emplace(handle->GetAppId(), std::move(*handle));
- break;
- }
- }
- } else {
- for (auto& reader : readers_) {
- int result;
- auto handles = reader.GetHandles(&result);
- if (!handles && result != TIZEN_ERROR_NONE)
- return PMINFO_R_ERROR;
-
- if (!handles)
- continue;
-
- for (auto& handle : *handles)
- if (filter_checker.Check(handle))
- list.emplace(handle.GetAppId(), std::move(handle));
- }
- }
-
- return PMINFO_R_OK;
-}
-
-ShmAppReader::ShmAppReader(uid_t uid) : uid_(uid) {
- readers_.emplace_back(
- ShmNameProvider::AppConfig(uid),
- ShmNameProvider::AppHandle(uid),
- ShmNameProvider::AppIndexs(uid),
- ShmNameProvider::AppKeys(uid));
- if (uid > REGULAR_USER)
- readers_.emplace_back(
- ShmNameProvider::AppConfig(GLOBAL_USER),
- ShmNameProvider::AppHandle(GLOBAL_USER),
- ShmNameProvider::AppIndexs(GLOBAL_USER),
- ShmNameProvider::AppKeys(GLOBAL_USER));
-}
-
-bool ShmAppReader::Init() {
- if (_is_writer()) {
- LOGD("process(%d) is writer", getpid());
- return false;
- }
-
- for (auto& reader : readers_) {
- if (!reader.Init()) {
- LOGE("Init reader fail");
- return false;
- }
- }
-
- return true;
-}
-
-ShmAppReader::FilterChecker::FilterChecker(uid_t uid)
- : uid_(uid), appid_filter_(nullptr) {}
-
-bool ShmAppReader::FilterChecker::Init(pkgmgrinfo_filter_x* filter) {
- for (auto* it = filter->list_metadata; it != nullptr; it = g_slist_next(it)) {
- auto node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(it->data);
- if (node->key == nullptr)
- continue;
-
- metadata_map_[node->key] = (node->value ? node->value : "");
- }
-
- for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
- auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
-
- if (node->prop == E_PMINFO_APPINFO_PROP_APP_ID && node->value) {
- LOG(DEBUG) << "E_PMINFO_APPINFO_PROP_APP_ID filter : " << node->value;
- appid_filter_ = node->value;
- }
-
- if (node->prop == E_PMINFO_APPINFO_PROP_PRIVILEGE && node->value)
- privilege_filters_.emplace(node->value);
- }
-
- if (CheckAppStorageStatus(filter)) {
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, true) != PMINFO_R_OK) {
- LOG(ERROR) << "Fail to add check storage value to filter";
- return false;
- }
- }
-
- for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
- auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
- filter_checker_.emplace_back(std::make_pair(FilterCheckerProvider::GetInst().
- GetAppFilterChecker(node->prop), node->value));
- }
-
- return true;
-}
-
-bool ShmAppReader::FilterChecker::Check(const AppInfoHandle& handle) {
- if (!metadata_map_.empty() && !CheckMetadataFilter(&handle, metadata_map_))
- return false;
-
- if (!privilege_filters_.empty() &&
- !CheckPrivilegeFilters(handle.GetPackage(), uid_, privilege_filters_))
- return false;
-
- for (auto [checker, value] : filter_checker_)
- if (!checker->CheckFilter(value, &handle))
- return false;
-
- return true;
-}
-
-const char* ShmAppReader::FilterChecker::AppIdFilterValue() {
- return appid_filter_;
-}
-
-} // namespace shared_memory
-} // namespace pkgmgr_common
+++ /dev/null
-#ifndef COMMON_SHM_APP_READER_HH_
-#define COMMON_SHM_APP_READER_HH_
-
-#include <unordered_map>
-#include <unordered_set>
-#include <vector>
-
-#include "app_filter_checker_base.hh"
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgrinfo_private.h"
-#include "shm_config.hh"
-#include "shm_reader.hh"
-
-namespace pkgmgr_common {
-namespace shared_memory {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-
-class EXPORT_API ShmAppReader {
- public:
- ShmAppReader(uid_t uid);
-
- bool Init();
- int GetHandles(pkgmgrinfo_filter_x* filter,
- std::map<std::string, AppInfoHandle>& list);
-
- private:
- class EXPORT_API FilterChecker {
- public:
- FilterChecker(uid_t uid);
- bool Init(pkgmgrinfo_filter_x* filter);
- bool Check(const AppInfoHandle& handle);
- const char* AppIdFilterValue();
-
- private:
- uid_t uid_;
- const char* appid_filter_ = nullptr;
- std::unordered_map<std::string, std::string> metadata_map_;
- std::unordered_set<std::string> privilege_filters_;
- std::vector<std::pair<IAppFilterChecker*, const char*>> filter_checker_;
- };
-
- uid_t uid_;
- std::vector<ShmReader<AppInfoHandle>> readers_;
-};
-
-} // namespace shared_memory
-} // namespace pkgmgr_common
-
-#endif // COMMON_SHM_APP_READER_HH_
+++ /dev/null
-/*
- * 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.
- */
-
-#include "shm_config.hh"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <time.h>
-#include <unistd.h>
-#include <tzplatform_config.h>
-
-#include "utils/logging.hh"
-
-#include "pkgmgrinfo_storage_status.h"
-
-#include <fstream>
-
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_INFO"
-
-namespace {
-
-uid_t globaluser_uid = -1;
-
-uid_t GetGlobalUID() {
- if (globaluser_uid == (uid_t)-1)
- globaluser_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
-
- return globaluser_uid;
-}
-
-uid_t ConvertUID(uid_t uid) {
- if (uid < REGULAR_USER)
- return GetGlobalUID();
- else
- return uid;
-}
-
-} // namespace
-
-namespace pkgmgr_common {
-namespace shared_memory {
-
-static constexpr const char PKG_CONFIG[] = ".pkgmgr_pkg_config";
-static constexpr const char PKG_HANDLE_SHM_NAME[] = ".pkgmgr_info_pkg_handle";
-static constexpr const char PKG_INDEXS_SHM_NAME[] = ".pkgmgr_info_pkg_indexs";
-static constexpr const char PKG_KEYS_SHM_NAME[] = ".pkgmgr_info_pkg_keys";
-static constexpr const char APP_CONFIG[] = ".pkgmgr_app_config";
-static constexpr const char APP_HANDLE_SHM_NAME[] = ".pkgmgr_info_app_handle";
-static constexpr const char APP_INDEXS_SHM_NAME[] = ".pkgmgr_info_app_indexs";
-static constexpr const char APP_KEYS_SHM_NAME[] = ".pkgmgr_info_app_keys";
-
-static std::string GetName(const char* prefix, uid_t uid) {
- return std::string(prefix) + "_" + std::to_string(uid);
-}
-
-const char* ShmNameProvider::PkgConfig(uid_t uid) {
- uid = ConvertUID(uid);
- auto it = pkg_config_names_.find(uid);
- if (it != pkg_config_names_.end())
- return it->second.c_str();
-
- return pkg_config_names_.emplace(uid, GetName(PKG_CONFIG, uid))
- .first->second.c_str();
-}
-
-const char* ShmNameProvider::PkgHandle(uid_t uid) {
- uid = ConvertUID(uid);
- auto it = pkg_handle_names_.find(uid);
- if (it != pkg_handle_names_.end())
- return it->second.c_str();
-
- return pkg_handle_names_.emplace(uid, GetName(PKG_HANDLE_SHM_NAME, uid))
- .first->second.c_str();
-}
-
-const char* ShmNameProvider::PkgIndexs(uid_t uid) {
- uid = ConvertUID(uid);
- auto it = pkg_indexs_names_.find(uid);
- if (it != pkg_indexs_names_.end())
- return it->second.c_str();
-
- return pkg_indexs_names_.emplace(uid, GetName(PKG_INDEXS_SHM_NAME, uid))
- .first->second.c_str();
-}
-
-const char* ShmNameProvider::PkgKeys(uid_t uid) {
- uid = ConvertUID(uid);
- auto it = pkg_keys_names_.find(uid);
- if (it != pkg_keys_names_.end())
- return it->second.c_str();
-
- return pkg_keys_names_.emplace(uid, GetName(PKG_KEYS_SHM_NAME, uid))
- .first->second.c_str();
-}
-
-const char* ShmNameProvider::AppConfig(uid_t uid) {
- uid = ConvertUID(uid);
- auto it = app_config_names_.find(uid);
- if (it != app_config_names_.end())
- return it->second.c_str();
-
- return app_config_names_.emplace(uid, GetName(APP_CONFIG, uid))
- .first->second.c_str();
-}
-
-const char* ShmNameProvider::AppHandle(uid_t uid) {
- uid = ConvertUID(uid);
- auto it = app_handle_names_.find(uid);
- if (it != app_handle_names_.end())
- return it->second.c_str();
-
- return app_handle_names_.emplace(uid, GetName(APP_HANDLE_SHM_NAME, uid))
- .first->second.c_str();
-}
-
-const char* ShmNameProvider::AppIndexs(uid_t uid) {
- uid = ConvertUID(uid);
- auto it = app_indexs_names_.find(uid);
- if (it != app_indexs_names_.end())
- return it->second.c_str();
-
- return app_indexs_names_.emplace(uid, GetName(APP_INDEXS_SHM_NAME, uid))
- .first->second.c_str();
-}
-
-const char* ShmNameProvider::AppKeys(uid_t uid) {
- uid = ConvertUID(uid);
- auto it = app_keys_names_.find(uid);
- if (it != app_keys_names_.end())
- return it->second.c_str();
-
- return app_keys_names_.emplace(uid, GetName(APP_KEYS_SHM_NAME, uid))
- .first->second.c_str();
-}
-
-ShmMapper::ShmMapper(const char* shm_name)
- : shm_name_(shm_name), mem_size_(0), mem_ptr_(nullptr) {}
-
-ShmMapper::~ShmMapper() {
- if (mem_ptr_ && munmap(mem_ptr_, mem_size_) != 0)
- LOGE("Failed to munmap %s", shm_name_);
-}
-
-uint8_t* ShmMapper::GetPtr() const {
- return mem_ptr_;
-}
-
-size_t ShmMapper::GetSize() const {
- return mem_size_;
-}
-
-ShmWriteMapper::ShmWriteMapper(const char* shm_name) :
- ShmMapper(shm_name), fd_(-1) {}
-
-ShmWriteMapper::~ShmWriteMapper() {
- if (fd_ != -1)
- close(fd_);
- fd_ = -1;
-}
-
-bool ShmWriteMapper::Init(size_t mem_size) {
- if(shm_unlink(shm_name_) != 0) {
- LOGD("failed to unlink(%s) %d", shm_name_, errno);
- } else {
- LOGD("success to unlink(%s)", shm_name_);
- }
-
- int fd = shm_open(shm_name_, O_CREAT|O_RDWR, 0664);
- if(fd == -1) {
- LOGE("failed to open(%s). errno(%d)", shm_name_, errno);
- return false;
- }
-
- if(ftruncate(fd, mem_size) != 0) {
- LOGE("failed to truncate (%d:%zu)", fd, mem_size);
- close(fd);
- return false;
- }
-
- uint8_t* mem_ptr = nullptr;
- if (mem_size != 0) {
- mem_ptr = (uint8_t*)mmap(NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- if(mem_ptr == MAP_FAILED) {
- LOGE("failed to mmap(%s), size(%zu). errno(%d)", shm_name_, mem_size, errno);
- if(ftruncate(fd, 0) != 0)
- LOGE("failed to truncate (%d:0)", fd);
-
- shm_unlink(shm_name_);
- close(fd);
- return false;
- }
- }
-
- fd_ = fd;
- mem_size_ = mem_size;
- mem_ptr_ = mem_ptr;
-
- return true;
-}
-
-bool ShmWriteMapper::Resize(size_t mem_size) {
- LOGD("try resize %zu to %zu", mem_size_, mem_size);
-
- if (munmap(mem_ptr_, mem_size_) != 0) {
- LOGE("Failed to munmap %s", shm_name_);
- return false;
- }
-
- if (ftruncate(fd_, mem_size) != 0) {
- LOGE("failed to truncate (%d:%zu), %s", fd_, mem_size, shm_name_);
- return false;
- }
-
- uint8_t* mem_ptr = (uint8_t*)mmap(NULL, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd_, 0);
- if(mem_ptr == MAP_FAILED) {
- LOGE("failed to mmap(%s). errno(%d)", shm_name_, errno);
- if(ftruncate(fd_, 0) != 0)
- LOGE("failed to truncate (%d:0)", fd_);
-
- shm_unlink(shm_name_);
- close(fd_);
- fd_ = -1;
- return false;
- }
-
- mem_size_ = mem_size;
- mem_ptr_ = mem_ptr;
-
- return true;
-}
-
-ShmReadMapper::ShmReadMapper(const char* shm_name) :
- ShmMapper(shm_name), fd_(-1) {}
-
-ShmReadMapper::~ShmReadMapper() {
- if (fd_ != -1)
- close(fd_);
- fd_ = -1;
-}
-
-bool ShmReadMapper::Init() {
- if(fd_ > 0) return true;
-
- int fd = shm_open(shm_name_, O_RDONLY, 0664);
- if(fd == -1) {
- LOGE("failed to open(%s). errno(%d)", shm_name_, errno);
- return false;
- }
-
- fd_ = fd;
- return true;
-}
-
-bool ShmReadMapper::LoadAll(size_t mem_size) {
- if(mem_ptr_){
- if (mem_size == mem_size_) {
- return true;
- } else {
- if (munmap(mem_ptr_, mem_size_) != 0) {
- LOGE("Failed to munmap %s", shm_name_);
- return false;
- }
- mem_ptr_ = nullptr;
- mem_size_ = 0;
- }
- }
-
- uint8_t* shm = (uint8_t*)mmap(NULL, mem_size, PROT_READ, MAP_SHARED, fd_, 0);
- if (shm == MAP_FAILED) {
- LOGE("failed to mmap(%s). errno(%d)", shm_name_, errno);
- close(fd_);
- fd_ = -1;
- mem_ptr_ = nullptr;
- mem_size_ = 0;
- return false;
- }
-
- mem_ptr_ = shm;
- mem_size_ = mem_size;
-
- return true;
-}
-
-uint8_t* ShmReadMapper::CopyPartial(size_t offset, size_t size) {
- uint8_t* ptr = reinterpret_cast<uint8_t*>(malloc(size));
- if (ptr == nullptr) {
- LOGE("Out of memory, len(%zu)", size);
- close(fd_);
- fd_ = -1;
- return nullptr;
- }
-
- if (mem_ptr_ && ((offset + size) < mem_size_)) {// case in-mmap, read mem
- memcpy(ptr, mem_ptr_, size);
- } else { // case out-mmap, read file
- if (lseek(fd_, offset, SEEK_SET) == -1) {
- LOGE("lseek fail fd(%d), index(%zd)", fd_, offset);
- free(ptr);
- close(fd_);
- fd_ = -1;
- return nullptr;
- }
-
- ssize_t read_num = read(fd_, ptr, size);
- LOGD("read_num: %zd, len: %zu", read_num, size);
- if (read_num == -1) {
- LOGE("Failed to read %zu bytes, read_num(%zd)", size, read_num);
- free(ptr);
- close(fd_);
- fd_ = -1;
- return nullptr;
- }
- }
- return ptr;
-}
-
-ShmConfigHandler::~ShmConfigHandler() {
- if (has_lock_) {
- Unlock();
- }
-
- if (config_data_)
- munmap(config_data_, sizeof(ConfigData));
-}
-
-bool ShmConfigHandler::Create() {
- if(shm_unlink(shm_name_) != 0) {
- LOGD("failed to unlink(%s) %d", shm_name_, errno);
- } else {
- LOGD("success to unlink(%s)", shm_name_);
- }
-
- int fd = shm_open(shm_name_, O_CREAT|O_RDWR, 0664);
- if(fd == -1) {
- LOGE("failed to open(%s). errno(%d)", shm_name_, errno);
- return false;
- }
-
- if (fchmod(fd, 0666) != 0) {
- LOGE("Failed to change permission to 0666, %d", errno);
- return false;
- }
-
- size_t len = sizeof(ConfigData);
- LOGD("config_data len : %zu", len);
- LOGD("pthread_rwlock_t len : %zu", sizeof(pthread_rwlock_t));
- if(ftruncate(fd, len) != 0) {
- LOGE("failed to truncate (%d:%zu)", fd, len);
- close(fd);
- return false;
- }
-
- config_data_ = (ConfigData*)mmap(NULL, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- if(config_data_ == MAP_FAILED) {
- LOGE("failed to mmap(%s). errno(%d)", shm_name_, errno);
- if(ftruncate(fd, 0) != 0)
- LOGE("failed to truncate (%d:0)", fd);
-
- shm_unlink(shm_name_);
- close(fd);
- return false;
- }
- close(fd);
-
- pthread_rwlockattr_t attr;
- if (pthread_rwlockattr_init(&attr)) {
- LOGE("pthread_mutexattr_init fail");
- return false;
- }
-
- if (pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_SHARED)) {
- LOGE("pthread_mutexattr_setpshared fail");
- pthread_rwlockattr_destroy(&attr);
- return false;
- }
-
- if (pthread_rwlock_init(&config_data_->lock, &attr)) {
- LOGE("pthread_mutex_init fail");
- pthread_rwlockattr_destroy(&attr);
- return false;
- }
-
- if (pthread_rwlockattr_destroy(&attr)) {
- LOGE("pthread_rwlockattr_destroy fail");
- return false;
- }
-
- return true;
-}
-
-bool ShmConfigHandler::Load() {
- int fd = shm_open(shm_name_, O_RDWR, 0664);
- if(fd == -1) {
- LOGE("failed to open(%s). errno(%d)", shm_name_, errno);
- return false;
- }
-
- config_data_ = (ConfigData*)mmap(NULL, sizeof(ConfigData), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
- if(config_data_ == MAP_FAILED) {
- LOGE("failed to mmap(%s). errno(%d)", shm_name_, errno);
- close(fd);
- return false;
- }
- close(fd);
-
- return true;
-}
-
-int ShmConfigHandler::GetWriteLock() {
- if (has_lock_) {
- LOGD("This object already has lock");
- return 0;
- }
-
- timespec timeout {
- .tv_sec = 5,
- .tv_nsec = 0,
- };
-
- LOGD("try get write lock");
- int ret = pthread_rwlock_timedwrlock(&config_data_->lock, &timeout);
- if (ret != 0) {
- LOGE("Failed to get write lock, %d", ret);
- return ret;
- }
-
- has_lock_ = true;
- return 0;
-}
-
-int ShmConfigHandler::GetReadLock() {
- if (has_lock_) {
- LOGD("This object already has lock");
- return 0;
- }
-
- LOGD("try get read lock");
- int ret = pthread_rwlock_tryrdlock(&config_data_->lock);
- if (ret != 0) {
- LOGE("Failed to get read lock, %d", ret);
- return ret;
- }
-
- has_lock_ = true;
- return 0;
-}
-
-int ShmConfigHandler::Unlock() {
- if (!has_lock_) {
- LOGD("This object doesn't have a lock");
- return 0;
- }
- LOGD("try unlock");
- int ret = pthread_rwlock_unlock(&config_data_->lock);
- if (ret != 0) {
- LOGE("Failed to unlock, %d", ret);
- return ret;
- }
-
- has_lock_ = false;
- return ret;
-}
-
-size_t ShmConfigHandler::GetMemSize() const {
- return config_data_->mem_size;
-}
-
-size_t ShmConfigHandler::GetIndexMemSize() const {
- return config_data_->index_mem_size;
-}
-
-size_t ShmConfigHandler::GetKeyMemSize() const {
- return config_data_->key_mem_size;
-}
-
-void ShmConfigHandler::SetMemSize(size_t mem_size) {
- config_data_->mem_size = mem_size;
-}
-
-void ShmConfigHandler::SetIndexMemSize(size_t index_mem_size) {
- config_data_->index_mem_size = index_mem_size;
-}
-
-void ShmConfigHandler::SetKeyMemSize(size_t key_mem_size) {
- config_data_->key_mem_size = key_mem_size;
-}
-
-
-} // namespace shared_memory
-} // namespace pkgmgr_common
+++ /dev/null
-/*
- * 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.
- */
-
-#ifndef COMMON_SHM_CONFIG_HH_
-#define COMMON_SHM_CONFIG_HH_
-
-#include <pthread.h>
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <map>
-#include <string>
-
-namespace pkgmgr_common {
-namespace shared_memory {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-class EXPORT_API ShmNameProvider {
- public:
- static const char* PkgConfig(uid_t uid);
- static const char* PkgHandle(uid_t uid);
- static const char* PkgIndexs(uid_t uid);
- static const char* PkgKeys(uid_t uid);
- static const char* AppConfig(uid_t uid);
- static const char* AppHandle(uid_t uid);
- static const char* AppIndexs(uid_t uid);
- static const char* AppKeys(uid_t uid);
-
- private:
- ShmNameProvider() = delete;
- static inline std::map<uid_t, std::string> pkg_config_names_;
- static inline std::map<uid_t, std::string> pkg_handle_names_;
- static inline std::map<uid_t, std::string> pkg_indexs_names_;
- static inline std::map<uid_t, std::string> pkg_keys_names_;
- static inline std::map<uid_t, std::string> app_config_names_;
- static inline std::map<uid_t, std::string> app_handle_names_;
- static inline std::map<uid_t, std::string> app_indexs_names_;
- static inline std::map<uid_t, std::string> app_keys_names_;
-};
-
-class EXPORT_API ShmMapper {
- public:
- ShmMapper(const char* shm_name);
- virtual ~ShmMapper();
- uint8_t* GetPtr() const;
- size_t GetSize() const;
-
- protected:
- const char* shm_name_;
- size_t mem_size_;
- uint8_t* mem_ptr_;
-};
-
-class EXPORT_API ShmWriteMapper : public ShmMapper {
- public:
- ShmWriteMapper(const char* shm_name);
- ~ShmWriteMapper();
-
- bool Init(size_t mem_size);
- bool Resize(size_t mem_size);
-
- private:
- int fd_;
-};
-
-class EXPORT_API ShmReadMapper : public ShmMapper {
- public:
- ShmReadMapper(const char* shm_name);
- ~ShmReadMapper();
-
- bool Init();
- bool LoadAll(size_t mem_size);
- uint8_t* CopyPartial(size_t offset, size_t size);
-
- private:
- int fd_;
-};
-
-class EXPORT_API ShmConfigHandler {
- public:
- ShmConfigHandler(const char* shm_name) :
- config_data_(nullptr), has_lock_(false), shm_name_(shm_name) {}
- ~ShmConfigHandler();
-
- bool Create();
- bool Load();
- int GetWriteLock();
- int GetReadLock();
- int Unlock();
- size_t GetMemSize() const;
- size_t GetIndexMemSize() const;
- size_t GetKeyMemSize() const;
- void SetMemSize(size_t app_mem_size);
- void SetIndexMemSize(size_t app_index_mem_size);
- void SetKeyMemSize(size_t pkg_mem_size);
-
- private:
- struct ConfigData {
- pthread_rwlock_t lock;
- size_t mem_size;
- size_t index_mem_size;
- size_t key_mem_size;
- };
-
- ConfigData* config_data_;
- bool has_lock_;
- const char* shm_name_;
-};
-
-struct HandleMappingData {
- uint32_t key_index;
- uint32_t index;
- uint32_t len;
-};
-
-} // namespace shared_memory
-} // namespace pkgmgr_common
-
-#endif // COMMON_SHM_CONFIG_HH_
+++ /dev/null
-/*
- * Copyright (c) 2025 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.
- */
-
-#include "shm_pkg_reader.hh"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "utils/logging.hh"
-
-#include "pkgmgrinfo_private.h"
-#include "pkgmgrinfo_storage_status.h"
-#include "filter_checker/filter_checker_provider.hh"
-#include "manager/pkginfo_manager.h"
-
-
-
-
-#include <fstream>
-
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_INFO"
-
-namespace pkgmgr_common {
-namespace shared_memory {
-
-inline bool CheckMetadataFilter(const PkgInfoHandle* info,
- const std::unordered_map<std::string, std::string>& metadata_map) {
- for (auto node : info->GetMetadata()) {
- if (node.Key() != nullptr) {
- auto metadata = metadata_map.find(node.Key());
- if (metadata == metadata_map.end())
- continue;
-
- if (metadata->second.empty() ||
- strcmp(node.Value() ? node.Value() : "", metadata->second.c_str()) == 0)
- return true;
- }
- }
- return false;
-}
-
-inline bool CheckPkgFilters(pkgmgrinfo_filter_x* filter,
- const PkgInfoHandle* info,
- const std::unordered_map<std::string, std::string>& metadata_map) {
- for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
- auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
- auto* checker = FilterCheckerProvider::GetInst().
- GetPkgFilterChecker(node->prop);
- if (!checker->CheckFilter(node->value, info))
- return false;
- }
-
- bool pass = true;
- if (!metadata_map.empty())
- pass = CheckMetadataFilter(info, metadata_map);
-
- return pass;
-}
-
-int ShmPkgReader::GetHandles(pkgmgrinfo_filter_x* filter,
- std::map<std::string, PkgInfoHandle>& list) {
- FilterChecker filter_checker;
- if (!filter_checker.Init(filter)) {
- LOG(ERROR) << "Failted to initialize filter checker";
- return PMINFO_R_ERROR;
- }
-
- if (filter_checker.PkgIdFilterValue()) {
- for (auto& reader : readers_) {
- int result;
- auto handle = reader.GetHandle(filter_checker.PkgIdFilterValue(), &result);
- if (!handle) {
- if (result == TIZEN_ERROR_NO_DATA)
- continue;
- else if (result != TIZEN_ERROR_NONE)
- return PMINFO_R_ERROR;
- } else {
- if (filter_checker.Check(*handle))
- list.emplace(handle->GetPackage(), std::move(*handle));
- break;
- }
- }
- } else {
- for (auto& reader : readers_) {
- int result;
- auto handles = reader.GetHandles(&result);
- if (!handles && result != TIZEN_ERROR_NONE)
- return PMINFO_R_ERROR;
-
- if (!handles)
- continue;
-
- for (auto& handle : *handles)
- if (filter_checker.Check(handle))
- list.emplace(handle.GetPackage(), std::move(handle));
- }
- }
-
- return PMINFO_R_OK;
-}
-
-std::optional<PkgInfoHandle> ShmPkgReader::GetHandle(const char* pkgid) {
- for (auto& reader : readers_) {
- if (!reader.Init()) {
- LOGE("reader.Init() fail");
- continue;
- }
- int result;
- auto handle = reader.GetHandle(pkgid, &result);
- if (handle)
- return handle;
- }
-
- return std::nullopt;
-}
-
-ShmPkgReader::ShmPkgReader(uid_t uid) {
- readers_.emplace_back(
- ShmNameProvider::PkgConfig(uid),
- ShmNameProvider::PkgHandle(uid),
- ShmNameProvider::PkgIndexs(uid),
- ShmNameProvider::PkgKeys(uid));
- if (uid > REGULAR_USER)
- readers_.emplace_back(
- ShmNameProvider::PkgConfig(GLOBAL_USER),
- ShmNameProvider::PkgHandle(GLOBAL_USER),
- ShmNameProvider::PkgIndexs(GLOBAL_USER),
- ShmNameProvider::PkgKeys(GLOBAL_USER));
-}
-
-bool ShmPkgReader::Init() {
- if (_is_writer()) {
- LOGD("process(%d) is writer", getpid());
- return false;
- }
-
- for (auto& reader : readers_) {
- if (!reader.Init()) {
- LOGE("Init reader fail");
- return false;
- }
- }
-
- return true;
-}
-
-bool ShmPkgReader::FilterChecker::Init(pkgmgrinfo_filter_x* filter) {
- for (auto* it = filter->list_pkg_metadata; it != nullptr;
- it = g_slist_next(it)) {
- auto node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(it->data);
- if (node->key == nullptr)
- continue;
-
- metadata_map_[node->key] = (node->value ? node->value : "");
- }
-
- for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
- auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
- if (node->prop == E_PMINFO_PKGINFO_PROP_PACKAGE_ID && node->value) {
- LOG(DEBUG) << "E_PMINFO_PKGINFO_PROP_PACKAGE_ID filter : " << node->value;
- pkgid_filter_ = node->value;
- break;
- }
- }
-
- if (CheckPackageStorageStatus(filter)) {
- if (pkgmgrinfo_pkginfo_filter_add_bool(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE, true) != PMINFO_R_OK) {
- LOG(ERROR) << "Fail to add check storage value to filter";
- return false;
- }
- }
-
- for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
- auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
- filter_checker_.emplace_back(std::make_pair(FilterCheckerProvider::GetInst().
- GetPkgFilterChecker(node->prop), node->value));
- }
-
- return true;
-}
-
-bool ShmPkgReader::FilterChecker::Check(const PkgInfoHandle& handle) {
- if (!metadata_map_.empty() && !CheckMetadataFilter(&handle, metadata_map_))
- return false;
-
- for (auto [checker, value] : filter_checker_)
- if (!checker->CheckFilter(value, &handle))
- return false;
-
- return true;
-}
-
-const char* ShmPkgReader::FilterChecker::PkgIdFilterValue() {
- return pkgid_filter_;
-}
-
-} // namespace shared_memory
-} // namespace pkgmgr_common
+++ /dev/null
-#ifndef COMMON_SHM_PKG_READER_HH_
-#define COMMON_SHM_PKG_READER_HH_
-
-#include <optional>
-#include <vector>
-
-#include "pkg_filter_checker_base.hh"
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgrinfo_private.h"
-#include "shm_config.hh"
-#include "shm_reader.hh"
-
-namespace pkgmgr_common {
-namespace shared_memory {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-class EXPORT_API ShmPkgReader {
- public:
- ShmPkgReader(uid_t uid);
-
- bool Init();
- int GetHandles(pkgmgrinfo_filter_x* filter,
- std::map<std::string, PkgInfoHandle>& list);
- std::optional<PkgInfoHandle> GetHandle(const char* pkgid);
-
- private:
- class EXPORT_API FilterChecker {
- public:
- bool Init(pkgmgrinfo_filter_x* filter);
- bool Check(const PkgInfoHandle& handle);
- const char* PkgIdFilterValue();
-
- private:
- const char* pkgid_filter_ = nullptr;
- std::unordered_map<std::string, std::string> metadata_map_;
- std::vector<std::pair<IPkgFilterChecker*, const char*>> filter_checker_;
- };
-
- private:
- std::vector<ShmReader<PkgInfoHandle>> readers_;
-};
-
-} // namespace shared_memory
-} // namespace pkgmgr_common
-
-#endif // COMMON_SHM_PKG_READER_HH_
+++ /dev/null
-/*
- * Copyright (c) 2025 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.
- */
-
-#include "shm_reader.hh"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-#include "utils/logging.hh"
-
-#include "pkgmgrinfo_storage_status.h"
-#include "filter_checker/filter_checker_provider.hh"
-#include "manager/pkginfo_manager.h"
-
-#include <fstream>
-
-#undef LOG_TAG
-#define LOG_TAG "PKGMGR_INFO"
-
-namespace pkgmgr_common {
-namespace shared_memory {
-
-template<typename T>
-bool ShmReader<T>::Init() {
- if (!config_handler_.Load()) {
- LOGE("Failed to load config handler");
- return false;
- }
-
- int ret = config_handler_.GetReadLock();
- if (ret != 0) {
- LOGE("Fail to get read lock, %d", ret);
- return false;
- }
-
- auto indexs = ReadIndexs();
- if (!indexs) {
- LOGE("Failed to get pkg indexs");
- return false;
- }
-
- mapping_data_ = std::move(*indexs);
-
- return true;
-}
-
-template<typename T>
-std::optional<std::vector<T>> ShmReader<T>::GetHandles(int* result) {
- return ReadHandles(result);
-}
-
-template<typename T>
-std::optional<T> ShmReader<T>::GetHandle(const char* key, int* result) {
- int index = FindIndex(key, result);
- if (index < 0)
- return std::nullopt;
-
- auto handle = ReadHandle(mapping_data_[index].index, mapping_data_[index].len);
- if (!handle) {
- LOGE("Failed to read app");
- *result = TIZEN_ERROR_IO_ERROR;
- return std::nullopt;
- }
-
- *result = TIZEN_ERROR_NONE;
- return std::move(*handle);
-}
-
-template<typename T>
-std::optional<std::vector<T>> ShmReader<T>::ReadHandles(int* result) {
- if (!result)
- return std::nullopt;
- *result = TIZEN_ERROR_NONE;
-
- auto indexs = ReadIndexs();
- if (!indexs) {
- LOGE("Failed to get app indexs");
- *result = TIZEN_ERROR_IO_ERROR;
- return std::nullopt;
- }
-
- if (indexs->empty()) {
- LOGD("The app doesn't exist");
- return std::vector<T>{};
- }
-
- if(!handle_mapper_.Init()) {
- *result = TIZEN_ERROR_IO_ERROR;
- return std::nullopt;
- }
-
- size_t mapping_len = GetMemSize();
- if(!handle_mapper_.LoadAll(mapping_len)) {
- *result = TIZEN_ERROR_IO_ERROR;
- return std::nullopt;
- }
-
- std::vector<T> handles;
- uint8_t* ptr = handle_mapper_.GetPtr();
- for (const auto& mapping : *indexs)
- handles.emplace_back(std::make_unique<tizen_base::Parcel>(ptr + mapping.index, mapping.len, true));
-
- return handles;
-}
-
-template<typename T>
-std::optional<T> ShmReader<T>::ReadHandle(
- uint32_t index, uint32_t len) {
- if (mapping_data_.empty()) {
- LOGD("The handle doesn't exist");
- return std::nullopt;
- }
-
- if(!handle_mapper_.Init()) {
- return std::nullopt;
- }
-
- uint8_t* ptr = handle_mapper_.CopyPartial(index, len);
- if (ptr == nullptr) {
- return std::nullopt;
- }
-
- return T(std::make_unique<tizen_base::Parcel>(ptr, len, false));
-}
-
-template<typename T>
-std::optional<std::vector<HandleMappingData>> ShmReader<T>::ReadIndexs() {
- size_t indexs_len = GetIndexMemSize();
- if (indexs_len == 0) {
- LOGD("Empty index");
- return std::vector<HandleMappingData>{};
- }
-
- if (indexs_len % sizeof(HandleMappingData) != 0) {
- LOGE("Invalid app indexs size : %zu", indexs_len);
- return std::nullopt;
- }
- int index_count = indexs_len / sizeof(HandleMappingData);
-
- if(!index_mapper_.Init()) {
- return std::nullopt;
- }
-
- if(!index_mapper_.LoadAll(indexs_len)) {
- return std::nullopt;
- }
-
- std::vector<HandleMappingData> result;
- auto ptr = (HandleMappingData*)index_mapper_.GetPtr();
- while(index_count--) {
- result.emplace_back(HandleMappingData {
- .key_index = ptr->key_index,
- .index = ptr->index,
- .len = ptr->len
- });
- ptr++;
- }
-
- return result;
-}
-
-template<typename T>
-int ShmReader<T>::FindIndex(const char* key, int* result) {
- if (mapping_data_.empty()) {
- LOGD("The pkg doesn't exist");
- *result = TIZEN_ERROR_NO_DATA;
- return -1;
- }
-
- if(!key_mapper_.Init()) {
- *result = TIZEN_ERROR_IO_ERROR;
- return -1;
- }
-
- size_t mapping_len = GetKeyMemSize();
- if(!key_mapper_.LoadAll(mapping_len)) {
- *result = TIZEN_ERROR_IO_ERROR;
- return -1;
- }
-
- std::vector<const char*> keys;
- const char* ptr = reinterpret_cast<const char*>(key_mapper_.GetPtr());
- for (const auto& mapping : mapping_data_)
- keys.emplace_back(ptr + mapping.key_index);
-
- int l = 0;
- int r = keys.size();
- int index = -1;
-
- while (l < r) {
- int mid = (l + r) / 2;
- int result = strcmp(key, keys[mid]);
- if (result == 0) {
- index = mid;
- break;
- } else if (result < 0) {
- r = mid;
- } else {
- l = mid+1;
- }
- }
-
- *result = TIZEN_ERROR_NONE;
- return index;
-}
-
-template<typename T>
-size_t ShmReader<T>::GetMemSize() const {
- return config_handler_.GetMemSize();
-}
-
-template<typename T>
-size_t ShmReader<T>::GetIndexMemSize() const {
- return config_handler_.GetIndexMemSize();
-}
-
-template<typename T>
-size_t ShmReader<T>::GetKeyMemSize() const {
- return config_handler_.GetKeyMemSize();
-}
-
-} // namespace shared_memory
-} // namespace pkgmgr_common
+++ /dev/null
-#ifndef COMMON_SHM_READER_HH_
-#define COMMON_SHM_READER_HH_
-
-#include <optional>
-#include <vector>
-
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgrinfo_private.h"
-#include "shm_config.hh"
-
-namespace pkgmgr_common {
-namespace shared_memory {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-template<typename T>
-class EXPORT_API ShmReader {
- public:
- ShmReader(const char* config_shm_name,
- const char* handle_shm_name, const char* index_shm_name,
- const char* key_shm_name) :
- config_handler_(config_shm_name),
- handle_mapper_(handle_shm_name),
- index_mapper_(index_shm_name),
- key_mapper_(key_shm_name) {}
- bool Init();
- std::optional<std::vector<T>> GetHandles(int* result);
- std::optional<T> GetHandle(const char* key, int* result);
-
- private:
- std::optional<std::vector<HandleMappingData>> ReadIndexs();
- std::optional<std::vector<T>> ReadHandles(int* result);
- std::optional<T> ReadHandle(uint32_t index, uint32_t len);
- int FindIndex(const char* key, int* result);
- size_t GetMemSize() const;
- size_t GetIndexMemSize() const;
- size_t GetKeyMemSize() const;
-
- protected:
- std::vector<HandleMappingData> mapping_data_;
- ShmConfigHandler config_handler_;
- ShmReadMapper handle_mapper_;
- ShmReadMapper index_mapper_;
- ShmReadMapper key_mapper_;
-};
-
-template class ShmReader<PkgInfoHandle>;
-template class ShmReader<AppInfoHandle>;
-
-} // namespace shared_memory
-} // namespace pkgmgr_common
-
-#endif // COMMON_SHM_READER_HH_
#include "pkgmgr_query_index.h"
#include "client/pkginfo_client.hh"
-#include "common/pkgmgr_info_handle.hh"
#include "common/parcel/appinfo_parcelable.hh"
#include "common/parcel/certinfo_parcelable.hh"
#include "common/parcel/command_parcelable.hh"
#include "common/parcel/pkginfo_parcelable.hh"
#include "common/parcel/query_parcelable.hh"
#include "common/parcel/result_parcelable.hh"
-#include "common/parcel/ro_appinfo_parcelable.hh"
-#include "common/parcel/ro_pkginfo_parcelable.hh"
-#include "common/shared_memory/shm_pkg_reader.hh"
#include "utils/logging.hh"
#include "pkg_write_type.hh"
#define EXPORT_API __attribute__((visibility("default")))
namespace pcp = pkgmgr_common::parcel;
-namespace pc = pkgmgr_common;
namespace {
-static int is_writer_ = 0;
-
int ValidateParcelable(
std::shared_ptr<pcp::AbstractParcelable> parcel,
pcp::ParcelableType parcel_type) {
} // namespace
extern "C" EXPORT_API int _pkginfo_get_packages(uid_t uid,
- pkgmgrinfo_filter_x* filter, int flag, void *packages) {
- auto list = reinterpret_cast<std::map<std::string, pc::PkgInfoHandle>*>(packages);
+ pkgmgrinfo_filter_x* filter, int flag, GHashTable* packages) {
std::shared_ptr<pcp::AbstractParcelable> parcelable(
new pcp::FilterParcelable(uid,
static_cast<pkgmgrinfo_filter_x*>(filter), flag, false));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::GET_PKG_INFO);
if (!client.SendRequest())
return PMINFO_R_ERROR;
return ptr->GetRequestResult();
}
- if (ptr->GetType() != pcp::ParcelableType::ROPkgInfo) {
+ if (ptr->GetType() != pcp::ParcelableType::PkgInfo) {
LOG(ERROR) << "Invalid parcelable type";
return PMINFO_R_ERROR;
}
- std::shared_ptr<pcp::ROPkgInfoParcelable> return_parcel(
- std::static_pointer_cast<pcp::ROPkgInfoParcelable>(
+ std::shared_ptr<pcp::PkgInfoParcelable> return_parcel(
+ std::static_pointer_cast<pcp::PkgInfoParcelable>(
ptr));
auto result_list = return_parcel->ExtractPkgInfo();
return PMINFO_R_ENOENT;
}
for (auto& pkginfo : result_list)
- list->emplace(pkginfo.GetPackage(), std::move(pkginfo));
+ g_hash_table_insert(packages, reinterpret_cast<gpointer>(pkginfo->package),
+ reinterpret_cast<gpointer>(pkginfo.get()));
return PMINFO_R_OK;
}
std::shared_ptr<pcp::AbstractParcelable> parcelable(
new pcp::DepInfoParcelable(std::string(pkgid)));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::GET_PKG_DEP_INFO);
if (!client.SendRequest())
return PMINFO_R_ERROR;
return PMINFO_R_OK;
}
-int _appinfo_get_applications(uid_t uid,
- pkgmgrinfo_filter_x *filter, int flag, void *applications) {
- auto list = reinterpret_cast<std::map<std::string, pc::AppInfoHandle>*>(applications);
+extern "C" EXPORT_API int _appinfo_get_applications(uid_t uid,
+ pkgmgrinfo_filter_x* filter, int flag, GHashTable* packages) {
std::shared_ptr<pcp::AbstractParcelable> parcelable(
new pcp::FilterParcelable(uid,
static_cast<pkgmgrinfo_filter_x*>(filter), flag, false));
pkgmgr_client::PkgInfoClient client(
- std::move(parcelable), uid, pkgmgr_common::ReqType::GET_APP_INFO);
+ parcelable, uid, pkgmgr_common::ReqType::GET_APP_INFO);
if (!client.SendRequest())
return PMINFO_R_ERROR;
return ret;
}
- if (ptr->GetType() != pcp::ParcelableType::ROAppInfo) {
+ if (ptr->GetType() != pcp::ParcelableType::AppInfo) {
LOG(ERROR) << "Invalid parcelable type";
return PMINFO_R_ERROR;
}
- std::shared_ptr<pcp::ROAppInfoParcelable> return_parcel(
- std::static_pointer_cast<pcp::ROAppInfoParcelable>(ptr));
+ std::shared_ptr<pcp::AppInfoParcelable> return_parcel(
+ std::static_pointer_cast<pcp::AppInfoParcelable>(ptr));
- auto result_list = return_parcel->ExtractAppInfo();
+ std::vector<std::shared_ptr<application_x>> result_list = return_parcel->ExtractAppInfo();
for (auto& app : result_list)
- list->emplace(app.GetAppId(), std::move(app));
+ g_hash_table_insert(packages, reinterpret_cast<gpointer>(app->appid),
+ reinterpret_cast<gpointer>(app.get()));
return PMINFO_R_OK;
}
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return nullptr;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), _getuid(),
+ pkgmgr_client::PkgInfoClient client(parcelable, _getuid(),
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::WRITE_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
{ QUERY_INDEX_CERTINFO_COMPARE_PKG_CERTINFO, { l_pkgid, r_pkgid } },
pkgmgr_common::DBType::DB_TYPE_FILE_CERTDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), 0,
+ pkgmgr_client::PkgInfoClient client(parcelable, 0,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
{ QUERY_INDEX_CERTINFO_COMPARE_APP_CERTINFO, { l_appid, r_appid } },
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_READ));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::READ_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::WRITE_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::WRITE_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
std::shared_ptr<package_x>(mfx, [] (package_x*) -> void {})),
pkgmgr_common::PkgWriteType::Insert, false);
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::SET_PKG_INFO);
if (!client.SendRequest())
return PMINFO_R_ERROR;
- int ret = ValidateParcelable(
+ return ValidateParcelable(
client.GetResultParcel(), pcp::ParcelableType::Result);
- if (ret == PMINFO_R_OK)
- is_writer_ = 1;
-
- return ret;
}
extern "C" EXPORT_API int _parser_update_manifest_info(
std::shared_ptr<package_x>(mfx, [] (package_x*) -> void {})),
pkgmgr_common::PkgWriteType::Update, false);
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::SET_PKG_INFO);
if (!client.SendRequest())
return PMINFO_R_ERROR;
- int ret = ValidateParcelable(
+ return ValidateParcelable(
client.GetResultParcel(), pcp::ParcelableType::Result);
- if (ret == PMINFO_R_OK)
- is_writer_ = 1;
-
- return ret;
}
extern "C" EXPORT_API int _parser_delete_manifest_info(
std::shared_ptr<package_x>(mfx, [] (package_x*) -> void {})),
pkgmgr_common::PkgWriteType::Delete, false);
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::SET_PKG_INFO);
if (!client.SendRequest())
return PMINFO_R_ERROR;
- int ret = ValidateParcelable(
+ return ValidateParcelable(
client.GetResultParcel(), pcp::ParcelableType::Result);
- if (ret == PMINFO_R_OK)
- is_writer_ = 1;
-
- return ret;
}
extern "C" EXPORT_API int _pkginfo_insert_certinfo(const char* pkgid,
pkgmgr_certinfo_x* cert, uid_t uid) {
std::shared_ptr<pcp::AbstractParcelable> parcelable(
new pcp::CertInfoParcelable(uid, cert, false));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::SET_CERT_INFO);
if (!client.SendRequest())
new pcp::CertInfoParcelable(uid,
std::string(pkgid)));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), uid,
+ pkgmgr_client::PkgInfoClient client(parcelable, uid,
pkgmgr_common::ReqType::GET_CERT_INFO);
if (!client.SendRequest())
return PMINFO_R_ERROR;
pkgmgr_common::DBType::DB_TYPE_FILE_CERTDB,
pkgmgr_common::DBOperationType::OPERATION_TYPE_WRITE));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), 0,
+ pkgmgr_client::PkgInfoClient client(parcelable, 0,
pkgmgr_common::ReqType::WRITE_QUERY);
if (!client.SendRequest())
return PMINFO_R_ERROR;
new pcp::CommandParcelable(_getuid(),
CommandType::UpdatePendingCache, { pkgid }));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), _getuid(),
+ pkgmgr_client::PkgInfoClient client(parcelable, _getuid(),
pkgmgr_common::ReqType::COMMAND);
- is_writer_ = 0;
if (!client.SendRequest())
return PMINFO_R_ERROR;
std::shared_ptr<pcp::AbstractParcelable> parcelable(
new pcp::CreateDBParcelable(uid));
- pkgmgr_client::PkgInfoClient client(std::move(parcelable), _getuid(),
+ pkgmgr_client::PkgInfoClient client(parcelable, _getuid(),
pkgmgr_common::ReqType::CREATE_DB);
if (!client.SendRequest())
return PMINFO_R_OK;
}
-extern "C" EXPORT_API int _is_writer() {
- return is_writer_;
+extern "C" EXPORT_API int _write_package_to_parcel(
+ package_x *info, parcel_h parcel) {
+ auto parcelable =
+ std::make_shared<pcp::PkgInfoParcelable>(
+ 0,
+ std::vector<std::shared_ptr<package_x>>(1,
+ std::shared_ptr<package_x>(info, [] (package_x*) -> void {})),
+ false);
+
+ tizen_base::Parcel p;
+ p.WriteParcelable(*parcelable.get());
+
+ if (parcel_write_uint32(parcel, p.GetDataSize()) != PARCEL_ERROR_NONE) {
+ LOG(ERROR) << "Failed to write data size";
+ return PMINFO_R_ERROR;
+ }
+
+ if (parcel_burst_write(parcel, p.GetData(),
+ p.GetDataSize()) != PARCEL_ERROR_NONE) {
+ LOG(ERROR) << "Failed to write data";
+ return PMINFO_R_ERROR;
+ }
+
+ return PMINFO_R_OK;
+}
+
+extern "C" EXPORT_API int _read_package_from_parcel(
+ parcel_h parcel, package_x **info) {
+ int ret;
+ uint32_t data_size;
+ unsigned char* buf;
+
+ if (parcel_read_uint32(parcel, &data_size) != PARCEL_ERROR_NONE) {
+ LOG(ERROR) << "Failed to read data size";
+ return PMINFO_R_ERROR;
+ }
+
+ buf = reinterpret_cast<unsigned char*>(malloc(data_size));
+ if (buf == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ if (parcel_burst_read(parcel, buf, data_size) != PARCEL_ERROR_NONE) {
+ LOG(ERROR) << "Failed to read data";
+ free(buf);
+ return PMINFO_R_ERROR;
+ }
+
+ auto abstract_parcelable =
+ pcp::ParcelableFactory::GetInst().CreateParcel(buf, data_size, false);
+
+ if (abstract_parcelable == nullptr ||
+ abstract_parcelable->GetType() != pcp::ParcelableType::PkgInfo) {
+ LOG(ERROR) << "Invalid parcel or type";
+ return PMINFO_R_ERROR;
+ }
+
+ auto* pkginfo_parcelable = dynamic_cast<pcp::PkgInfoParcelable*>(abstract_parcelable.get());
+ if (pkginfo_parcelable == nullptr) {
+ LOG(ERROR) << "Parcel is empty";
+ return PMINFO_R_ERROR;
+ }
+
+ auto pkginfo = pkginfo_parcelable->ExtractPkgInfo();
+ if (pkginfo.size() != 1) {
+ LOG(ERROR) << "invalid size of packages";
+ for (auto& pkg : pkginfo)
+ pkgmgrinfo_basic_free_package(pkg.get());
+ return PMINFO_R_ERROR;
+ }
+
+ *info = pkginfo[0].get();
+
+ return PMINFO_R_OK;
+}
+
+extern "C" EXPORT_API int _write_application_to_parcel(
+ application_x *info, parcel_h parcel) {
+ auto parcelable =
+ std::make_shared<pcp::AppInfoParcelable>(
+ 0,
+ std::vector<std::shared_ptr<application_x>>(1,
+ std::shared_ptr<application_x>(info, [] (application_x*) -> void {})));
+
+ tizen_base::Parcel p;
+ p.WriteParcelable(*parcelable.get());
+
+ if (parcel_write_uint32(parcel, p.GetDataSize()) != PARCEL_ERROR_NONE) {
+ LOG(ERROR) << "Failed to write data size";
+ return PMINFO_R_ERROR;
+ }
+
+ if (parcel_burst_write(parcel, p.GetData(),
+ p.GetDataSize()) != PARCEL_ERROR_NONE) {
+ LOG(ERROR) << "Failed to write data";
+ return PMINFO_R_ERROR;
+ }
+
+ return PMINFO_R_OK;
+}
+
+extern "C" EXPORT_API int _read_application_from_parcel(
+ parcel_h parcel, application_x **info) {
+ int ret;
+ uint32_t data_size;
+ unsigned char* buf;
+
+ if (parcel_read_uint32(parcel, &data_size) != PARCEL_ERROR_NONE) {
+ LOG(ERROR) << "Failed to read data size";
+ return PMINFO_R_ERROR;
+ }
+
+ buf = reinterpret_cast<unsigned char*>(malloc(data_size));
+ if (buf == nullptr) {
+ LOG(ERROR) << "Out of memory";
+ return PMINFO_R_ERROR;
+ }
+
+ if (parcel_burst_read(parcel, buf, data_size) != PARCEL_ERROR_NONE) {
+ LOG(ERROR) << "Failed to read data";
+ free(buf);
+ return PMINFO_R_ERROR;
+ }
+
+ auto abstract_parcelable =
+ pcp::ParcelableFactory::GetInst().CreateParcel(buf, data_size, false);
+
+ if (abstract_parcelable == nullptr ||
+ abstract_parcelable->GetType() != pcp::ParcelableType::AppInfo) {
+ LOG(ERROR) << "Invalid parcel or type";
+ return PMINFO_R_ERROR;
+ }
+
+ auto* appinfo_parcelable = dynamic_cast<pcp::AppInfoParcelable*>(abstract_parcelable.get());
+ if (appinfo_parcelable == nullptr) {
+ LOG(ERROR) << "Parcel is empty";
+ return PMINFO_R_ERROR;
+ }
+
+ auto appinfo = appinfo_parcelable->ExtractAppInfo();
+ if (appinfo.size() != 1) {
+ LOG(ERROR) << "invalid size of apps";
+ for (auto& app : appinfo)
+ pkgmgrinfo_basic_free_application(app.get());
+ return PMINFO_R_ERROR;
+ }
+
+ *info = appinfo[0].get();
+
+ return PMINFO_R_OK;
}
#endif
int _pkginfo_get_packages(uid_t uid,
- pkgmgrinfo_filter_x *filter, int flag, void *packages);
+ pkgmgrinfo_filter_x *filter, int flag, GHashTable *packages);
int _pkginfo_get_depends_on(uid_t uid,
const char *pkgid, GList **dependencies);
int _appinfo_get_applications(uid_t uid,
- pkgmgrinfo_filter_x *filter, int flag, void *applications);
+ pkgmgrinfo_filter_x *filter, int flag, GHashTable *packages);
char *_appinfo_get_localed_label(const char *appid, const char *locale,
uid_t uid);
int _parser_create_and_initialize_db(uid_t uid);
-int _is_writer();
+int _write_package_to_parcel(package_x *info, parcel_h parcel);
+
+int _read_package_from_parcel(parcel_h parcel, package_x **info);
+
+int _write_application_to_parcel(application_x *info, parcel_h parcel);
+
+int _read_application_from_parcel(parcel_h parcel, application_x **info);
#ifdef __cplusplus
}
--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <dlfcn.h>
+
+#include <glib.h>
+
+#include "pkgmgr-info.h"
+#include "pkgmgrinfo_debug.h"
+#include "pkgmgrinfo_extension.h"
+#include "pkgmgrinfo_private.h"
+#include "pkgmgr_parser.h"
+#include "manager/pkginfo_manager.h"
+
+static bool _get_bool_value(const char *str)
+{
+ if (str && !strcmp(str, "true"))
+ return true;
+ else
+ return false;
+}
+
+static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
+{
+ pkgmgr_appinfo_x *info = data;
+
+ if (info != NULL) {
+ if (info->package)
+ free((void *)info->package);
+ if (info->locale)
+ free((void *)info->locale);
+
+ pkgmgrinfo_basic_free_application(info->app_info);
+ free((void *)info);
+ }
+}
+
+static void __free_applications(gpointer data)
+{
+ pkgmgrinfo_basic_free_application((application_x *)data);
+}
+
+static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
+{
+ pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
+ pkgmgrinfo_appinfo_disable_type value = GPOINTER_TO_INT(data2);
+
+ if (value == E_APPINFO_DISABLE_TYPE_PKG)
+ return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
+ ? 0 : 1;
+ else
+ return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
+ ? 0 : 1;
+}
+
+static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
+ pkgmgrinfo_appinfo_disable_type type)
+{
+ GSList *link;
+
+ if (filter == NULL)
+ return false;
+
+ link = g_slist_find_custom(filter->list,
+ GINT_TO_POINTER(type), __disable_chk_func);
+ if (link)
+ return true;
+
+ return false;
+}
+
+static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
+ pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
+{
+ int ret = PMINFO_R_OK;
+ GHashTable *list;
+ pkgmgr_appinfo_x *info;
+
+ if (appid == NULL || filter == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ __free_applications);
+ if (list == NULL)
+ return PMINFO_R_ERROR;
+
+ ret = _appinfo_get_applications(uid, filter,
+ PMINFO_APPINFO_GET_ALL, list);
+ if (ret != PMINFO_R_OK) {
+ g_hash_table_destroy(list);
+ return ret;
+ }
+
+ if (!g_hash_table_size(list) || !g_hash_table_lookup(list, appid) ||
+ ((application_x *)g_hash_table_lookup(list, appid))->package == NULL) {
+ _LOGD("appinfo for [%s] is not existed for user [%d]",
+ appid, uid);
+ g_hash_table_destroy(list);
+ return PMINFO_R_ENOENT;
+ }
+
+ info = calloc(1, sizeof(pkgmgr_appinfo_x));
+ if (info == NULL) {
+ _LOGE("out of memory");
+ g_hash_table_destroy(list);
+ return PMINFO_R_ERROR;
+ }
+
+ info->app_info = (application_x *)g_hash_table_lookup(list, appid);
+ info->locale = strdup(info->app_info->locale);
+ if (!info->locale) {
+ _LOGE("out of memory");
+ g_hash_table_destroy(list);
+ free(info);
+ return PMINFO_R_ERROR;
+ }
+ info->package = strdup(info->app_info->package);
+ if (!info->package) {
+ _LOGE("out of memory");
+ free(info->locale);
+ g_hash_table_destroy(list);
+ free(info);
+ return PMINFO_R_ERROR;
+ }
+
+ /* just free list only */
+ g_hash_table_steal(list, (gconstpointer)appid);
+ g_hash_table_destroy(list);
+
+ *handle = info;
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
+ const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
+{
+ int ret;
+ pkgmgrinfo_appinfo_filter_h filter;
+
+ if (appid == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ ret = pkgmgrinfo_appinfo_filter_add_string(filter,
+ PMINFO_APPINFO_PROP_APP_ID, appid);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_DISABLE, true);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_disabled_appinfo(
+ const char *appid, pkgmgrinfo_appinfo_h *handle)
+{
+ return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
+ appid, _getuid(), handle);
+}
+
+static char *__get_real_appid(const char *appid)
+{
+ char *str;
+ char *saveptr;
+ char *token;
+
+ str = strdup(appid);
+ if (str == NULL)
+ return NULL;
+
+ token = strtok_r(str, "::", &saveptr);
+ if (token == NULL)
+ return str;
+
+ LOGD("Real appid = %s", token);
+ token = strdup(token);
+ free(str);
+ return token;
+}
+
+API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
+ pkgmgrinfo_appinfo_h *handle)
+{
+ int ret;
+ pkgmgrinfo_appinfo_filter_h filter;
+ char *real_appid;
+
+ if (appid == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ real_appid = __get_real_appid(appid);
+ if (real_appid == NULL) {
+ LOGE("Out of memory");
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_add_string(filter,
+ PMINFO_APPINFO_PROP_APP_ID, real_appid);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ free(real_appid);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_DISABLE, false);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ free(real_appid);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_PKG_DISABLE, false);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ free(real_appid);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _pkgmgrinfo_get_appinfo(real_appid, uid, filter, handle);
+ free(real_appid);
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_appinfo(
+ const char *appid, pkgmgrinfo_appinfo_h *handle)
+{
+ return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
+}
+
+API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
+ pkgmgrinfo_appinfo_h *handle)
+{
+ int ret;
+ pkgmgrinfo_appinfo_filter_h filter;
+
+ if (appid == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ ret = pkgmgrinfo_appinfo_filter_add_string(filter,
+ PMINFO_APPINFO_PROP_APP_ID, appid);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_all_appinfo(
+ const char *appid, pkgmgrinfo_appinfo_h *handle)
+{
+ return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
+}
+
+static gpointer __copy_str(gconstpointer src, gpointer data)
+{
+ const char *tmp = (const char *)src;
+ char *buffer;
+
+ buffer = strdup(tmp);
+ if (buffer == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ return buffer;
+}
+
+static gpointer __copy_label(gconstpointer src, gpointer data)
+{
+ label_x *tmp = (label_x *)src;
+ label_x *label;
+
+ label = calloc(1, sizeof(label_x));
+ if (label == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->name)
+ label->name = strdup(tmp->name);
+ if (tmp->text)
+ label->text = strdup(tmp->text);
+ if (tmp->lang)
+ label->lang = strdup(tmp->lang);
+
+ return label;
+}
+
+static gpointer __copy_icon(gconstpointer src, gpointer data)
+{
+ icon_x *tmp = (icon_x *)src;
+ icon_x *icon;
+
+ icon = calloc(1, sizeof(icon_x));
+ if (icon == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->text)
+ icon->text = strdup(tmp->text);
+ if (tmp->lang)
+ icon->lang = strdup(tmp->lang);
+ if (tmp->section)
+ icon->section = strdup(tmp->section);
+ if (tmp->size)
+ icon->size = strdup(tmp->size);
+ if (tmp->resolution)
+ icon->resolution = strdup(tmp->resolution);
+
+ return icon;
+}
+
+static gpointer __copy_metadata(gconstpointer src, gpointer data)
+{
+ metadata_x *tmp = (metadata_x *)src;
+ metadata_x *metadata;
+
+ metadata = calloc(1, sizeof(metadata_x));
+ if (metadata == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->key)
+ metadata->key = strdup(tmp->key);
+ if (tmp->value)
+ metadata->value = strdup(tmp->value);
+
+ return metadata;
+}
+
+static gpointer __copy_datacontrol(gconstpointer src, gpointer data)
+{
+ datacontrol_x *tmp = (datacontrol_x *)src;
+ datacontrol_x *datacontrol;
+
+ datacontrol = calloc(1, sizeof(datacontrol_x));
+ if (datacontrol == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->providerid)
+ datacontrol->providerid = strdup(tmp->providerid);
+ if (tmp->access)
+ datacontrol->access = strdup(tmp->access);
+ if (tmp->type)
+ datacontrol->type = strdup(tmp->type);
+ if (tmp->trusted)
+ datacontrol->trusted = strdup(tmp->trusted);
+
+ return datacontrol;
+}
+
+static gpointer __copy_appcontrol(gconstpointer src, gpointer data)
+{
+ appcontrol_x *tmp = (appcontrol_x *)src;
+ appcontrol_x *appcontrol;
+
+ appcontrol = calloc(1, sizeof(appcontrol_x));
+ if (appcontrol == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->operation)
+ appcontrol->operation = strdup(tmp->operation);
+ if (tmp->uri)
+ appcontrol->uri = strdup(tmp->uri);
+ if (tmp->mime)
+ appcontrol->mime = strdup(tmp->mime);
+
+ return appcontrol;
+}
+
+static gpointer __copy_splashscreens(gconstpointer src, gpointer data)
+{
+ splashscreen_x *tmp = (splashscreen_x *)src;
+ splashscreen_x *splashscreen;
+
+ splashscreen = (splashscreen_x *)calloc(1, sizeof(splashscreen_x));
+ if (splashscreen == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->src)
+ splashscreen->src = strdup(tmp->src);
+ if (tmp->type)
+ splashscreen->type = strdup(tmp->type);
+ if (tmp->orientation)
+ splashscreen->orientation = strdup(tmp->orientation);
+ if (tmp->indicatordisplay)
+ splashscreen->indicatordisplay = strdup(tmp->indicatordisplay);
+ if (tmp->operation)
+ splashscreen->operation = strdup(tmp->operation);
+ if (tmp->color_depth)
+ splashscreen->color_depth = strdup(tmp->color_depth);
+
+ return splashscreen;
+}
+
+static gpointer __copy_res_control(gconstpointer src, gpointer data)
+{
+ res_control_x *tmp = (res_control_x *)src;
+ res_control_x *res_control;
+
+ res_control = (res_control_x *)calloc(1, sizeof(res_control_x));
+ if (res_control == NULL) {
+ LOGE("memory alloc failed");
+ *(int *)data = -1;
+ return NULL;
+ }
+
+ if (tmp->res_type)
+ res_control->res_type = strdup(tmp->res_type);
+ if (tmp->min_res_version)
+ res_control->min_res_version = strdup(tmp->min_res_version);
+ if (tmp->max_res_version)
+ res_control->max_res_version = strdup(tmp->max_res_version);
+ if (tmp->auto_close)
+ res_control->auto_close = strdup(tmp->auto_close);
+
+ return res_control;
+}
+
+static int _appinfo_copy_appinfo(
+ application_x **application, application_x *data)
+{
+ application_x *app_info;
+ int ret;
+
+ app_info = calloc(1, sizeof(application_x));
+ if (app_info == NULL) {
+ LOGE("memory alloc failed");
+ return PMINFO_R_ERROR;
+ }
+
+ if (data->appid != NULL)
+ app_info->appid = strdup(data->appid);
+ if (data->exec != NULL)
+ app_info->exec = strdup(data->exec);
+ if (data->nodisplay != NULL)
+ app_info->nodisplay = strdup(data->nodisplay);
+ if (data->multiple != NULL)
+ app_info->multiple = strdup(data->multiple);
+ if (data->taskmanage != NULL)
+ app_info->taskmanage = strdup(data->taskmanage);
+ if (data->type != NULL)
+ app_info->type = strdup(data->type);
+ if (data->categories != NULL)
+ app_info->categories = strdup(data->categories);
+ if (data->hwacceleration != NULL)
+ app_info->hwacceleration = strdup(data->hwacceleration);
+ if (data->screenreader != NULL)
+ app_info->screenreader = strdup(data->screenreader);
+ if (data->mainapp != NULL)
+ app_info->mainapp = strdup(data->mainapp);
+ if (data->package != NULL)
+ app_info->package = strdup(data->package);
+ if (data->recentimage != NULL)
+ app_info->recentimage = strdup(data->recentimage);
+ if (data->launchcondition != NULL)
+ app_info->launchcondition = strdup(data->launchcondition);
+ if (data->indicatordisplay != NULL)
+ app_info->indicatordisplay = strdup(data->indicatordisplay);
+ if (data->portraitimg != NULL)
+ app_info->portraitimg = strdup(data->portraitimg);
+ if (data->landscapeimg != NULL)
+ app_info->landscapeimg = strdup(data->landscapeimg);
+ if (data->guestmode_visibility != NULL)
+ app_info->guestmode_visibility =
+ strdup(data->guestmode_visibility);
+ if (data->component != NULL)
+ app_info->component = strdup(data->component);
+ if (data->permission_type != NULL)
+ app_info->permission_type = strdup(data->permission_type);
+ if (data->component_type != NULL)
+ app_info->component_type = strdup(data->component_type);
+ if (data->preload != NULL)
+ app_info->preload = strdup(data->preload);
+ if (data->submode != NULL)
+ app_info->submode = strdup(data->submode);
+ if (data->submode_mainid != NULL)
+ app_info->submode_mainid = strdup(data->submode_mainid);
+ if (data->process_pool != NULL)
+ app_info->process_pool = strdup(data->process_pool);
+ if (data->installed_storage != NULL)
+ app_info->installed_storage = strdup(data->installed_storage);
+ if (data->autorestart != NULL)
+ app_info->autorestart = strdup(data->autorestart);
+ if (data->onboot != NULL)
+ app_info->onboot = strdup(data->onboot);
+ if (data->support_disable != NULL)
+ app_info->support_disable = strdup(data->support_disable);
+ if (data->ui_gadget != NULL)
+ app_info->ui_gadget = strdup(data->ui_gadget);
+ if (data->launch_mode != NULL)
+ app_info->launch_mode = strdup(data->launch_mode);
+ if (data->package_type != NULL)
+ app_info->package_type = strdup(data->package_type);
+ if (data->effective_appid != NULL)
+ app_info->effective_appid = strdup(data->effective_appid);
+ if (data->splash_screen_display != NULL)
+ app_info->splash_screen_display =
+ strdup(data->splash_screen_display);
+
+ /* GList */
+ ret = 0;
+ app_info->label = g_list_copy_deep(data->label, __copy_label, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->icon = g_list_copy_deep(data->icon, __copy_icon, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->category = g_list_copy_deep(data->category, __copy_str, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->metadata = g_list_copy_deep(data->metadata,
+ __copy_metadata, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->datacontrol = g_list_copy_deep(data->datacontrol,
+ __copy_datacontrol, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->appcontrol = g_list_copy_deep(data->appcontrol,
+ __copy_appcontrol, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->background_category =
+ g_list_copy_deep(data->background_category,
+ __copy_str, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->splashscreens = g_list_copy_deep(data->splashscreens,
+ __copy_splashscreens, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = 0;
+ app_info->res_control = g_list_copy_deep(data->res_control, __copy_res_control, &ret);
+ if (ret < 0) {
+ LOGE("memory alloc failed");
+ pkgmgrinfo_basic_free_application(app_info);
+ return PMINFO_R_ERROR;
+ }
+
+ *application = app_info;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_appinfo_h *clone)
+{
+ pkgmgr_appinfo_x *info;
+ pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL)
+ return PMINFO_R_EINVAL;
+
+ info = calloc(1, sizeof(pkgmgr_appinfo_x));
+ if (info == NULL) {
+ LOGE("memory alloc failed");
+ return PMINFO_R_ERROR;
+ }
+
+ if (temp->package != NULL)
+ info->package = strdup(temp->package);
+ if (temp->locale != NULL)
+ info->locale = strdup(temp->locale);
+
+ info->app_component = temp->app_component;
+
+ if (_appinfo_copy_appinfo(&info->app_info, temp->app_info) < 0) {
+ LOGE("appinfo copy failed");
+ if (info->package)
+ free((void *)info->package);
+ if (info->locale)
+ free(info->locale);
+ free(info);
+ return PMINFO_R_ERROR;
+ }
+
+ *clone = info;
+
+ return PMINFO_R_OK;
+}
+
+static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
+ pkgmgrinfo_filter_x *filter, int flag,
+ pkgmgrinfo_app_list_cb app_list_cb,
+ void *user_data)
+{
+ application_x *app;
+ pkgmgr_appinfo_x info;
+ GHashTable *list;
+ GHashTableIter iter;
+ gpointer value;
+ int ret;
+
+ list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ __free_applications);
+ if (list == NULL)
+ return PMINFO_R_ERROR;
+
+ ret = _appinfo_get_applications(uid, filter,
+ flag | PMINFO_APPINFO_GET_BASICINFO, list);
+ if (ret == PMINFO_R_ERROR) {
+ g_hash_table_destroy(list);
+ return ret;
+ }
+
+ g_hash_table_iter_init(&iter, list);
+ while (g_hash_table_iter_next(&iter, NULL, &value)) {
+ app = (application_x *)value;
+ info.app_info = app;
+ info.locale = info.app_info->locale;
+ info.package = app->package;
+ if (app_list_cb(&info, user_data) < 0)
+ break;
+ }
+ g_hash_table_destroy(list);
+
+ return PMINFO_R_OK;
+}
+
+static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
+
+API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_app_component component,
+ pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
+{
+ int ret;
+ pkgmgrinfo_appinfo_filter_h filter;
+ char *pkgid;
+ const char *comp_str = NULL;
+
+ if (handle == NULL || app_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (pkgmgrinfo_appinfo_filter_create(&filter))
+ return PMINFO_R_ERROR;
+
+ if (pkgmgrinfo_appinfo_filter_add_string(filter,
+ PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ comp_str = __appcomponent_str(component);
+
+ if (comp_str) {
+ if (pkgmgrinfo_appinfo_filter_add_string(filter,
+ PMINFO_APPINFO_PROP_APP_COMPONENT,
+ comp_str)) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
+ PMINFO_APPINFO_GET_ALL, app_func, user_data);
+
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_app_component component,
+ pkgmgrinfo_app_list_cb app_func, void *user_data)
+{
+ return pkgmgrinfo_appinfo_get_usr_list(handle,
+ component, app_func, user_data, _getuid());
+}
+
+API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
+ pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
+ void *user_data)
+{
+ int ret;
+ pkgmgrinfo_appinfo_filter_h filter;
+
+ if (app_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (pkgmgrinfo_appinfo_filter_create(&filter))
+ return PMINFO_R_ERROR;
+
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _appinfo_get_filtered_foreach_appinfo(uid, filter, flag, app_func,
+ user_data);
+
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_installed_list_full(
+ pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
+{
+ return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
+ _getuid(), flag, user_data);
+}
+
+API int pkgmgrinfo_appinfo_get_usr_installed_list(
+ pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
+{
+ int ret;
+ pkgmgrinfo_appinfo_filter_h filter;
+
+ if (app_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ /* create an empty filter */
+ ret = pkgmgrinfo_appinfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _appinfo_get_filtered_foreach_appinfo(uid, filter,
+ PMINFO_APPINFO_GET_ALL, app_func, user_data);
+
+ pkgmgrinfo_appinfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
+ void *user_data)
+{
+ return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
+ user_data);
+}
+
+API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appid == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL || info->app_info->appid == NULL)
+ return PMINFO_R_ERROR;
+ *appid = (char *)info->app_info->appid;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_pkgname(
+ pkgmgrinfo_appinfo_h handle, char **pkg_name)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->package == NULL)
+ return PMINFO_R_ERROR;
+
+ *pkg_name = (char *)info->package;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->package == NULL)
+ return PMINFO_R_ERROR;
+
+ *pkgid = (char *)info->package;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_pkgtype(
+ pkgmgrinfo_appinfo_h handle, char **pkgtype)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ *pkgtype = (char *)info->app_info->package_type;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(exec == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL || info->app_info->exec == NULL)
+ return PMINFO_R_ERROR;
+ *exec = (char *)info->app_info->exec;
+
+ return PMINFO_R_OK;
+}
+
+
+API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
+{
+ icon_x *ptr;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(icon == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->app_info->icon == NULL) {
+ *icon = "";
+ return PMINFO_R_OK;
+ }
+
+ ptr = (icon_x *)info->app_info->icon->data;
+ if (ptr == NULL)
+ return PMINFO_R_ERROR;
+
+ if (ptr->text == NULL)
+ return PMINFO_R_ERROR;
+ else
+ *icon = ptr->text;
+
+ return PMINFO_R_OK;
+}
+
+
+API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
+{
+ label_x *ptr;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ char *lbl = NULL;
+ const char *locale;
+ GList *tmp;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(label == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ locale = info->locale;
+ if (locale == NULL)
+ locale = DEFAULT_LOCALE;
+
+ for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
+ ptr = (label_x *)tmp->data;
+ if (ptr == NULL || strcmp(locale, ptr->lang) != 0)
+ continue;
+ lbl = ptr->text;
+ break;
+ }
+
+ if (lbl != NULL) {
+ *label = lbl;
+ return PMINFO_R_OK;
+ }
+
+ for (tmp = info->app_info->label; tmp; tmp = tmp->next) {
+ ptr = (label_x *)tmp->data;
+ if (ptr == NULL || strcmp(DEFAULT_LOCALE, ptr->lang) != 0)
+ continue;
+ lbl = ptr->text;
+ break;
+ }
+
+ *label = lbl ? lbl : "";
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
+ const char *locale, uid_t uid, char **label)
+{
+ char *val;
+
+ retvm_if(appid == NULL || locale == NULL || label == NULL,
+ PMINFO_R_EINVAL, "Argument is NULL");
+ val = _appinfo_get_localed_label(appid, locale, uid);
+ if (val == NULL)
+ return PMINFO_R_ERROR;
+
+ *label = val;
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_localed_label(
+ const char *appid, const char *locale, char **label)
+{
+ return pkgmgrinfo_appinfo_usr_get_localed_label(
+ appid, locale, _getuid(), label);
+}
+
+API int pkgmgrinfo_appinfo_get_metadata_value(
+ pkgmgrinfo_appinfo_h handle, const char *metadata_key,
+ char **metadata_value)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
+ retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
+ "metadata_value is NULL");
+
+ GList *list_md = NULL;
+ metadata_x *metadata = NULL;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ list_md = info->app_info->metadata;
+
+ for (; list_md; list_md = list_md->next) {
+ metadata = (metadata_x *)list_md->data;
+ if (metadata && metadata->key) {
+ if (strcasecmp(metadata->key, metadata_key) == 0) {
+ if (metadata->value == NULL)
+ *metadata_value = "";
+ else
+ *metadata_value =
+ (char *)metadata->value;
+ return PMINFO_R_OK;
+ }
+ }
+ }
+
+ return PMINFO_R_EINVAL;
+}
+
+static pkgmgrinfo_app_component __appcomponent_convert(const char *comp)
+{
+ if (strcasecmp(comp, "uiapp") == 0)
+ return PMINFO_UI_APP;
+ else if (strcasecmp(comp, "svcapp") == 0)
+ return PMINFO_SVC_APP;
+ else if (strcasecmp(comp, "widgetapp") == 0)
+ return PMINFO_WIDGET_APP;
+ else if (strcasecmp(comp, "watchapp") == 0)
+ return PMINFO_WATCH_APP;
+ else if (strcasecmp(comp, "componentbasedapp") == 0)
+ return PMINFO_COMPONENT_BASED_APP;
+ else
+ return -1;
+}
+
+static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
+{
+ switch (comp) {
+ case PMINFO_UI_APP:
+ return "uiapp";
+ case PMINFO_SVC_APP:
+ return "svcapp";
+ case PMINFO_WIDGET_APP:
+ return "widgetapp";
+ case PMINFO_WATCH_APP:
+ return "watchapp";
+ case PMINFO_COMPONENT_BASED_APP:
+ return "componentbasedapp";
+ default:
+ return NULL;
+ }
+}
+
+API int pkgmgrinfo_appinfo_get_component(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_component *component)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ int comp;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(component == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ comp = __appcomponent_convert(info->app_info->component);
+ if (comp < 0)
+ return PMINFO_R_ERROR;
+
+ *component = comp;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_apptype(
+ pkgmgrinfo_appinfo_h handle, char **app_type)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(app_type == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL || info->app_info->type == NULL)
+ return PMINFO_R_ERROR;
+ *app_type = (char *)info->app_info->type;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_notification_icon(
+ pkgmgrinfo_appinfo_h handle, char **icon)
+{
+ char *val;
+ icon_x *ptr;
+ GList *tmp;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(icon == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->icon; tmp; tmp = tmp->next) {
+ ptr = (icon_x *)tmp->data;
+ if (ptr == NULL || ptr->section == NULL)
+ continue;
+
+ val = (char *)ptr->section;
+ if (val && strcmp(val, "notification") == 0) {
+ *icon = (char *)ptr->text;
+ return PMINFO_R_OK;
+ }
+ }
+
+ return PMINFO_R_ERROR;
+}
+
+API int pkgmgrinfo_appinfo_get_recent_image_type(
+ pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
+{
+ char *val;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(type == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL || info->app_info->recentimage == NULL)
+ return PMINFO_R_ERROR;
+
+ val = (char *)info->app_info->recentimage;
+ if (strcasecmp(val, "capture") == 0)
+ *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
+ else if (strcasecmp(val, "icon") == 0)
+ *type = PMINFO_RECENTIMAGE_USE_ICON;
+ else
+ *type = PMINFO_RECENTIMAGE_USE_NOTHING;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_preview_image(
+ pkgmgrinfo_appinfo_h handle, char **preview_img)
+{
+ char *val;
+ image_x *ptr;
+ GList *tmp;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->image; tmp; tmp = tmp->next) {
+ ptr = (image_x *)tmp->data;
+ if (ptr == NULL || ptr->section == NULL)
+ continue;
+
+ val = (char *)ptr->section;
+ if (val && strcmp(val, "preview") == 0) {
+ *preview_img = (char *)ptr->text;
+ return PMINFO_R_OK;
+ }
+ }
+
+ return PMINFO_R_ERROR;
+}
+
+API int pkgmgrinfo_appinfo_get_permission_type(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_permission_type *permission)
+{
+ const char *val;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(permission == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ val = info->app_info->permission_type;
+ if (val == NULL)
+ return PMINFO_R_ERROR;
+
+ if (strcmp(val, "signature") == 0)
+ *permission = PMINFO_PERMISSION_SIGNATURE;
+ else if (strcmp(val, "privilege") == 0)
+ *permission = PMINFO_PERMISSION_PRIVILEGE;
+ else
+ *permission = PMINFO_PERMISSION_NORMAL;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_component_type(
+ pkgmgrinfo_appinfo_h handle, char **component_type)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(component_type == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL || info->app_info->component_type == NULL)
+ return PMINFO_R_ERROR;
+
+ *component_type = (char *)info->app_info->component_type;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_hwacceleration(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_hwacceleration *hwacceleration)
+{
+ char *val;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL || info->app_info->hwacceleration == NULL)
+ return PMINFO_R_ERROR;
+
+ val = (char *)info->app_info->hwacceleration;
+ if (strcasecmp(val, "off") == 0)
+ *hwacceleration = PMINFO_HWACCELERATION_OFF;
+ else if (strcasecmp(val, "on") == 0)
+ *hwacceleration = PMINFO_HWACCELERATION_ON;
+ else
+ *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_screenreader(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_screenreader *screenreader)
+{
+ char *val;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL || info->app_info->screenreader == NULL)
+ return PMINFO_R_ERROR;
+
+ val = (char *)info->app_info->screenreader;
+ if (strcasecmp(val, "screenreader-off") == 0)
+ *screenreader = PMINFO_SCREENREADER_OFF;
+ else if (strcasecmp(val, "screenreader-on") == 0)
+ *screenreader = PMINFO_SCREENREADER_ON;
+ else
+ *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_effectimage(
+ pkgmgrinfo_appinfo_h handle, char **portrait_img,
+ char **landscape_img)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->app_info->portraitimg == NULL)
+ *portrait_img = "";
+ else
+ *portrait_img = (char *)info->app_info->portraitimg;
+
+ if (info->app_info->landscapeimg == NULL)
+ *landscape_img = "";
+ else
+ *landscape_img = (char *)info->app_info->landscapeimg;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_effectimage_type(
+ pkgmgrinfo_appinfo_h handle, char **effectimage_type)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || effectimage_type == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->effectimage_type == NULL)
+ return PMINFO_R_ERROR;
+
+ *effectimage_type = (char *)info->app_info->effectimage_type;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_submode_mainid(
+ pkgmgrinfo_appinfo_h handle, char **submode_mainid)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->app_info->submode_mainid == NULL)
+ *submode_mainid = "";
+ else
+ *submode_mainid = (char *)info->app_info->submode_mainid;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_installed_storage_location(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_installed_storage *storage)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info && info->app_info->installed_storage) {
+ if (strcmp(info->app_info->installed_storage,
+ "installed_internal") == 0)
+ *storage = PMINFO_INTERNAL_STORAGE;
+ else if (strcmp(info->app_info->installed_storage,
+ "installed_external") == 0)
+ *storage = PMINFO_EXTERNAL_STORAGE;
+ else
+ return PMINFO_R_ERROR;
+ } else {
+ return PMINFO_R_ERROR;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_launch_mode(
+ pkgmgrinfo_appinfo_h handle, char **mode)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(mode == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ if (info->app_info->launch_mode == NULL)
+ return PMINFO_R_ERROR;
+
+ *mode = (char *)(info->app_info->launch_mode);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_alias_appid(
+ pkgmgrinfo_appinfo_h handle, char **alias_appid)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || alias_appid == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->alias_appid == NULL)
+ return PMINFO_R_ERROR;
+
+ *alias_appid = (char *)info->app_info->alias_appid;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_effective_appid(
+ pkgmgrinfo_appinfo_h handle, char **effective_appid)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || effective_appid == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->app_info->effective_appid == NULL)
+ *effective_appid = "";
+ else
+ *effective_appid = (char *)info->app_info->effective_appid;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_tep_name(
+ pkgmgrinfo_appinfo_h handle, char **tep_name)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || tep_name == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->app_info->tep_name == NULL)
+ *tep_name = "";
+ else
+ *tep_name = (char *)info->app_info->tep_name;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_zip_mount_file(
+ pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || zip_mount_file == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->app_info->zip_mount_file == NULL)
+ *zip_mount_file = "";
+ else
+ *zip_mount_file = (char *)info->app_info->zip_mount_file;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_root_path(
+ pkgmgrinfo_appinfo_h handle, char **root_path)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || root_path == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->root_path == NULL)
+ return PMINFO_R_ERROR;
+
+ *root_path = (char *)info->app_info->root_path;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_api_version(
+ pkgmgrinfo_appinfo_h handle, char **api_version)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || api_version == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->api_version == NULL)
+ return PMINFO_R_ERROR;
+
+ *api_version = (char *)info->app_info->api_version;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_installed_time(
+ pkgmgrinfo_appinfo_h handle, int *installed_time)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || installed_time == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL ||
+ info->app_info->package_installed_time == NULL)
+ return PMINFO_R_ERROR;
+
+ *installed_time = atoi(info->app_info->package_installed_time);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
+ const char *type, uid_t uid, char **appid, char **access)
+{
+ int ret;
+
+ if (providerid == NULL || type == NULL || appid == NULL ||
+ access == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = _appinfo_get_datacontrol_info(
+ providerid, type, uid, appid, access);
+ /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
+ * implementation, return PMINFO_R_ERROR. This should be
+ * modified later...
+ */
+ if (ret == PMINFO_R_ENOENT) {
+ LOGE("no datacontrol info of %s", providerid);
+ ret = PMINFO_R_ERROR;
+ }
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
+ const char *type, char **appid, char **access)
+{
+ return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
+ type, _getuid(), appid, access);
+}
+
+API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
+ uid_t uid, char **appid)
+{
+ int ret;
+
+ if (providerid == NULL || appid == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
+ /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
+ * implementation, return PMINFO_R_ERROR. This should be
+ * modified later...
+ */
+ if (ret == PMINFO_R_ENOENT) {
+ LOGE("no datacontrol appid of %s", providerid);
+ ret = PMINFO_R_ERROR;
+ }
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_datacontrol_appid(
+ const char *providerid, char **appid)
+{
+ return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
+ providerid, _getuid(), appid);
+}
+
+API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
+ const char *providerid, const char *type, uid_t uid,
+ char **appid, bool *is_trusted)
+{
+ int ret;
+ char *trusted = NULL;
+
+ if (providerid == NULL || type == NULL || appid == NULL ||
+ is_trusted == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
+ appid, &trusted);
+
+ /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
+ * implementation, return PMINFO_R_ERROR. This should be
+ * modified later...
+ */
+ if (ret == PMINFO_R_ENOENT) {
+ LOGE("no datacontrol trusted info of %s", providerid);
+ ret = PMINFO_R_ERROR;
+ }
+ *is_trusted = _get_bool_value(trusted);
+ free(trusted);
+
+ return ret;
+}
+
+API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
+ const char *type, char **appid, bool *is_trusted)
+{
+ return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
+ type, _getuid(), appid, is_trusted);
+}
+
+API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
+ const char *providerid, const char *type,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func,
+ void *user_data, uid_t uid)
+{
+ int ret;
+ int count = 0;
+ GList *list = NULL;
+ GList *tmp = NULL;
+
+ if (providerid == NULL || type == NULL || privilege_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
+ if (ret == PMINFO_R_ERROR) {
+ g_list_free_full(list, free);
+ return ret;
+ }
+
+ for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
+ count++;
+ ret = privilege_func((char *)tmp->data, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ g_list_free_full(list, free);
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
+ const char *providerid, const char *type,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func,
+ void *user_data)
+{
+ return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
+ providerid, type, privilege_func, user_data, _getuid());
+}
+
+API int pkgmgrinfo_appinfo_get_support_mode(
+ pkgmgrinfo_appinfo_h handle, int *support_mode)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info->support_mode)
+ *support_mode = atoi(info->app_info->support_mode);
+ else
+ *support_mode = 0;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_category_list_cb category_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(category_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret = -1;
+ const char *category;
+ GList *tmp;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
+ category = (const char *)tmp->data;
+ if (category) {
+ ret = category_func(category, user_data);
+ if (ret < 0)
+ break;
+ }
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret = -1;
+ metadata_x *ptr;
+ GList *tmp;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->metadata; tmp; tmp = tmp->next) {
+ ptr = (metadata_x *)tmp->data;
+ if (ptr == NULL)
+ continue;
+ if (ptr->key) {
+ ret = metadata_func(ptr->key, ptr->value ?
+ ptr->value : "", user_data);
+ if (ret < 0)
+ break;
+ }
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
+ const char *operation,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func,
+ void *user_data, uid_t uid)
+{
+ int ret;
+ GList *privilege_list = NULL;
+ GList *tmp_list;
+
+ if (appid == NULL || operation == NULL || privilege_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
+ &privilege_list);
+ if (ret == PMINFO_R_ENOENT) {
+ return PMINFO_R_OK;
+ } else if (ret != PMINFO_R_OK) {
+ g_list_free_full(privilege_list, free);
+ return ret;
+ }
+
+ for (tmp_list = privilege_list; tmp_list != NULL;
+ tmp_list = g_list_next(tmp_list)) {
+ ret = privilege_func((char *)tmp_list->data, user_data);
+ if (ret != 0)
+ break;
+ }
+
+ g_list_free_full(privilege_list, free);
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
+ const char *operation,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func,
+ void *user_data)
+{
+ return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
+ operation, privilege_func, user_data, _getuid());
+}
+
+API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
+ GList *tmp;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+ appcontrol = (appcontrol_x *)tmp->data;
+ if (appcontrol == NULL || !strcasecmp(
+ appcontrol->visibility, "remote-only"))
+ continue;
+ ret = appcontrol_func(appcontrol->operation,
+ appcontrol->uri, appcontrol->mime, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
+ GList *tmp;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+ appcontrol = (appcontrol_x *)tmp->data;
+ if (appcontrol == NULL || !strcasecmp(
+ appcontrol->visibility, "local-only"))
+ continue;
+ ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
+ appcontrol->mime, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_background_category(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_background_category_list_cb category_func,
+ void *user_data)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ GList *tmp;
+ char *category;
+
+ if (handle == NULL || category_func == NULL || info->app_info == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ for (tmp = info->app_info->background_category; tmp; tmp = tmp->next) {
+ category = (char *)tmp->data;
+ if (category == NULL)
+ continue;
+
+ if (category_func(category, user_data) < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
+ void *user_data)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ splashscreen_x *splashscreen;
+ GList *tmp;
+ int ret;
+
+ if (info == NULL || info->app_info == NULL
+ || splash_screen_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ for (tmp = info->app_info->splashscreens; tmp; tmp = tmp->next) {
+ splashscreen = (splashscreen_x *)tmp->data;
+ if (splashscreen == NULL)
+ continue;
+ ret = splash_screen_func(splashscreen->src,
+ splashscreen->type,
+ splashscreen->orientation,
+ splashscreen->indicatordisplay,
+ splashscreen->operation,
+ splashscreen->color_depth,
+ user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_res_control_list_cb res_control_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(res_control_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret = -1;
+ res_control_x *res_control;
+ GList *tmp;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->res_control; tmp; tmp = tmp->next) {
+ res_control = (res_control_x *)tmp->data;
+ if (res_control == NULL)
+ continue;
+ ret = res_control_func(res_control->res_type,
+ res_control->min_res_version,
+ res_control->max_res_version,
+ res_control->auto_close,
+ user_data);
+ if (ret < 0)
+ break;
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_nodisplay(
+ pkgmgrinfo_appinfo_h handle, bool *nodisplay)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->nodisplay == NULL)
+ return PMINFO_R_ERROR;
+
+ *nodisplay = _get_bool_value(info->app_info->nodisplay);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_multiple(
+ pkgmgrinfo_appinfo_h handle, bool *multiple)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(multiple == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->multiple == NULL)
+ return PMINFO_R_ERROR;
+
+ *multiple = _get_bool_value(info->app_info->multiple);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
+ pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->indicatordisplay == NULL)
+ return PMINFO_R_ERROR;
+
+ *indicator_disp = _get_bool_value(info->app_info->indicatordisplay);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_taskmanage(
+ pkgmgrinfo_appinfo_h handle, bool *taskmanage)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->taskmanage == NULL)
+ return PMINFO_R_ERROR;
+
+ *taskmanage = _get_bool_value(info->app_info->taskmanage);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_enabled(
+ pkgmgrinfo_appinfo_h handle, bool *enabled)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(enabled == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->is_disabled == NULL)
+ return PMINFO_R_ERROR;
+
+ *enabled = !_get_bool_value(info->app_info->is_disabled);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_onboot(
+ pkgmgrinfo_appinfo_h handle, bool *onboot)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(onboot == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->onboot == NULL)
+ return PMINFO_R_ERROR;
+
+ *onboot = _get_bool_value(info->app_info->onboot);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_autorestart(
+ pkgmgrinfo_appinfo_h handle, bool *autorestart)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->autorestart == NULL)
+ return PMINFO_R_ERROR;
+
+ *autorestart = _get_bool_value(info->app_info->autorestart);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_mainapp(
+ pkgmgrinfo_appinfo_h handle, bool *mainapp)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->mainapp == NULL)
+ return PMINFO_R_ERROR;
+
+ *mainapp = _get_bool_value(info->app_info->mainapp);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_preload(
+ pkgmgrinfo_appinfo_h handle, bool *preload)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(preload == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->preload == NULL)
+ return PMINFO_R_ERROR;
+
+ *preload = _get_bool_value(info->app_info->preload);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_submode(
+ pkgmgrinfo_appinfo_h handle, bool *submode)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(submode == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->submode == NULL)
+ return PMINFO_R_ERROR;
+
+ *submode = _get_bool_value(info->app_info->submode);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_process_pool(
+ pkgmgrinfo_appinfo_h handle, bool *process_pool)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (handle == NULL || process_pool == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ *process_pool = _get_bool_value(info->app_info->process_pool);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_category_exist(
+ pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
+ retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
+
+ const char *val;
+ GList *tmp;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ *exist = 0;
+ for (tmp = info->app_info->category; tmp; tmp = tmp->next) {
+ val = (const char *)tmp->data;
+ if (val == NULL)
+ continue;
+ if (strcasecmp(val, category) == 0) {
+ *exist = 1;
+ break;
+ }
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
+ bool *ui_gadget)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+ if (info->app_info->ui_gadget == NULL)
+ info->app_info->ui_gadget = strdup("false");
+
+ *ui_gadget = _get_bool_value(info->app_info->ui_gadget);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
+ bool *support_disable)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || info->app_info == NULL || support_disable == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ *support_disable = _get_bool_value(info->app_info->support_disable);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
+ bool *removable)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || info->app_info == NULL || removable == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ *removable = _get_bool_value(info->app_info->removable);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || info->app_info == NULL || system == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ *system = _get_bool_value(info->app_info->package_system);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_disabled(
+ pkgmgrinfo_appinfo_h handle, bool *disabled)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(disabled == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info->app_info == NULL || info->app_info->is_disabled == NULL)
+ return PMINFO_R_ERROR;
+
+ *disabled = _get_bool_value(info->app_info->is_disabled);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(global == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ if (info->app_info == NULL || info->app_info->for_all_users == NULL)
+ return PMINFO_R_ERROR;
+
+ *global = _get_bool_value(info->app_info->for_all_users);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_splash_screen_display(
+ pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || splash_screen_display == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL ||
+ info->app_info->splash_screen_display == NULL)
+ return PMINFO_R_ERROR;
+
+ *splash_screen_display =
+ _get_bool_value(info->app_info->splash_screen_display);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_setup_appid(
+ pkgmgrinfo_appinfo_h handle, char **setup_appid)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || setup_appid == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->setup_appid == NULL)
+ return PMINFO_R_ERROR;
+
+ *setup_appid = info->app_info->setup_appid;
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
+ bool *support_ambient)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || support_ambient == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->support_ambient == NULL)
+ return PMINFO_R_ERROR;
+
+ *support_ambient = _get_bool_value(info->app_info->support_ambient);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_get_light_user_switch_mode(
+ pkgmgrinfo_appinfo_h handle, char **mode)
+{
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ if (info == NULL || mode == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->app_info == NULL || info->app_info->light_user_switch_mode == NULL)
+ return PMINFO_R_ERROR;
+
+ *mode = info->app_info->light_user_switch_mode;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ __cleanup_appinfo(info);
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
+{
+ return pkgmgrinfo_pkginfo_filter_create(handle);
+}
+
+API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
+{
+ return pkgmgrinfo_pkginfo_filter_destroy(handle);
+}
+
+static gint __compare_func(gconstpointer data1, gconstpointer data2)
+{
+ pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
+ pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
+
+ if (node1->prop == node2->prop)
+ return 0;
+ else if (node1->prop > node2->prop)
+ return 1;
+ else
+ return -1;
+}
+
+API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
+ const char *property, const int value)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL,
+ "Filter handle input parameter is NULL\n");
+ char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
+ char *val = NULL;
+ GSList *link = NULL;
+ int prop = -1;
+
+ prop = _pminfo_appinfo_convert_to_prop_int(property);
+ if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
+ prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
+ _LOGE("Invalid Integer Property\n");
+ return PMINFO_R_EINVAL;
+ }
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+ pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
+ sizeof(pkgmgrinfo_node_x));
+ if (node == NULL) {
+ _LOGE("Out of Memory!!!\n");
+ return PMINFO_R_ERROR;
+ }
+ snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
+ val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
+ if (val == NULL) {
+ _LOGE("Out of Memory\n");
+ free(node);
+ node = NULL;
+ return PMINFO_R_ERROR;
+ }
+ node->prop = prop;
+ node->value = val;
+
+ /*
+ * If API is called multiple times for same property,
+ * we should override the previous values.
+ * Last value set will be used for filtering.
+ */
+ link = g_slist_find_custom(filter->list,
+ (gconstpointer)node, __compare_func);
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
+ filter->list = g_slist_delete_link(filter->list, link);
+ }
+ filter->list = g_slist_append(filter->list, (gpointer)node);
+ return PMINFO_R_OK;
+
+}
+
+API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
+ const char *property, const bool value)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL,
+ "Filter handle input parameter is NULL\n");
+ char *val = NULL;
+ GSList *link = NULL;
+ int prop = -1;
+
+ prop = _pminfo_appinfo_convert_to_prop_bool(property);
+ if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
+ prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
+ _LOGE("Invalid Boolean Property\n");
+ return PMINFO_R_EINVAL;
+ }
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+ pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
+ sizeof(pkgmgrinfo_node_x));
+ if (node == NULL) {
+ _LOGE("Out of Memory!!!\n");
+ return PMINFO_R_ERROR;
+ }
+ if (value)
+ val = strndup("true", 4);
+ else
+ val = strndup("false", 5);
+ if (val == NULL) {
+ _LOGE("Out of Memory\n");
+ free(node);
+ node = NULL;
+ return PMINFO_R_ERROR;
+ }
+ node->prop = prop;
+ node->value = val;
+ /*
+ * If API is called multiple times for same property,
+ * we should override the previous values.
+ * Last value set will be used for filtering.
+ */
+ link = g_slist_find_custom(filter->list,
+ (gconstpointer)node, __compare_func);
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
+ filter->list = g_slist_delete_link(filter->list, link);
+ }
+ filter->list = g_slist_append(filter->list, (gpointer)node);
+ return PMINFO_R_OK;
+
+}
+
+API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
+ const char *property, const char *value)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL,
+ "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL,
+ "Filter handle input parameter is NULL\n");
+ retvm_if(value == NULL, PMINFO_R_EINVAL,
+ "Filter handle input parameter is NULL\n");
+ char *val = NULL;
+ pkgmgrinfo_node_x *ptr = NULL;
+ char prev[PKG_STRING_LEN_MAX] = {'\0'};
+ char temp[PKG_STRING_LEN_MAX] = {'\0'};
+ GSList *link = NULL;
+ int prop = -1;
+ int ret;
+
+ prop = _pminfo_appinfo_convert_to_prop_str(property);
+ if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
+ prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
+ _LOGE("Invalid String Property\n");
+ return PMINFO_R_EINVAL;
+ }
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+ pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
+ sizeof(pkgmgrinfo_node_x));
+ if (node == NULL) {
+ _LOGE("Out of Memory!!!\n");
+ return PMINFO_R_ERROR;
+ }
+ node->prop = prop;
+ switch (prop) {
+ case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
+ node->value = strdup(value);
+ link = g_slist_find_custom(filter->list,
+ (gconstpointer)node, __compare_func);
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
+ filter->list = g_slist_delete_link(filter->list, link);
+ }
+ filter->list = g_slist_append(filter->list, (gpointer)node);
+ break;
+ case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
+ val = (char *)calloc(1, PKG_STRING_LEN_MAX);
+ if (val == NULL) {
+ _LOGE("Out of Memory\n");
+ free(node);
+ node = NULL;
+ return PMINFO_R_ERROR;
+ }
+ link = g_slist_find_custom(filter->list,
+ (gconstpointer)node, __compare_func);
+ if (link) {
+ ptr = (pkgmgrinfo_node_x *)link->data;
+ strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
+ _LOGI("Previous value is %s\n", prev);
+ _pkgmgrinfo_node_destroy(ptr);
+ filter->list = g_slist_delete_link(filter->list, link);
+ ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
+ "%s,%s", prev, value);
+ if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
+ _LOGE("snprintf fail\n");
+ free(node);
+ free(val);
+ return PMINFO_R_ERROR;
+ }
+ strncpy(val, temp, PKG_STRING_LEN_MAX);
+ _LOGI("New value is %s\n", val);
+ node->value = val;
+ filter->list = g_slist_append(
+ filter->list, (gpointer)node);
+ memset(temp, '\0', PKG_STRING_LEN_MAX);
+ } else {
+ snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
+ strncpy(val, temp, PKG_STRING_LEN_MAX);
+ _LOGI("First value is %s\n", val);
+ node->value = val;
+ filter->list = g_slist_append(
+ filter->list, (gpointer)node);
+ memset(temp, '\0', PKG_STRING_LEN_MAX);
+ }
+ break;
+ default:
+ node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
+ link = g_slist_find_custom(filter->list,
+ (gconstpointer)node, __compare_func);
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
+ filter->list = g_slist_delete_link(filter->list, link);
+ }
+ filter->list = g_slist_append(filter->list, (gpointer)node);
+ break;
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_usr_filter_count(
+ pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
+{
+ GHashTable *list;
+ int ret;
+ int query_count;
+ pkgmgrinfo_filter_x *filter;
+
+ if (handle == NULL || count == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ filter = (pkgmgrinfo_filter_x *)handle;
+ list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ __free_applications);
+ if (list == NULL)
+ return PMINFO_R_ERROR;
+
+ if (__check_disable_filter_exist(
+ handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
+ if (pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
+ g_hash_table_destroy(list);
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ if (__check_disable_filter_exist(
+ handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
+ if (pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
+ g_hash_table_destroy(list);
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ ret = _appinfo_get_applications(uid, filter, 0, list);
+ query_count = g_hash_table_size(list);
+ g_hash_table_destroy(list);
+ if (ret == PMINFO_R_ERROR)
+ return ret;
+
+ *count = query_count;
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_filter_count(
+ pkgmgrinfo_appinfo_filter_h handle, int *count)
+{
+ return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
+}
+
+API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
+ pkgmgrinfo_appinfo_filter_h handle,
+ pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
+{
+ if (handle == NULL || app_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (__check_disable_filter_exist(
+ handle, E_APPINFO_DISABLE_TYPE_APP) == false) {
+ if (pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_APP_DISABLE, false))
+ return PMINFO_R_ERROR;
+ }
+
+ if (__check_disable_filter_exist(
+ handle, E_APPINFO_DISABLE_TYPE_PKG) == false) {
+ if (pkgmgrinfo_appinfo_filter_add_bool(handle,
+ PMINFO_APPINFO_PROP_PKG_DISABLE, false))
+ return PMINFO_R_ERROR;
+ }
+
+ return _appinfo_get_filtered_foreach_appinfo(uid,
+ handle, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
+}
+
+API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
+ pkgmgrinfo_appinfo_filter_h handle,
+ pkgmgrinfo_app_list_cb app_cb, void *user_data)
+{
+ return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
+ handle, app_cb, user_data, _getuid());
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_create(
+ pkgmgrinfo_appinfo_metadata_filter_h *handle)
+{
+ return pkgmgrinfo_pkginfo_filter_create(handle);
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_destroy(
+ pkgmgrinfo_appinfo_metadata_filter_h handle)
+{
+ return pkgmgrinfo_pkginfo_filter_destroy(handle);
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_add(
+ pkgmgrinfo_appinfo_metadata_filter_h handle,
+ const char *key, const char *value)
+{
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+ pkgmgrinfo_metadata_node_x *node;
+
+ /* value can be NULL.
+ * In that case all apps with specified key should be displayed
+ */
+ if (key == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
+ if (node == NULL) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ node->key = strdup(key);
+ if (value && strlen(value))
+ node->value = strdup(value);
+
+ filter->list_metadata = g_slist_append(filter->list_metadata,
+ (gpointer)node);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
+ pkgmgrinfo_appinfo_metadata_filter_h handle,
+ pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
+{
+ if (handle == NULL || app_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_DISABLE, false))
+ return PMINFO_R_ERROR;
+
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_PKG_DISABLE, false))
+ return PMINFO_R_ERROR;
+
+ return _appinfo_get_filtered_foreach_appinfo(uid, handle,
+ PMINFO_APPINFO_GET_ALL, app_cb,
+ user_data);
+}
+
+API int pkgmgrinfo_appinfo_metadata_filter_foreach(
+ pkgmgrinfo_appinfo_metadata_filter_h handle,
+ pkgmgrinfo_app_list_cb app_cb, void *user_data)
+{
+ return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
+ user_data, _getuid());
+}
+
+API int pkgmgrinfo_appinfo_is_guestmode_visibility(
+ pkgmgrinfo_appinfo_h handle, bool *status)
+{
+ const char *val;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
+ retvm_if(status == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ val = info->app_info->guestmode_visibility;
+ *status = _get_bool_value(val);
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL,
+ PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
+ GList *tmp;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+ appcontrol = (appcontrol_x *)tmp->data;
+ if (appcontrol == NULL ||
+ !strcasecmp(appcontrol->visibility,
+ "remote-only"))
+ continue;
+ ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
+ appcontrol->mime, appcontrol->id, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL,
+ PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
+ GList *tmp;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+ appcontrol = (appcontrol_x *)tmp->data;
+ if (appcontrol == NULL ||
+ !strcasecmp(appcontrol->visibility,
+ "local-only"))
+ continue;
+ ret = appcontrol_func(appcontrol->operation, appcontrol->uri,
+ appcontrol->mime, appcontrol->id, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_appcontrol_v3(pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v3 appcontrol_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL,
+ PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
+ GList *tmp;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+ appcontrol = (appcontrol_x *)tmp->data;
+ if (appcontrol == NULL ||
+ !strcasecmp(appcontrol->visibility,
+ "remote-only"))
+ continue;
+ ret = appcontrol_func(appcontrol, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v3(
+ pkgmgrinfo_appinfo_h handle,
+ pkgmgrinfo_app_control_list_cb_v3 appcontrol_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
+ retvm_if(appcontrol_func == NULL,
+ PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret;
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ appcontrol_x *appcontrol;
+ GList *tmp;
+
+ if (info->app_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->app_info->appcontrol; tmp; tmp = tmp->next) {
+ appcontrol = (appcontrol_x *)tmp->data;
+ if (appcontrol == NULL ||
+ !strcasecmp(appcontrol->visibility,
+ "local-only"))
+ continue;
+ ret = appcontrol_func(appcontrol, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_appcontrol_get_operation(
+ pkgmgrinfo_appinfo_app_control_h handle,
+ const char **operation) {
+ appcontrol_x *app_control = (appcontrol_x *)handle;
+
+ if (app_control == NULL || operation == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (app_control->operation == NULL)
+ return PMINFO_R_ENOENT;
+ *operation = app_control->operation;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_appcontrol_get_uri(
+ pkgmgrinfo_appinfo_app_control_h handle,
+ const char **uri) {
+ appcontrol_x *app_control = (appcontrol_x *)handle;
+
+ if (app_control == NULL || uri == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (app_control->uri == NULL)
+ return PMINFO_R_ENOENT;
+ *uri = app_control->uri;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_appcontrol_get_mime(
+ pkgmgrinfo_appinfo_app_control_h handle,
+ const char **mime) {
+ appcontrol_x *app_control = (appcontrol_x *)handle;
+
+ if (app_control == NULL || mime == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (app_control->mime == NULL)
+ return PMINFO_R_ENOENT;
+ *mime = app_control->mime;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_appcontrol_get_id(
+ pkgmgrinfo_appinfo_app_control_h handle,
+ const char **id) {
+ appcontrol_x *app_control = (appcontrol_x *)handle;
+
+ if (app_control == NULL || id == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (app_control->id == NULL)
+ return PMINFO_R_ENOENT;
+ *id = app_control->id;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_appcontrol_foreach_privilege(
+ pkgmgrinfo_appinfo_app_control_h handle,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func,
+ void *user_data) {
+ int ret;
+ GList *tmp_list;
+ appcontrol_x *app_control = (appcontrol_x *)handle;
+
+ if (app_control == NULL || privilege_func == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ for (tmp_list = app_control->privileges; tmp_list != NULL;
+ tmp_list = g_list_next(tmp_list)) {
+ ret = privilege_func((char *)tmp_list->data, user_data);
+ if (ret != 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_to_parcel(pkgmgrinfo_appinfo_h handle, parcel_h* parcel)
+{
+ parcel_h result = NULL;
+ int ret;
+
+ if (parcel_create(&result) != PARCEL_ERROR_NONE) {
+ _LOGE("parcel_create fail");
+ return PMINFO_R_ERROR;
+ }
+
+ pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
+ ret = _write_application_to_parcel(info->app_info, result);
+ if (ret != PMINFO_R_OK) {
+ _LOGE("_write_application_to_parcel fail, %d", ret);
+ parcel_destroy(result);
+ return ret;
+ }
+
+ ret = parcel_write_int32(result, (int32_t)info->app_component);
+ if (ret != PARCEL_ERROR_NONE) {
+ _LOGE("Failed to write uid");
+ parcel_destroy(result);
+ return PMINFO_R_ERROR;
+ }
+
+ *parcel = result;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_appinfo_from_parcel(parcel_h parcel, pkgmgrinfo_appinfo_h* handle)
+{
+ pkgmgr_appinfo_x *info;
+ application_x* app;
+ int ret;
+ int32_t app_component;
+
+ info = calloc(1, sizeof(pkgmgr_appinfo_x));
+ if (info == NULL) {
+ _LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _read_application_from_parcel(parcel, &info->app_info);
+ if (ret != PMINFO_R_OK) {
+ _LOGE("_read_application_from_parcel fail, %d", ret);
+ __cleanup_appinfo(info);
+ return ret;
+ }
+
+ info->locale = strdup(info->app_info->locale);
+ if (info->locale == NULL) {
+ _LOGE("Out of memory");
+ __cleanup_appinfo(info);
+ return PMINFO_R_ERROR;
+ }
+
+ info->package = strdup(info->app_info->package);
+ if (!info->package) {
+ _LOGE("out of memory");
+ __cleanup_appinfo(info);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = parcel_read_int32(parcel, &app_component);
+ if (ret != PARCEL_ERROR_NONE) {
+ _LOGE("Failed to read app component");
+ __cleanup_appinfo(info);
+ return PMINFO_R_ERROR;
+ }
+ info->app_component = app_component;
+
+ *handle = info;
+
+ return PMINFO_R_OK;
+}
+++ /dev/null
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdbool.h>
-#include <string.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <dlfcn.h>
-
-#include <glib.h>
-
-#include "pkgmgr-info.h"
-#include "pkgmgrinfo_debug.h"
-#include "pkgmgrinfo_private.h"
-#include "pkgmgrinfo_extension.h"
-#include "pkgmgr_parser.h"
-#include "manager/pkginfo_manager.h"
-#include "pkgmgr_info_handle.hh"
-#include "shared_memory/shm_app_reader.hh"
-
-#include "utils/logging.hh"
-
-#include <chrono>
-
-namespace pc = pkgmgr_common;
-namespace ps = pkgmgr_common::shared_memory;
-
-struct pkgmgr_appinfo_x {
- const char *package;
- const char *locale;
- pkgmgrinfo_app_component app_component;
- const pc::AppInfoHandle* app_info;
-};
-
-static bool _get_bool_value(const char *str)
-{
- if (str && !strcmp(str, "true"))
- return true;
- else
- return false;
-}
-
-static void __cleanup_appinfo(pkgmgr_appinfo_x *data)
-{
- pkgmgr_appinfo_x *info = data;
-
- if (info != NULL) {
- delete info->app_info;
- free((void *)info);
- }
-}
-
-static gint __disable_chk_func(gconstpointer data1, gconstpointer data2)
-{
- pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
- pkgmgrinfo_appinfo_disable_type value =
- static_cast<pkgmgrinfo_appinfo_disable_type>(GPOINTER_TO_INT(data2));
-
- if (value == E_APPINFO_DISABLE_TYPE_PKG)
- return (node->prop == E_PMINFO_APPINFO_PROP_PKG_DISABLE)
- ? 0 : 1;
- else
- return (node->prop == E_PMINFO_APPINFO_PROP_APP_DISABLE)
- ? 0 : 1;
-}
-
-static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter,
- pkgmgrinfo_appinfo_disable_type type)
-{
- GSList *link;
-
- if (filter == NULL)
- return false;
-
- link = g_slist_find_custom(filter->list,
- GINT_TO_POINTER(type), __disable_chk_func);
- if (link)
- return true;
-
- return false;
-}
-
-static int _pkgmgrinfo_get_appinfo(const char *appid, uid_t uid,
- pkgmgrinfo_appinfo_filter_h filter, pkgmgrinfo_appinfo_h *handle)
-{
- if (appid == NULL || filter == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- int ret = PMINFO_R_OK;
- ps::ShmAppReader reader(uid);
- std::map<std::string, pc::AppInfoHandle> list;
- pkgmgr_appinfo_x *info;
-
- if (reader.Init()) {
- ret = reader.GetHandles(reinterpret_cast<pkgmgrinfo_filter_x*>(filter), list);
- } else {
- ret = _appinfo_get_applications(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_APPINFO_GET_ALL, &list);
- }
- if (ret != PMINFO_R_OK)
- return ret;
-
- auto it = list.find(appid);
- if (it == list.end()) {
- _LOGD("appinfo for [%s] is not existed for user [%d]", appid, uid);
- return PMINFO_R_ENOENT;
- }
-
- info = reinterpret_cast<pkgmgr_appinfo_x*>(
- calloc(1, sizeof(pkgmgr_appinfo_x)));
- if (info == NULL) {
- _LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- info->app_info = new pc::AppInfoHandle(std::move(it->second));
- info->locale = info->app_info->GetLocale();
- info->package = info->app_info->GetPackage();
-
- *handle = info;
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
- const char *appid, uid_t uid, pkgmgrinfo_appinfo_h *handle)
-{
- int ret;
- pkgmgrinfo_appinfo_filter_h filter;
-
- if (appid == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = pkgmgrinfo_appinfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- ret = pkgmgrinfo_appinfo_filter_add_string(filter,
- PMINFO_APPINFO_PROP_APP_ID, appid);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_DISABLE, true);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
- pkgmgrinfo_appinfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_disabled_appinfo(
- const char *appid, pkgmgrinfo_appinfo_h *handle)
-{
- return pkgmgrinfo_appinfo_get_usr_disabled_appinfo(
- appid, _getuid(), handle);
-}
-
-static char *__get_real_appid(const char *appid)
-{
- char *str;
- char *saveptr;
- char *token;
-
- str = strdup(appid);
- if (str == NULL)
- return NULL;
-
- token = strtok_r(str, "::", &saveptr);
- if (token == NULL)
- return str;
-
- LOGD("Real appid = %s", token);
- token = strdup(token);
- free(str);
- return token;
-}
-
-API int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid, uid_t uid,
- pkgmgrinfo_appinfo_h *handle)
-{
- int ret;
- pkgmgrinfo_appinfo_filter_h filter;
- char *real_appid;
-
- if (appid == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = pkgmgrinfo_appinfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- real_appid = __get_real_appid(appid);
- if (real_appid == NULL) {
- LOGE("Out of memory");
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = pkgmgrinfo_appinfo_filter_add_string(filter,
- PMINFO_APPINFO_PROP_APP_ID, real_appid);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- free(real_appid);
- return PMINFO_R_ERROR;
- }
-
- ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_DISABLE, false);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- free(real_appid);
- return PMINFO_R_ERROR;
- }
-
- ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_PKG_DISABLE, false);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- free(real_appid);
- return PMINFO_R_ERROR;
- }
-
- ret = _pkgmgrinfo_get_appinfo(real_appid, uid, filter, handle);
- free(real_appid);
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_appinfo(
- const char *appid, pkgmgrinfo_appinfo_h *handle)
-{
- return pkgmgrinfo_appinfo_get_usr_appinfo(appid, _getuid(), handle);
-}
-
-API int pkgmgrinfo_appinfo_get_usr_all_appinfo(const char *appid, uid_t uid,
- pkgmgrinfo_appinfo_h *handle)
-{
- int ret;
- pkgmgrinfo_appinfo_filter_h filter;
-
- if (appid == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = pkgmgrinfo_appinfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- ret = pkgmgrinfo_appinfo_filter_add_string(filter,
- PMINFO_APPINFO_PROP_APP_ID, appid);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = _pkgmgrinfo_get_appinfo(appid, uid, filter, handle);
- pkgmgrinfo_appinfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_all_appinfo(
- const char *appid, pkgmgrinfo_appinfo_h *handle)
-{
- return pkgmgrinfo_appinfo_get_usr_all_appinfo(appid, _getuid(), handle);
-}
-
-API int pkgmgrinfo_appinfo_clone_appinfo(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_appinfo_h *clone)
-{
- pkgmgr_appinfo_x *info;
- pkgmgr_appinfo_x *temp = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL)
- return PMINFO_R_EINVAL;
-
- info = reinterpret_cast<pkgmgr_appinfo_x*>(
- calloc(1, sizeof(pkgmgr_appinfo_x)));
- if (info == NULL) {
- LOGE("memory alloc failed");
- return PMINFO_R_ERROR;
- }
-
- info->app_component = temp->app_component;
- info->app_info = new pc::AppInfoHandle(temp->app_info->Clone());
- info->locale = info->app_info->GetLocale();
- info->package = info->app_info->GetPackage();
-
- *clone = info;
-
- return PMINFO_R_OK;
-}
-
-static int _appinfo_get_filtered_foreach_appinfo(uid_t uid,
- pkgmgrinfo_filter_x *filter, int flag,
- pkgmgrinfo_app_list_cb app_list_cb,
- void *user_data)
-{
- int ret;
- pkgmgr_appinfo_x info;
- ps::ShmAppReader reader(uid);
- std::map<std::string, pc::AppInfoHandle> list;
- if (reader.Init())
- ret = reader.GetHandles(reinterpret_cast<pkgmgrinfo_filter_x*>(filter), list);
- else
- ret = _appinfo_get_applications(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_APPINFO_GET_ALL, &list);
- if (ret == PMINFO_R_ERROR)
- return ret;
-
- for (const auto& app : list) {
- info.app_info = &app.second;
- info.locale = info.app_info->GetLocale();
- info.package = info.app_info->GetPackage();
- if (app_list_cb(&info, user_data) < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-static const char *__appcomponent_str(pkgmgrinfo_app_component comp);
-
-API int pkgmgrinfo_appinfo_get_usr_list(pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_app_component component,
- pkgmgrinfo_app_list_cb app_func, void *user_data, uid_t uid)
-{
- int ret;
- pkgmgrinfo_appinfo_filter_h filter;
- char *pkgid;
- const char *comp_str = NULL;
-
- if (handle == NULL || app_func == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid)) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (pkgmgrinfo_appinfo_filter_create(&filter))
- return PMINFO_R_ERROR;
-
- if (pkgmgrinfo_appinfo_filter_add_string(filter,
- PMINFO_APPINFO_PROP_APP_PACKAGE, pkgid)) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- comp_str = __appcomponent_str(component);
-
- if (comp_str) {
- if (pkgmgrinfo_appinfo_filter_add_string(filter,
- PMINFO_APPINFO_PROP_APP_COMPONENT,
- comp_str)) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
- }
-
- ret = _appinfo_get_filtered_foreach_appinfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_APPINFO_GET_ALL, app_func, user_data);
-
- pkgmgrinfo_appinfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_list(pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_app_component component,
- pkgmgrinfo_app_list_cb app_func, void *user_data)
-{
- return pkgmgrinfo_appinfo_get_usr_list(handle,
- component, app_func, user_data, _getuid());
-}
-
-API int pkgmgrinfo_appinfo_get_usr_installed_list_full(
- pkgmgrinfo_app_list_cb app_func, uid_t uid, int flag,
- void *user_data)
-{
- int ret;
- pkgmgrinfo_appinfo_filter_h filter;
-
- if (app_func == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (pkgmgrinfo_appinfo_filter_create(&filter))
- return PMINFO_R_ERROR;
-
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, false)) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = _appinfo_get_filtered_foreach_appinfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- flag, app_func, user_data);
-
- pkgmgrinfo_appinfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_installed_list_full(
- pkgmgrinfo_app_list_cb app_func, int flag, void *user_data)
-{
- return pkgmgrinfo_appinfo_get_usr_installed_list_full(app_func,
- _getuid(), flag, user_data);
-}
-
-API int pkgmgrinfo_appinfo_get_usr_installed_list(
- pkgmgrinfo_app_list_cb app_func, uid_t uid, void *user_data)
-{
- int ret;
- pkgmgrinfo_appinfo_filter_h filter;
-
- if (app_func == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- /* create an empty filter */
- ret = pkgmgrinfo_appinfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_DISABLE, false)) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_PKG_DISABLE, false)) {
- pkgmgrinfo_appinfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = _appinfo_get_filtered_foreach_appinfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_APPINFO_GET_ALL, app_func, user_data);
-
- pkgmgrinfo_appinfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_installed_list(pkgmgrinfo_app_list_cb app_func,
- void *user_data)
-{
- return pkgmgrinfo_appinfo_get_usr_installed_list(app_func, _getuid(),
- user_data);
-}
-
-API int pkgmgrinfo_appinfo_get_appid(pkgmgrinfo_appinfo_h handle, char **appid)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appid == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL || info->app_info->GetAppId() == NULL)
- return PMINFO_R_ERROR;
- *appid = const_cast<char*>(info->app_info->GetAppId());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_pkgname(
- pkgmgrinfo_appinfo_h handle, char **pkg_name)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(pkg_name == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->package == NULL)
- return PMINFO_R_ERROR;
-
- *pkg_name = const_cast<char*>(info->package);
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_appinfo_h handle, char **pkgid)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(pkgid == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->package == NULL)
- return PMINFO_R_ERROR;
-
- *pkgid = const_cast<char*>(info->package);
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_pkgtype(
- pkgmgrinfo_appinfo_h handle, char **pkgtype)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(pkgtype == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- *pkgtype = const_cast<char*>(info->app_info->GetPackageType());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_exec(pkgmgrinfo_appinfo_h handle, char **exec)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(exec == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL || info->app_info->GetExec() == NULL)
- return PMINFO_R_ERROR;
- *exec = const_cast<char*>(info->app_info->GetExec());
-
- return PMINFO_R_OK;
-}
-
-
-API int pkgmgrinfo_appinfo_get_icon(pkgmgrinfo_appinfo_h handle, char **icon)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(icon == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- auto iter = info->app_info->GetIcon();
- if (iter.begin() == iter.end())
- return PMINFO_R_ERROR;
-
- pc::Icon ic(*iter.begin());
- if (ic.Text() == NULL)
- return PMINFO_R_ERROR;
- else
- *icon = const_cast<char*>(ic.Text());
-
- return PMINFO_R_OK;
-}
-
-
-API int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label)
-{
- pkgmgr_appinfo_x* info = (pkgmgr_appinfo_x *)handle;
- char* lbl = nullptr;
- const char* locale;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(label == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- locale = info->locale;
- if (locale == NULL)
- locale = DEFAULT_LOCALE;
-
- for (auto iter : info->app_info->GetLabel()) {
- if (strcmp(locale, iter.Lang()) != 0)
- continue;
- lbl = const_cast<char*>(iter.Text());
- break;
- }
-
- for (auto iter : info->app_info->GetLabel()) {
- if (strcmp(DEFAULT_LOCALE, iter.Lang()) != 0)
- continue;
- lbl = const_cast<char*>(iter.Text());
- break;
- }
-
- if (lbl)
- *label = lbl;
- else
- *label = const_cast<char*>("");
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_usr_get_localed_label(const char *appid,
- const char *locale, uid_t uid, char **label)
-{
- char *val;
-
- retvm_if(appid == NULL || locale == NULL || label == NULL,
- PMINFO_R_EINVAL, "Argument is NULL");
- val = _appinfo_get_localed_label(appid, locale, uid);
- if (val == NULL)
- return PMINFO_R_ERROR;
-
- *label = val;
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_localed_label(
- const char *appid, const char *locale, char **label)
-{
- return pkgmgrinfo_appinfo_usr_get_localed_label(
- appid, locale, _getuid(), label);
-}
-
-API int pkgmgrinfo_appinfo_get_metadata_value(
- pkgmgrinfo_appinfo_h handle, const char *metadata_key,
- char **metadata_value)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
- retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
- "metadata_value is NULL");
-
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- for (auto metadata : info->app_info->GetMetadata()) {
- if (metadata.Key()) {
- if (strcasecmp(metadata.Key(), metadata_key) == 0) {
- if (metadata.Value() == NULL)
- *metadata_value = const_cast<char*>("");
- else
- *metadata_value = const_cast<char*>(metadata.Value());
- return PMINFO_R_OK;
- }
- }
- }
-
- return PMINFO_R_EINVAL;
-}
-
-static int __appcomponent_convert(const char *comp)
-{
- if (strcasecmp(comp, "uiapp") == 0)
- return PMINFO_UI_APP;
- else if (strcasecmp(comp, "svcapp") == 0)
- return PMINFO_SVC_APP;
- else if (strcasecmp(comp, "widgetapp") == 0)
- return PMINFO_WIDGET_APP;
- else if (strcasecmp(comp, "watchapp") == 0)
- return PMINFO_WATCH_APP;
- else if (strcasecmp(comp, "componentbasedapp") == 0)
- return PMINFO_COMPONENT_BASED_APP;
- else
- return -1;
-}
-
-static const char *__appcomponent_str(pkgmgrinfo_app_component comp)
-{
- switch (comp) {
- case PMINFO_UI_APP:
- return "uiapp";
- case PMINFO_SVC_APP:
- return "svcapp";
- case PMINFO_WIDGET_APP:
- return "widgetapp";
- case PMINFO_WATCH_APP:
- return "watchapp";
- case PMINFO_COMPONENT_BASED_APP:
- return "componentbasedapp";
- default:
- return NULL;
- }
-}
-
-API int pkgmgrinfo_appinfo_get_component(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_component *component)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- int comp;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(component == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- comp = __appcomponent_convert(info->app_info->GetComponent());
- if (comp < 0)
- return PMINFO_R_ERROR;
-
- *component = static_cast<pkgmgrinfo_app_component>(comp);
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_apptype(
- pkgmgrinfo_appinfo_h handle, char **app_type)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(app_type == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL || info->app_info->GetType() == NULL)
- return PMINFO_R_ERROR;
- *app_type = const_cast<char*>(info->app_info->GetType());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_notification_icon(
- pkgmgrinfo_appinfo_h handle, char **icon)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(icon == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- auto iter = info->app_info->GetIcon();
- if (iter.begin() == iter.end())
- return PMINFO_R_ERROR;
-
- for (auto ic : iter) {
- if (ic.Section() && strcmp(ic.Section(), "notification") == 0) {
- *icon = const_cast<char*>(ic.Text());
- return PMINFO_R_OK;
- }
- }
-
- return PMINFO_R_ERROR;
-}
-
-API int pkgmgrinfo_appinfo_get_recent_image_type(
- pkgmgrinfo_appinfo_h handle, pkgmgrinfo_app_recentimage *type)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(type == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL || info->app_info->GetRecentimage() == NULL)
- return PMINFO_R_ERROR;
-
- const char* val = info->app_info->GetRecentimage();
- if (strcasecmp(val, "capture") == 0)
- *type = PMINFO_RECENTIMAGE_USE_CAPTURE;
- else if (strcasecmp(val, "icon") == 0)
- *type = PMINFO_RECENTIMAGE_USE_ICON;
- else
- *type = PMINFO_RECENTIMAGE_USE_NOTHING;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_preview_image(
- pkgmgrinfo_appinfo_h handle, char **preview_img)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(preview_img == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto image : info->app_info->GetImage()) {
- if (image.Section() == NULL)
- continue;
-
- if (image.Section() && strcmp(image.Section(), "preview") == 0) {
- *preview_img = const_cast<char*>(image.Text());
- return PMINFO_R_OK;
- }
- }
-
- return PMINFO_R_ERROR;
-}
-
-API int pkgmgrinfo_appinfo_get_permission_type(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_permission_type *permission)
-{
- const char *val;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(permission == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- val = info->app_info->GetPermissionType();
- if (val == NULL)
- return PMINFO_R_ERROR;
-
- if (strcmp(val, "signature") == 0)
- *permission = PMINFO_PERMISSION_SIGNATURE;
- else if (strcmp(val, "privilege") == 0)
- *permission = PMINFO_PERMISSION_PRIVILEGE;
- else
- *permission = PMINFO_PERMISSION_NORMAL;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_component_type(
- pkgmgrinfo_appinfo_h handle, char **component_type)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(component_type == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL || info->app_info->GetComponentType() == NULL)
- return PMINFO_R_ERROR;
-
- *component_type = const_cast<char*>(info->app_info->GetComponentType());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_hwacceleration(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_hwacceleration *hwacceleration)
-{
- char *val;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(hwacceleration == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL || info->app_info->GetHwAcceleration() == NULL)
- return PMINFO_R_ERROR;
-
- val = const_cast<char*>(info->app_info->GetHwAcceleration());
- if (strcasecmp(val, "off") == 0)
- *hwacceleration = PMINFO_HWACCELERATION_OFF;
- else if (strcasecmp(val, "on") == 0)
- *hwacceleration = PMINFO_HWACCELERATION_ON;
- else
- *hwacceleration = PMINFO_HWACCELERATION_DEFAULT;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_screenreader(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_screenreader *screenreader)
-{
- char *val;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(screenreader == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL || info->app_info->GetScreenReader() == NULL)
- return PMINFO_R_ERROR;
-
- val = const_cast<char*>(info->app_info->GetScreenReader());
- if (strcasecmp(val, "screenreader-off") == 0)
- *screenreader = PMINFO_SCREENREADER_OFF;
- else if (strcasecmp(val, "screenreader-on") == 0)
- *screenreader = PMINFO_SCREENREADER_ON;
- else
- *screenreader = PMINFO_SCREENREADER_USE_SYSTEM_SETTING;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_effectimage(
- pkgmgrinfo_appinfo_h handle, char **portrait_img,
- char **landscape_img)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(portrait_img == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- retvm_if(landscape_img == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->app_info->GetPortraitImg() == NULL)
- *portrait_img = const_cast<char*>("");
- else
- *portrait_img = const_cast<char*>(info->app_info->GetPortraitImg());
-
- if (info->app_info->GetLandscapeImg() == NULL)
- *landscape_img = const_cast<char*>("");
- else
- *landscape_img = const_cast<char*>(info->app_info->GetLandscapeImg());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_effectimage_type(
- pkgmgrinfo_appinfo_h handle, char **effectimage_type)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || effectimage_type == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL || info->app_info->GetEffectImageType() == NULL)
- return PMINFO_R_ERROR;
-
- *effectimage_type = const_cast<char*>(info->app_info->GetEffectImageType());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_submode_mainid(
- pkgmgrinfo_appinfo_h handle, char **submode_mainid)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(submode_mainid == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->app_info->GetSubmodeMainId() == NULL)
- *submode_mainid = const_cast<char*>("");
- else
- *submode_mainid = const_cast<char*>(info->app_info->GetSubmodeMainId());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_installed_storage_location(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_installed_storage *storage)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info && info->app_info->GetInstalledStorage()) {
- if (strcmp(info->app_info->GetInstalledStorage(),
- "installed_internal") == 0)
- *storage = PMINFO_INTERNAL_STORAGE;
- else if (strcmp(info->app_info->GetInstalledStorage(),
- "installed_external") == 0)
- *storage = PMINFO_EXTERNAL_STORAGE;
- else
- return PMINFO_R_ERROR;
- } else {
- return PMINFO_R_ERROR;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_launch_mode(
- pkgmgrinfo_appinfo_h handle, char **mode)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(mode == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- if (info->app_info->GetLaunchMode() == NULL)
- return PMINFO_R_ERROR;
-
- *mode = const_cast<char*>(info->app_info->GetLaunchMode());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_alias_appid(
- pkgmgrinfo_appinfo_h handle, char **alias_appid)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || alias_appid == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL || info->app_info->GetAliasAppid() == NULL)
- return PMINFO_R_ERROR;
-
- *alias_appid = const_cast<char*>(info->app_info->GetAliasAppid());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_effective_appid(
- pkgmgrinfo_appinfo_h handle, char **effective_appid)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || effective_appid == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->app_info->GetEffectiveAppId() == NULL)
- *effective_appid = const_cast<char*>("");
- else
- *effective_appid = const_cast<char*>(info->app_info->GetEffectiveAppId());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_tep_name(
- pkgmgrinfo_appinfo_h handle, char **tep_name)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || tep_name == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->app_info->GetTepName() == NULL)
- *tep_name = const_cast<char*>("");
- else
- *tep_name = const_cast<char*>(info->app_info->GetTepName());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_zip_mount_file(
- pkgmgrinfo_appinfo_h handle, char **zip_mount_file)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || zip_mount_file == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->app_info->GetZipMountFile() == NULL)
- *zip_mount_file = const_cast<char*>("");
- else
- *zip_mount_file = const_cast<char*>(info->app_info->GetZipMountFile());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_root_path(
- pkgmgrinfo_appinfo_h handle, char **root_path)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || root_path == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL || info->app_info->GetRootPath() == NULL)
- return PMINFO_R_ERROR;
-
- *root_path = const_cast<char*>(info->app_info->GetRootPath());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_api_version(
- pkgmgrinfo_appinfo_h handle, char **api_version)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || api_version == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL || info->app_info->GetApiVersion() == NULL)
- return PMINFO_R_ERROR;
-
- *api_version = const_cast<char*>(info->app_info->GetApiVersion());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_installed_time(
- pkgmgrinfo_appinfo_h handle, int *installed_time)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || installed_time == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL ||
- info->app_info->GetPackageInstalledTime() == NULL)
- return PMINFO_R_ERROR;
-
- *installed_time = atoi(info->app_info->GetPackageInstalledTime());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_usr_get_datacontrol_info(const char *providerid,
- const char *type, uid_t uid, char **appid, char **access)
-{
- int ret;
-
- if (providerid == NULL || type == NULL || appid == NULL ||
- access == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = _appinfo_get_datacontrol_info(
- providerid, type, uid, appid, access);
- /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
- * implementation, return PMINFO_R_ERROR. This should be
- * modified later...
- */
- if (ret == PMINFO_R_ENOENT) {
- LOGE("no datacontrol info of %s", providerid);
- ret = PMINFO_R_ERROR;
- }
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_datacontrol_info(const char *providerid,
- const char *type, char **appid, char **access)
-{
- return pkgmgrinfo_appinfo_usr_get_datacontrol_info(providerid,
- type, _getuid(), appid, access);
-}
-
-API int pkgmgrinfo_appinfo_usr_get_datacontrol_appid(const char *providerid,
- uid_t uid, char **appid)
-{
- int ret;
-
- if (providerid == NULL || appid == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = _appinfo_get_datacontrol_appid(providerid, uid, appid);
- /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
- * implementation, return PMINFO_R_ERROR. This should be
- * modified later...
- */
- if (ret == PMINFO_R_ENOENT) {
- LOGE("no datacontrol appid of %s", providerid);
- ret = PMINFO_R_ERROR;
- }
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_datacontrol_appid(
- const char *providerid, char **appid)
-{
- return pkgmgrinfo_appinfo_usr_get_datacontrol_appid(
- providerid, _getuid(), appid);
-}
-
-API int pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(
- const char *providerid, const char *type, uid_t uid,
- char **appid, bool *is_trusted)
-{
- int ret;
- char *trusted = NULL;
-
- if (providerid == NULL || type == NULL || appid == NULL ||
- is_trusted == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = _appinfo_get_datacontrol_trusted_info(providerid, type, uid,
- appid, &trusted);
-
- /* FIXME: It should return PMINFO_R_ENOENT but to keep previous
- * implementation, return PMINFO_R_ERROR. This should be
- * modified later...
- */
- if (ret == PMINFO_R_ENOENT) {
- LOGE("no datacontrol trusted info of %s", providerid);
- ret = PMINFO_R_ERROR;
- }
- *is_trusted = _get_bool_value(trusted);
- free(trusted);
-
- return ret;
-}
-
-API int pkgmgrinfo_appinfo_get_datacontrol_trsuted_info(const char *providerid,
- const char *type, char **appid, bool *is_trusted)
-{
- return pkgmgrinfo_appinfo_usr_get_datacontrol_trusted_info(providerid,
- type, _getuid(), appid, is_trusted);
-}
-
-API int pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
- const char *providerid, const char *type,
- pkgmgrinfo_pkg_privilege_list_cb privilege_func,
- void *user_data, uid_t uid)
-{
- int ret;
- int count = 0;
- GList *list = NULL;
- GList *tmp = NULL;
-
- if (providerid == NULL || type == NULL || privilege_func == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = _appinfo_get_datacontrol_privileges(providerid, type, uid, &list);
- if (ret == PMINFO_R_ERROR) {
- g_list_free_full(list, free);
- return ret;
- }
-
- for (tmp = list; tmp != NULL; tmp = g_list_next(tmp)) {
- count++;
- ret = privilege_func((char *)tmp->data, user_data);
- if (ret < 0)
- break;
- }
-
- g_list_free_full(list, free);
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_datacontrol_privileges(
- const char *providerid, const char *type,
- pkgmgrinfo_pkg_privilege_list_cb privilege_func,
- void *user_data)
-{
- return pkgmgrinfo_appinfo_usr_foreach_datacontrol_privileges(
- providerid, type, privilege_func, user_data, _getuid());
-}
-
-API int pkgmgrinfo_appinfo_get_support_mode(
- pkgmgrinfo_appinfo_h handle, int *support_mode)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(support_mode == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info->GetSupportMode())
- *support_mode = atoi(info->app_info->GetSupportMode());
- else
- *support_mode = 0;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_category(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_category_list_cb category_func, void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(category_func == NULL, PMINFO_R_EINVAL,
- "Callback function is NULL");
- int ret = -1;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (const char* category : info->app_info->GetCategory()) {
- if (category) {
- ret = category_func(category, user_data);
- if (ret < 0)
- break;
- }
- }
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_metadata(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_metadata_list_cb metadata_func, void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
- "Callback function is NULL");
- int ret = -1;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto metadata : info->app_info->GetMetadata()) {
- if (metadata.Key()) {
- ret = metadata_func(metadata.Key(), metadata.Value() ?
- metadata.Value() : "", user_data);
- if (ret < 0)
- break;
- }
- }
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(const char *appid,
- const char *operation,
- pkgmgrinfo_pkg_privilege_list_cb privilege_func,
- void *user_data, uid_t uid)
-{
- int ret;
- GList *privilege_list = NULL;
- GList *tmp_list;
-
- if (appid == NULL || operation == NULL || privilege_func == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = _appinfo_get_appcontrol_privileges(appid, operation, uid,
- &privilege_list);
- if (ret == PMINFO_R_ENOENT) {
- return PMINFO_R_OK;
- } else if (ret != PMINFO_R_OK) {
- g_list_free_full(privilege_list, free);
- return ret;
- }
-
- for (tmp_list = privilege_list; tmp_list != NULL;
- tmp_list = g_list_next(tmp_list)) {
- ret = privilege_func((char *)tmp_list->data, user_data);
- if (ret != 0)
- break;
- }
-
- g_list_free_full(privilege_list, free);
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_appcontrol_privileges(const char *appid,
- const char *operation,
- pkgmgrinfo_pkg_privilege_list_cb privilege_func,
- void *user_data)
-{
- return pkgmgrinfo_appinfo_usr_foreach_appcontrol_privileges(appid,
- operation, privilege_func, user_data, _getuid());
-}
-
-API int pkgmgrinfo_appinfo_foreach_appcontrol(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
- "Callback function is NULL");
- int ret;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto appcontrol : info->app_info->GetAppcontrol()) {
- if (!strcasecmp(appcontrol.Visibility(), "remote-only"))
- continue;
- ret = appcontrol_func(appcontrol.Operation(),
- appcontrol.Uri(), appcontrol.Mime(), user_data);
- if (ret < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_remote_appcontrol(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb appcontrol_func, void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appcontrol_func == NULL, PMINFO_R_EINVAL,
- "Callback function is NULL");
- int ret;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto appcontrol : info->app_info->GetAppcontrol()) {
- if (!strcasecmp(appcontrol.Visibility(), "local-only"))
- continue;
- ret = appcontrol_func(appcontrol.Operation(), appcontrol.Uri(),
- appcontrol.Mime(), user_data);
- if (ret < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_background_category(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_background_category_list_cb category_func,
- void *user_data)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || category_func == NULL || info->app_info == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- for (const char* category : info->app_info->GetBackgroundCategory()) {
- if (category == NULL)
- continue;
-
- if (category_func(category, user_data) < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_splash_screen(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_splash_screen_list_cb splash_screen_func,
- void *user_data)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
- int ret;
-
- if (info == NULL || info->app_info == NULL
- || splash_screen_func == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- for (auto splashscreen : info->app_info->GetSplashscreens()) {
- ret = splash_screen_func(
- splashscreen.Src(),
- splashscreen.Type(),
- splashscreen.Orientation(),
- splashscreen.Indicatordisplay(),
- splashscreen.Operation(),
- splashscreen.ColorDepth(),
- user_data);
- if (ret < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_res_control(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_res_control_list_cb res_control_func,
- void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(res_control_func == NULL, PMINFO_R_EINVAL,
- "Callback function is NULL");
- int ret = -1;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto res_control : info->app_info->GetResControl()) {
- ret = res_control_func(res_control.ResType(),
- res_control.MinResVersion(),
- res_control.MaxResVersion(),
- res_control.AutoClose(),
- user_data);
- if (ret < 0)
- break;
- }
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_nodisplay(
- pkgmgrinfo_appinfo_h handle, bool *nodisplay)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(nodisplay == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetNodisplay() == NULL)
- return PMINFO_R_ERROR;
-
- *nodisplay = _get_bool_value(info->app_info->GetNodisplay());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_multiple(
- pkgmgrinfo_appinfo_h handle, bool *multiple)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(multiple == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetMultiple() == NULL)
- return PMINFO_R_ERROR;
-
- *multiple = _get_bool_value(info->app_info->GetMultiple());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_indicator_display_allowed(
- pkgmgrinfo_appinfo_h handle, bool *indicator_disp)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(indicator_disp == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetIndicatorDisplay() == NULL)
- return PMINFO_R_ERROR;
-
- *indicator_disp = _get_bool_value(info->app_info->GetIndicatorDisplay());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_taskmanage(
- pkgmgrinfo_appinfo_h handle, bool *taskmanage)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(taskmanage == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetTaskManage() == NULL)
- return PMINFO_R_ERROR;
-
- *taskmanage = _get_bool_value(info->app_info->GetTaskManage());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_enabled(
- pkgmgrinfo_appinfo_h handle, bool *enabled)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(enabled == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetIsDisabled() == NULL)
- return PMINFO_R_ERROR;
-
- *enabled = !_get_bool_value(info->app_info->GetIsDisabled());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_onboot(
- pkgmgrinfo_appinfo_h handle, bool *onboot)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(onboot == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetOnboot() == NULL)
- return PMINFO_R_ERROR;
-
- *onboot = _get_bool_value(info->app_info->GetOnboot());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_autorestart(
- pkgmgrinfo_appinfo_h handle, bool *autorestart)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(autorestart == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetAutoRestart() == NULL)
- return PMINFO_R_ERROR;
-
- *autorestart = _get_bool_value(info->app_info->GetAutoRestart());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_mainapp(
- pkgmgrinfo_appinfo_h handle, bool *mainapp)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(mainapp == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetMainApp() == NULL)
- return PMINFO_R_ERROR;
-
- *mainapp = _get_bool_value(info->app_info->GetMainApp());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_preload(
- pkgmgrinfo_appinfo_h handle, bool *preload)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(preload == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetPreload() == NULL)
- return PMINFO_R_ERROR;
-
- *preload = _get_bool_value(info->app_info->GetPreload());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_submode(
- pkgmgrinfo_appinfo_h handle, bool *submode)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(submode == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetSubmode() == NULL)
- return PMINFO_R_ERROR;
-
- *submode = _get_bool_value(info->app_info->GetSubmode());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_process_pool(
- pkgmgrinfo_appinfo_h handle, bool *process_pool)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (handle == NULL || process_pool == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- *process_pool = _get_bool_value(info->app_info->GetProcessPool());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_category_exist(
- pkgmgrinfo_appinfo_h handle, const char *category, bool *exist)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(category == NULL, PMINFO_R_EINVAL, "category is NULL");
- retvm_if(exist == NULL, PMINFO_R_EINVAL, "exist is NULL");
-
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- *exist = 0;
- for (const char* val : info->app_info->GetCategory()) {
- if (val == NULL)
- continue;
- if (strcasecmp(val, category) == 0) {
- *exist = 1;
- break;
- }
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_ui_gadget(pkgmgrinfo_appinfo_h handle,
- bool *ui_gadget)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info == NULL || info->app_info == NULL || ui_gadget == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- const char* tmp = info->app_info->GetUiGadget();
- *ui_gadget = _get_bool_value(tmp ? tmp : "false");
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_support_disable(pkgmgrinfo_appinfo_h handle,
- bool *support_disable)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info == NULL || info->app_info == NULL || support_disable == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- *support_disable = _get_bool_value(info->app_info->GetSupportDisable());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_removable(pkgmgrinfo_appinfo_h handle,
- bool *removable)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info == NULL || info->app_info == NULL || removable == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- *removable = _get_bool_value(info->app_info->GetRemovable());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_system(pkgmgrinfo_appinfo_h handle, bool *system)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info == NULL || info->app_info == NULL || system == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- *system = _get_bool_value(info->app_info->GetPackageSystem());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_disabled(
- pkgmgrinfo_appinfo_h handle, bool *disabled)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(disabled == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL || info->app_info->GetIsDisabled() == NULL)
- return PMINFO_R_ERROR;
-
- *disabled = _get_bool_value(info->app_info->GetIsDisabled());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_global(pkgmgrinfo_appinfo_h handle, bool *global)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(global == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- if (info->app_info == NULL || info->app_info->GetForAllUsers() == NULL)
- return PMINFO_R_ERROR;
-
- *global = _get_bool_value(info->app_info->GetForAllUsers());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_splash_screen_display(
- pkgmgrinfo_appinfo_h handle, bool *splash_screen_display)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info == NULL || splash_screen_display == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL ||
- info->app_info->GetSplashScreenDisplay() == NULL)
- return PMINFO_R_ERROR;
-
- *splash_screen_display =
- _get_bool_value(info->app_info->GetSplashScreenDisplay());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_setup_appid(
- pkgmgrinfo_appinfo_h handle, char **setup_appid)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info == NULL || setup_appid == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL || info->app_info->GetSetupAppId() == NULL)
- return PMINFO_R_ERROR;
-
- *setup_appid = const_cast<char*>(info->app_info->GetSetupAppId());
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_is_support_ambient(pkgmgrinfo_appinfo_h handle,
- bool *support_ambient)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info == NULL || support_ambient == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL || info->app_info->GetSupportAmbient() == NULL)
- return PMINFO_R_ERROR;
-
- *support_ambient = _get_bool_value(info->app_info->GetSupportAmbient());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_get_light_user_switch_mode(
- pkgmgrinfo_appinfo_h handle, char **mode)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info == NULL || mode == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->app_info == NULL || info->app_info->GetLightUserSwitchMode() == NULL)
- return PMINFO_R_ERROR;
-
- *mode = const_cast<char*>(info->app_info->GetLightUserSwitchMode());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_destroy_appinfo(pkgmgrinfo_appinfo_h handle)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- __cleanup_appinfo(info);
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_filter_create(pkgmgrinfo_appinfo_filter_h *handle)
-{
- return pkgmgrinfo_pkginfo_filter_create(handle);
-}
-
-API int pkgmgrinfo_appinfo_filter_destroy(pkgmgrinfo_appinfo_filter_h handle)
-{
- return pkgmgrinfo_pkginfo_filter_destroy(handle);
-}
-
-static gint __compare_func(gconstpointer data1, gconstpointer data2)
-{
- pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
- pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
-
- if (node1->prop == node2->prop)
- return 0;
- else if (node1->prop > node2->prop)
- return 1;
- else
- return -1;
-}
-
-API int pkgmgrinfo_appinfo_filter_add_int(pkgmgrinfo_appinfo_filter_h handle,
- const char *property, const int value)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL,
- "Filter handle input parameter is NULL\n");
- retvm_if(property == NULL, PMINFO_R_EINVAL,
- "Filter handle input parameter is NULL\n");
- char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
- char *val = NULL;
- GSList *link = NULL;
- int prop = -1;
-
- prop = _pminfo_appinfo_convert_to_prop_int(property);
- if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_INT ||
- prop > E_PMINFO_APPINFO_PROP_APP_MAX_INT) {
- _LOGE("Invalid Integer Property\n");
- return PMINFO_R_EINVAL;
- }
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
- pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
- sizeof(pkgmgrinfo_node_x));
- if (node == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
- snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
- val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
- if (val == NULL) {
- _LOGE("Out of Memory\n");
- free(node);
- node = NULL;
- return PMINFO_R_ERROR;
- }
- node->prop = prop;
- node->value = val;
-
- /*
- * If API is called multiple times for same property,
- * we should override the previous values.
- * Last value set will be used for filtering.
- */
- link = g_slist_find_custom(filter->list,
- (gconstpointer)node, __compare_func);
- if (link) {
- _pkgmgrinfo_node_destroy(
- reinterpret_cast<pkgmgrinfo_node_x*>(link->data));
- filter->list = g_slist_delete_link(filter->list, link);
- }
- filter->list = g_slist_append(filter->list, (gpointer)node);
- return PMINFO_R_OK;
-
-}
-
-API int pkgmgrinfo_appinfo_filter_add_bool(pkgmgrinfo_appinfo_filter_h handle,
- const char *property, const bool value)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL,
- "Filter handle input parameter is NULL\n");
- retvm_if(property == NULL, PMINFO_R_EINVAL,
- "Filter handle input parameter is NULL\n");
- char *val = NULL;
- GSList *link = NULL;
- int prop = -1;
-
- prop = _pminfo_appinfo_convert_to_prop_bool(property);
- if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_BOOL ||
- prop > E_PMINFO_APPINFO_PROP_APP_MAX_BOOL) {
- _LOGE("Invalid Boolean Property\n");
- return PMINFO_R_EINVAL;
- }
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
- pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
- sizeof(pkgmgrinfo_node_x));
- if (node == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
- if (value)
- val = strndup("true", 4);
- else
- val = strndup("false", 5);
- if (val == NULL) {
- _LOGE("Out of Memory\n");
- free(node);
- node = NULL;
- return PMINFO_R_ERROR;
- }
- node->prop = prop;
- node->value = val;
- /*
- * If API is called multiple times for same property,
- * we should override the previous values.
- * Last value set will be used for filtering.
- */
- link = g_slist_find_custom(filter->list,
- (gconstpointer)node, __compare_func);
- if (link) {
- _pkgmgrinfo_node_destroy(
- reinterpret_cast<pkgmgrinfo_node_x*>(link->data));
- filter->list = g_slist_delete_link(filter->list, link);
- }
- filter->list = g_slist_append(filter->list, (gpointer)node);
- return PMINFO_R_OK;
-
-}
-
-API int pkgmgrinfo_appinfo_filter_add_string(pkgmgrinfo_appinfo_filter_h handle,
- const char *property, const char *value)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL,
- "Filter handle input parameter is NULL\n");
- retvm_if(property == NULL, PMINFO_R_EINVAL,
- "Filter handle input parameter is NULL\n");
- retvm_if(value == NULL, PMINFO_R_EINVAL,
- "Filter handle input parameter is NULL\n");
- char *val = NULL;
- pkgmgrinfo_node_x *ptr = NULL;
- char prev[PKG_STRING_LEN_MAX] = {'\0'};
- char temp[PKG_STRING_LEN_MAX] = {'\0'};
- GSList *link = NULL;
- int prop = -1;
- int ret;
-
- prop = _pminfo_appinfo_convert_to_prop_str(property);
- if (prop < E_PMINFO_APPINFO_PROP_APP_MIN_STR ||
- prop > E_PMINFO_APPINFO_PROP_APP_MAX_STR) {
- _LOGE("Invalid String Property\n");
- return PMINFO_R_EINVAL;
- }
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
- pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)calloc(1,
- sizeof(pkgmgrinfo_node_x));
- if (node == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
- node->prop = prop;
- switch (prop) {
- case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
- node->value = strdup(value);
- link = g_slist_find_custom(filter->list,
- (gconstpointer)node, __compare_func);
- if (link) {
- _pkgmgrinfo_node_destroy(
- reinterpret_cast<pkgmgrinfo_node_x*>(link->data));
- filter->list = g_slist_delete_link(filter->list, link);
- }
- filter->list = g_slist_append(filter->list, (gpointer)node);
- break;
- case E_PMINFO_APPINFO_PROP_APP_CATEGORY:
- val = (char *)calloc(1, PKG_STRING_LEN_MAX);
- if (val == NULL) {
- _LOGE("Out of Memory\n");
- free(node);
- node = NULL;
- return PMINFO_R_ERROR;
- }
- link = g_slist_find_custom(filter->list,
- (gconstpointer)node, __compare_func);
- if (link) {
- ptr = (pkgmgrinfo_node_x *)link->data;
- strncpy(prev, ptr->value, PKG_STRING_LEN_MAX - 1);
- _LOGI("Previous value is %s\n", prev);
- _pkgmgrinfo_node_destroy(ptr);
- filter->list = g_slist_delete_link(filter->list, link);
- ret = snprintf(temp, PKG_STRING_LEN_MAX - 1,
- "%s,%s", prev, value);
- if (ret < 0 || ret > PKG_STRING_LEN_MAX - 1) {
- _LOGE("snprintf fail\n");
- free(node);
- free(val);
- return PMINFO_R_ERROR;
- }
- strncpy(val, temp, PKG_STRING_LEN_MAX);
- _LOGI("New value is %s\n", val);
- node->value = val;
- filter->list = g_slist_append(
- filter->list, (gpointer)node);
- memset(temp, '\0', PKG_STRING_LEN_MAX);
- } else {
- snprintf(temp, PKG_STRING_LEN_MAX - 1, "%s", value);
- strncpy(val, temp, PKG_STRING_LEN_MAX);
- _LOGI("First value is %s\n", val);
- node->value = val;
- filter->list = g_slist_append(
- filter->list, (gpointer)node);
- memset(temp, '\0', PKG_STRING_LEN_MAX);
- }
- break;
- default:
- node->value = strndup(value, PKG_STRING_LEN_MAX - 1);
- link = g_slist_find_custom(filter->list,
- (gconstpointer)node, __compare_func);
- if (link) {
- _pkgmgrinfo_node_destroy(
- reinterpret_cast<pkgmgrinfo_node_x*>(link->data));
- filter->list = g_slist_delete_link(filter->list, link);
- }
- filter->list = g_slist_append(filter->list, (gpointer)node);
- break;
- }
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_usr_filter_count(
- pkgmgrinfo_appinfo_filter_h handle, int *count, uid_t uid)
-{
- int ret;
- pkgmgrinfo_filter_x *filter;
-
- if (handle == NULL || count == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- filter = (pkgmgrinfo_filter_x *)handle;
- if (__check_disable_filter_exist(
- filter, E_APPINFO_DISABLE_TYPE_APP) == false) {
- if (pkgmgrinfo_appinfo_filter_add_bool(handle,
- PMINFO_APPINFO_PROP_APP_DISABLE, false))
- return PMINFO_R_ERROR;
- }
-
- if (__check_disable_filter_exist(
- filter, E_APPINFO_DISABLE_TYPE_PKG) == false) {
- if (pkgmgrinfo_appinfo_filter_add_bool(handle,
- PMINFO_APPINFO_PROP_PKG_DISABLE, false))
- return PMINFO_R_ERROR;
- }
-
- ps::ShmAppReader reader(uid);
- std::map<std::string, pc::AppInfoHandle> list;
-
- if (reader.Init())
- ret = reader.GetHandles(reinterpret_cast<pkgmgrinfo_filter_x*>(filter), list);
- else
- ret = _appinfo_get_applications(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- 0, &list);
- if (ret == PMINFO_R_ERROR)
- return ret;
-
- *count = list.size();
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_filter_count(
- pkgmgrinfo_appinfo_filter_h handle, int *count)
-{
- return pkgmgrinfo_appinfo_usr_filter_count(handle, count, _getuid());
-}
-
-API int pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
- pkgmgrinfo_appinfo_filter_h handle,
- pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
-{
- if (handle == NULL || app_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- pkgmgrinfo_filter_x* filter = reinterpret_cast<pkgmgrinfo_filter_x*>(handle);
- if (__check_disable_filter_exist(
- filter, E_APPINFO_DISABLE_TYPE_APP) == false) {
- if (pkgmgrinfo_appinfo_filter_add_bool(handle,
- PMINFO_APPINFO_PROP_APP_DISABLE, false))
- return PMINFO_R_ERROR;
- }
-
- if (__check_disable_filter_exist(
- filter, E_APPINFO_DISABLE_TYPE_PKG) == false) {
- if (pkgmgrinfo_appinfo_filter_add_bool(handle,
- PMINFO_APPINFO_PROP_PKG_DISABLE, false))
- return PMINFO_R_ERROR;
- }
-
- return _appinfo_get_filtered_foreach_appinfo(uid,
- filter, PMINFO_APPINFO_GET_ALL, app_cb, user_data);
-}
-
-API int pkgmgrinfo_appinfo_filter_foreach_appinfo(
- pkgmgrinfo_appinfo_filter_h handle,
- pkgmgrinfo_app_list_cb app_cb, void *user_data)
-{
- return pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(
- handle, app_cb, user_data, _getuid());
-}
-
-API int pkgmgrinfo_appinfo_metadata_filter_create(
- pkgmgrinfo_appinfo_metadata_filter_h *handle)
-{
- return pkgmgrinfo_pkginfo_filter_create(handle);
-}
-
-API int pkgmgrinfo_appinfo_metadata_filter_destroy(
- pkgmgrinfo_appinfo_metadata_filter_h handle)
-{
- return pkgmgrinfo_pkginfo_filter_destroy(handle);
-}
-
-API int pkgmgrinfo_appinfo_metadata_filter_add(
- pkgmgrinfo_appinfo_metadata_filter_h handle,
- const char *key, const char *value)
-{
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
- pkgmgrinfo_metadata_node_x *node;
-
- /* value can be NULL.
- * In that case all apps with specified key should be displayed
- */
- if (key == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(
- calloc(1, sizeof(pkgmgrinfo_metadata_node_x)));
- if (node == NULL) {
- LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- node->key = strdup(key);
- if (value && strlen(value))
- node->value = strdup(value);
-
- filter->list_metadata = g_slist_append(filter->list_metadata,
- (gpointer)node);
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_usr_metadata_filter_foreach(
- pkgmgrinfo_appinfo_metadata_filter_h handle,
- pkgmgrinfo_app_list_cb app_cb, void *user_data, uid_t uid)
-{
- if (handle == NULL || app_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
-
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_APP_DISABLE, false))
- return PMINFO_R_ERROR;
-
- if (pkgmgrinfo_appinfo_filter_add_bool(filter,
- PMINFO_APPINFO_PROP_PKG_DISABLE, false))
- return PMINFO_R_ERROR;
-
- return _appinfo_get_filtered_foreach_appinfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(handle),
- PMINFO_APPINFO_GET_ALL, app_cb,
- user_data);
-}
-
-API int pkgmgrinfo_appinfo_metadata_filter_foreach(
- pkgmgrinfo_appinfo_metadata_filter_h handle,
- pkgmgrinfo_app_list_cb app_cb, void *user_data)
-{
- return pkgmgrinfo_appinfo_usr_metadata_filter_foreach(handle, app_cb,
- user_data, _getuid());
-}
-
-API int pkgmgrinfo_appinfo_is_guestmode_visibility(
- pkgmgrinfo_appinfo_h handle, bool *status)
-{
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL\n");
- retvm_if(status == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- *status = _get_bool_value(info->app_info->GetGuestModeVisibility());
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_appcontrol_v2(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
- void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appcontrol_func == NULL,
- PMINFO_R_EINVAL, "Callback function is NULL");
- int ret;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto appcontrol : info->app_info->GetAppcontrol()) {
- if (!strcasecmp(appcontrol.Visibility(), "remote-only"))
- continue;
- ret = appcontrol_func(appcontrol.Operation(), appcontrol.Uri(),
- appcontrol.Mime(), appcontrol.Id(), user_data);
- if (ret < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v2(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb_v2 appcontrol_func,
- void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appcontrol_func == NULL,
- PMINFO_R_EINVAL, "Callback function is NULL");
- int ret;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto appcontrol : info->app_info->GetAppcontrol()) {;
- if (!strcasecmp(appcontrol.Visibility(), "local-only"))
- continue;
- ret = appcontrol_func(appcontrol.Operation(), appcontrol.Uri(),
- appcontrol.Mime(), appcontrol.Id(), user_data);
- if (ret < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_appcontrol_v3(pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb_v3 appcontrol_func,
- void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appcontrol_func == NULL,
- PMINFO_R_EINVAL, "Callback function is NULL");
- int ret;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto appcontrol : info->app_info->GetAppcontrol()) {;
- if (!strcasecmp(appcontrol.Visibility(), "remote-only"))
- continue;
- ret = appcontrol_func((void*)&appcontrol, user_data);
- if (ret < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_foreach_remote_appcontrol_v3(
- pkgmgrinfo_appinfo_h handle,
- pkgmgrinfo_app_control_list_cb_v3 appcontrol_func,
- void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "appinfo handle is NULL");
- retvm_if(appcontrol_func == NULL,
- PMINFO_R_EINVAL, "Callback function is NULL");
- int ret;
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- if (info->app_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto appcontrol : info->app_info->GetAppcontrol()) {;
- if (!strcasecmp(appcontrol.Visibility(), "local-only"))
- continue;
- ret = appcontrol_func((void*)&appcontrol, user_data);
- if (ret < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_appcontrol_get_operation(
- pkgmgrinfo_appinfo_app_control_h handle,
- const char **operation) {
- pc::Appcontrol* app_control = (pc::Appcontrol*)handle;
-
- if (app_control == NULL || operation == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (app_control->Operation() == NULL)
- return PMINFO_R_ENOENT;
- *operation = app_control->Operation();
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_appcontrol_get_uri(
- pkgmgrinfo_appinfo_app_control_h handle,
- const char **uri) {
- pc::Appcontrol* app_control = (pc::Appcontrol*)handle;
-
- if (app_control == NULL || uri == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (app_control->Uri() == NULL)
- return PMINFO_R_ENOENT;
- *uri = app_control->Uri();
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_appcontrol_get_mime(
- pkgmgrinfo_appinfo_app_control_h handle,
- const char **mime) {
- pc::Appcontrol* app_control = (pc::Appcontrol*)handle;
-
- if (app_control == NULL || mime == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (app_control->Mime() == NULL)
- return PMINFO_R_ENOENT;
- *mime = app_control->Mime();
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_appcontrol_get_id(
- pkgmgrinfo_appinfo_app_control_h handle,
- const char **id) {
- pc::Appcontrol* app_control = (pc::Appcontrol*)handle;
-
- if (app_control == NULL || id == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (app_control->Id() == NULL)
- return PMINFO_R_ENOENT;
- *id = app_control->Id();
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_appcontrol_foreach_privilege(
- pkgmgrinfo_appinfo_app_control_h handle,
- pkgmgrinfo_pkg_privilege_list_cb privilege_func,
- void *user_data) {
- int ret;
- pc::Appcontrol* app_control = (pc::Appcontrol*)handle;
-
- if (app_control == NULL || privilege_func == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- for (auto priv : app_control->Privileges()) {
- ret = privilege_func(priv, user_data);
- if (ret != 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_to_parcel(pkgmgrinfo_appinfo_h handle, parcel_h* parcel)
-{
- int ret;
- parcel_h result;
- constexpr uint32_t metadata_size = 4;
- uint32_t metadata[metadata_size];
- pkgmgr_appinfo_x *info = (pkgmgr_appinfo_x *)handle;
-
- // ad-hoc, to handle architecture issue (32 vs 64, BE vs LE)
- // we should send all integers in parcel API (not burst)
- metadata[0] = sizeof(void *);
- metadata[1] = sizeof(application_x);
- metadata[2] = static_cast<uint32_t>(info->app_component);
- metadata[3] = info->app_info->GetDataSize();
-
- if (parcel_create(&result) != PARCEL_ERROR_NONE) {
- _LOGE("parcel_create fail");
- return PMINFO_R_ERROR;
- }
-
- for(uint32_t i = 0; i < metadata_size; i++) {
- ret = parcel_write_uint32(result,static_cast<uint32_t>(metadata[i]));
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to write metadata");
- parcel_destroy(result);
- return PMINFO_R_ERROR;
- }
- }
-
- uint32_t pure_data_size =
- info->app_info->GetDataSize() - sizeof(application_x);
- ret = parcel_burst_write(result, info->app_info->GetData(), pure_data_size);
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to write pkginfo data");
- parcel_destroy(result);
- return PMINFO_R_ERROR;
- }
-
- constexpr int n_item = sizeof(application_x) / (sizeof(void*));
- void **appx = (void **)(info->app_info->GetData() + pure_data_size);
-
- for(int i = 0; i < n_item; i++) {
- ret = parcel_write_int32(result,GPOINTER_TO_INT(appx[i]));
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to write appinfo data");
- parcel_destroy(result);
- return PMINFO_R_ERROR;
- }
- }
-
- *parcel = result;
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_appinfo_from_parcel(parcel_h parcel, pkgmgrinfo_appinfo_h* handle)
-{
- int ret;
- pkgmgr_appinfo_x *result;
- constexpr uint32_t metadata_size = 4;
- uint32_t metadata[metadata_size];
-
- for(uint32_t i = 0; i<metadata_size; i++) {
- ret = parcel_read_uint32(parcel, &metadata[i]);
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to write metadata");
- return PMINFO_R_ERROR;
- }
- }
- // ad-hoc, to handle architecture issue (32 vs 64, BE vs LE)
- // metadata[0] : creator's ptr size
- // metadata[1] : creator's application_x size
- // metadata[2] : creator's app_component
- // metadata[3] : size of following data
-
- uint32_t data_size = metadata[3] - metadata[1] + sizeof(application_x);
- uint32_t pure_data_size = metadata[3] - metadata[1];
-
- uint8_t* data = (uint8_t*)calloc(data_size, sizeof(uint8_t));
- if(data == NULL) {
- _LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- ret = parcel_burst_read(parcel, data, metadata[3] - metadata[1]);
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to read data data");
- free(data);
- return PMINFO_R_ERROR;
- }
-
- // ad-hoc, to handle architecture issue (32 vs 64, BE vs LE)
- constexpr int appx_item_num = sizeof(application_x) / (sizeof(void*));
- void** appx = (void**)(data + pure_data_size);
- for(int i = 0; i < appx_item_num; i++) {
- int32_t value = 0;
- ret = parcel_read_int32(parcel, &value);
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to read pkginfo data");
- free(data);
- return PMINFO_R_ERROR;
- }
-
- if constexpr(sizeof(void*) == 4) {
- appx[i] = reinterpret_cast<void*>(value);
- } else {
- appx[i] = reinterpret_cast<void*>(static_cast<int64_t>(value));
- }
- }
-
- result = (pkgmgr_appinfo_x*)calloc(1, sizeof(pkgmgr_appinfo_x));
- if(result == NULL) {
- _LOGE("out of memory");
- free(data);
- return PMINFO_R_ERROR;
- }
-
- result->app_info = new (std::nothrow) pc::AppInfoHandle(std::make_unique<tizen_base::Parcel>(data, data_size, false));
- if(result->app_info == NULL) {
- _LOGE("Out of memory");
- free(data);
- __cleanup_appinfo(result);
- return PMINFO_R_ERROR;
- }
-
- result->app_component = static_cast<pkgmgrinfo_app_component>(metadata[2]);
- result->package = strdup(result->app_info->GetPackage());
- if(result->package == NULL) {
- _LOGE("Out of memory");
- __cleanup_appinfo(result);
- return PMINFO_R_ERROR;
- }
-
- *handle = result;
- return PMINFO_R_OK;
-}
\ No newline at end of file
#define retm_if(expr, fmt, arg...) do { \
if (expr) { \
- PKGMGR_INFO_DEBUG_ERR("(%s) "#fmt, #expr, ##arg); \
+ PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
return; \
} \
} while (0)
#define retvm_if(expr, val, fmt, arg...) do { \
if (expr) { \
- PKGMGR_INFO_DEBUG_ERR("(%s) "#fmt, #expr, ##arg); \
+ PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
return (val); \
} \
} while (0)
#define trym_if(expr, fmt, arg...) do { \
if (expr) { \
- PKGMGR_INFO_DEBUG_ERR("(%s) "#fmt, #expr, ##arg); \
+ PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
goto catch; \
} \
} while (0)
#define tryvm_if(expr, val, fmt, arg...) do { \
if (expr) { \
- PKGMGR_INFO_DEBUG_ERR("(%s) "#fmt, #expr, ##arg); \
+ PKGMGR_INFO_DEBUG_ERR("(%s) "fmt, #expr, ##arg); \
val; \
goto catch; \
} \
--- /dev/null
+/*
+ * pkgmgr-info
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
+ * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
+ *
+ * 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.
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <sys/smack.h>
+#include <linux/limits.h>
+#include <sys/stat.h>
+
+#include <glib.h>
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_extension.h"
+#include "pkgmgrinfo_private.h"
+#include "pkgmgrinfo_debug.h"
+#include "pkgmgr-info.h"
+#include "manager/pkginfo_manager.h"
+
+static bool _get_bool_value(const char *str)
+{
+ if (str && !strcmp(str, "true"))
+ return true;
+ else
+ return false;
+}
+
+static gint __compare_func(gconstpointer data1, gconstpointer data2)
+{
+ pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
+ pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
+ if (node1->prop == node2->prop)
+ return 0;
+ else if (node1->prop > node2->prop)
+ return 1;
+ else
+ return -1;
+}
+
+static gint __pkg_disable_chk_func(gconstpointer data1, gconstpointer data2)
+{
+ pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
+
+ if (node->prop == E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE)
+ return 0;
+ else
+ return 1;
+}
+
+static void __destroy_metadata_node(gpointer data)
+{
+ pkgmgrinfo_metadata_node_x *node = (pkgmgrinfo_metadata_node_x *)data;
+ if (node->key)
+ free(node->key);
+ if (node->value)
+ free(node->value);
+ free(node);
+}
+
+static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
+{
+ ret_if(data == NULL);
+ if (data->locale) {
+ free((void *)data->locale);
+ data->locale = NULL;
+ }
+
+ pkgmgrinfo_basic_free_package(data->pkg_info);
+ free((void *)data);
+ data = NULL;
+ return;
+}
+
+static void __free_packages(gpointer data)
+{
+ pkgmgrinfo_basic_free_package((package_x *)data);
+}
+
+static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter)
+{
+ GSList *link;
+
+ if (filter == NULL)
+ return false;
+
+ link = g_slist_find_custom(filter->list, NULL, __pkg_disable_chk_func);
+ if (link)
+ return true;
+
+ return false;
+}
+
+static int _pkginfo_get_filtered_foreach_pkginfo(uid_t uid,
+ pkgmgrinfo_filter_x *filter, int flag,
+ pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
+{
+ int ret;
+ package_x *pkg;
+ pkgmgr_pkginfo_x info;
+ GHashTable *list;
+ GHashTableIter iter;
+ gpointer value;
+
+ list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ __free_packages);
+ if (list == NULL)
+ return PMINFO_R_ERROR;
+
+ if (__check_disable_filter_exist(filter) == false) {
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
+ if (ret != PMINFO_R_OK) {
+ _LOGE("Failed to add filter");
+ g_hash_table_destroy(list);
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ ret = _pkginfo_get_packages(uid, filter, flag, list);
+ if (ret == PMINFO_R_ERROR) {
+ g_hash_table_destroy(list);
+ return ret;
+ }
+
+ g_hash_table_iter_init(&iter, list);
+ while (g_hash_table_iter_next(&iter, NULL, &value)) {
+ pkg = (package_x *)value;
+ info.uid = uid;
+ info.pkg_info = pkg;
+ info.locale = pkg->locale;
+ if (pkg_list_cb(&info, user_data) < 0)
+ break;
+ }
+
+ g_hash_table_destroy(list);
+
+ return PMINFO_R_OK;
+}
+
+static int _pkgmgrinfo_get_pkginfo(const char *pkgid, uid_t uid,
+ pkgmgrinfo_pkginfo_filter_h filter, pkgmgrinfo_pkginfo_h *handle)
+{
+ int ret;
+ GHashTable *list;
+ pkgmgr_pkginfo_x *info;
+
+ if (pkgid == NULL || filter == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ __free_packages);
+ if (list == NULL)
+ return PMINFO_R_ERROR;
+
+ ret = _pkginfo_get_packages(uid, filter, PMINFO_PKGINFO_GET_ALL, list);
+ if (ret != PMINFO_R_OK) {
+ g_hash_table_destroy(list);
+ return ret;
+ }
+
+ if (!g_hash_table_size(list) || !g_hash_table_lookup(list, pkgid)) {
+ _LOGD("pkginfo for [%s] is not existed for user [%d]",
+ pkgid, uid);
+ g_hash_table_destroy(list);
+ return PMINFO_R_ENOENT;
+ }
+
+ info = calloc(1, sizeof(pkgmgr_pkginfo_x));
+ if (info == NULL) {
+ _LOGE("out of memory");
+ g_hash_table_destroy(list);
+ return PMINFO_R_ERROR;
+ }
+
+ info->uid = uid;
+ info->pkg_info = (package_x *)g_hash_table_lookup(list, pkgid);
+ info->locale = strdup(info->pkg_info->locale);
+ if (info->locale == NULL) {
+ _LOGE("Out of memory");
+ g_hash_table_destroy(list);
+ free(info);
+ return PMINFO_R_ERROR;
+ }
+
+ /* just free list only */
+ g_hash_table_steal(list, (gconstpointer)pkgid);
+ g_hash_table_destroy(list);
+
+ *handle = info;
+
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid,
+ pkgmgrinfo_pkginfo_h *handle)
+{
+ int ret;
+ pkgmgrinfo_pkginfo_filter_h filter;
+
+ if (pkgid == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ ret = pkgmgrinfo_pkginfo_filter_add_string(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+ ret = _pkgmgrinfo_get_pkginfo(pkgid, uid, filter, handle);
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid,
+ pkgmgrinfo_pkginfo_h *handle)
+{
+ return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, _getuid(), handle);
+}
+
+API int pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(const char *pkgid,
+ uid_t uid, pkgmgrinfo_pkginfo_h *handle)
+{
+ int ret;
+ pkgmgrinfo_pkginfo_filter_h filter;
+
+ if (pkgid == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK) {
+ return ret;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_string(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, true);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _pkgmgrinfo_get_pkginfo(pkgid, uid, filter, handle);
+ if (ret == PMINFO_R_ENOENT)
+ LOGE("disabled pkginfo for [%s] is not existed for user [%d]",
+ pkgid, uid);
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_get_usr_all_pkginfo(const char *pkgid, uid_t uid,
+ pkgmgrinfo_pkginfo_h *handle)
+{
+ int ret;
+ pkgmgrinfo_pkginfo_filter_h filter;
+
+ if (pkgid == NULL || handle == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ ret = pkgmgrinfo_pkginfo_filter_add_string(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE, false);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _pkgmgrinfo_get_pkginfo(pkgid, uid, filter, handle);
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_get_disabled_pkginfo(const char *pkgid,
+ pkgmgrinfo_pkginfo_h *handle)
+{
+ return pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(pkgid, _getuid(),
+ handle);
+}
+
+API int pkgmgrinfo_pkginfo_get_all_pkginfo(const char *pkgid,
+ pkgmgrinfo_pkginfo_h *handle)
+{
+ return pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid, _getuid(), handle);
+}
+
+API int pkgmgrinfo_pkginfo_get_usr_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb,
+ int flag, void *user_data, uid_t uid)
+{
+ int ret;
+ pkgmgrinfo_pkginfo_filter_h filter;
+
+ if (pkg_list_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ /* create an empty filter */
+ ret = pkgmgrinfo_pkginfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ ret = _pkginfo_get_filtered_foreach_pkginfo(uid, filter, flag,
+ pkg_list_cb, user_data);
+
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_get_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb,
+ int flag, void *user_data)
+{
+ return pkgmgrinfo_pkginfo_get_usr_list_full(pkg_list_cb, flag,
+ user_data, _getuid());
+}
+
+API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
+ void *user_data, uid_t uid)
+{
+ int ret;
+ pkgmgrinfo_pkginfo_filter_h filter;
+
+ if (pkg_list_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ /* create an empty filter */
+ ret = pkgmgrinfo_pkginfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ ret = _pkginfo_get_filtered_foreach_pkginfo(uid, filter,
+ PMINFO_PKGINFO_GET_ALL, pkg_list_cb, user_data);
+
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
+ void *user_data)
+{
+ return pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data,
+ _getuid());
+}
+
+API int pkgmgrinfo_pkginfo_get_usr_disabled_list(
+ pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
+{
+ int ret;
+ pkgmgrinfo_pkginfo_filter_h filter;
+
+ if (pkg_list_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = pkgmgrinfo_pkginfo_filter_create(&filter);
+ if (ret != PMINFO_R_OK)
+ return ret;
+
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, true);
+ if (ret != PMINFO_R_OK) {
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _pkginfo_get_filtered_foreach_pkginfo(uid, filter,
+ PMINFO_PKGINFO_GET_ALL, pkg_list_cb, user_data);
+
+ pkgmgrinfo_pkginfo_filter_destroy(filter);
+
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_get_disabled_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
+ void *user_data)
+{
+ return pkgmgrinfo_pkginfo_get_usr_disabled_list(pkg_list_cb, user_data,
+ _getuid());
+}
+
+API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->package == NULL)
+ return PMINFO_R_ERROR;
+
+ *pkg_name = (char *)info->pkg_info->package;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->package == NULL)
+ return PMINFO_R_ERROR;
+
+ *pkgid = (char *)info->pkg_info->package;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->type == NULL)
+ *type = "";
+ else
+ *type = (char *)info->pkg_info->type;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->version == NULL)
+ *version = "";
+ else
+ *version = (char *)info->pkg_info->version;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_api_version(pkgmgrinfo_pkginfo_h handle, char **api_version)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(api_version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->api_version == NULL)
+ *api_version = "";
+ else
+ *api_version = (char *)info->pkg_info->api_version;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_name)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(tep_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->tep_name == NULL)
+ return PMINFO_R_ERROR;
+
+ *tep_name = (char *)info->pkg_info->tep_name;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_zip_mount_file(pkgmgrinfo_pkginfo_h handle, char **zip_mount_file)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(zip_mount_file == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->zip_mount_file == NULL)
+ *zip_mount_file = "";
+ else
+ *zip_mount_file = (char *)info->pkg_info->zip_mount_file;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(ext_image_path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->external_path == NULL)
+ return PMINFO_R_ENOENT;
+
+ *ext_image_path = (char *)info->pkg_info->external_path;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
+{
+ char *val;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
+ return PMINFO_R_ERROR;
+
+ val = (char *)info->pkg_info->installlocation;
+ if (strcmp(val, "internal-only") == 0)
+ *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
+ else if (strcmp(val, "prefer-external") == 0)
+ *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
+ else
+ *location = PMINFO_INSTALL_LOCATION_AUTO;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ char *temp = NULL;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->package_size == NULL) {
+ temp = strdup("");
+ if (temp == NULL) {
+ _LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ } else {
+ info->pkg_info->package_size = temp;
+ }
+ }
+
+ *size = atoi((char *)info->pkg_info->package_size);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
+{
+ icon_x *ptr;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+
+ if (info->pkg_info == NULL || info->pkg_info->icon == NULL)
+ return PMINFO_R_ERROR;
+
+ ptr = (icon_x *)info->pkg_info->icon->data;
+ if (ptr == NULL)
+ return PMINFO_R_ERROR;
+
+ /* TODO : should we return empty string if there was no icon? */
+ if (ptr->text == NULL)
+ *icon = "";
+ else
+ *icon = ptr->text;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
+{
+ label_x *ptr;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
+
+ if (info->pkg_info == NULL || info->pkg_info->label == NULL)
+ return PMINFO_R_ERROR;
+
+ ptr = (label_x *)info->pkg_info->label->data;
+ if (ptr == NULL)
+ return PMINFO_R_ERROR;
+
+ /* TODO : should we return empty string if there was no label? */
+ if (ptr->text == NULL)
+ *label = "";
+ else
+ *label = ptr->text;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
+{
+ description_x *ptr;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->description == NULL)
+ return PMINFO_R_ERROR;
+
+ ptr = (description_x *)info->pkg_info->description->data;
+ if (ptr == NULL)
+ return PMINFO_R_ERROR;
+
+ if (ptr->text == NULL)
+ *description = "";
+ else
+ *description = (char *)ptr->text;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ author_x *author;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->author == NULL)
+ return PMINFO_R_ERROR;
+
+ author = (author_x *)info->pkg_info->author->data;
+ if (author == NULL)
+ return PMINFO_R_ERROR;
+
+ if (author->text == NULL)
+ *author_name = "";
+ else
+ *author_name = (char *)author->text;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ author_x *author;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->author == NULL)
+ return PMINFO_R_ERROR;
+
+ author = (author_x *)info->pkg_info->author->data;
+ if (author == NULL)
+ return PMINFO_R_ERROR;
+
+ if (author->email == NULL)
+ *author_email = "";
+ else
+ *author_email = (char *)author->email;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ author_x *author;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->author == NULL)
+ return PMINFO_R_ERROR;
+
+ author = (author_x *)info->pkg_info->author->data;
+ if (author == NULL)
+ return PMINFO_R_ERROR;
+
+ if (author->href == NULL)
+ *author_href = "";
+ else
+ *author_href = (char *)author->href;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->installed_storage == NULL)
+ return PMINFO_R_ERROR;
+
+ if (strcmp(info->pkg_info->installed_storage, "installed_internal") == 0)
+ *storage = PMINFO_INTERNAL_STORAGE;
+ else if (strcmp(info->pkg_info->installed_storage, "installed_external") == 0)
+ *storage = PMINFO_EXTERNAL_STORAGE;
+ else if (strcmp(info->pkg_info->installed_storage, "installed_extended") == 0)
+ *storage = PMINFO_EXTENDED_STORAGE;
+ else
+ return PMINFO_R_ERROR;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->installed_time == NULL)
+ return PMINFO_R_ERROR;
+
+ *installed_time = atoi(info->pkg_info->installed_time);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->storeclient_id == NULL)
+ *storeclientid = "";
+ else
+ *storeclientid = (char *)info->pkg_info->storeclient_id;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->mainapp_id == NULL)
+ return PMINFO_R_ERROR;
+
+ *mainappid = (char *)info->pkg_info->mainapp_id;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->package_url == NULL)
+ *url = "";
+ else
+ *url = (char *)info->pkg_info->package_url;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->root_path == NULL)
+ return PMINFO_R_ERROR;
+
+ *path = (char *)info->pkg_info->root_path;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->csc_path == NULL)
+ *path = "";
+ else
+ *path = (char *)info->pkg_info->csc_path;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_res_type(pkgmgrinfo_pkginfo_h handle,
+ char **res_type)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(res_type == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->res_type == NULL)
+ return PMINFO_R_ENOENT;
+
+ *res_type = (char *)info->pkg_info->res_type;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_res_version(pkgmgrinfo_pkginfo_h handle,
+ char **res_version)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(res_version == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->res_version == NULL)
+ return PMINFO_R_ENOENT;
+
+ *res_version = (char *)info->pkg_info->res_version;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_light_user_switch_mode(pkgmgrinfo_pkginfo_h handle, char **mode)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(mode == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ if (info->pkg_info->light_user_switch_mode == NULL)
+ return PMINFO_R_ERROR;
+
+ *mode = (char *)info->pkg_info->light_user_switch_mode;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_get_support_mode(pkgmgrinfo_pkginfo_h handle, int *support_mode)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ if (info->pkg_info->support_mode)
+ *support_mode = atoi(info->pkg_info->support_mode);
+ else
+ *support_mode = 0;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+#if 0 /* smack issue occured, check later */
+ char *pkgid = NULL;
+ pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
+ if (pkgid == NULL) {
+ _LOGD("invalid func parameters\n");
+ return PMINFO_R_ERROR;
+ }
+ _LOGD("pkgmgr_get_pkg_external_validation() called\n");
+
+ FILE *fp = NULL;
+ char app_mmc_path[FILENAME_MAX] = { 0, };
+ char app_dir_path[FILENAME_MAX] = { 0, };
+ char app_mmc_internal_path[FILENAME_MAX] = { 0, };
+ snprintf(app_dir_path, FILENAME_MAX, "%s%s", PKG_INSTALLATION_PATH, pkgid);
+ snprintf(app_mmc_path, FILENAME_MAX, "%s%s", PKG_SD_PATH, pkgid);
+ snprintf(app_mmc_internal_path, FILENAME_MAX, "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
+
+ /*check whether application is in external memory or not */
+ fp = fopen(app_mmc_path, "r");
+ if (fp == NULL) {
+ _LOGD(" app path in external memory not accesible\n");
+ } else {
+ fclose(fp);
+ fp = NULL;
+ *accessible = 1;
+ _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
+ return PMINFO_R_OK;
+ }
+
+ /*check whether application is in internal or not */
+ if (fp == NULL) {
+ _LOGD(" app path in internal memory not accesible\n");
+ *accessible = 0;
+ return PMINFO_R_ERROR;
+ } else {
+ fclose(fp);
+ /*check whether the application is installed in SD card
+ but SD card is not present*/
+ fp = fopen(app_mmc_internal_path, "r");
+ if (fp == NULL) {
+ *accessible = 1;
+ _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
+ return PMINFO_R_OK;
+ } else {
+ *accessible = 0;
+ _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
+ }
+ fclose(fp);
+ }
+
+ _LOGD("pkgmgr_get_pkg_external_validation() end\n");
+#endif
+
+ *accessible = 1;
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->removable == NULL)
+ return PMINFO_R_ERROR;
+
+ *removable = _get_bool_value(info->pkg_info->removable);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
+{
+ char *val;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->installlocation == NULL)
+ return PMINFO_R_ERROR;
+
+ val = (char *)info->pkg_info->installlocation;
+ if (strcmp(val, "internal-only") == 0)
+ *movable = 0;
+ else
+ *movable = 1;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->preload == NULL)
+ return PMINFO_R_ERROR;
+
+ *preload = _get_bool_value(info->pkg_info->preload);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->system == NULL)
+ return PMINFO_R_ERROR;
+
+ *system = _get_bool_value(info->pkg_info->system);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->readonly == NULL)
+ return PMINFO_R_ERROR;
+
+ *readonly = _get_bool_value(info->pkg_info->readonly);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->update == NULL)
+ return PMINFO_R_ERROR;
+
+ *update = _get_bool_value(info->pkg_info->update);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_support_disable(pkgmgrinfo_pkginfo_h handle, bool *support_disable)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(support_disable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->support_disable == NULL)
+ return PMINFO_R_ERROR;
+
+ *support_disable = _get_bool_value(info->pkg_info->support_disable);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_global(pkgmgrinfo_pkginfo_h handle, bool *global)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->for_all_users == NULL)
+ return PMINFO_R_ERROR;
+
+ *global = _get_bool_value(info->pkg_info->for_all_users);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users)
+{
+ return pkgmgrinfo_pkginfo_is_global(handle, for_all_users);
+}
+
+API int pkgmgrinfo_pkginfo_is_lib(pkgmgrinfo_pkginfo_h handle, bool *lib)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+ retvm_if(lib == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL\n");
+
+ if (info->pkg_info == NULL || info->pkg_info->lib == NULL)
+ return PMINFO_R_ERROR;
+
+ *lib = _get_bool_value(info->pkg_info->lib);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
+
+ __cleanup_pkginfo(info);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
+{
+ pkgmgrinfo_filter_x *filter;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
+
+ filter = (pkgmgrinfo_filter_x *)calloc(1, sizeof(pkgmgrinfo_filter_x));
+ if (filter == NULL) {
+ _LOGE("Out of Memory!!!");
+ return PMINFO_R_ERROR;
+ }
+
+ *handle = filter;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
+{
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+
+ if (filter->list)
+ g_slist_free_full(filter->list,
+ (GDestroyNotify)_pkgmgrinfo_node_destroy);
+
+ if (filter->list_metadata)
+ g_slist_free_full(filter->list_metadata,
+ __destroy_metadata_node);
+ if (filter->list_pkg_metadata)
+ g_slist_free_full(filter->list_pkg_metadata,
+ __destroy_metadata_node);
+
+ free(filter);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
+ const char *property, const int value)
+{
+ char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
+ char *val;
+ GSList *link;
+ int prop;
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+ pkgmgrinfo_node_x *node;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+
+ prop = _pminfo_pkginfo_convert_to_prop_int(property);
+ if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
+ prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
+ _LOGE("Invalid Integer Property\n");
+ return PMINFO_R_EINVAL;
+ }
+ node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
+ if (node == NULL) {
+ _LOGE("Out of Memory!!!\n");
+ return PMINFO_R_ERROR;
+ }
+ snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
+ val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
+ if (val == NULL) {
+ _LOGE("Out of Memory\n");
+ free(node);
+ return PMINFO_R_ERROR;
+ }
+ node->prop = prop;
+ node->value = val;
+ /*If API is called multiple times for same property, we should override the previous values.
+ Last value set will be used for filtering.*/
+ link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
+ filter->list = g_slist_delete_link(filter->list, link);
+ }
+ filter->list = g_slist_append(filter->list, (gpointer)node);
+ return PMINFO_R_OK;
+
+}
+
+API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
+ const char *property, const bool value)
+{
+ char *val;
+ GSList *link;
+ int prop;
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+ pkgmgrinfo_node_x *node;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+
+ prop = _pminfo_pkginfo_convert_to_prop_bool(property);
+ if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
+ prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
+ _LOGE("Invalid Boolean Property\n");
+ return PMINFO_R_EINVAL;
+ }
+ node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
+ if (node == NULL) {
+ _LOGE("Out of Memory!!!\n");
+ return PMINFO_R_ERROR;
+ }
+ if (value)
+ val = strndup("true", 4);
+ else
+ val = strndup("false", 5);
+ if (val == NULL) {
+ _LOGE("Out of Memory\n");
+ free(node);
+ return PMINFO_R_ERROR;
+ }
+ node->prop = prop;
+ node->value = val;
+ /*If API is called multiple times for same property, we should override the previous values.
+ Last value set will be used for filtering.*/
+ link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
+ filter->list = g_slist_delete_link(filter->list, link);
+ }
+ filter->list = g_slist_append(filter->list, (gpointer)node);
+ return PMINFO_R_OK;
+
+}
+
+API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
+ const char *property, const char *value)
+{
+ char *val;
+ GSList *link;
+ int prop;
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+ pkgmgrinfo_node_x *node;
+
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+ retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
+
+ prop = _pminfo_pkginfo_convert_to_prop_str(property);
+ if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
+ prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
+ _LOGE("Invalid String Property\n");
+ return PMINFO_R_EINVAL;
+ }
+ node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
+ if (node == NULL) {
+ _LOGE("Out of Memory!!!\n");
+ return PMINFO_R_ERROR;
+ }
+ if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
+ val = strndup("auto", PKG_STRING_LEN_MAX - 1);
+ else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
+ val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
+ else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
+ val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
+ else if (strcmp(value, "installed_internal") == 0)
+ val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
+ else if (strcmp(value, "installed_external") == 0)
+ val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
+ else
+ val = strndup(value, PKG_STRING_LEN_MAX - 1);
+ if (val == NULL) {
+ _LOGE("Out of Memory\n");
+ free(node);
+ return PMINFO_R_ERROR;
+ }
+ node->prop = prop;
+ node->value = val;
+ /*If API is called multiple times for same property, we should override the previous values.
+ Last value set will be used for filtering.*/
+ link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
+ if (link) {
+ _pkgmgrinfo_node_destroy(link->data);
+ filter->list = g_slist_delete_link(filter->list, link);
+ }
+ filter->list = g_slist_append(filter->list, (gpointer)node);
+ return PMINFO_R_OK;
+
+}
+
+API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count, uid_t uid)
+{
+ int ret;
+ int query_count;
+ GHashTable *list = NULL;
+
+ if (handle == NULL || count == NULL) {
+ _LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ list = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+ __free_packages);
+ if (list == NULL)
+ return PMINFO_R_ERROR;
+
+ if (__check_disable_filter_exist((pkgmgrinfo_filter_x *)handle) == false) {
+ ret = pkgmgrinfo_pkginfo_filter_add_bool(handle,
+ PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
+ if (ret != PMINFO_R_OK) {
+ g_hash_table_destroy(list);
+ return PMINFO_R_ERROR;
+ }
+ }
+
+ ret = _pkginfo_get_packages(uid, handle, PMINFO_PKGINFO_GET_BASICINFO, list);
+ query_count = g_hash_table_size(list);
+ g_hash_table_destroy(list);
+ if (ret == PMINFO_R_ERROR)
+ return ret;
+ *count = query_count;
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
+{
+ return pkgmgrinfo_pkginfo_usr_filter_count(handle, count, _getuid());
+}
+
+API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(
+ pkgmgrinfo_pkginfo_filter_h handle,
+ pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
+{
+ if (handle == NULL || pkg_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ return _pkginfo_get_filtered_foreach_pkginfo(uid, handle,
+ PMINFO_PKGINFO_GET_ALL, pkg_cb, user_data);
+}
+
+API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
+ pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
+{
+ return pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, pkg_cb, user_data, _getuid());
+}
+
+API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret;
+ privilege_x *privilege;
+ appdefined_privilege_x *appdefined_privilege;
+ GList *tmp;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->pkg_info->privileges; tmp; tmp = tmp->next) {
+ privilege = (privilege_x *)tmp->data;
+ if (privilege == NULL)
+ continue;
+ ret = privilege_func(privilege->value, user_data);
+ if (ret < 0)
+ return PMINFO_R_OK;
+ }
+
+ for (tmp = info->pkg_info->appdefined_privileges; tmp;
+ tmp = tmp->next) {
+ appdefined_privilege = (appdefined_privilege_x *)tmp->data;
+ if (appdefined_privilege == NULL)
+ continue;
+ ret = privilege_func(appdefined_privilege->value, user_data);
+ if (ret < 0)
+ return PMINFO_R_OK;
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_foreach_privilege_v2(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_privilege_list_cb_v2 privilege_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
+ int ret;
+ privilege_x *privilege;
+ appdefined_privilege_x *appdefined_privilege;
+ pkgmgrinfo_privilege_x privilege_handle;
+ GList *tmp;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->pkg_info->privileges; tmp; tmp = tmp->next) {
+
+ privilege = (privilege_x *)tmp->data;
+ if (privilege == NULL)
+ continue;
+ privilege_handle.category = PMINFO_PRIVILEGE_NORMAL;
+ privilege_handle.priv = (void *)privilege;
+ ret = privilege_func((pkgmgrinfo_pkginfo_privilege_h)&privilege_handle, user_data);
+ if (ret < 0)
+ return PMINFO_R_OK;
+ }
+
+ for (tmp = info->pkg_info->appdefined_privileges; tmp;
+ tmp = tmp->next) {
+ appdefined_privilege = (appdefined_privilege_x *)tmp->data;
+ if (appdefined_privilege == NULL)
+ continue;
+ privilege_handle.category = PMINFO_PRIVILEGE_APPDEFINES;
+ privilege_handle.priv = (void *)appdefined_privilege;
+ ret = privilege_func((pkgmgrinfo_pkginfo_privilege_h)&privilege_handle, user_data);
+ if (ret < 0)
+ return PMINFO_R_OK;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_get_privilege_category(pkgmgrinfo_pkginfo_privilege_h handle, pkgmgrinfo_privilege_category *category)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "privilege handle is NULL");
+ retvm_if(category == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ *category = ((pkgmgrinfo_privilege_x *)handle)->category;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_get_privilege_name(pkgmgrinfo_pkginfo_privilege_h handle, char **name)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "privilege handle is NULL");
+ retvm_if(name == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ int ret = PMINFO_R_OK;
+ pkgmgrinfo_privilege_x *privilege_handle = (pkgmgrinfo_privilege_x *)handle;
+ switch (privilege_handle->category) {
+ case PMINFO_PRIVILEGE_NORMAL:
+ *name = ((privilege_x *)privilege_handle->priv)->value;
+ break;
+ case PMINFO_PRIVILEGE_APPDEFINES:
+ *name = ((appdefined_privilege_x *)privilege_handle->priv)->value;
+ break;
+ default:
+ LOGE("Invalid privilege category : %d",
+ privilege_handle->category);
+ ret = PMINFO_R_ERROR;
+ break;
+ }
+
+ return ret;
+}
+
+API int pkgmgrinfo_get_privilege_type(pkgmgrinfo_pkginfo_privilege_h handle, char **type)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "privilege handle is NULL");
+ retvm_if(type == NULL, PMINFO_R_EINVAL,
+ "Argument supplied to hold return value is NULL");
+
+ int ret = PMINFO_R_OK;
+ pkgmgrinfo_privilege_x *privilege_handle = (pkgmgrinfo_privilege_x *)handle;
+ switch (privilege_handle->category) {
+ case PMINFO_PRIVILEGE_NORMAL:
+ *type = ((privilege_x *)privilege_handle->priv)->type;
+ break;
+ case PMINFO_PRIVILEGE_APPDEFINES:
+ *type = ((appdefined_privilege_x *)privilege_handle->priv)->type;
+ break;
+ default:
+ LOGE("Invalid privilege category : %d",
+ privilege_handle->category);
+ ret = PMINFO_R_ERROR;
+ break;
+ }
+
+ return ret;
+}
+
+API int pkgmgrinfo_pkginfo_foreach_plugin(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_plugin_list_cb plugin_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(plugin_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret;
+ plugin_x *plugin;
+ GList *tmp;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->pkg_info->plugin; tmp; tmp = tmp->next) {
+ plugin = (plugin_x *)tmp->data;
+ if (plugin == NULL)
+ continue;
+ ret = plugin_func(plugin->pkgid, plugin->appid,
+ plugin->plugin_type, plugin->plugin_name, user_data);
+ if (ret < 0)
+ return PMINFO_R_OK;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_foreach_appdefined_privilege(
+ pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_appdefined_privilege_list_cb privilege_func,
+ void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(privilege_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret;
+ appdefined_privilege_x *privilege;
+ GList *tmp;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->pkg_info->appdefined_privileges; tmp;
+ tmp = tmp->next) {
+ privilege = (appdefined_privilege_x *)tmp->data;
+ if (privilege == NULL)
+ continue;
+ ret = privilege_func(privilege->value, privilege->license,
+ user_data);
+ if (ret < 0)
+ break;
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_foreach_dependency(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_dependency_list_cb dependency_cb,
+ void *user_data)
+{
+ int ret;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ GList *tmp;
+ dependency_x *dependency;
+
+ if (handle == NULL || dependency_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->pkg_info->dependencies; tmp; tmp = tmp->next) {
+ dependency = (dependency_x *)tmp->data;
+ if (dependency == NULL)
+ continue;
+ ret = dependency_cb(info->pkg_info->package,
+ dependency->depends_on, dependency->type,
+ dependency->required_version, user_data);
+ if (ret < 0)
+ break;
+ }
+
+ return PMINFO_R_OK;
+}
+
+static void __free_depends_on(gpointer data)
+{
+ dependency_x *dep = (dependency_x *)data;
+ pkgmgrinfo_basic_free_dependency(dep);
+}
+
+/* This API is not exported at the header file */
+API int pkgmgrinfo_pkginfo_foreach_depends_on_by_pkgid(const char *pkgid,
+ pkgmgrinfo_pkg_dependency_list_cb dependency_cb,
+ void *user_data, uid_t uid)
+{
+ int ret;
+ GList *pkg_list = NULL;
+ GList *l;
+ dependency_x *dep;
+
+ if (pkgid == NULL || dependency_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = _pkginfo_get_depends_on(uid, pkgid, &pkg_list);
+ if (ret != PMINFO_R_OK)
+ return PMINFO_R_ERROR;
+
+ for (l = pkg_list; l != NULL; l = g_list_next(l)) {
+ dep = (dependency_x *)l->data;
+ ret = dependency_cb(dep->pkgid, dep->depends_on,
+ dep->type, dep->required_version, user_data);
+ if (ret < 0)
+ break;
+ }
+ g_list_free_full(pkg_list, __free_depends_on);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_foreach_depends_on(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_dependency_list_cb dependency_cb,
+ void *user_data)
+{
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ if (handle == NULL || dependency_cb == NULL || info->pkg_info == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ return pkgmgrinfo_pkginfo_foreach_depends_on_by_pkgid(
+ info->pkg_info->package, dependency_cb, user_data,
+ info->uid);
+}
+
+API int pkgmgrinfo_pkginfo_foreach_res_allowed_package(
+ pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_res_allowed_package_list_cb res_allowed_package_cb,
+ void *user_data)
+{
+ int ret;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ GList *res_pkgs;
+ res_allowed_package_x *res_allowed_package;
+
+ if (handle == NULL || res_allowed_package_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (res_pkgs = info->pkg_info->res_allowed_packages; res_pkgs;
+ res_pkgs = res_pkgs->next) {
+ res_allowed_package = (res_allowed_package_x *)res_pkgs->data;
+ if (res_allowed_package == NULL)
+ continue;
+
+ ret = res_allowed_package_cb(
+ res_allowed_package->allowed_package,
+ res_allowed_package->required_privileges,
+ user_data);
+ if (ret < 0)
+ return PMINFO_R_OK;
+ }
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_foreach_required_privilege(
+ required_privilege_h handle,
+ pkgmgrinfo_pkg_privilege_list_cb privilege_func,
+ void *user_data)
+{
+ int ret;
+ GList *privs;
+
+ if (privilege_func == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ for (privs = (GList *)handle; privs; privs = privs->next) {
+ ret = privilege_func((char *)privs->data, user_data);
+ if (ret < 0)
+ return PMINFO_R_OK;
+ }
+
+ return PMINFO_R_OK;
+}
+
+int __compare_package_version(const char *version, int *major,
+ int *minor, int *macro, int *nano)
+{
+ char *version_temp = NULL;
+ char *major_str = NULL;
+ char *minor_str = NULL;
+ char *macro_str = NULL;
+ char *nano_str = NULL;
+ char *save_str = NULL;
+
+ if (version == NULL || major == NULL || minor == NULL ||
+ macro == NULL || nano == NULL) {
+ return PMINFO_R_EINVAL;
+ }
+
+ version_temp = strdup(version);
+ if (version_temp == NULL) {
+ LOGE("Out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ major_str = strtok_r(version_temp, ".", &save_str);
+ if (major_str == NULL) {
+ _LOGE("major version is NULL");
+ free(version_temp);
+ return PMINFO_R_ERROR;
+ }
+
+ minor_str = strtok_r(NULL, ".", &save_str);
+ if (minor_str == NULL) {
+ _LOGE("minor version is NULL");
+ free(version_temp);
+ return PMINFO_R_ERROR;
+ }
+
+ *major = atoi(major_str);
+ *minor = atoi(minor_str);
+ *macro = 0;
+ *nano = 0;
+ macro_str = strtok_r(NULL, ".", &save_str);
+ if (macro_str == NULL) {
+ _LOGD("macro version is NULL");
+ } else {
+ *macro = atoi(macro_str);
+ nano_str = strtok_r(NULL, ".", &save_str);
+ if (nano_str) {
+ *nano = atoi(nano_str);
+ _LOGD("nano version exists");
+ }
+ }
+ _LOGD("version = [%s] -> major = [%d], minor = [%d]," \
+ " macro = [%d], nano = [%d]", version, *major,
+ *minor, *macro, *nano);
+
+ free(version_temp);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_compare_package_version(const char *current_version,
+ const char *target_version,
+ pkgmgrinfo_version_compare_type *res)
+{
+ int ret = 0;
+ int current_version_major = 0;
+ int current_version_minor = 0;
+ int current_version_macro = 0;
+ int current_version_nano = 0;
+ int target_version_major = 0;
+ int target_version_minor = 0;
+ int target_version_macro = 0;
+ int target_version_nano = 0;
+
+ if (current_version == NULL || target_version == NULL ||
+ res == NULL) {
+ _LOGE("Invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ ret = __compare_package_version(target_version,
+ &target_version_major, &target_version_minor,
+ &target_version_macro, &target_version_nano);
+ if (ret < 0) {
+ _LOGE("Failed to compare target version(%d)", ret);
+ return PMINFO_R_ERROR;
+ }
+
+ ret = __compare_package_version(current_version,
+ ¤t_version_major, ¤t_version_minor,
+ ¤t_version_macro, ¤t_version_nano);
+ if (ret < 0) {
+ _LOGE("Failed to compare current version(%d)", ret);
+ return PMINFO_R_ERROR;
+ }
+
+ _LOGD("new[%d.%d.%d.%d] old[%d.%d.%d.%d]", target_version_major,
+ target_version_minor, target_version_macro,
+ target_version_nano, current_version_major,
+ current_version_minor, current_version_macro,
+ target_version_nano);
+
+ if (target_version_major > current_version_major)
+ *res = PMINFO_VERSION_NEW;
+ else if (target_version_major < current_version_major)
+ *res = PMINFO_VERSION_OLD;
+ else if (target_version_minor > current_version_minor)
+ *res = PMINFO_VERSION_NEW;
+ else if (target_version_minor < current_version_minor)
+ *res = PMINFO_VERSION_OLD;
+ else if (target_version_macro > current_version_macro)
+ *res = PMINFO_VERSION_NEW;
+ else if (target_version_macro < current_version_macro)
+ *res = PMINFO_VERSION_OLD;
+ else if (target_version_nano > current_version_nano)
+ *res = PMINFO_VERSION_NEW;
+ else if (target_version_nano < current_version_nano)
+ *res = PMINFO_VERSION_OLD;
+ else
+ *res = PMINFO_VERSION_SAME;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_foreach_metadata(pkgmgrinfo_pkginfo_h handle,
+ pkgmgrinfo_pkg_metadata_list_cb metadata_func, void *user_data)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
+ "Callback function is NULL");
+ int ret = -1;
+ metadata_x *ptr;
+ GList *tmp;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ if (info->pkg_info == NULL)
+ return PMINFO_R_ERROR;
+
+ for (tmp = info->pkg_info->metadata; tmp; tmp = tmp->next) {
+ ptr = (metadata_x *)tmp->data;
+ if (ptr == NULL)
+ continue;
+ if (ptr->key) {
+ ret = metadata_func(ptr->key, ptr->value ?
+ ptr->value : "", user_data);
+ if (ret < 0)
+ break;
+ }
+ }
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_metadata_filter_create(
+ pkgmgrinfo_pkginfo_metadata_filter_h *handle)
+{
+ return pkgmgrinfo_pkginfo_filter_create(handle);
+}
+
+API int pkgmgrinfo_pkginfo_metadata_filter_destroy(
+ pkgmgrinfo_pkginfo_metadata_filter_h handle)
+{
+ return pkgmgrinfo_pkginfo_filter_destroy(handle);
+}
+
+API int pkgmgrinfo_pkginfo_metadata_filter_add(
+ pkgmgrinfo_pkginfo_metadata_filter_h handle,
+ const char *key, const char *value)
+{
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+ pkgmgrinfo_metadata_node_x *node;
+
+ /* value can be NULL.
+ * In that case all pkgs with specified key should be displayed
+ */
+ if (handle == NULL || key == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ node = calloc(1, sizeof(pkgmgrinfo_metadata_node_x));
+ if (node == NULL) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ node->key = strdup(key);
+ if (value && strlen(value))
+ node->value = strdup(value);
+
+ filter->list_pkg_metadata = g_slist_append(filter->list_pkg_metadata,
+ (gpointer)node);
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_usr_metadata_filter_foreach(
+ pkgmgrinfo_pkginfo_metadata_filter_h handle,
+ pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
+{
+ if (handle == NULL || pkg_cb == NULL) {
+ LOGE("invalid parameter");
+ return PMINFO_R_EINVAL;
+ }
+
+ pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
+
+ if (pkgmgrinfo_pkginfo_filter_add_bool(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false))
+ return PMINFO_R_ERROR;
+
+ return _pkginfo_get_filtered_foreach_pkginfo(uid, handle,
+ PMINFO_PKGINFO_GET_ALL, pkg_cb,
+ user_data);
+}
+
+API int pkgmgrinfo_pkginfo_metadata_filter_foreach(
+ pkgmgrinfo_pkginfo_metadata_filter_h handle,
+ pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
+{
+ return pkgmgrinfo_pkginfo_usr_metadata_filter_foreach(handle, pkg_cb,
+ user_data, _getuid());
+}
+
+API int pkgmgrinfo_pkginfo_get_metadata_value(
+ pkgmgrinfo_pkginfo_h handle, const char *metadata_key,
+ char **metadata_value)
+{
+ retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
+ retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
+ retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
+ "metadata_value is NULL");
+
+ GList *list_md = NULL;
+ metadata_x *metadata = NULL;
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+
+ list_md = info->pkg_info->metadata;
+
+ for (; list_md; list_md = list_md->next) {
+ metadata = (metadata_x *)list_md->data;
+ if (metadata && metadata->key) {
+ if (strcasecmp(metadata->key, metadata_key) == 0) {
+ if (metadata->value == NULL)
+ *metadata_value = "";
+ else
+ *metadata_value =
+ (char *)metadata->value;
+ return PMINFO_R_OK;
+ }
+ }
+ }
+
+ return PMINFO_R_EINVAL;
+}
+
+API int pkgmgrinfo_pkginfo_to_parcel(pkgmgrinfo_pkginfo_h handle, parcel_h* parcel)
+{
+ parcel_h result = NULL;
+ int ret;
+
+ if (parcel_create(&result) != PARCEL_ERROR_NONE) {
+ _LOGE("parcel_create fail");
+ return PMINFO_R_ERROR;
+ }
+
+ pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
+ ret = _write_package_to_parcel(info->pkg_info, result);
+ if (ret != PMINFO_R_OK) {
+ _LOGE("_write_package_to_parcel fail, %d", ret);
+ parcel_destroy(result);
+ return ret;
+ }
+
+ ret = parcel_write_uint32(result, info->uid);
+ if (ret != PARCEL_ERROR_NONE) {
+ _LOGE("Failed to write uid");
+ parcel_destroy(result);
+ return PMINFO_R_ERROR;
+ }
+
+ *parcel = result;
+
+ return PMINFO_R_OK;
+}
+
+API int pkgmgrinfo_pkginfo_from_parcel(parcel_h parcel, pkgmgrinfo_pkginfo_h* handle)
+{
+ pkgmgr_pkginfo_x *info;
+ package_x* pkg;
+ int ret;
+
+ info = calloc(1, sizeof(pkgmgr_pkginfo_x));
+ if (info == NULL) {
+ _LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ ret = _read_package_from_parcel(parcel, &info->pkg_info);
+ if (ret != PMINFO_R_OK) {
+ _LOGE("_read_package_from_parcel fail, %d", ret);
+ __cleanup_pkginfo(info);
+ return ret;
+ }
+
+ ret = parcel_read_uint32(parcel, &info->uid);
+ if (ret != PARCEL_ERROR_NONE) {
+ _LOGE("Failed to read uid");
+ __cleanup_pkginfo(info);
+ return PMINFO_R_ERROR;
+ }
+
+ info->locale = strdup(info->pkg_info->locale);
+ if (info->locale == NULL) {
+ _LOGE("Out of memory");
+ __cleanup_pkginfo(info);
+ return PMINFO_R_ERROR;
+ }
+
+ *handle = info;
+
+ return PMINFO_R_OK;
+}
+++ /dev/null
-/*
- * pkgmgr-info
- *
- * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>,
- * Jaeho Lee <jaeho81.lee@samsung.com>, Shobhit Srivastava <shobhit.s@samsung.com>
- *
- * 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 _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdbool.h>
-#include <unistd.h>
-#include <ctype.h>
-#include <sys/smack.h>
-#include <linux/limits.h>
-#include <sys/stat.h>
-
-#include <glib.h>
-
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-#include "pkgmgrinfo_extension.h"
-#include "pkgmgrinfo_debug.h"
-#include "pkgmgr-info.h"
-#include "manager/pkginfo_manager.h"
-#include "pkgmgr_info_handle.hh"
-#include "common/shared_memory/shm_pkg_reader.hh"
-
-#include "utils/logging.hh"
-
-#include <chrono>
-
-namespace pc = pkgmgr_common;
-namespace ps = pkgmgr_common::shared_memory;
-
-struct pkgmgr_pkginfo_x {
- uid_t uid;
- const pc::PkgInfoHandle* pkg_info;
- char *locale;
-};
-
-static bool _get_bool_value(const char *str)
-{
- if (str && !strcmp(str, "true"))
- return true;
- else
- return false;
-}
-
-static gint __compare_func(gconstpointer data1, gconstpointer data2)
-{
- pkgmgrinfo_node_x *node1 = (pkgmgrinfo_node_x *)data1;
- pkgmgrinfo_node_x *node2 = (pkgmgrinfo_node_x *)data2;
- if (node1->prop == node2->prop)
- return 0;
- else if (node1->prop > node2->prop)
- return 1;
- else
- return -1;
-}
-
-static gint __pkg_disable_chk_func(gconstpointer data1, gconstpointer data2)
-{
- pkgmgrinfo_node_x *node = (pkgmgrinfo_node_x *)data1;
-
- if (node->prop == E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE)
- return 0;
- else
- return 1;
-}
-
-static void __destroy_metadata_node(gpointer data)
-{
- pkgmgrinfo_metadata_node_x *node = (pkgmgrinfo_metadata_node_x *)data;
- if (node->key)
- free(node->key);
- if (node->value)
- free(node->value);
- free(node);
-}
-
-static void __cleanup_pkginfo(pkgmgr_pkginfo_x *data)
-{
- ret_if(data == NULL);
-
- if (data->pkg_info)
- delete data->pkg_info;
- free(data);
-}
-
-static bool __check_disable_filter_exist(pkgmgrinfo_filter_x *filter)
-{
- GSList *link;
-
- if (filter == NULL)
- return false;
-
- link = g_slist_find_custom(filter->list, NULL, __pkg_disable_chk_func);
- if (link)
- return true;
-
- return false;
-}
-
-static int _pkginfo_get_filtered_foreach_pkginfo(uid_t uid,
- pkgmgrinfo_filter_x *filter, int flag,
- pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data)
-{
- int ret;
- ps::ShmPkgReader reader(uid);
- std::map<std::string, pc::PkgInfoHandle> list;
- pkgmgr_pkginfo_x info;
-
- if (__check_disable_filter_exist(filter) == false) {
- ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
- if (ret != PMINFO_R_OK) {
- _LOGE("Failed to add filter");
- return PMINFO_R_ERROR;
- }
- }
- if (reader.Init())
- ret = reader.GetHandles(reinterpret_cast<pkgmgrinfo_filter_x*>(filter), list);
- else
- ret = _pkginfo_get_packages(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_PKGINFO_GET_ALL, &list);
- if (ret == PMINFO_R_ERROR)
- return ret;
-
- for (const auto& pkg : list) {
- info.uid = uid;
- info.pkg_info = &pkg.second;
- info.locale = const_cast<char*>(pkg.second.GetLocale());
- if (pkg_list_cb(&info, user_data) < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-static int _pkgmgrinfo_get_pkginfo(const char *pkgid, uid_t uid,
- pkgmgrinfo_pkginfo_filter_h filter, pkgmgrinfo_pkginfo_h *handle)
-{
- if (pkgid == NULL || filter == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- int ret;
- ps::ShmPkgReader reader(uid);
- std::map<std::string, pc::PkgInfoHandle> list;
- if (reader.Init()) {
- ret = reader.GetHandles(reinterpret_cast<pkgmgrinfo_filter_x*>(filter), list);
- } else {
- ret = _pkginfo_get_packages(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_PKGINFO_GET_ALL, &list);
- }
- if (ret != PMINFO_R_OK)
- return ret;
-
- auto it = list.find(pkgid);
- if (it == list.end()) {
- _LOGD("pkginfo for [%s] is not existed for user [%d]", pkgid, uid);
- return PMINFO_R_ENOENT;
- }
-
- pkgmgr_pkginfo_x *info = reinterpret_cast<pkgmgr_pkginfo_x*>(
- calloc(1, sizeof(pkgmgr_pkginfo_x)));
- if (info == NULL) {
- _LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- info->uid = uid;
- info->pkg_info = new pc::PkgInfoHandle(std::move(it->second));
- info->locale = const_cast<char*>(info->pkg_info->GetLocale());
-
- *handle = info;
-
- return ret;
-}
-
-API int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char *pkgid, uid_t uid,
- pkgmgrinfo_pkginfo_h *handle)
-{
- int ret;
- pkgmgrinfo_pkginfo_filter_h filter;
-
- if (pkgid == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- ret = pkgmgrinfo_pkginfo_filter_add_string(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
- ret = _pkgmgrinfo_get_pkginfo(pkgid, uid, filter, handle);
- pkgmgrinfo_pkginfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_pkginfo_get_pkginfo(const char *pkgid,
- pkgmgrinfo_pkginfo_h *handle)
-{
- return pkgmgrinfo_pkginfo_get_usr_pkginfo(pkgid, _getuid(), handle);
-}
-
-API int pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(const char *pkgid,
- uid_t uid, pkgmgrinfo_pkginfo_h *handle)
-{
- int ret;
- pkgmgrinfo_pkginfo_filter_h filter;
-
- if (pkgid == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_create(&filter);
- if (ret != PMINFO_R_OK) {
- return ret;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_add_string(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, true);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = _pkgmgrinfo_get_pkginfo(pkgid, uid, filter, handle);
- if (ret == PMINFO_R_ENOENT)
- LOGE("disabled pkginfo for [%s] is not existed for user [%d]",
- pkgid, uid);
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- return ret;
-}
-
-API int pkgmgrinfo_pkginfo_get_usr_all_pkginfo(const char *pkgid, uid_t uid,
- pkgmgrinfo_pkginfo_h *handle)
-{
- int ret;
- pkgmgrinfo_pkginfo_filter_h filter;
-
- if (pkgid == NULL || handle == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- ret = pkgmgrinfo_pkginfo_filter_add_string(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_ID, pkgid);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE, false);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = _pkgmgrinfo_get_pkginfo(pkgid, uid, filter, handle);
- pkgmgrinfo_pkginfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_pkginfo_get_disabled_pkginfo(const char *pkgid,
- pkgmgrinfo_pkginfo_h *handle)
-{
- return pkgmgrinfo_pkginfo_get_usr_disabled_pkginfo(pkgid, _getuid(),
- handle);
-}
-
-API int pkgmgrinfo_pkginfo_get_all_pkginfo(const char *pkgid,
- pkgmgrinfo_pkginfo_h *handle)
-{
- return pkgmgrinfo_pkginfo_get_usr_all_pkginfo(pkgid, _getuid(), handle);
-}
-
-API int pkgmgrinfo_pkginfo_get_usr_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb,
- int flag, void *user_data, uid_t uid)
-{
- int ret;
- pkgmgrinfo_pkginfo_filter_h filter;
-
- if (pkg_list_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- /* create an empty filter */
- ret = pkgmgrinfo_pkginfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- ret = _pkginfo_get_filtered_foreach_pkginfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- flag, pkg_list_cb, user_data);
-
- pkgmgrinfo_pkginfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_pkginfo_get_list_full(pkgmgrinfo_pkg_list_cb pkg_list_cb,
- int flag, void *user_data)
-{
- return pkgmgrinfo_pkginfo_get_usr_list_full(pkg_list_cb, flag,
- user_data, _getuid());
-}
-
-API int pkgmgrinfo_pkginfo_get_usr_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
- void *user_data, uid_t uid)
-{
- int ret;
- pkgmgrinfo_pkginfo_filter_h filter;
-
- if (pkg_list_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- /* create an empty filter */
- ret = pkgmgrinfo_pkginfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- ret = _pkginfo_get_filtered_foreach_pkginfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_PKGINFO_GET_ALL, pkg_list_cb, user_data);
-
- pkgmgrinfo_pkginfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_pkginfo_get_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
- void *user_data)
-{
- return pkgmgrinfo_pkginfo_get_usr_list(pkg_list_cb, user_data,
- _getuid());
-}
-
-API int pkgmgrinfo_pkginfo_get_usr_disabled_list(
- pkgmgrinfo_pkg_list_cb pkg_list_cb, void *user_data, uid_t uid)
-{
- int ret;
- pkgmgrinfo_pkginfo_filter_h filter;
-
- if (pkg_list_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = pkgmgrinfo_pkginfo_filter_create(&filter);
- if (ret != PMINFO_R_OK)
- return ret;
-
- ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, true);
- if (ret != PMINFO_R_OK) {
- pkgmgrinfo_pkginfo_filter_destroy(filter);
- return PMINFO_R_ERROR;
- }
-
- ret = _pkginfo_get_filtered_foreach_pkginfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_PKGINFO_GET_ALL, pkg_list_cb, user_data);
-
- pkgmgrinfo_pkginfo_filter_destroy(filter);
-
- return ret;
-}
-
-API int pkgmgrinfo_pkginfo_get_disabled_list(pkgmgrinfo_pkg_list_cb pkg_list_cb,
- void *user_data)
-{
- return pkgmgrinfo_pkginfo_get_usr_disabled_list(pkg_list_cb, user_data,
- _getuid());
-}
-
-API int pkgmgrinfo_pkginfo_get_pkgname(pkgmgrinfo_pkginfo_h handle, char **pkg_name)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(pkg_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetPackage() == NULL)
- return PMINFO_R_ERROR;
-
- *pkg_name = const_cast<char*>(info->pkg_info->GetPackage());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_pkgid(pkgmgrinfo_pkginfo_h handle, char **pkgid)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetPackage() == NULL)
- return PMINFO_R_ERROR;
-
- *pkgid = const_cast<char*>(info->pkg_info->GetPackage());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_type(pkgmgrinfo_pkginfo_h handle, char **type)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(type == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetType() == NULL)
- *type = const_cast<char*>("");
- else
- *type = const_cast<char*>(info->pkg_info->GetType());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_version(pkgmgrinfo_pkginfo_h handle, char **version)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetVersion() == NULL)
- *version = const_cast<char*>("");
- else
- *version = const_cast<char*>(info->pkg_info->GetVersion());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_api_version(pkgmgrinfo_pkginfo_h handle, char **api_version)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(api_version == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetApiVersion() == NULL)
- *api_version = const_cast<char*>("");
- else
- *api_version = const_cast<char*>(info->pkg_info->GetApiVersion());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_tep_name(pkgmgrinfo_pkginfo_h handle, char **tep_name)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(tep_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetTepName() == NULL)
- return PMINFO_R_ERROR;
-
- *tep_name = const_cast<char*>(info->pkg_info->GetTepName());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_zip_mount_file(pkgmgrinfo_pkginfo_h handle, char **zip_mount_file)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(zip_mount_file == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetZipMountFile() == NULL)
- *zip_mount_file = const_cast<char*>("");
- else
- *zip_mount_file = const_cast<char*>(info->pkg_info->GetZipMountFile());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_external_image_path(pkgmgrinfo_pkginfo_h handle, char **ext_image_path)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(ext_image_path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetExternalPath() == NULL)
- return PMINFO_R_ENOENT;
-
- *ext_image_path = const_cast<char*>(info->pkg_info->GetExternalPath());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_install_location(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_install_location *location)
-{
- const char *val;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(location == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetInstallLocation() == NULL)
- return PMINFO_R_ERROR;
-
- val = info->pkg_info->GetInstallLocation();
- if (strcmp(val, "internal-only") == 0)
- *location = PMINFO_INSTALL_LOCATION_INTERNAL_ONLY;
- else if (strcmp(val, "prefer-external") == 0)
- *location = PMINFO_INSTALL_LOCATION_PREFER_EXTERNAL;
- else
- *location = PMINFO_INSTALL_LOCATION_AUTO;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_package_size(pkgmgrinfo_pkginfo_h handle, int *size)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(size == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetPackageSize() == NULL) {
- *size = 0;
- return PMINFO_R_OK;
- }
-
- *size = atoi(info->pkg_info->GetPackageSize());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_icon(pkgmgrinfo_pkginfo_h handle, char **icon)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
- retvm_if(icon == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- auto iter = info->pkg_info->GetIcon();
- if (iter.begin() == iter.end())
- return PMINFO_R_ERROR;
-
- pc::Icon result(*iter.begin());
- /* TODO : should we return empty string if there was no icon? */
- if (result.Text() == NULL)
- *icon = const_cast<char*>("");
- else
- *icon = const_cast<char*>(result.Text());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_label(pkgmgrinfo_pkginfo_h handle, char **label)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
- retvm_if(label == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- auto iter = info->pkg_info->GetLabel();
- if (iter.begin() == iter.end())
- return PMINFO_R_ERROR;
-
- pc::Label result(*iter.begin());
- /* TODO : should we return empty string if there was no label? */
- if (result.Text() == NULL)
- *label = const_cast<char*>("");
- else
- *label = const_cast<char*>(result.Text());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_description(pkgmgrinfo_pkginfo_h handle, char **description)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(description == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- auto iter = info->pkg_info->GetDescription();
- if (iter.begin() == iter.end())
- return PMINFO_R_ERROR;
-
- pc::Description result(*iter.begin());
- if (result.Text() == NULL)
- *description = const_cast<char*>("");
- else
- *description = const_cast<char*>(result.Text());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_author_name(pkgmgrinfo_pkginfo_h handle, char **author_name)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(author_name == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- auto iter = info->pkg_info->GetAuthor();
- if (iter.begin() == iter.end())
- return PMINFO_R_ERROR;
-
- pc::Author result(*iter.begin());
- if (result.Text() == NULL)
- *author_name = const_cast<char*>("");
- else
- *author_name = const_cast<char*>(result.Text());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_author_email(pkgmgrinfo_pkginfo_h handle, char **author_email)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(author_email == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- auto iter = info->pkg_info->GetAuthor();
- if (iter.begin() == iter.end())
- return PMINFO_R_ERROR;
-
- pc::Author result(*iter.begin());
- if (result.Email() == NULL)
- *author_email = const_cast<char*>("");
- else
- *author_email = const_cast<char*>(result.Email());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_author_href(pkgmgrinfo_pkginfo_h handle, char **author_href)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(author_href == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- auto iter = info->pkg_info->GetAuthor();
- if (iter.begin() == iter.end())
- return PMINFO_R_ERROR;
-
- pc::Author result(*iter.begin());
- if (result.Href() == NULL)
- *author_href = const_cast<char*>("");
- else
- *author_href = const_cast<char*>(result.Href());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_installed_storage(pkgmgrinfo_pkginfo_h handle, pkgmgrinfo_installed_storage *storage)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(storage == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- const char* installed_storage = nullptr;
- if (info->pkg_info == NULL ||
- (installed_storage = info->pkg_info->GetInstalledStorage()) == NULL)
- return PMINFO_R_ERROR;
-
- if (strcmp(installed_storage, "installed_internal") == 0)
- *storage = PMINFO_INTERNAL_STORAGE;
- else if (strcmp(installed_storage, "installed_external") == 0)
- *storage = PMINFO_EXTERNAL_STORAGE;
- else if (strcmp(installed_storage, "installed_extended") == 0)
- *storage = PMINFO_EXTENDED_STORAGE;
- else
- return PMINFO_R_ERROR;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_installed_time(pkgmgrinfo_pkginfo_h handle, int *installed_time)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(installed_time == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetInstalledTime() == NULL)
- return PMINFO_R_ERROR;
-
- *installed_time = atoi(info->pkg_info->GetInstalledTime());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_storeclientid(pkgmgrinfo_pkginfo_h handle, char **storeclientid)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(storeclientid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetStoreClientId() == NULL)
- *storeclientid = const_cast<char*>("");
- else
- *storeclientid = const_cast<char*>(info->pkg_info->GetStoreClientId());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_mainappid(pkgmgrinfo_pkginfo_h handle, char **mainappid)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(mainappid == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetMainAppId() == NULL)
- return PMINFO_R_ERROR;
-
- *mainappid = const_cast<char*>(info->pkg_info->GetMainAppId());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_url(pkgmgrinfo_pkginfo_h handle, char **url)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(url == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetPackageUrl() == NULL)
- *url = const_cast<char*>("");
- else
- *url = const_cast<char*>(info->pkg_info->GetPackageUrl());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_root_path(pkgmgrinfo_pkginfo_h handle, char **path)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetRootPath() == NULL)
- return PMINFO_R_ERROR;
-
- *path = const_cast<char*>(info->pkg_info->GetRootPath());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_csc_path(pkgmgrinfo_pkginfo_h handle, char **path)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(path == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetCscPath() == NULL)
- *path = const_cast<char*>("");
- else
- *path = const_cast<char*>(info->pkg_info->GetCscPath());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_res_type(pkgmgrinfo_pkginfo_h handle,
- char **res_type)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(res_type == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetResType() == NULL)
- return PMINFO_R_ENOENT;
-
- *res_type = const_cast<char*>(info->pkg_info->GetResType());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_res_version(pkgmgrinfo_pkginfo_h handle,
- char **res_version)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(res_version == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetResVersion() == NULL)
- return PMINFO_R_ENOENT;
-
- *res_version = const_cast<char*>(info->pkg_info->GetResVersion());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_light_user_switch_mode(pkgmgrinfo_pkginfo_h handle, char **mode)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(mode == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- if (info->pkg_info->GetLightUserSwitchMode() == NULL)
- return PMINFO_R_ERROR;
-
- *mode = const_cast<char*>(info->pkg_info->GetLightUserSwitchMode());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_get_support_mode(pkgmgrinfo_pkginfo_h handle, int *support_mode)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(support_mode == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- if (info->pkg_info->GetSupportMode())
- *support_mode = atoi(info->pkg_info->GetSupportMode());
- else
- *support_mode = 0;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_accessible(pkgmgrinfo_pkginfo_h handle, bool *accessible)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(accessible == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
-#if 0 /* smack issue occured, check later */
- char *pkgid = NULL;
- pkgmgrinfo_pkginfo_get_pkgid(handle, &pkgid);
- if (pkgid == NULL) {
- _LOGD("invalid func parameters\n");
- return PMINFO_R_ERROR;
- }
- _LOGD("pkgmgr_get_pkg_external_validation() called\n");
-
- FILE *fp = NULL;
- char app_mmc_path[FILENAME_MAX] = { 0, };
- char app_dir_path[FILENAME_MAX] = { 0, };
- char app_mmc_internal_path[FILENAME_MAX] = { 0, };
- snprintf(app_dir_path, FILENAME_MAX, "%s%s", PKG_INSTALLATION_PATH, pkgid);
- snprintf(app_mmc_path, FILENAME_MAX, "%s%s", PKG_SD_PATH, pkgid);
- snprintf(app_mmc_internal_path, FILENAME_MAX, "%s%s/.mmc", PKG_INSTALLATION_PATH, pkgid);
-
- /*check whether application is in external memory or not */
- fp = fopen(app_mmc_path, "r");
- if (fp == NULL) {
- _LOGD(" app path in external memory not accesible\n");
- } else {
- fclose(fp);
- fp = NULL;
- *accessible = 1;
- _LOGD("pkgmgr_get_pkg_external_validation() : SD_CARD \n");
- return PMINFO_R_OK;
- }
-
- /*check whether application is in internal or not */
- if (fp == NULL) {
- _LOGD(" app path in internal memory not accesible\n");
- *accessible = 0;
- return PMINFO_R_ERROR;
- } else {
- fclose(fp);
- /*check whether the application is installed in SD card
- but SD card is not present*/
- fp = fopen(app_mmc_internal_path, "r");
- if (fp == NULL) {
- *accessible = 1;
- _LOGD("pkgmgr_get_pkg_external_validation() : INTERNAL_MEM \n");
- return PMINFO_R_OK;
- } else {
- *accessible = 0;
- _LOGD("pkgmgr_get_pkg_external_validation() : ERROR_MMC_STATUS \n");
- }
- fclose(fp);
- }
-
- _LOGD("pkgmgr_get_pkg_external_validation() end\n");
-#endif
-
- *accessible = 1;
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_removable(pkgmgrinfo_pkginfo_h handle, bool *removable)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(removable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetRemovable() == NULL)
- return PMINFO_R_ERROR;
-
- *removable = _get_bool_value(info->pkg_info->GetRemovable());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_movable(pkgmgrinfo_pkginfo_h handle, bool *movable)
-{
- char *val;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(movable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetInstallLocation() == NULL)
- return PMINFO_R_ERROR;
-
- val = const_cast<char*>(info->pkg_info->GetInstallLocation());
- if (strcmp(val, "internal-only") == 0)
- *movable = 0;
- else
- *movable = 1;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_preload(pkgmgrinfo_pkginfo_h handle, bool *preload)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(preload == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetPreload() == NULL)
- return PMINFO_R_ERROR;
-
- *preload = _get_bool_value(info->pkg_info->GetPreload());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_system(pkgmgrinfo_pkginfo_h handle, bool *system)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(system == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetSystem() == NULL)
- return PMINFO_R_ERROR;
-
- *system = _get_bool_value(info->pkg_info->GetSystem());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_readonly(pkgmgrinfo_pkginfo_h handle, bool *readonly)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(readonly == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetReadonly() == NULL)
- return PMINFO_R_ERROR;
-
- *readonly = _get_bool_value(info->pkg_info->GetReadonly());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_update(pkgmgrinfo_pkginfo_h handle, bool *update)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(update == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetUpdate() == NULL)
- return PMINFO_R_ERROR;
-
- *update = _get_bool_value(info->pkg_info->GetUpdate());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_support_disable(pkgmgrinfo_pkginfo_h handle, bool *support_disable)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(support_disable == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetSupportDisable() == NULL)
- return PMINFO_R_ERROR;
-
- *support_disable = _get_bool_value(info->pkg_info->GetSupportDisable());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_global(pkgmgrinfo_pkginfo_h handle, bool *global)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(global == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetForAllUsers() == NULL)
- return PMINFO_R_ERROR;
-
- *global = _get_bool_value(info->pkg_info->GetForAllUsers());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_is_for_all_users(pkgmgrinfo_pkginfo_h handle, bool *for_all_users)
-{
- return pkgmgrinfo_pkginfo_is_global(handle, for_all_users);
-}
-
-API int pkgmgrinfo_pkginfo_is_lib(pkgmgrinfo_pkginfo_h handle, bool *lib)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
- retvm_if(lib == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL\n");
-
- if (info->pkg_info == NULL || info->pkg_info->GetLib() == NULL)
- return PMINFO_R_ERROR;
-
- *lib = _get_bool_value(info->pkg_info->GetLib());
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h handle)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL\n");
-
- __cleanup_pkginfo(info);
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_filter_create(pkgmgrinfo_pkginfo_filter_h *handle)
-{
- pkgmgrinfo_filter_x *filter;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle output parameter is NULL\n");
-
- filter = (pkgmgrinfo_filter_x *)calloc(1, sizeof(pkgmgrinfo_filter_x));
- if (filter == NULL) {
- _LOGE("Out of Memory!!!");
- return PMINFO_R_ERROR;
- }
-
- *handle = filter;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_filter_destroy(pkgmgrinfo_pkginfo_filter_h handle)
-{
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-
- if (filter->list)
- g_slist_free_full(filter->list,
- (GDestroyNotify)_pkgmgrinfo_node_destroy);
-
- if (filter->list_metadata)
- g_slist_free_full(filter->list_metadata,
- __destroy_metadata_node);
- if (filter->list_pkg_metadata)
- g_slist_free_full(filter->list_pkg_metadata,
- __destroy_metadata_node);
-
- free(filter);
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_filter_add_int(pkgmgrinfo_pkginfo_filter_h handle,
- const char *property, const int value)
-{
- char buf[PKG_VALUE_STRING_LEN_MAX] = {'\0'};
- char *val;
- GSList *link;
- int prop;
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
- pkgmgrinfo_node_x *node;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
- retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-
- prop = _pminfo_pkginfo_convert_to_prop_int(property);
- if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_INT ||
- prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_INT) {
- _LOGE("Invalid Integer Property\n");
- return PMINFO_R_EINVAL;
- }
- node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
- if (node == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
- snprintf(buf, PKG_VALUE_STRING_LEN_MAX - 1, "%d", value);
- val = strndup(buf, PKG_VALUE_STRING_LEN_MAX - 1);
- if (val == NULL) {
- _LOGE("Out of Memory\n");
- free(node);
- return PMINFO_R_ERROR;
- }
- node->prop = prop;
- node->value = val;
- /*If API is called multiple times for same property, we should override the previous values.
- Last value set will be used for filtering.*/
- link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
- if (link) {
- _pkgmgrinfo_node_destroy(reinterpret_cast<pkgmgrinfo_node_x*>(link->data));
- filter->list = g_slist_delete_link(filter->list, link);
- }
- filter->list = g_slist_append(filter->list, (gpointer)node);
- return PMINFO_R_OK;
-
-}
-
-API int pkgmgrinfo_pkginfo_filter_add_bool(pkgmgrinfo_pkginfo_filter_h handle,
- const char *property, const bool value)
-{
- char *val;
- GSList *link;
- int prop;
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
- pkgmgrinfo_node_x *node;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
- retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-
- prop = _pminfo_pkginfo_convert_to_prop_bool(property);
- if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_BOOL ||
- prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_BOOL) {
- _LOGE("Invalid Boolean Property\n");
- return PMINFO_R_EINVAL;
- }
- node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
- if (node == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
- if (value)
- val = strndup("true", 4);
- else
- val = strndup("false", 5);
- if (val == NULL) {
- _LOGE("Out of Memory\n");
- free(node);
- return PMINFO_R_ERROR;
- }
- node->prop = prop;
- node->value = val;
- /*If API is called multiple times for same property, we should override the previous values.
- Last value set will be used for filtering.*/
- link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
- if (link) {
- _pkgmgrinfo_node_destroy(reinterpret_cast<pkgmgrinfo_node_x*>(link->data));
- filter->list = g_slist_delete_link(filter->list, link);
- }
- filter->list = g_slist_append(filter->list, (gpointer)node);
- return PMINFO_R_OK;
-
-}
-
-API int pkgmgrinfo_pkginfo_filter_add_string(pkgmgrinfo_pkginfo_filter_h handle,
- const char *property, const char *value)
-{
- char *val;
- GSList *link;
- int prop;
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
- pkgmgrinfo_node_x *node;
-
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
- retvm_if(property == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
- retvm_if(value == NULL, PMINFO_R_EINVAL, "Filter handle input parameter is NULL\n");
-
- prop = _pminfo_pkginfo_convert_to_prop_str(property);
- if (prop < E_PMINFO_PKGINFO_PROP_PACKAGE_MIN_STR ||
- prop > E_PMINFO_PKGINFO_PROP_PACKAGE_MAX_STR) {
- _LOGE("Invalid String Property\n");
- return PMINFO_R_EINVAL;
- }
- node = (pkgmgrinfo_node_x *)calloc(1, sizeof(pkgmgrinfo_node_x));
- if (node == NULL) {
- _LOGE("Out of Memory!!!\n");
- return PMINFO_R_ERROR;
- }
- if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_AUTO) == 0)
- val = strndup("auto", PKG_STRING_LEN_MAX - 1);
- else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_INTERNAL) == 0)
- val = strndup("internal-only", PKG_STRING_LEN_MAX - 1);
- else if (strcmp(value, PMINFO_PKGINFO_INSTALL_LOCATION_EXTERNAL) == 0)
- val = strndup("prefer-external", PKG_STRING_LEN_MAX - 1);
- else if (strcmp(value, "installed_internal") == 0)
- val = strndup("installed_internal", PKG_STRING_LEN_MAX - 1);
- else if (strcmp(value, "installed_external") == 0)
- val = strndup("installed_external", PKG_STRING_LEN_MAX - 1);
- else
- val = strndup(value, PKG_STRING_LEN_MAX - 1);
- if (val == NULL) {
- _LOGE("Out of Memory\n");
- free(node);
- return PMINFO_R_ERROR;
- }
- node->prop = prop;
- node->value = val;
- /*If API is called multiple times for same property, we should override the previous values.
- Last value set will be used for filtering.*/
- link = g_slist_find_custom(filter->list, (gconstpointer)node, __compare_func);
- if (link) {
- _pkgmgrinfo_node_destroy(reinterpret_cast<pkgmgrinfo_node_x*>(link->data));
- filter->list = g_slist_delete_link(filter->list, link);
- }
- filter->list = g_slist_append(filter->list, (gpointer)node);
- return PMINFO_R_OK;
-
-}
-
-API int pkgmgrinfo_pkginfo_usr_filter_count(pkgmgrinfo_pkginfo_filter_h filter, int *count, uid_t uid)
-{
- int ret;
- ps::ShmPkgReader reader(uid);
- std::map<std::string, pc::PkgInfoHandle> list;
-
- if (filter == NULL || count == NULL) {
- _LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (__check_disable_filter_exist((pkgmgrinfo_filter_x *)filter) == false) {
- ret = pkgmgrinfo_pkginfo_filter_add_bool(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false);
- if (ret != PMINFO_R_OK)
- return PMINFO_R_ERROR;
- }
-
- if (reader.Init())
- ret = reader.GetHandles(reinterpret_cast<pkgmgrinfo_filter_x*>(filter), list);
- else
- ret = _pkginfo_get_packages(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(filter),
- PMINFO_PKGINFO_GET_ALL, &list);
- if (ret == PMINFO_R_ERROR)
- return ret;
- *count = list.size();
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_filter_count(pkgmgrinfo_pkginfo_filter_h handle, int *count)
-{
- return pkgmgrinfo_pkginfo_usr_filter_count(handle, count, _getuid());
-}
-
-API int pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(
- pkgmgrinfo_pkginfo_filter_h handle,
- pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
-{
- if (handle == NULL || pkg_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- return _pkginfo_get_filtered_foreach_pkginfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(handle),
- PMINFO_PKGINFO_GET_ALL, pkg_cb, user_data);
-}
-
-API int pkgmgrinfo_pkginfo_filter_foreach_pkginfo(pkgmgrinfo_pkginfo_filter_h handle,
- pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
-{
- return pkgmgrinfo_pkginfo_usr_filter_foreach_pkginfo(handle, pkg_cb, user_data, _getuid());
-}
-
-API int pkgmgrinfo_pkginfo_foreach_privilege(pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_pkg_privilege_list_cb privilege_func, void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
- retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
-
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto priv : info->pkg_info->GetPrivileges()) {
- if (privilege_func(priv.Value(), user_data) < 0)
- return PMINFO_R_OK;
- }
-
- for (auto priv : info->pkg_info->GetAppdefinedPrivileges()) {
- if (privilege_func(priv.Value(), user_data) < 0)
- return PMINFO_R_OK;
- }
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_foreach_privilege_v2(pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_pkg_privilege_list_cb_v2 privilege_func,
- void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
- retvm_if(privilege_func == NULL, PMINFO_R_EINVAL, "Callback function is NULL");
- int ret;
- pkgmgrinfo_privilege_x privilege_handle;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto priv : info->pkg_info->GetPrivileges()) {
- privilege_handle.category = PMINFO_PRIVILEGE_NORMAL;
- privilege_handle.priv = reinterpret_cast<const void*>(&priv);
- ret = privilege_func(
- reinterpret_cast<pkgmgrinfo_pkginfo_privilege_h>(&privilege_handle),
- user_data);
- if (ret < 0)
- return PMINFO_R_OK;
- }
-
- for (auto priv : info->pkg_info->GetAppdefinedPrivileges()) {
- privilege_handle.category = PMINFO_PRIVILEGE_APPDEFINES;
- privilege_handle.priv = reinterpret_cast<const void*>(&priv);
- ret = privilege_func(
- reinterpret_cast<pkgmgrinfo_pkginfo_privilege_h>(&privilege_handle),
- user_data);
- if (ret < 0)
- return PMINFO_R_OK;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_get_privilege_category(pkgmgrinfo_pkginfo_privilege_h handle, pkgmgrinfo_privilege_category *category)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "privilege handle is NULL");
- retvm_if(category == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- *category = reinterpret_cast<pkgmgrinfo_privilege_x*>(handle)->category;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_get_privilege_name(pkgmgrinfo_pkginfo_privilege_h handle, char **name)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "privilege handle is NULL");
- retvm_if(name == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- int ret = PMINFO_R_OK;
- pkgmgrinfo_privilege_x *privilege_handle =
- reinterpret_cast<pkgmgrinfo_privilege_x*>(handle);
- switch (privilege_handle->category) {
- case PMINFO_PRIVILEGE_NORMAL:
- *name = const_cast<char*>(reinterpret_cast<const pc::Privilege*>(privilege_handle->priv)->Value());
- break;
- case PMINFO_PRIVILEGE_APPDEFINES:
- *name = const_cast<char*>(reinterpret_cast<const pc::AppdefinedPrivilege*>(
- privilege_handle->priv)->Value());
- break;
- default:
- LOGE("Invalid privilege category : %d",
- privilege_handle->category);
- ret = PMINFO_R_ERROR;
- break;
- }
-
- return ret;
-}
-
-API int pkgmgrinfo_get_privilege_type(pkgmgrinfo_pkginfo_privilege_h handle, char **type)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "privilege handle is NULL");
- retvm_if(type == NULL, PMINFO_R_EINVAL,
- "Argument supplied to hold return value is NULL");
-
- int ret = PMINFO_R_OK;
- pkgmgrinfo_privilege_x *privilege_handle = (pkgmgrinfo_privilege_x *)handle;
- switch (privilege_handle->category) {
- case PMINFO_PRIVILEGE_NORMAL:
- *type = reinterpret_cast<const privilege_x*>(privilege_handle->priv)->type;
- break;
- case PMINFO_PRIVILEGE_APPDEFINES:
- *type = reinterpret_cast<const appdefined_privilege_x*>(
- privilege_handle->priv)->type;
- break;
- default:
- LOGE("Invalid privilege category : %d",
- privilege_handle->category);
- ret = PMINFO_R_ERROR;
- break;
- }
-
- return ret;
-}
-
-API int pkgmgrinfo_pkginfo_foreach_plugin(pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_plugin_list_cb plugin_func, void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
- retvm_if(plugin_func == NULL, PMINFO_R_EINVAL,
- "Callback function is NULL");
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto plugin : info->pkg_info->GetPlugin()) {
- if (plugin_func(plugin.Pkgid(), plugin.Appid(),
- plugin.PluginType(), plugin.PluginName(), user_data) < 0)
- return PMINFO_R_OK;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_foreach_appdefined_privilege(
- pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_pkg_appdefined_privilege_list_cb privilege_func,
- void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
- retvm_if(privilege_func == NULL, PMINFO_R_EINVAL,
- "Callback function is NULL");
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto priv : info->pkg_info->GetAppdefinedPrivileges()) {
- if (privilege_func(priv.Value(), priv.License(), user_data) < 0)
- break;
- }
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_foreach_dependency(pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_pkg_dependency_list_cb dependency_cb,
- void *user_data)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
- if (handle == NULL || dependency_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto dep : info->pkg_info->GetDependencies()) {
- if (dependency_cb(info->pkg_info->GetPackage(), dep.DependsOn(),
- dep.Type(), dep.RequiredVersion(), user_data) < 0)
- break;
- }
-
- return PMINFO_R_OK;
-}
-
-static void __free_depends_on(gpointer data)
-{
- dependency_x *dep = (dependency_x *)data;
- pkgmgrinfo_basic_free_dependency(dep);
-}
-
-extern "C" {
-
-/* This API is not exported at the header file */
-API int pkgmgrinfo_pkginfo_foreach_depends_on_by_pkgid(const char *pkgid,
- pkgmgrinfo_pkg_dependency_list_cb dependency_cb,
- void *user_data, uid_t uid)
-{
- int ret;
- GList *pkg_list = NULL;
- GList *l;
- dependency_x *dep;
-
- if (pkgid == NULL || dependency_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = _pkginfo_get_depends_on(uid, pkgid, &pkg_list);
- if (ret != PMINFO_R_OK)
- return PMINFO_R_ERROR;
-
- for (l = pkg_list; l != NULL; l = g_list_next(l)) {
- dep = (dependency_x *)l->data;
- ret = dependency_cb(dep->pkgid, dep->depends_on,
- dep->type, dep->required_version, user_data);
- if (ret < 0)
- break;
- }
- g_list_free_full(pkg_list, __free_depends_on);
-
- return PMINFO_R_OK;
-}
-
-}
-
-API int pkgmgrinfo_pkginfo_foreach_depends_on(pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_pkg_dependency_list_cb dependency_cb,
- void *user_data)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- if (handle == NULL || dependency_cb == NULL || info->pkg_info == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- return pkgmgrinfo_pkginfo_foreach_depends_on_by_pkgid(
- info->pkg_info->GetPackage(), dependency_cb, user_data,
- info->uid);
-}
-
-API int pkgmgrinfo_pkginfo_foreach_res_allowed_package(
- pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_res_allowed_package_list_cb res_allowed_package_cb,
- void *user_data)
-{
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- if (handle == NULL || res_allowed_package_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto res_allowed_package :
- info->pkg_info->GetResAllowedPackages()) {
- auto required_privilege =
- res_allowed_package.GetRequiredPrivileges();
- if (res_allowed_package_cb(
- res_allowed_package.AllowedPackage(),
- &required_privilege,
- user_data) < 0)
- return PMINFO_R_OK;
- }
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_foreach_required_privilege(
- required_privilege_h handle,
- pkgmgrinfo_pkg_privilege_list_cb privilege_func,
- void *user_data)
-{
- auto* privs = reinterpret_cast<pc::Iterable<const char*>*>(handle);
-
- if (privilege_func == NULL || privs == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- for (auto priv : *privs)
- if (privilege_func((char*)priv, user_data) < 0)
- return PMINFO_R_OK;
-
- return PMINFO_R_OK;
-}
-
-int __compare_package_version(const char *version, int *major,
- int *minor, int *macro, int *nano)
-{
- char *version_temp = NULL;
- char *major_str = NULL;
- char *minor_str = NULL;
- char *macro_str = NULL;
- char *nano_str = NULL;
- char *save_str = NULL;
-
- if (version == NULL || major == NULL || minor == NULL ||
- macro == NULL || nano == NULL) {
- return PMINFO_R_EINVAL;
- }
-
- version_temp = strdup(version);
- if (version_temp == NULL) {
- LOGE("Out of memory");
- return PMINFO_R_ERROR;
- }
-
- major_str = strtok_r(version_temp, ".", &save_str);
- if (major_str == NULL) {
- _LOGE("major version is NULL");
- free(version_temp);
- return PMINFO_R_ERROR;
- }
-
- minor_str = strtok_r(NULL, ".", &save_str);
- if (minor_str == NULL) {
- _LOGE("minor version is NULL");
- free(version_temp);
- return PMINFO_R_ERROR;
- }
-
- *major = atoi(major_str);
- *minor = atoi(minor_str);
- *macro = 0;
- *nano = 0;
- macro_str = strtok_r(NULL, ".", &save_str);
- if (macro_str == NULL) {
- _LOGD("macro version is NULL");
- } else {
- *macro = atoi(macro_str);
- nano_str = strtok_r(NULL, ".", &save_str);
- if (nano_str) {
- *nano = atoi(nano_str);
- _LOGD("nano version exists");
- }
- }
- _LOGD("version = [%s] -> major = [%d], minor = [%d]," \
- " macro = [%d], nano = [%d]", version, *major,
- *minor, *macro, *nano);
-
- free(version_temp);
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_compare_package_version(const char *current_version,
- const char *target_version,
- pkgmgrinfo_version_compare_type *res)
-{
- int ret = 0;
- int current_version_major = 0;
- int current_version_minor = 0;
- int current_version_macro = 0;
- int current_version_nano = 0;
- int target_version_major = 0;
- int target_version_minor = 0;
- int target_version_macro = 0;
- int target_version_nano = 0;
-
- if (current_version == NULL || target_version == NULL ||
- res == NULL) {
- _LOGE("Invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- ret = __compare_package_version(target_version,
- &target_version_major, &target_version_minor,
- &target_version_macro, &target_version_nano);
- if (ret < 0) {
- _LOGE("Failed to compare target version(%d)", ret);
- return PMINFO_R_ERROR;
- }
-
- ret = __compare_package_version(current_version,
- ¤t_version_major, ¤t_version_minor,
- ¤t_version_macro, ¤t_version_nano);
- if (ret < 0) {
- _LOGE("Failed to compare current version(%d)", ret);
- return PMINFO_R_ERROR;
- }
-
- _LOGD("new[%d.%d.%d.%d] old[%d.%d.%d.%d]", target_version_major,
- target_version_minor, target_version_macro,
- target_version_nano, current_version_major,
- current_version_minor, current_version_macro,
- target_version_nano);
-
- if (target_version_major > current_version_major)
- *res = PMINFO_VERSION_NEW;
- else if (target_version_major < current_version_major)
- *res = PMINFO_VERSION_OLD;
- else if (target_version_minor > current_version_minor)
- *res = PMINFO_VERSION_NEW;
- else if (target_version_minor < current_version_minor)
- *res = PMINFO_VERSION_OLD;
- else if (target_version_macro > current_version_macro)
- *res = PMINFO_VERSION_NEW;
- else if (target_version_macro < current_version_macro)
- *res = PMINFO_VERSION_OLD;
- else if (target_version_nano > current_version_nano)
- *res = PMINFO_VERSION_NEW;
- else if (target_version_nano < current_version_nano)
- *res = PMINFO_VERSION_OLD;
- else
- *res = PMINFO_VERSION_SAME;
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_foreach_metadata(pkgmgrinfo_pkginfo_h handle,
- pkgmgrinfo_pkg_metadata_list_cb metadata_func, void *user_data)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL");
- retvm_if(metadata_func == NULL, PMINFO_R_EINVAL,
- "Callback function is NULL");
- int ret = -1;
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- if (info->pkg_info == NULL)
- return PMINFO_R_ERROR;
-
- for (auto metadata : info->pkg_info->GetMetadata()) {
- if (metadata.Key()) {
- ret = metadata_func(metadata.Key(), metadata.Value() ?
- metadata.Value() : "", user_data);
- if (ret < 0)
- break;
- }
- }
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_metadata_filter_create(
- pkgmgrinfo_pkginfo_metadata_filter_h *handle)
-{
- return pkgmgrinfo_pkginfo_filter_create(handle);
-}
-
-API int pkgmgrinfo_pkginfo_metadata_filter_destroy(
- pkgmgrinfo_pkginfo_metadata_filter_h handle)
-{
- return pkgmgrinfo_pkginfo_filter_destroy(handle);
-}
-
-API int pkgmgrinfo_pkginfo_metadata_filter_add(
- pkgmgrinfo_pkginfo_metadata_filter_h handle,
- const char *key, const char *value)
-{
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
- pkgmgrinfo_metadata_node_x *node;
-
- /* value can be NULL.
- * In that case all pkgs with specified key should be displayed
- */
- if (handle == NULL || key == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(
- calloc(1, sizeof(pkgmgrinfo_metadata_node_x)));
- if (node == NULL) {
- LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- node->key = strdup(key);
- if (value && strlen(value))
- node->value = strdup(value);
-
- filter->list_pkg_metadata = g_slist_append(filter->list_pkg_metadata,
- (gpointer)node);
-
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_usr_metadata_filter_foreach(
- pkgmgrinfo_pkginfo_metadata_filter_h handle,
- pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data, uid_t uid)
-{
- if (handle == NULL || pkg_cb == NULL) {
- LOGE("invalid parameter");
- return PMINFO_R_EINVAL;
- }
-
- pkgmgrinfo_filter_x *filter = (pkgmgrinfo_filter_x *)handle;
-
- if (pkgmgrinfo_pkginfo_filter_add_bool(filter,
- PMINFO_PKGINFO_PROP_PACKAGE_DISABLE, false))
- return PMINFO_R_ERROR;
-
- return _pkginfo_get_filtered_foreach_pkginfo(uid,
- reinterpret_cast<pkgmgrinfo_filter_x*>(handle),
- PMINFO_PKGINFO_GET_ALL, pkg_cb, user_data);
-}
-
-API int pkgmgrinfo_pkginfo_metadata_filter_foreach(
- pkgmgrinfo_pkginfo_metadata_filter_h handle,
- pkgmgrinfo_pkg_list_cb pkg_cb, void *user_data)
-{
- return pkgmgrinfo_pkginfo_usr_metadata_filter_foreach(handle, pkg_cb,
- user_data, _getuid());
-}
-
-API int pkgmgrinfo_pkginfo_get_metadata_value(
- pkgmgrinfo_pkginfo_h handle, const char *metadata_key,
- char **metadata_value)
-{
- retvm_if(handle == NULL, PMINFO_R_EINVAL, "pkginfo handle is NULL %d", 1);
- retvm_if(metadata_key == NULL, PMINFO_R_EINVAL, "metadata_key is NULL");
- retvm_if(metadata_value == NULL, PMINFO_R_EINVAL,
- "metadata_value is NULL");
-
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- for (auto metadata : info->pkg_info->GetMetadata()) {
- if (!metadata.Key())
- continue;
-
- if (strcasecmp(metadata.Key(), metadata_key) == 0) {
- if (metadata.Value() == NULL)
- *metadata_value = const_cast<char*>("");
- else
- *metadata_value = const_cast<char*>(metadata.Value());
- return PMINFO_R_OK;
- }
- }
-
- return PMINFO_R_EINVAL;
-}
-
-API int pkgmgrinfo_pkginfo_to_parcel(pkgmgrinfo_pkginfo_h handle, parcel_h* parcel)
-{
- int ret;
- parcel_h result;
- constexpr uint32_t metadata_size = 4;
- uint32_t metadata[metadata_size];
- pkgmgr_pkginfo_x *info = (pkgmgr_pkginfo_x *)handle;
-
- // ad-hoc, to handle architecture issue (32 vs 64, BE vs LE)
- // we should send all integers in parcel API (not burst)
- metadata[0] = sizeof(void *);
- metadata[1] = sizeof(package_x);
- metadata[2] = info->uid;
- metadata[3] = info->pkg_info->GetDataSize();
-
- if (parcel_create(&result) != PARCEL_ERROR_NONE) {
- _LOGE("parcel_create fail");
- return PMINFO_R_ERROR;
- }
-
- for(uint32_t i = 0; i < metadata_size; i++) {
- ret = parcel_write_uint32(result, static_cast<uint32_t>(metadata[i]));
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to write metadata");
- parcel_destroy(result);
- return PMINFO_R_ERROR;
- }
- }
-
- uint32_t pure_data_size = info->pkg_info->GetDataSize() - sizeof(package_x);
- ret = parcel_burst_write(result, info->pkg_info->GetData(), pure_data_size);
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to write pkginfo data");
- parcel_destroy(result);
- return PMINFO_R_ERROR;
- }
-
- constexpr int n_item = sizeof(package_x) / (sizeof(void*));
- void **pkgx = (void **)(info->pkg_info->GetData() + pure_data_size);
-
- for(int i = 0; i < n_item; i++) {
- ret = parcel_write_int32(result,GPOINTER_TO_INT(pkgx[i]));
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to write pkginfo data");
- parcel_destroy(result);
- return PMINFO_R_ERROR;
- }
- }
-
- *parcel = result;
- return PMINFO_R_OK;
-}
-
-API int pkgmgrinfo_pkginfo_from_parcel(parcel_h parcel, pkgmgrinfo_pkginfo_h* handle)
-{
- int ret;
- pkgmgr_pkginfo_x *result;
- constexpr uint32_t metadata_size = 4;
- uint32_t metadata[metadata_size];
-
- for(uint32_t i = 0; i<metadata_size; i++) {
- ret = parcel_read_uint32(parcel, &metadata[i]);
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to write metadata");
- return PMINFO_R_ERROR;
- }
- }
- // ad-hoc, to handle architecture issue (32 vs 64, BE vs LE)
- // metadata[0] : creator's ptr size
- // metadata[1] : creator's package_x size
- // metadata[2] : creator's uid
- // metadata[3] : size of following data
-
- uint32_t data_size = metadata[3] - metadata[1] + sizeof(package_x);
- uint32_t pure_data_size = metadata[3] - metadata[1];
-
- uint8_t* data = (uint8_t*)calloc(data_size, sizeof(uint8_t));
- if(data == NULL) {
- _LOGE("out of memory");
- return PMINFO_R_ERROR;
- }
-
- ret = parcel_burst_read(parcel, data, metadata[3] - metadata[1]);
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to read data data");
- free(data);
- return PMINFO_R_ERROR;
- }
-
- // ad-hoc, to handle architecture issue (32 vs 64, BE vs LE)
- constexpr int pkgx_item_num = sizeof(package_x) / (sizeof(void*));
- void** pkgx = (void**)(data + pure_data_size);
- for(int i = 0; i < pkgx_item_num; i++) {
- int32_t value = 0;
- ret = parcel_read_int32(parcel, &value);
- if (ret != PARCEL_ERROR_NONE) {
- _LOGE("Failed to read pkginfo data");
- free(data);
- return PMINFO_R_ERROR;
- }
-
- if constexpr(sizeof(void*) == 4) {
- pkgx[i] = reinterpret_cast<void*>(value);
- } else {
- int64_t tmp = static_cast<int64_t>(value);
- pkgx[i] = reinterpret_cast<void*>(tmp);
- }
- }
-
- result = (pkgmgr_pkginfo_x*)calloc(1, sizeof(pkgmgr_pkginfo_x));
- if(result == NULL) {
- _LOGE("out of memory");
- free(data);
- return PMINFO_R_ERROR;
- }
-
- result->pkg_info = new (std::nothrow) pc::PkgInfoHandle(std::make_unique<tizen_base::Parcel>(data, data_size, false));
- if(result->pkg_info == NULL) {
- _LOGE("Out of memory");
- free(data);
- __cleanup_pkginfo(result);
- return PMINFO_R_ERROR;
- }
-
- result->uid = metadata[2];
- result->locale = strdup(result->pkg_info->GetLocale());
- if(result->locale == NULL) {
- _LOGE("Out of memory");
- __cleanup_pkginfo(result);
- return PMINFO_R_ERROR;
- }
-
- *handle = result;
- return PMINFO_R_OK;
-}
switch (node->prop) {
case E_PMINFO_PKGINFO_PROP_PACKAGE_ID:
- _LOGD("E_PMINFO_PKGINFO_PROP_PACKAGE_ID filter : %s", node->value);
snprintf(buf, sizeof(buf), "pi.package=?");
break;
case E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE:
break;
}
case E_PMINFO_APPINFO_PROP_APP_ID:
- _LOGD("E_PMINFO_APPINFO_PROP_APP_ID filter : %s", node->value);
snprintf(buf, sizeof(buf), "ai.app_id=?");
break;
case E_PMINFO_APPINFO_PROP_APP_COMPONENT:
return PMINFO_R_OK;
}
-API int __pkginfo_check_installed_storage(const char *package, const char *installed_storage, const char *external_path)
+API int __pkginfo_check_installed_storage(package_x *pkginfo)
{
char buf[MAX_QUERY_LEN] = {'\0'};
int ret;
- retvm_if(package == NULL, PMINFO_R_OK, "pkgid is NULL\n");
- retvm_if(installed_storage == NULL, PMINFO_R_ERROR,
+ retvm_if(pkginfo->package == NULL, PMINFO_R_OK, "pkgid is NULL\n");
+ retvm_if(pkginfo->installed_storage == NULL, PMINFO_R_ERROR,
"installed_storage is NULL\n");
- if (strcmp(installed_storage, "installed_external") == 0) {
- snprintf(buf, MAX_QUERY_LEN - 1, "%s", external_path);
+ if (strcmp(pkginfo->installed_storage, "installed_external") == 0) {
+ snprintf(buf, MAX_QUERY_LEN - 1, "%s", pkginfo->external_path);
ret = access(buf, R_OK);
if (ret != 0) {
_LOGE("can not access [%s] - %d", buf, ret);
return PMINFO_R_OK;
}
-API int __appinfo_check_installed_storage(const char *installed_storage, const char *external_path)
+API int __appinfo_check_installed_storage(application_x *appinfo)
{
- retvm_if(installed_storage == NULL, PMINFO_R_ERROR,
+ retvm_if(appinfo->installed_storage == NULL, PMINFO_R_ERROR,
"installed_storage is NULL\n");
- if (strcmp(installed_storage, "installed_external") == 0) {
- retvm_if(external_path == NULL, PMINFO_R_ERROR,
+ if (strcmp(appinfo->installed_storage, "installed_external") == 0) {
+ retvm_if(appinfo->external_path == NULL, PMINFO_R_ERROR,
"external path is NULL\n");
- if (access(external_path, R_OK) != 0) {
- _LOGE("can not access [%s]", external_path);
+ if (access(appinfo->external_path, R_OK) != 0) {
+ _LOGE("can not access [%s]", appinfo->external_path);
return PMINFO_R_ERROR;
}
}
E_APPINFO_DISABLE_TYPE_APP
} pkgmgrinfo_appinfo_disable_type;
+typedef struct _pkgmgr_pkginfo_x {
+ uid_t uid;
+ package_x *pkg_info;
+ char *locale;
+} pkgmgr_pkginfo_x;
+
+typedef struct _pkgmgr_appinfo_x {
+ const char *package;
+ char *locale;
+ pkgmgrinfo_app_component app_component;
+ application_x *app_info;
+} pkgmgr_appinfo_x;
+
/*For filter APIs*/
typedef struct _pkgmgrinfo_filter_x {
uid_t uid;
typedef struct _pkgmgrinfo_privilege_x {
pkgmgrinfo_privilege_category category;
- const void *priv;
+ void *priv;
} pkgmgrinfo_privilege_x;
pkgmgrinfo_pkginfo_filter_prop_str _pminfo_pkginfo_convert_to_prop_str(const char *property);
pkgmgrinfo_appinfo_filter_prop_int _pminfo_appinfo_convert_to_prop_int(const char *property);
pkgmgrinfo_appinfo_filter_prop_bool _pminfo_appinfo_convert_to_prop_bool(const char *property);
+pkgmgrinfo_pkginfo_filter_prop_range _pminfo_pkginfo_convert_to_prop_range(const char *property);
+
void _pkgmgrinfo_node_destroy(pkgmgrinfo_node_x *node);
+int _check_create_cert_db(void);
int __get_filter_condition(gpointer data, uid_t uid, char **condition, GList **param);
int __get_pkg_metadata_filter_condition(gpointer data, char **condition, GList **param);
int __get_metadata_filter_condition(gpointer data, char **condition, GList **param);
int _add_icon_info_into_list(const char *locale, char *value, GList **icon);
int _add_label_info_into_list(const char *locale, char *value, GList **label);
-int __pkginfo_check_installed_storage(const char *package, const char *installed_storage, const char *external_path);
-int __appinfo_check_installed_storage(const char *installed_storage, const char *external_path);
+int __pkginfo_check_installed_storage(package_x *pkginfo);
+int __appinfo_check_installed_storage(application_x *appinfo);
char *__get_type_from_path(const char *pkg_path);
pkg_plugin_set *__load_library(const char *pkg_type);
void __unload_library(const char *pkg_type);
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SERVER_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/cynara_checker CYNARA_CHECKER_SRCS)
-##AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/ FILTER_CHECKER_SRCS)
-##AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/pkg_filter_checker/ PKG_FILTER_CHECKER_SRCS)
-##AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/app_filter_checker/ APP_FILTER_CHECKER_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/ FILTER_CHECKER_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/pkg_filter_checker/ PKG_FILTER_CHECKER_SRCS)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/filter_checker/app_filter_checker/ APP_FILTER_CHECKER_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/database DATABASE_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/request_handler REQUEST_HANDLER_SRCS)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/shared_memory SHARED_MEMORY_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/src/utils/ UTIL_SRCS)
ADD_LIBRARY(pkgmgr-info-server SHARED
${CYNARA_CHECKER_SRCS}
-## ${FILTER_CHECKER_SRCS}
-## ${PKG_FILTER_CHECKER_SRCS}
-## ${APP_FILTER_CHECKER_SRCS}
+ ${FILTER_CHECKER_SRCS}
+ ${PKG_FILTER_CHECKER_SRCS}
+ ${APP_FILTER_CHECKER_SRCS}
${SERVER_SRCS}
${DATABASE_SRCS}
${REQUEST_HANDLER_SRCS}
- ${SHARED_MEMORY_SRCS}
${UTIL_SRCS}
)
SET_TARGET_PROPERTIES(pkgmgr-info-server PROPERTIES SOVERSION ${MAJORVER})
SET_TARGET_PROPERTIES(pkgmgr-info-server PROPERTIES VERSION ${FULLVER})
-TARGET_LINK_LIBRARIES(pkgmgr-info-server pkgmgr-info ${libpkgs_server_LDFLAGS} rt)
+TARGET_LINK_LIBRARIES(pkgmgr-info-server pkgmgr-info ${libpkgs_server_LDFLAGS})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/pkgmgr-info-server.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/pkgmgr-info-server.pc @ONLY)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fpic -std=c++17 -pthread")
-TARGET_LINK_LIBRARIES(${PKGINFO_SERVER} ${libpkgs_LDFLAGS} ${libpkgmgr-parser_LDFLAGS} pkgmgr-info-server pthread)
+TARGET_LINK_LIBRARIES(${PKGINFO_SERVER} ${libpkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PKGINFO_SERVER} ${libpkgmgr-parser_LDFLAGS})
+TARGET_LINK_LIBRARIES(${PKGINFO_SERVER} PUBLIC pkgmgr-info-server pthread)
SET_TARGET_PROPERTIES(${PKGINFO_SERVER} PROPERTIES LINKER_LANGUAGE CXX)
INSTALL(TARGETS ${PKGINFO_SERVER} DESTINATION bin)
#include "pkgmgrinfo_private.h"
#include "pkgmgr_parser.h"
#include "pkgmgrinfo_internal.h"
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgr_info_handle_writer.hh"
namespace {
return strdup(str->c_str());
}
-const char* GetCString2(int idx, const tizen_base::Database::Result::Record& rec) {
- return rec.GetCString(idx);
-}
-
int GetSplashScreens(const tizen_base::Database& db,
- const char* appid, pkgmgr_common::AppInfoHandleWriter& writer) {
+ const char* appid, GList** splashscreens) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT src, type, orientation, indicatordisplay, "
"operation, color_depth "
return PMINFO_R_ERROR;
}
- auto& list_writer = writer.GetSplashscreensListWriter();
for (const auto& rec : r) {
- list_writer.AddItem()
- .WriteSrc(GetCString2(0, rec))
- .WriteType(GetCString2(1, rec))
- .WriteOrientation(GetCString2(2, rec))
- .WriteIndicatordisplay(GetCString2(3, rec))
- .WriteOperation(GetCString2(4, rec))
- .WriteColorDepth(GetCString2(5, rec));
+ splashscreen_x* info = static_cast<splashscreen_x*>(
+ calloc(1, sizeof(splashscreen_x)));
+ if (info == nullptr) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ int idx = 0;
+ info->src = GetCString(idx++, rec);
+ info->type = GetCString(idx++, rec);
+ info->orientation = GetCString(idx++, rec);
+ info->indicatordisplay = GetCString(idx++, rec);
+ info->operation = GetCString(idx++, rec);
+ info->color_depth = GetCString(idx++, rec);
+ *splashscreens = g_list_prepend(*splashscreens, info);
}
return PMINFO_R_OK;
}
-void GetAppControlPrivileges(const tizen_base::Database& db,
- const char* app_id, const char* app_control,
- pkgmgr_common::ListWriter<char*>& writer) {
+int GetMetadata(const tizen_base::Database& db,
+ const char* appid, GList** metadata) {
auto q = std::move(tizen_base::Database::Sql(
- "SELECT privilege "
- "FROM package_app_app_control_privilege "
- "WHERE app_id=? AND app_control=?")
- .Bind(app_id)
- .Bind(app_control));
+ "SELECT md_key, md_value "
+ "FROM package_app_app_metadata WHERE app_id=?")
+ .Bind(appid));
auto r = db.Exec(q);
- if (!r)
+ if (!r) {
_LOGE("db.Exec() failed: %s", static_cast<const char*>(r));
+ return PMINFO_R_ERROR;
+ }
for (const auto& rec : r) {
- const char* val = GetCString2(0, rec);
- if (val)
- writer.Write(val);
+ metadata_x* info = static_cast<metadata_x*>(
+ calloc(1, sizeof(metadata_x)));
+ if (info == nullptr) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ int idx = 0;
+ info->key = GetCString(idx++, rec);
+ info->value = GetCString(idx++, rec);
+ *metadata = g_list_prepend(*metadata, info);
}
+
+ return PMINFO_R_OK;
}
-int GetMetadata(const tizen_base::Database& db,
- const char* appid, pkgmgr_common::AppInfoHandleWriter& writer) {
+GList* GetAppControlPrivileges(const tizen_base::Database& db,
+ const char* app_id, const char* app_control) {
auto q = std::move(tizen_base::Database::Sql(
- "SELECT md_key, md_value "
- "FROM package_app_app_metadata WHERE app_id=?")
- .Bind(appid));
+ "SELECT privilege "
+ "FROM package_app_app_control_privilege "
+ "WHERE app_id=? AND app_control=?")
+ .Bind(app_id)
+ .Bind(app_control));
auto r = db.Exec(q);
if (!r) {
_LOGE("db.Exec() failed: %s", static_cast<const char*>(r));
- return PMINFO_R_ERROR;
+ return nullptr;
}
- auto& list_writer = writer.GetMetadataListWriter();
+ GList* privileges = nullptr;
for (const auto& rec : r) {
- list_writer.AddItem()
- .WriteKey(GetCString2(0, rec))
- .WriteValue(GetCString2(1, rec));
+ char* val = GetCString(0, rec);
+ if (val)
+ privileges = g_list_prepend(privileges, (gpointer)val);
}
- return PMINFO_R_OK;
+ return privileges;
}
-void ParseAppControl(const tizen_base::Database& db,
- pkgmgr_common::AppInfoHandleWriter& writer,
+void ParseAppControl(const tizen_base::Database& db, GList** appcontrol,
const char* appcontrol_str, const char* visibility,
const char* id, const char* appid) {
char* dup;
char* token;
char* ptr = nullptr;
+ appcontrol_x* ac;
if (appcontrol_str == nullptr)
return;
return;
}
- auto& app_control_list_writer = writer.GetAppcontrolListWriter();
do {
- auto& app_control_writer = app_control_list_writer.AddItem();
+ ac = static_cast<appcontrol_x*>(calloc(1, sizeof(appcontrol_x)));
+ if (ac == nullptr) {
+ _LOGE("out of memory");
+ break;
+ }
token = strtok_r(dup, "|", &ptr);
if (token && strcmp(token, "NULL"))
- app_control_writer.WriteOperation(token);
+ ac->operation = strdup(token);
token = strtok_r(nullptr, "|", &ptr);
if (token && strcmp(token, "NULL"))
- app_control_writer.WriteUri(token);
+ ac->uri = strdup(token);
token = strtok_r(nullptr, "|", &ptr);
if (token && strcmp(token, "NULL"))
- app_control_writer.WriteMime(token);
- app_control_writer.WriteVisibility(visibility);
- app_control_writer.WriteId(id);
- GetAppControlPrivileges(db, appid, appcontrol_str,
- app_control_writer.GetPrivilegeListWriter());
+ ac->mime = strdup(token);
+ ac->visibility = strdup(visibility);
+ ac->id = strdup(id);
+ ac->privileges = GetAppControlPrivileges(db, appid, appcontrol_str);
+ *appcontrol = g_list_prepend(*appcontrol, ac);
} while ((token = strtok_r(nullptr, ";", &ptr)));
free(dup);
}
int GetAppControl(const tizen_base::Database& db,
- const char* appid, pkgmgr_common::AppInfoHandleWriter& writer) {
+ const char* appid, GList** appcontrol) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT app_control, visibility, app_control_id "
"FROM package_app_app_control WHERE app_id=?")
}
for (const auto& rec : r) {
- ParseAppControl(db, writer, GetCString2(0, rec),
- GetCString2(1, rec), GetCString2(2, rec), appid);
+ ParseAppControl(db, appcontrol, rec.GetString(0)->c_str(),
+ rec.GetString(1)->c_str(), rec.GetString(2)->c_str(), appid);
}
return PMINFO_R_OK;
}
int GetCategory(const tizen_base::Database& db,
- const char* appid, pkgmgr_common::AppInfoHandleWriter& writer) {
+ const char* appid, GList** category) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT category "
"FROM package_app_app_category WHERE app_id=?")
return PMINFO_R_ERROR;
}
- auto& list_writer = writer.GetCategoryListWriter();
for (const auto& rec : r) {
- const char* val = GetCString2(0, rec);
+ char* val = GetCString(0, rec);
if (val)
- list_writer.Write(val);
+ *category = g_list_prepend(*category, (gpointer)val);
}
return PMINFO_R_OK;
}
int GetResControl(const tizen_base::Database& db, const char* appid,
- pkgmgr_common::AppInfoHandleWriter& writer) {
+ GList** res_control) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT res_type, min_res_version, max_res_version, auto_close "
"FROM package_app_res_control WHERE app_id=? "
return PMINFO_R_ERROR;
}
- auto& list_writer = writer.GetResControlListWriter();
for (const auto& rec : r) {
- list_writer.AddItem()
- .WriteResType(GetCString2(0, rec))
- .WriteMinResVersion(GetCString2(1, rec))
- .WriteMaxResVersion(GetCString2(2, rec))
- .WriteAutoClose(GetCString2(3, rec));
+ res_control_x* info = static_cast<res_control_x*>(
+ calloc(1, sizeof(res_control_x)));
+ if (info == nullptr) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ int idx = 0;
+ info->res_type = GetCString(idx++, rec);
+ info->min_res_version = GetCString(idx++, rec);
+ info->max_res_version = GetCString(idx++, rec);
+ info->auto_close = GetCString(idx++, rec);
+ *res_control = g_list_prepend(*res_control, info);
}
return PMINFO_R_OK;
}
-void __get_background_category(const char* value,
- pkgmgr_common::AppInfoHandleWriter& writer) {
+GList* __get_background_category(const char* value) {
+ GList* category_list = nullptr;
int convert_value = 0;
if (!value || strlen(value) == 0)
- return;
+ return nullptr;
convert_value = atoi(value);
if (convert_value < 0)
- return;
+ return nullptr;
- auto& list_writer = writer.GetBackgroundCategoryListWriter();
if (convert_value & APP_BG_CATEGORY_USER_DISABLE_TRUE_VAL)
- list_writer.Write(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_USER_DISABLE_TRUE_STR));
else
- list_writer.Write(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_USER_DISABLE_FALSE_STR));
if (convert_value & APP_BG_CATEGORY_MEDIA_VAL)
- list_writer.Write(APP_BG_CATEGORY_MEDIA_STR);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_MEDIA_STR));
if (convert_value & APP_BG_CATEGORY_DOWNLOAD_VAL)
- list_writer.Write(APP_BG_CATEGORY_DOWNLOAD_STR);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_DOWNLOAD_STR));
if (convert_value & APP_BG_CATEGORY_BGNETWORK_VAL)
- list_writer.Write(APP_BG_CATEGORY_BGNETWORK_STR);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_BGNETWORK_STR));
if (convert_value & APP_BG_CATEGORY_LOCATION_VAL)
- list_writer.Write(APP_BG_CATEGORY_LOCATION_STR);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_LOCATION_STR));
if (convert_value & APP_BG_CATEGORY_SENSOR_VAL)
- list_writer.Write(APP_BG_CATEGORY_SENSOR_STR);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_SENSOR_STR));
if (convert_value & APP_BG_CATEGORY_IOTCOMM_VAL)
- list_writer.Write(APP_BG_CATEGORY_IOTCOMM_STR);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_IOTCOMM_STR));
if (convert_value & APP_BG_CATEGORY_SYSTEM_VAL)
- list_writer.Write(APP_BG_CATEGORY_SYSTEM);
+ category_list = g_list_prepend(category_list,
+ strdup(APP_BG_CATEGORY_SYSTEM));
+
+ return category_list;
}
constexpr const char join_localized_info[] =
}
bool CheckPkgDisableFilter(PackageDisableFilterStatus expected,
- const char* package_disable, const char* package, const char* appid) {
+ const char* package_disable, application_x* app_info) {
if (!package_disable)
return true;
if (result == PackageDisableFilterStatus::True)
LOGW("The package [%s] to which the application [%s] belongs is disabled",
- package, appid);
+ app_info->package, app_info->appid);
return false;
}
bool CheckAppDisableFilter(const pkgmgrinfo_filter_x* filter,
- const char* appid, const char* is_disabled) {
+ const application_x* app_info) {
GSList* tmp_list = nullptr;
pkgmgrinfo_node_x* tmp_node = nullptr;
int property = -1;
if (property != tmp_node->prop)
continue;
- if (strcasecmp(tmp_node->value, is_disabled) == 0)
+ if (strcasecmp(tmp_node->value, app_info->is_disabled) == 0)
return true;
- if (strcasecmp(is_disabled, "true") == 0)
- LOGW("The application [%s] is disabled", appid);
+ if (strcasecmp(app_info->is_disabled, "true") == 0)
+ LOGW("The application [%s] is disabled", app_info->appid);
return false;
}
int DoGetAppInfo(const tizen_base::Database& db, uid_t db_uid, uid_t uid,
const char* locale, pkgmgrinfo_filter_x* filter, int flag,
- std::vector<pkgmgr_common::AppInfoHandle>& appinfo_list) {
+ std::vector<std::shared_ptr<application_x>>& applications) {
static const char query_raw[] =
"SELECT DISTINCT ai.app_id, ai.app_installed_storage, "
"ai.app_external_path";
static const char query_uid_info_clause[] =
" LEFT OUTER JOIN package_app_info_for_uid AS ui "
"ON (ai.app_id=ui.app_id AND ui.uid=?)";
- const char* tmp_record = nullptr;
+ char* bg_category_str = nullptr;
+ char* tmp_record = nullptr;
std::list<std::string> bind_params;
bool is_check_storage = true;
const uid_t global_user_uid = GLOBAL_USER;
bind_params.push_back(locale);
}
- query += query_package_disable;
+ if (pkg_disable_filter_status != PackageDisableFilterStatus::None)
+ query += query_package_disable;
bind_params.push_back(std::to_string(uid));
is_check_storage = __check_app_storage_status(filter);
}
for (const auto& rec : r) {
- pkgmgr_common::AppInfoHandleWriter writer;
- writer.WriteLocale(locale);
+ application_x* info = static_cast<application_x*>(
+ calloc(1, sizeof(application_x)));
+ if (info == nullptr) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+ std::shared_ptr<application_x> info_auto(info,
+ pkgmgrinfo_basic_free_application);
+
+ info->locale = strdup(locale);
+ if (info->locale == nullptr) {
+ LOGE("Out of memory");
+ return PMINFO_R_ERROR;
+ }
int idx = 0;
- const char* appid = nullptr;
- const char* package = nullptr;
- const char* installed_storage = nullptr;
- const char* external_path = nullptr;
- const char* is_disabled = nullptr;
- const char* splash_screen_display = nullptr;
-
- writer.WriteAppId(appid = GetCString2(idx++, rec));
- writer.WriteInstalledStorage(installed_storage = GetCString2(idx++, rec));
- writer.WriteExternalPath(external_path = GetCString2(idx++, rec));
- is_disabled = GetCString2(idx++, rec);
+ info->appid = GetCString(idx++, rec);
+ info->installed_storage = GetCString(idx++, rec);
+ info->external_path = GetCString(idx++, rec);
+ info->is_disabled = GetCString(idx++, rec);
if (flag & PMINFO_APPINFO_GET_BASICINFO) {
- writer.WriteIsDisabled(is_disabled);
- writer.WriteComponent(GetCString2(idx++, rec));
- writer.WriteExec(GetCString2(idx++, rec));
- writer.WriteNodisplay(GetCString2(idx++, rec));
- writer.WriteType(GetCString2(idx++, rec));
- writer.WriteOnboot(GetCString2(idx++, rec));
- writer.WriteMultiple(GetCString2(idx++, rec));
- writer.WriteAutoRestart(GetCString2(idx++, rec));
- writer.WriteTaskManage(GetCString2(idx++, rec));
- writer.WriteHwAcceleration(GetCString2(idx++, rec));
- writer.WriteScreenReader(GetCString2(idx++, rec));
- writer.WriteMainApp(GetCString2(idx++, rec));
- writer.WriteRecentimage(GetCString2(idx++, rec));
- writer.WriteLaunchCondition(GetCString2(idx++, rec));
- writer.WriteIndicatorDisplay(GetCString2(idx++, rec));
- writer.WritePortraitImg(GetCString2(idx++, rec));
- writer.WriteLandscapeImg(GetCString2(idx++, rec));
- writer.WriteGuestModeVisibility(GetCString2(idx++, rec));
- writer.WritePermissionType(GetCString2(idx++, rec));
- writer.WritePreload(GetCString2(idx++, rec));
- writer.WriteSubmode(GetCString2(idx++, rec));
- writer.WriteSubmodeMainId(GetCString2(idx++, rec));
- writer.WriteLaunchMode(GetCString2(idx++, rec));
- writer.WriteUiGadget(GetCString2(idx++, rec));
- writer.WriteSupportDisable(GetCString2(idx++, rec));
- writer.WriteProcessPool(GetCString2(idx++, rec));
- __get_background_category(GetCString2(idx++, rec), writer);
- writer.WritePackageType(GetCString2(idx++, rec));
- writer.WriteRootPath(GetCString2(idx++, rec));
- writer.WriteApiVersion(GetCString2(idx++, rec));
- writer.WriteEffectiveAppId(GetCString2(idx++, rec));
- writer.WriteSplashScreenDisplay(splash_screen_display = GetCString2(idx++, rec));
- writer.WriteTepName(GetCString2(idx++, rec));
- writer.WriteZipMountFile(GetCString2(idx++, rec));
- writer.WriteComponentType(GetCString2(idx++, rec));
- package = GetCString2(idx++, rec);
- writer.WritePackage(package);
- writer.WritePackageSystem(GetCString2(idx++, rec));
- writer.WriteRemovable(GetCString2(idx++, rec));
- writer.WritePackageInstalledTime(GetCString2(idx++, rec));
- writer.WriteSupportMode(GetCString2(idx++, rec));
- writer.WriteSupportAmbient(GetCString2(idx++, rec));
- writer.WriteSetupAppId(GetCString2(idx++, rec));
- writer.WriteLightUserSwitchMode(GetCString2(idx++, rec));
+ info->component = GetCString(idx++, rec);
+ info->exec = GetCString(idx++, rec);
+ info->nodisplay = GetCString(idx++, rec);
+ info->type = GetCString(idx++, rec);
+ info->onboot = GetCString(idx++, rec);
+ info->multiple = GetCString(idx++, rec);
+ info->autorestart = GetCString(idx++, rec);
+ info->taskmanage = GetCString(idx++, rec);
+ info->hwacceleration = GetCString(idx++, rec);
+ info->screenreader = GetCString(idx++, rec);
+ info->mainapp = GetCString(idx++, rec);
+ info->recentimage = GetCString(idx++, rec);
+ info->launchcondition = GetCString(idx++, rec);
+ info->indicatordisplay = GetCString(idx++, rec);
+ info->portraitimg = GetCString(idx++, rec);
+ info->landscapeimg = GetCString(idx++, rec);
+ info->guestmode_visibility = GetCString(idx++, rec);
+ info->permission_type = GetCString(idx++, rec);
+ info->preload = GetCString(idx++, rec);
+ info->submode = GetCString(idx++, rec);
+ info->submode_mainid = GetCString(idx++, rec);
+ info->launch_mode = GetCString(idx++, rec);
+ info->ui_gadget = GetCString(idx++, rec);
+ info->support_disable = GetCString(idx++, rec);
+ info->process_pool = GetCString(idx++, rec);
+ bg_category_str = GetCString(idx++, rec);
+ info->package_type = GetCString(idx++, rec);
+ info->root_path = GetCString(idx++, rec);
+ info->api_version = GetCString(idx++, rec);
+ info->effective_appid = GetCString(idx++, rec);
+ info->splash_screen_display = GetCString(idx++, rec);
+ info->tep_name = GetCString(idx++, rec);
+ info->zip_mount_file = GetCString(idx++, rec);
+ info->component_type = GetCString(idx++, rec);
+ info->package = GetCString(idx++, rec);
+ info->package_system = GetCString(idx++, rec);
+ info->removable = GetCString(idx++, rec);
+ info->package_installed_time = GetCString(idx++, rec);
+ info->support_mode = GetCString(idx++, rec);
+ info->support_ambient = GetCString(idx++, rec);
+ info->setup_appid = GetCString(idx++, rec);
+ info->light_user_switch_mode = GetCString(idx++, rec);
+ info->background_category = __get_background_category(
+ bg_category_str);
+ free(bg_category_str);
}
- writer.WriteForAllUsers((db_uid != global_user_uid) ? "false" : "true");
+ info->for_all_users =
+ strdup((db_uid != global_user_uid) ?
+ "false" : "true");
if (db_uid != global_user_uid) {
idx = idx + 2;
} else {
- tmp_record = GetCString2(idx++, rec);
+ tmp_record = GetCString(idx++, rec);
if (tmp_record != nullptr) {
- if (is_disabled &&
- strcasecmp(is_disabled, "false") == 0 &&
- strcasecmp(tmp_record, "false") == 0)
- writer.WriteIsDisabled(tmp_record);
+ if (info->is_disabled &&
+ strcasecmp(info->is_disabled, "false") == 0 &&
+ strcasecmp(tmp_record, "false") == 0) {
+ free(info->is_disabled);
+ info->is_disabled = tmp_record;
+ } else {
+ free(tmp_record);
+ }
}
- tmp_record = GetCString2(idx++, rec);
+ tmp_record = GetCString(idx++, rec);
if (tmp_record != nullptr) {
- if (splash_screen_display &&
- strcasecmp(splash_screen_display, "false") == 0 &&
- strcasecmp(tmp_record, "false") == 0)
- writer.WriteSplashScreenDisplay(tmp_record);
+ if (info->splash_screen_display &&
+ strcasecmp(info->splash_screen_display, "false") == 0 &&
+ strcasecmp(tmp_record, "false") == 0) {
+ free(info->splash_screen_display);
+ info->splash_screen_display = tmp_record;
+ } else {
+ free(tmp_record);
+ }
}
}
if (flag & PMINFO_APPINFO_GET_LABEL) {
- auto& list_writer = writer.GetLabelListWriter();
- list_writer.AddItem()
- .WriteText(GetCString2(idx++, rec))
- .WriteLang(locale);
+ tmp_record = GetCString(idx++, rec);
+ if (_add_label_info_into_list(locale, tmp_record,
+ &info->label)) {
+ if (tmp_record)
+ free(tmp_record);
+
+ return PMINFO_R_ERROR;
+ }
}
if (flag & PMINFO_APPINFO_GET_ICON) {
- auto& list_writer = writer.GetIconListWriter();
- list_writer.AddItem()
- .WriteText(GetCString2(idx++, rec))
- .WriteLang(locale);
+ tmp_record = GetCString(idx++, rec);
+ if (_add_icon_info_into_list(locale, tmp_record,
+ &info->icon)) {
+ if (tmp_record)
+ free(tmp_record);
+
+ return PMINFO_R_ERROR;
+ }
}
- tmp_record = GetCString2(idx++, rec);
- if (tmp_record) {
- writer.WriteIsPackageDisabled(tmp_record);
- if (pkg_disable_filter_status != PackageDisableFilterStatus::None) {
+
+ if (pkg_disable_filter_status != PackageDisableFilterStatus::None) {
+ tmp_record = GetCString(idx++, rec);
+ if (tmp_record) {
bool filter_passed = CheckPkgDisableFilter(pkg_disable_filter_status,
- tmp_record, package, appid);
+ tmp_record, info);
+ free(tmp_record);
if (!filter_passed)
continue;
}
if (flag & PMINFO_APPINFO_GET_CATEGORY) {
- if (GetCategory(db, appid, writer))
+ if (GetCategory(db, info->appid, &info->category))
return PMINFO_R_ERROR;
}
if (flag & PMINFO_APPINFO_GET_APP_CONTROL) {
- if (GetAppControl(db, appid, writer))
+ if (GetAppControl(db, info->appid, &info->appcontrol))
return PMINFO_R_ERROR;
}
if (flag & PMINFO_APPINFO_GET_METADATA) {
- if (GetMetadata(db, appid, writer))
+ if (GetMetadata(db, info->appid, &info->metadata))
return PMINFO_R_ERROR;
}
if (flag & PMINFO_APPINFO_GET_SPLASH_SCREEN) {
- if (GetSplashScreens(db, appid, writer))
+ if (GetSplashScreens(db, info->appid, &info->splashscreens))
return PMINFO_R_ERROR;
}
if (flag & PMINFO_APPINFO_GET_RES_CONTROL) {
- if (GetResControl(db, appid, writer))
+ if (GetResControl(db, info->appid, &info->res_control))
return PMINFO_R_ERROR;
}
if (is_check_storage &&
- __appinfo_check_installed_storage(installed_storage,
- external_path) != PMINFO_R_OK) {
+ __appinfo_check_installed_storage(info) !=
+ PMINFO_R_OK) {
continue;
}
- if (is_disabled && !CheckAppDisableFilter(filter, appid, is_disabled))
+ if (!CheckAppDisableFilter(filter, info))
continue;
- appinfo_list.emplace_back(writer.ExtractAppInfo());
+ if (!(flag & PMINFO_APPINFO_GET_BASICINFO) && info->is_disabled) {
+ free(info->is_disabled);
+ info->is_disabled = nullptr;
+ }
+
+ applications.push_back(std::move(info_auto));
}
return PMINFO_R_OK;
API 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<pkgmgr_common::AppInfoHandle>& appinfo_list) {
+ std::vector<std::shared_ptr<application_x>>& appinfo_list) {
if (!static_cast<bool>(db) || filter == nullptr) {
LOGE("Invalid argument");
return PMINFO_R_EINVAL;
#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_internal.h"
+namespace {
+
+
+uid_t GetGlobalUID() {
+ const static uid_t globaluser_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+ return globaluser_uid;
+}
+
+
+} // namespace
+
namespace pkgmgr_server {
namespace database {
AppInfoDBHandler::~AppInfoDBHandler() {}
-std::vector<pkgmgr_common::AppInfoHandle> AppInfoDBHandler::DetachAppHandle() {
+std::vector<std::shared_ptr<application_x>> AppInfoDBHandler::DetachAppHandle() {
return std::move(handle_list_);
}
filter_ = filter;
}
-int AppInfoDBHandler::GetHandle() {
+int AppInfoDBHandler::GetHandleFromDB() {
if (!Connect()) {
LOG(ERROR) << "Failed to connect database";
return PMINFO_R_ERROR;
}
const auto& conn_list = GetConnection();
- std::vector<pkgmgr_common::AppInfoHandle> list;
+ std::vector<std::shared_ptr<application_x>> list;
int ret = PMINFO_R_OK;
for (const auto& [db, uid] : conn_list) {
ret = internal::GetAppInfo(db, filter_, uid, uid_, GetLocale(), list);
return ret;
}
+void AppInfoDBHandler::GetApplicationFromCache(uid_t uid,
+ const std::string& application) {
+ std::vector<std::shared_ptr<application_x>> app_list;
+ app_list = DBHandleProvider::GetInst(uid).GetApplications(GetPID(),
+ filter_, application);
+
+ handle_list_.reserve(app_list.size() + handle_list_.size());
+ std::move(std::begin(app_list), std::end(app_list),
+ std::back_inserter(handle_list_));
+}
+
+int AppInfoDBHandler::GetHandleFromCache() {
+ std::string application;
+
+ for (auto* it = filter_->list; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
+ if (node->prop == E_PMINFO_APPINFO_PROP_APP_ID) {
+ application = node->value;
+ break;
+ }
+ }
+
+ if (uid_ > REGULAR_USER)
+ GetApplicationFromCache(uid_, application);
+
+ GetApplicationFromCache(GetGlobalUID(), application);
+
+ if (handle_list_.empty())
+ return PMINFO_R_ENOENT;
+
+ return PMINFO_R_OK;
+}
+
int AppInfoDBHandler::Execute() {
std::shared_lock<std::shared_mutex> s(lock_);
SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
- return GetHandle();
+ if (DBHandleProvider::IsWriter(GetPID()))
+ return GetHandleFromDB();
+
+ if (uid_ <= GetDefaultUser() &&
+ CacheFlag::GetStatus() == CacheFlag::Status::PREPARED) {
+ auto cache_lock = CacheFlag::GetReaderLock();
+ if (cache_lock.try_lock() &&
+ CacheFlag::GetStatus() == CacheFlag::Status::PREPARED)
+ return GetHandleFromCache();
+ }
+
+ return GetHandleFromDB();
}
} // namespace database
#include <vector>
#include "abstract_db_handler.hh"
-#include "pkgmgr_info_handle.hh"
#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_private.h"
public:
AppInfoDBHandler(uid_t uid, int pid);
virtual ~AppInfoDBHandler();
- std::vector<pkgmgr_common::AppInfoHandle> DetachAppHandle();
+ std::vector<std::shared_ptr<application_x>> DetachAppHandle();
void SetFilter(pkgmgrinfo_filter_x* filter);
virtual int Execute();
protected:
- int GetHandle();
+ int GetHandleFromDB();
+ int GetHandleFromCache();
+ void GetApplicationFromCache(uid_t uid, const std::string& application);
pkgmgrinfo_filter_x* filter_;
- std::vector<pkgmgr_common::AppInfoHandle> handle_list_;
+ std::vector<std::shared_ptr<application_x>> handle_list_;
uid_t uid_;
};
#include "cache_flag.hh"
#include "db_handle_provider.hh"
-#include "shm_manager.hh"
#include "utils/logging.hh"
namespace pkgmgr_server {
auto lock = CacheFlag::GetWriterLock();
int ret = PMINFO_R_OK;
for (const auto& [db, uid] : conn_list) {
- ret = shared_memory::ShmManager::GetInst(uid)
- .CreateSharedMemory(db, uid_, GetLocale());
+ ret = DBHandleProvider::GetInst(uid)
+ .UpdateCache(db, GetPID(), uid_, false, GetLocale());
if (ret != PMINFO_R_OK) {
LOG(ERROR) << "Failed to update pkginfo cache : " << ret;
break;
#include "pkgmgrinfo_debug.h"
#include "pkgmgrinfo_internal.h"
#include "pkgmgrinfo_private.h"
-#include "pkgmgr_info_handle.hh"
-
-
-#include <fstream>
#ifdef LOG_TAG
#undef LOG_TAG
return uid;
}
+bool GetModifiedTime(const char* dbpath, timespec* t) {
+ if (dbpath == nullptr || t == nullptr) {
+ LOG(ERROR) << "Invalid argument";
+ return false;
+ }
+
+ struct stat attr;
+ if (stat(dbpath, &attr)) {
+ LOG(ERROR) << "Fail to get status from file "
+ << dbpath << " errno : " << errno;
+ return false;
+ }
+
+ *t = attr.st_mtim;
+
+ return true;
+}
+
} // namespace
namespace pkgmgr_server {
DBHandleProvider::provider_map_;
std::string DBHandleProvider::global_parser_filedb_path_;
std::string DBHandleProvider::cert_filedb_path_;
+std::unordered_set<pid_t> DBHandleProvider::writer_pid_list_;
+std::shared_mutex DBHandleProvider::pid_list_lock_;
DBHandleProvider::DBHandleProvider(uid_t uid) : uid_(uid) {
char* tmp_path;
return *prov;
}
+std::unordered_set<pid_t> DBHandleProvider::CrashedWriteRequestPIDs() {
+ std::unique_lock<std::shared_mutex> u(pid_list_lock_);
+
+ if (writer_pid_list_.empty())
+ return {};
+
+ LOG(DEBUG) << "Check process count : " << writer_pid_list_.size();
+ std::unordered_set<pid_t> remove_pids;
+ for (pid_t pid : writer_pid_list_) {
+ std::string status_path = "/proc/" + std::to_string(pid) + "/status";
+
+ int fd = open(status_path.c_str(), O_RDONLY);
+ if (fd < 0) {
+ LOG(ERROR) << "Process is crashed : " << pid;
+ remove_pids.emplace(pid);
+ } else {
+ close(fd);
+ }
+ }
+
+ return remove_pids;
+}
+
std::vector<std::pair<std::string, uid_t>> DBHandleProvider::GetParserDBPath() {
std::vector<std::pair<std::string, uid_t>> db_path_list;
return cert_filedb_path_;
}
+void DBHandleProvider::TrimCache() {
+ if (!released_)
+ ReleaseCache();
+}
+
+void DBHandleProvider::ReleaseCache() {
+ app_map_.clear();
+ pkg_map_.clear();
+ pending_pkg_.clear();
+ pkg_app_map_.clear();
+
+ released_ = true;
+}
+
+bool DBHandleProvider::IsWriter(pid_t pid) {
+ std::unique_lock<std::shared_mutex> s(pid_list_lock_);
+ return writer_pid_list_.find(pid) != writer_pid_list_.end();
+}
+
+int DBHandleProvider::UpdateCache(const tizen_base::Database& db, pid_t pid,
+ uid_t uid, bool write, const std::string& locale) {
+ pkg_map_.clear();
+ app_map_.clear();
+ pending_pkg_.clear();
+ pkg_app_map_.clear();
+
+ const char* dbpath = sqlite3_db_filename(db.GetRaw(), "main");
+
+ timespec start_time = { 0, };
+ timespec end_time = { 0, };
+ if (!GetModifiedTime(dbpath, &start_time))
+ return PMINFO_R_ERROR;
+
+ pkgmgrinfo_filter_x tmp_filter = { 0, };
+ tmp_filter.cache_flag = true;
+ std::map<std::string, std::shared_ptr<package_x>> pkgs;
+ int ret = internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
+ if (ret == PMINFO_R_OK) {
+ for (auto& [key, val] : pkgs)
+ AddPackage(std::move(val));
+ }
+
+ if (!GetModifiedTime(dbpath, &end_time))
+ return PMINFO_R_ERROR;
+
+ if (start_time.tv_sec != end_time.tv_sec ||
+ start_time.tv_nsec != end_time.tv_nsec) {
+ LOG(ERROR) << "Database(" << dbpath << ") modification was detected";
+ return PMINFO_R_ERROR;
+ }
+
+ std::vector<std::shared_ptr<application_x>> app_list;
+ ret = internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
+
+ if (!GetModifiedTime(dbpath, &end_time))
+ return PMINFO_R_ERROR;
+
+ if (start_time.tv_sec != end_time.tv_sec ||
+ start_time.tv_nsec != end_time.tv_nsec) {
+ LOG(ERROR) << "Database(" << dbpath << ") modification was detected";
+ return PMINFO_R_ERROR;
+ }
+
+ if (ret == PMINFO_R_OK) {
+ for (auto& app : app_list) {
+ auto it = pkg_map_.find(app->package);
+ if (it == pkg_map_.end()) {
+ LOG(ERROR) << "Can not find package from pkg_map";
+ return PMINFO_R_ERROR;
+ }
+
+ app->privileges = it->second->privileges;
+ AddApplication(std::move(app));
+ }
+ }
+
+ released_ = false;
+
+ return ret;
+}
+
+inline bool CheckMetadataFilter(GList* metadata_list,
+ const std::unordered_map<std::string, std::string>& metadata_map) {
+ for (auto* it = metadata_list; it != nullptr; it = g_list_next(it)) {
+ auto* node = reinterpret_cast<metadata_x*>(it->data);
+ if (node->key != nullptr) {
+ auto metadata = metadata_map.find(node->key);
+ if (metadata == metadata_map.end())
+ continue;
+
+ if (metadata->second.empty() ||
+ strcmp(node->value ? node->value : "", metadata->second.c_str()) == 0)
+ return true;
+ }
+ }
+ return false;
+}
+
+inline bool CheckPkgFilters(pkgmgrinfo_filter_x* filter,
+ const std::shared_ptr<package_x>& info,
+ const std::unordered_map<std::string, std::string>& metadata_map) {
+ for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
+ auto* checker = FilterCheckerProvider::GetInst().
+ GetPkgFilterChecker(node->prop);
+ if (!checker->CheckFilter(node, info.get()))
+ return false;
+ }
+
+ bool pass = true;
+ if (!metadata_map.empty())
+ pass = CheckMetadataFilter(info->metadata, metadata_map);
+
+ return pass;
+}
+
+std::vector<std::shared_ptr<package_x>> DBHandleProvider::GetPackages(
+ pid_t pid, pkgmgrinfo_filter_x* filter,
+ const std::string& package) {
+ std::vector<std::shared_ptr<package_x>> ret;
+
+ /* make metadata filter map */
+ std::unordered_map<std::string, std::string> metadata_map;
+ for (auto* it = filter->list_pkg_metadata; it != nullptr;
+ it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(it->data);
+ if (node->key == nullptr)
+ continue;
+ LOG(ERROR) << "add metadata filter";
+ metadata_map[node->key] = (node->value ? node->value : "");
+ }
+
+ if (internal::CheckPackageStorageStatus(filter)) {
+ if (pkgmgrinfo_pkginfo_filter_add_bool(filter,
+ PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE, true) != PMINFO_R_OK) {
+ LOG(ERROR) << "Fail to add check storage value to filter";
+ return {};
+ }
+ }
+ if (package.empty()) {
+ for (auto& info : pkg_map_) {
+ if (CheckPkgFilters(filter, info.second, metadata_map))
+ ret.push_back(info.second);
+ }
+ } else {
+ auto map_it = pkg_map_.find(package);
+ if (map_it != pkg_map_.end() && CheckPkgFilters(filter, map_it->second,
+ metadata_map))
+ ret.push_back(map_it->second);
+ }
+
+ return ret;
+}
+
+void DBHandleProvider::AddPackage(std::shared_ptr<package_x> info) {
+ pkg_map_[info->package] = std::move(info);
+}
+
+void DBHandleProvider::AddApplication(std::shared_ptr<application_x> info) {
+ std::string appid = info->appid;
+ std::string pkgid = info->package;
+ app_map_[appid] = std::move(info);
+ pkg_app_map_[pkgid].emplace(std::move(appid));
+}
+
+void DBHandleProvider::ErasePackage(const std::string& pkgid) {
+ auto it = pkg_app_map_.find(pkgid);
+ if (it != pkg_app_map_.end()) {
+ for (const auto& app : it->second)
+ app_map_.erase(app);
+ pkg_app_map_.erase(it);
+ }
+
+ pkg_map_.erase(pkgid);
+}
+
+inline bool CheckAppFilters(pkgmgrinfo_filter_x* filter,
+ const std::shared_ptr<application_x>& app_info,
+ const std::shared_ptr<package_x>& pkg_info,
+ const std::unordered_map<std::string, std::string>& metadata_map) {
+ for (auto* it = filter->list; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
+ auto* checker = FilterCheckerProvider::GetInst().
+ GetAppFilterChecker(node->prop);
+ if (!checker->CheckFilter(node, app_info.get(), pkg_info.get()))
+ return false;
+ }
+
+ bool pass = true;
+ if (!metadata_map.empty())
+ pass = CheckMetadataFilter(app_info->metadata, metadata_map);
+ return pass;
+}
+
+std::shared_ptr<package_x> DBHandleProvider::GetPackageByApp(
+ const char* appid) {
+ auto it = pkg_map_.find(appid);
+ if (it == pkg_map_.end())
+ return nullptr;
+
+ return it->second;
+}
+
+std::vector<std::shared_ptr<application_x>> DBHandleProvider::GetApplications(
+ pid_t pid, pkgmgrinfo_filter_x* filter,
+ const std::string& app) {
+ /* make metadata filter map */
+ std::unordered_map<std::string, std::string> metadata_map;
+ for (auto* it = filter->list_metadata; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(it->data);
+ if (node->key == nullptr)
+ continue;
+
+ metadata_map[node->key] = (node->value ? node->value : "");
+ }
+
+ std::vector<std::shared_ptr<application_x>> ret;
+ if (internal::CheckAppStorageStatus(filter)) {
+ if (pkgmgrinfo_appinfo_filter_add_bool(filter,
+ PMINFO_APPINFO_PROP_APP_CHECK_STORAGE, true) != PMINFO_R_OK) {
+ LOG(ERROR) << "Fail to add check storage value to filter";
+ return {};
+ }
+ }
+
+ if (app.empty()) {
+ for (auto& info : app_map_) {
+ if (CheckAppFilters(filter, info.second,
+ GetPackageByApp(info.second->package), metadata_map))
+ ret.push_back(info.second);
+ }
+ } else {
+ auto map_it = app_map_.find(app);
+ if (map_it != app_map_.end() &&
+ CheckAppFilters(filter, map_it->second,
+ GetPackageByApp(map_it->second->package), metadata_map))
+ ret.push_back(map_it->second);
+ }
+
+ return ret;
+}
+
+void DBHandleProvider::InsertWriterPID(pid_t pid) {
+ std::unique_lock<std::shared_mutex> u(pid_list_lock_);
+
+ writer_pid_list_.insert(pid);
+}
+
+bool DBHandleProvider::EraseWriterPID(pid_t pid) {
+ std::unique_lock<std::shared_mutex> u(pid_list_lock_);
+
+ return writer_pid_list_.erase(pid) == 1;
+}
+
+void DBHandleProvider::RegisterPendingPackageInfo(
+ const tizen_base::Database& db, package_x* info, pid_t pid, uid_t uid,
+ const std::string& locale, pkgmgr_common::PkgWriteType write_type) {
+ if (!info || !info->package)
+ return;
+
+ InsertWriterPID(pid);
+
+ if (write_type != pkgmgr_common::PkgWriteType::Delete) {
+ pkgmgrinfo_filter_x tmp_filter = { 0, };
+ pkgmgrinfo_node_x node = {
+ .prop = E_PMINFO_PKGINFO_PROP_PACKAGE_ID
+ };
+ tmp_filter.cache_flag = true;
+ tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
+ std::map<std::string, std::shared_ptr<package_x>> pkgs;
+
+ node.value = const_cast<char*>(info->package);
+ internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
+ node.prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE;
+ for (auto& [pkgid, pkg_handle] : pkgs) {
+ node.value = const_cast<char*>(pkgid.c_str());
+ std::vector<std::shared_ptr<application_x>> app_list;
+ internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
+
+ for (auto& app : app_list)
+ app->privileges = pkg_handle->privileges;
+
+ pending_pkg_[pkgid] = pid;
+ }
+
+ g_slist_free(tmp_filter.list);
+ } else {
+ pending_pkg_[info->package] = pid;
+ }
+}
+
+void DBHandleProvider::UpdatePendingPackageInfo(const tizen_base::Database& db,
+ uid_t uid, const std::string& locale,
+ const std::vector<std::string>& pkgids) {
+ pkgmgrinfo_filter_x tmp_filter = { 0, };
+ pkgmgrinfo_node_x node = { 0, };
+ tmp_filter.cache_flag = true;
+ tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
+ for (const auto& pkgid : pkgids) {
+ auto pkg_it = pending_pkg_.find(pkgid);
+ if (pkg_it == pending_pkg_.end())
+ continue;
+
+ LOG(WARNING) << "Update package : " << pkgid;
+
+ ErasePackage(pkgid);
+ std::map<std::string, std::shared_ptr<package_x>> pkgs;
+
+ node.prop = E_PMINFO_PKGINFO_PROP_PACKAGE_ID;
+ node.value = const_cast<char*>(pkgid.c_str());
+ internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
+ node.prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE;
+ for (auto& [pkgid, pkg_handle] : pkgs) {
+ std::vector<std::shared_ptr<application_x>> app_list;
+ internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
+
+ for (auto& app : app_list) {
+ app->privileges = pkg_handle->privileges;
+ AddApplication(std::move(app));
+ }
+
+ AddPackage(std::move(pkg_handle));
+ }
+
+ EraseWriterPID(pkg_it->second);
+ pending_pkg_.erase(pkg_it);
+ }
+
+ g_slist_free(tmp_filter.list);
+}
+
+void DBHandleProvider::UpdateCrashedWriterPackageInfo(
+ const tizen_base::Database& db,
+ uid_t uid, const std::string& locale,
+ const std::unordered_set<pid_t>& pids) {
+ std::vector<std::string> pkgids;
+ for (const auto& [pkgid, pid] : pending_pkg_) {
+ if (pids.find(pid) == pids.end())
+ continue;
+
+ EraseWriterPID(pid);
+ pkgids.emplace_back(pkgid);
+ }
+
+ UpdatePendingPackageInfo(db, uid, locale, pkgids);
+}
+
+bool DBHandleProvider::UpdateCachePkg(const tizen_base::Database& db, uid_t uid,
+ const std::string& pkgid, const std::string& locale) {
+ pkgmgrinfo_filter_x tmp_filter = { 0, };
+ pkgmgrinfo_node_x node = {
+ .prop = E_PMINFO_PKGINFO_PROP_PACKAGE_ID,
+ .value = const_cast<char*>(pkgid.c_str())
+ };
+ tmp_filter.cache_flag = true;
+ tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
+ std::map<std::string, std::shared_ptr<package_x>> pkgs;
+ internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
+ for (auto& [key, val] : pkgs) {
+ AddPackage(val);
+ for (auto& appid : pkg_app_map_[key])
+ app_map_.erase(appid);
+
+ pkg_app_map_.erase(key);
+ std::vector<std::shared_ptr<application_x>> app_list;
+ node.prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE;
+ node.value = const_cast<char*>(key.c_str());
+ internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
+ for (auto& app : app_list) {
+ app->privileges = val->privileges;
+ AddApplication(std::move(app));
+ }
+ }
+
+ return true;
+}
+
+bool DBHandleProvider::UpdateCacheApp(const tizen_base::Database& db, uid_t uid,
+ const std::string& appid, const std::string& locale) {
+ pkgmgrinfo_filter_x tmp_filter = { 0, };
+ pkgmgrinfo_node_x node = {
+ .prop = E_PMINFO_APPINFO_PROP_APP_ID,
+ .value = const_cast<char*>(appid.c_str())
+ };
+ tmp_filter.cache_flag = true;
+ tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
+
+ std::vector<std::shared_ptr<application_x>> app_list;
+ app_map_.erase(appid);
+ internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
+ g_slist_free(tmp_filter.list);
+
+ for (auto& app : app_list) {
+ auto it = pkg_map_.find(app->package);
+ if (it == pkg_map_.end()) {
+ LOG(ERROR) << "Can not find package from pkg_map";
+ return false;
+ }
+
+ pkg_app_map_[app->package].erase(app->appid);
+ app->privileges = it->second->privileges;
+ AddApplication(std::move(app));
+ }
+
+ return true;
+}
+
+bool DBHandleProvider::UpdateCacheAppByPkgid(const tizen_base::Database& db,
+ uid_t uid, const std::string& pkgid, const std::string& locale) {
+ auto it = pkg_map_.find(pkgid);
+ if (it == pkg_map_.end()) {
+ LOG(ERROR) << "Can not find package from pkg_map";
+ return false;
+ }
+
+ auto& pkg = it->second;
+ pkgmgrinfo_filter_x tmp_filter = { 0, };
+ pkgmgrinfo_node_x node = {
+ .prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE,
+ .value = pkg->package
+ };
+
+ tmp_filter.cache_flag = true;
+ tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
+
+ std::vector<std::shared_ptr<application_x>> app_list;
+ internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
+
+ for (auto& appid : pkg_app_map_[pkgid]) {
+ app_map_.erase(appid);
+ }
+ pkg_app_map_.erase(pkgid);
+
+ for (auto& app : app_list) {
+ app->privileges = pkg->privileges;
+ AddApplication(std::move(app));
+ }
+
+ g_slist_free(tmp_filter.list);
+ return true;
+}
+
} // namespace database
} // namespace pkgmgr_server
#include <vector>
#include <database.hpp>
+#include "filter_checker_provider.hh"
#include "pkg_write_type.hh"
#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_private.h"
#include "shared_object.hh"
-#include "shm_writer.hh"
namespace pkgmgr_server {
namespace database {
public:
~DBHandleProvider() = default;
static DBHandleProvider& GetInst(uid_t uid);
+ static std::unordered_set<pid_t> CrashedWriteRequestPIDs();
+ static bool IsWriter(pid_t pid);
std::vector<std::pair<std::string, uid_t>> GetParserDBPath();
std::string GetCertDBPath();
+ int UpdateCache(const tizen_base::Database& db, pid_t pid, uid_t uid,
+ bool write, const std::string& locale);
+ std::vector<std::shared_ptr<package_x>> GetPackages(
+ pid_t pid, pkgmgrinfo_filter_x* filter,
+ const std::string& package);
+ std::vector<std::shared_ptr<application_x>> GetApplications(
+ pid_t pid, pkgmgrinfo_filter_x* filter,
+ const std::string& app);
+ void TrimCache();
+ void RegisterPendingPackageInfo(const tizen_base::Database& db,
+ package_x* info, pid_t pid, uid_t uid, const std::string& locale,
+ pkgmgr_common::PkgWriteType write_type);
+ void UpdatePendingPackageInfo(const tizen_base::Database& db,
+ uid_t uid, const std::string& locale,
+ const std::vector<std::string>& pkgids);
+ void UpdateCrashedWriterPackageInfo(const tizen_base::Database& db,
+ uid_t uid, const std::string& locale,
+ const std::unordered_set<pid_t>& pids);
+ bool UpdateCachePkg(const tizen_base::Database& db, uid_t uid,
+ const std::string& pkgid, const std::string& locale);
+ bool UpdateCacheApp(const tizen_base::Database& db, uid_t uid,
+ const std::string& appid, const std::string& locale);
+ bool UpdateCacheAppByPkgid(const tizen_base::Database& db, uid_t uid,
+ const std::string& pkgid, const std::string& locale);
private:
explicit DBHandleProvider(uid_t uid);
+ void ReleaseCache();
+ void AddPackage(std::shared_ptr<package_x> info);
+ void AddApplication(std::shared_ptr<application_x> info);
+ void ErasePackage(const std::string& pkgid);
+ void InsertWriterPID(pid_t pid);
+ bool EraseWriterPID(pid_t pid);
+ std::shared_ptr<package_x> GetPackageByApp(const char* appid);
private:
static std::unordered_map<uid_t,
std::unique_ptr<DBHandleProvider>> provider_map_;
static std::string global_parser_filedb_path_;
static std::string cert_filedb_path_;
+ static std::unordered_set<pid_t> writer_pid_list_;
+ static std::shared_mutex pid_list_lock_;
uid_t uid_;
+ std::string user_parser_memdb_path_;
std::string user_parser_filedb_path_;
bool released_ = true;
+ std::unordered_map<std::string, std::shared_ptr<package_x>> pkg_map_;
+ std::unordered_map<std::string, std::shared_ptr<application_x>> app_map_;
+ std::unordered_map<std::string, std::unordered_set<std::string>> pkg_app_map_;
std::unordered_map<std::string, pid_t> pending_pkg_;
};
#include "pkgmgrinfo_internal.h"
#include "utils/logging.hh"
+namespace {
+
+uid_t GetGlobalUID() {
+ const static uid_t globaluser_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
+ return globaluser_uid;
+}
+
+} // namespace
+
namespace pkgmgr_server {
namespace database {
PkgGetDBHandler::~PkgGetDBHandler() {}
-std::vector<pkgmgr_common::PkgInfoHandle> PkgGetDBHandler::GetPkgHandle() {
+std::vector<std::shared_ptr<package_x>> PkgGetDBHandler::GetPkgHandle() {
return std::move(handle_list_);
}
filter_ = filter;
}
-int PkgGetDBHandler::GetHandle() {
+int PkgGetDBHandler::GetHandleFromDB() {
if (!Connect()) {
LOG(ERROR) << "Failed to connect database";
return PMINFO_R_ERROR;
const auto& conn_list = GetConnection();
int ret = PMINFO_R_OK;
- std::vector<pkgmgr_common::PkgInfoHandle> pkgs;
+ std::map<std::string, std::shared_ptr<package_x>> pkgs;
for (const auto& [db, uid] : conn_list) {
ret = internal::GetPkgInfo(db, filter_, uid, GetLocale(), pkgs);
if (ret == PMINFO_R_ERROR) {
if (pkgs.empty())
return PMINFO_R_ENOENT;
- handle_list_ = std::move(pkgs);
+ for (auto& [key, val] : pkgs)
+ handle_list_.push_back(std::move(val));
+
+ return PMINFO_R_OK;
+}
+
+void PkgGetDBHandler::GetPackageFromCache(uid_t uid,
+ const std::string& package) {
+ std::vector<std::shared_ptr<package_x>> pkg_list =
+ DBHandleProvider::GetInst(uid).GetPackages(GetPID(), filter_, package);
+
+ handle_list_.reserve(pkg_list.size() + handle_list_.size());
+ std::move(std::begin(pkg_list), std::end(pkg_list),
+ std::back_inserter(handle_list_));
+}
+
+int PkgGetDBHandler::GetHandleFromCache() {
+ std::string package;
+
+ for (auto* it = filter_->list; it != nullptr; it = g_slist_next(it)) {
+ auto node = reinterpret_cast<pkgmgrinfo_node_x*>(it->data);
+ if (node->prop == E_PMINFO_PKGINFO_PROP_PACKAGE_ID) {
+ package = node->value;
+ break;
+ }
+ }
+
+ if (uid_ > REGULAR_USER)
+ GetPackageFromCache(uid_, package);
+
+ GetPackageFromCache(GetGlobalUID(), package);
+
+ if (handle_list_.empty())
+ return PMINFO_R_ENOENT;
return PMINFO_R_OK;
}
SetOpType(pkgmgr_common::DBOperationType::OPERATION_TYPE_READ);
SetDBType(pkgmgr_common::DBType::DB_TYPE_FILE_PKGDB);
- return GetHandle();
+ if (DBHandleProvider::IsWriter(GetPID()))
+ return GetHandleFromDB();
+
+ if (uid_ <= GetDefaultUser() &&
+ CacheFlag::GetStatus() == CacheFlag::Status::PREPARED) {
+ auto cache_lock = CacheFlag::GetReaderLock();
+ if (cache_lock.try_lock() &&
+ CacheFlag::GetStatus() == CacheFlag::Status::PREPARED)
+ return GetHandleFromCache();
+ }
+
+ return GetHandleFromDB();
}
} // namespace database
#include "abstract_db_handler.hh"
#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_private.h"
-#include "pkgmgr_info_handle.hh"
namespace pkgmgr_server {
namespace database {
public:
PkgGetDBHandler(uid_t uid, int pid);
virtual ~PkgGetDBHandler();
- std::vector<pkgmgr_common::PkgInfoHandle> GetPkgHandle();
+ std::vector<std::shared_ptr<package_x>> GetPkgHandle();
void SetFilter(pkgmgrinfo_filter_x* filter);
virtual int Execute();
protected:
- int GetHandle();
+ int GetHandleFromDB();
+ int GetHandleFromCache();
+ void GetPackageFromCache(uid_t uid, const std::string& package);
pkgmgrinfo_filter_x* filter_ = nullptr;
- std::vector<pkgmgr_common::PkgInfoHandle> handle_list_;
+ std::vector<std::shared_ptr<package_x>> handle_list_;
uid_t uid_;
};
#include <vector>
#include "cache_flag.hh"
-#include "shm_manager.hh"
+#include "db_handle_provider.hh"
#include "utils/logging.hh"
#include "pkgmgrinfo_debug.h"
if (is_offline_ || ret != PMINFO_R_OK)
return ret;
-
auto lock = CacheFlag::GetWriterLock();
if (CacheFlag::GetStatus() == CacheFlag::Status::PREPARED) {
- shared_memory::ShmManager::GetInst(uid_).RegisterPendingPackageInfo(db,
+ DBHandleProvider::GetInst(uid_).RegisterPendingPackageInfo(db,
package_, GetPID(), uid_, GetLocale(), write_type_);
}
#include "utils/logging.hh"
#include "cache_flag.hh"
#include "db_handle_provider.hh"
-#include "shm_manager.hh"
#include "pkgmgrinfo_debug.h"
#include "pkgmgrinfo_internal.h"
const auto& conn_list = GetConnection();
int ret = PMINFO_R_ERROR;
- bool is_writer = shared_memory::ShmManager::IsWriter(GetPID());
+ bool is_writer = DBHandleProvider::IsWriter(GetPID());
for (const auto& conn : conn_list) {
ret = internal::ExecuteWriteQueries(conn.first, queries, args_list);
if (ret != PMINFO_R_OK) {
CacheFlag::SetStatus(CacheFlag::Status::PREPARING);
auto lock = CacheFlag::GetWriterLock();
for (auto& conn : conn_list) {
- auto& shm_manager = shared_memory::ShmManager::GetInst(conn.second);
+ auto& provider = database::DBHandleProvider::GetInst(conn.second);
for (const auto& [flag, name] : changes) {
switch (flag) {
case CacheChangeFlag::PKG:
- success = shm_manager.UpdatePkg(conn.first, uid_, name, GetLocale());
+ success = provider.UpdateCachePkg(conn.first, uid_, name, GetLocale());
break;
case CacheChangeFlag::APP:
- success = shm_manager.UpdateApp(conn.first, uid_, name, GetLocale());
+ success = provider.UpdateCacheApp(conn.first, uid_, name, GetLocale());
break;
case CacheChangeFlag::APPBYPKG:
success =
- shm_manager.UpdateAppByPkgid(conn.first, uid_, name, GetLocale());
+ provider.UpdateCacheAppByPkgid(conn.first, uid_, name, GetLocale());
break;
default:
break;
}
if (!success) {
- shm_manager.TrimCache();
+ provider.TrimCache();
break;
}
}
#include "remove_all_cache_db_handler.hh"
#include "cache_flag.hh"
-#include "shm_manager.hh"
+#include "db_handle_provider.hh"
#include "utils/logging.hh"
namespace {
if (CacheFlag::GetStatus() != CacheFlag::Status::PREPARED)
return PMINFO_R_OK;
CacheFlag::SetStatus(CacheFlag::Status::PREPARING);
- shared_memory::ShmManager::GetInst(GetUID()).TrimCache();
- shared_memory::ShmManager::GetInst(GetGlobalUID()).TrimCache();
+ database::DBHandleProvider::GetInst(GetUID()).TrimCache();
+ database::DBHandleProvider::GetInst(GetGlobalUID()).TrimCache();
CacheFlag::SetStatus(CacheFlag::Status::UNPREPARED);
#include "cache_flag.hh"
#include "db_handle_provider.hh"
-#include "shm_manager.hh"
namespace pkgmgr_server {
namespace database {
if (!Connect()) {
auto lock = CacheFlag::GetWriterLock();
- shared_memory::ShmManager::GetInst(GetUID()).TrimCache();
+ database::DBHandleProvider::GetInst(GetUID()).TrimCache();
return PMINFO_R_ERROR;
}
CacheFlag::SetStatus(CacheFlag::Status::PREPARING);
for (const auto& [db, uid] : conn_list) {
- auto& shm_manager = shared_memory::ShmManager::GetInst(uid);
+ auto& provider = database::DBHandleProvider::GetInst(uid);
if (!args_.empty())
- shm_manager.UpdatePendingPackageInfo(db, uid, GetLocale(), args_);
+ provider.UpdatePendingPackageInfo(db, uid, GetLocale(), args_);
else
- shm_manager.UpdateCrashedWriterPackageInfo(db, uid, GetLocale(), pids_);
+ provider.UpdateCrashedWriterPackageInfo(db, uid, GetLocale(), pids_);
}
CacheFlag::SetStatus(CacheFlag::Status::PREPARED);
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "app_disable_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+#include "utils/logging.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AppDisableAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ if (node->value == nullptr || app_info->is_disabled == nullptr)
+ return false;
+
+ if (strcasecmp(node->value, app_info->is_disabled) != 0) {
+ if (strcasecmp(app_info->is_disabled, "true") == 0)
+ LOG(WARNING) << "The application [" << app_info->appid << "] is disabled";
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef APP_DISABLE_APP_FILTER_CHECKER_HH_
+#define APP_DISABLE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AppDisableAppFilterChecker: public IAppFilterChecker {
+ public:
+ AppDisableAppFilterChecker() = default;
+ ~AppDisableAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // APP_DISABLE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "appid_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AppIdAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->appid != nullptr &&
+ strcmp(node->value, app_info->appid) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef APPID_APP_FILTER_CHECKER_HH_
+#define APPID_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AppIdAppFilterChecker: public IAppFilterChecker {
+ public:
+ AppIdAppFilterChecker() = default;
+ ~AppIdAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // APPID_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "auto_restart_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AutoRestartAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->autorestart != nullptr &&
+ strcasecmp(node->value, app_info->autorestart) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 AUTO_RESTART_APP_FILTER_CHECKER_HH_
+#define AUTO_RESTART_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AutoRestartAppFilterChecker: public IAppFilterChecker {
+ public:
+ AutoRestartAppFilterChecker() = default;
+ ~AutoRestartAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // AUTO_RESTART_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include <glib.h>
+
+#include "category_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool CategoryAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ for (auto* it = app_info->category; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<char*>(it->data);
+ if (value != nullptr && strcmp(value, node->value) == 0) return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef CATEGORY_APP_FILTER_CHECKER_HH_
+#define CATEGORY_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class CategoryAppFilterChecker: public IAppFilterChecker {
+ public:
+ CategoryAppFilterChecker() = default;
+ ~CategoryAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // CATEGORY_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "check_storage_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool CheckStorageAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value == nullptr || strcasecmp(node->value, "true") != 0 ||
+ __appinfo_check_installed_storage(app_info) == PMINFO_R_OK);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 CHECK_STORAGE_APP_FILTER_CHECKER_HH_
+#define CHECK_STORAGE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class CheckStorageAppFilterChecker: public IAppFilterChecker {
+ public:
+ CheckStorageAppFilterChecker() = default;
+ ~CheckStorageAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // CHECK_STORAGE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "component_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool ComponentAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->component != nullptr &&
+ strcmp(node->value, app_info->component) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef COMPONENT_APP_FILTER_CHECKER_HH_
+#define COMPONENT_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class ComponentAppFilterChecker: public IAppFilterChecker {
+ public:
+ ComponentAppFilterChecker() = default;
+ ~ComponentAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // COMPONENT_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "default_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool DefaultAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return true;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef DEFAULT_APP_FILTER_CHECKER_HH_
+#define DEFAULT_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class DefaultAppFilterChecker: public IAppFilterChecker {
+ public:
+ DefaultAppFilterChecker() = default;
+ ~DefaultAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // DEFAULT_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "exec_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool ExecAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->exec != nullptr &&
+ strcmp(node->value, app_info->exec) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef EXEC_APP_FILTER_CHECKER_HH_
+#define EXEC_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class ExecAppFilterChecker: public IAppFilterChecker {
+ public:
+ ExecAppFilterChecker() = default;
+ ~ExecAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // EXEC_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "hw_acceleration_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool HWAccelerationAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->hwacceleration != nullptr &&
+ strcmp(node->value, app_info->hwacceleration) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 HW_ACCELERATION_APP_FILTER_CHECKER_HH_
+#define HW_ACCELERATION_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class HWAccelerationAppFilterChecker: public IAppFilterChecker {
+ public:
+ HWAccelerationAppFilterChecker() = default;
+ ~HWAccelerationAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // HW_ACCELERATION_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "icon_app_filter_checker.hh"
+
+#include <glib.h>
+#include <string.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool IconAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ if (node->value == nullptr)
+ return false;
+
+ for (auto* it = app_info->icon; it; it = g_list_next(it)) {
+ auto path = reinterpret_cast<icon_x*>(it->data)->text;
+ if (path != nullptr && strcmp(path, node->value) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 ICON_APP_FILTER_CHECKER_HH_
+#define ICON_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class IconAppFilterChecker: public IAppFilterChecker {
+ public:
+ IconAppFilterChecker() = default;
+ ~IconAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // ICON_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "launch_condition_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool LaunchConditionAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->launchcondition != nullptr &&
+ strcmp(node->value, app_info->launchcondition) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 LAUNCH_CONDITION_APP_FILTER_CHECKER_HH_
+#define LAUNCH_CONDITION_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class LaunchConditionAppFilterChecker: public IAppFilterChecker {
+ public:
+ LaunchConditionAppFilterChecker() = default;
+ ~LaunchConditionAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // LAUNCH_CONDITION_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "mime_app_filter_checker.hh"
+
+#include <glib.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool MimeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ if (node->value == nullptr)
+ return false;
+ for (auto* it = app_info->appcontrol; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<appcontrol_x*>(it->data)->mime;
+ if (value != nullptr && strcmp(value, node->value) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 MIME_APP_FILTER_CHECKER_HH_
+#define MIME_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class MimeAppFilterChecker: public IAppFilterChecker {
+ public:
+ MimeAppFilterChecker() = default;
+ ~MimeAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // MIME_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "multiple_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool MultipleAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->multiple != nullptr &&
+ strcasecmp(node->value, app_info->multiple) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 MULTIPLE_APP_FILTER_CHECKER_HH_
+#define MULTIPLE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class MultipleAppFilterChecker: public IAppFilterChecker {
+ public:
+ MultipleAppFilterChecker() = default;
+ ~MultipleAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // MULTIPLE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "nodisplay_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool NoDisplayAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->nodisplay != nullptr &&
+ strcasecmp(node->value, app_info->nodisplay) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
+#define NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class NoDisplayAppFilterChecker: public IAppFilterChecker {
+ public:
+ NoDisplayAppFilterChecker() = default;
+ ~NoDisplayAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // NODISPLAY_DISABLE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "onboot_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool OnBootAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->onboot != nullptr &&
+ strcasecmp(node->value, app_info->onboot) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 ONBOOT_APP_FILTER_CHECKER_HH_
+#define ONBOOT_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class OnBootAppFilterChecker: public IAppFilterChecker {
+ public:
+ OnBootAppFilterChecker() = default;
+ ~OnBootAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // ONBOOT_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "operation_app_filter_checker.hh"
+
+#include <glib.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool OperationAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ for (auto* it = app_info->appcontrol; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<appcontrol_x*>(it->data)->operation;
+ if (value != nullptr && strcmp(value, node->value) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef OPERATION_APP_FILTER_CHECKER_HH_
+#define OPERATION_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class OperationAppFilterChecker: public IAppFilterChecker {
+ public:
+ OperationAppFilterChecker() = default;
+ ~OperationAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // OPERATION_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "pkg_disable_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+#include "utils/logging.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PkgDisableAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ if (node->value == nullptr || pkg_info->is_disabled == nullptr)
+ return false;
+
+ if (strcasecmp(node->value, pkg_info->is_disabled) != 0) {
+ if (strcasecmp(pkg_info->is_disabled, "true") == 0)
+ LOG(WARNING) << "The pacakge [" << pkg_info->package
+ << "] to which the application ["
+ << app_info->appid << "] belongs is disabled";
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef PKG_DISABLE_APP_FILTER_CHECKER_HH_
+#define PKG_DISABLE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PkgDisableAppFilterChecker: public IAppFilterChecker {
+ public:
+ PkgDisableAppFilterChecker() = default;
+ ~PkgDisableAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKG_DISABLE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "pkgid_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PkgIdAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->package != nullptr &&
+ strcmp(node->value, app_info->package) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef PKGID_APP_FILTER_CHECKER_HH_
+#define PKGID_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PkgIdAppFilterChecker: public IAppFilterChecker {
+ public:
+ PkgIdAppFilterChecker() = default;
+ ~PkgIdAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKGID_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "privilege_app_filter_checker.hh"
+
+#include <glib.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PrivilegeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ for (auto* it = app_info->privileges; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<privilege_x*>(it->data)->value;
+ if (value != nullptr && strcmp(value, node->value) == 0) return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef PRIVILEGE_APP_FILTER_CHECKER_HH_
+#define PRIVILEGE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PrivilegeAppFilterChecker: public IAppFilterChecker {
+ public:
+ PrivilegeAppFilterChecker() = default;
+ ~PrivilegeAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PRIVILEGE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "screen_reader_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool ScreenReaderAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->screenreader != nullptr &&
+ strcmp(node->value, app_info->screenreader) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 SCREEN_READER_APP_FILTER_CHECKER_HH_
+#define SCREEN_READER_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class ScreenReaderAppFilterChecker: public IAppFilterChecker {
+ public:
+ ScreenReaderAppFilterChecker() = default;
+ ~ScreenReaderAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // SCREEN_READER_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "storage_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool StorageAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->installed_storage != nullptr &&
+ strcasecmp(node->value, app_info->installed_storage) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef STORAGE_APP_FILTER_CHECKER_HH_
+#define STORAGE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class StorageAppFilterChecker: public IAppFilterChecker {
+ public:
+ StorageAppFilterChecker() = default;
+ ~StorageAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // STORAGE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "support_disable_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool SupportDisableAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->support_disable != nullptr &&
+ strcasecmp(node->value, app_info->ui_gadget) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 SUPPORT_DISABLE_APP_FILTER_CHECKER_HH_
+#define SUPPORT_DISABLE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class SupportDisableAppFilterChecker: public IAppFilterChecker {
+ public:
+ SupportDisableAppFilterChecker() = default;
+ ~SupportDisableAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // SUPPORT_DISABLE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "support_mode_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool SupportModeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->support_mode != nullptr &&
+ strcmp(node->value, app_info->support_mode) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 SUPPORT_MODE_APP_FILTER_CHECKER_HH_
+#define SUPPORT_MODE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class SupportModeAppFilterChecker: public IAppFilterChecker {
+ public:
+ SupportModeAppFilterChecker() = default;
+ ~SupportModeAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // SUPPORT_MODE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "task_manage_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool TaskManageAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->taskmanage != nullptr &&
+ strcasecmp(node->value, app_info->taskmanage) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 TASK_MANAGE_APP_FILTER_CHECKER_HH_
+#define TASK_MANAGE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class TaskManageAppFilterChecker: public IAppFilterChecker {
+ public:
+ TaskManageAppFilterChecker() = default;
+ ~TaskManageAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // TASK_MANAGE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "type_app_filter_checker.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool TypeAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->type != nullptr &&
+ strcmp(node->value, app_info->type) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef TYPE_APP_FILTER_CHECKER_HH_
+#define TYPE_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class TypeAppFilterChecker: public IAppFilterChecker {
+ public:
+ TypeAppFilterChecker() = default;
+ ~TypeAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // TYPE_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "ui_gadget_app_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool UIGadgetAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ return (node->value != nullptr && app_info->ui_gadget != nullptr &&
+ strcmp(node->value, app_info->ui_gadget) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 UI_GADGET_APP_FILTER_CHECKER_HH_
+#define UI_GADGET_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class UIGadgetAppFilterChecker: public IAppFilterChecker {
+ public:
+ UIGadgetAppFilterChecker() = default;
+ ~UIGadgetAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // UI_GADGET_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "uri_app_filter_checker.hh"
+
+#include <glib.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool URIAppFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) {
+ if (node->value == nullptr)
+ return false;
+ for (auto* it = app_info->appcontrol; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<appcontrol_x*>(it->data)->uri;
+ if (value != nullptr && strcmp(value, node->value) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 URI_APP_FILTER_CHECKER_HH_
+#define URI_APP_FILTER_CHECKER_HH_
+
+#include "app_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class URIAppFilterChecker: public IAppFilterChecker {
+ public:
+ URIAppFilterChecker() = default;
+ ~URIAppFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // URI_APP_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef APP_FILTER_CHECKER_BASE_HH_
+#define APP_FILTER_CHECKER_BASE_HH_
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class IAppFilterChecker {
+ public:
+ IAppFilterChecker() = default;
+ virtual ~IAppFilterChecker() = default;
+ virtual bool CheckFilter(pkgmgrinfo_node_x* node,
+ application_x* app_info, package_x* pkg_info) = 0;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // APP_FILTER_CHECKER_BASE_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 - 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 FILTER_CHECKER_LIST_HH_
+#define FILTER_CHECKER_LIST_HH_
+
+#include "app_filter_checker/app_disable_app_filter_checker.hh"
+#include "app_filter_checker/appid_app_filter_checker.hh"
+#include "app_filter_checker/auto_restart_app_filter_checker.hh"
+#include "app_filter_checker/category_app_filter_checker.hh"
+#include "app_filter_checker/check_storage_app_filter_checker.hh"
+#include "app_filter_checker/component_app_filter_checker.hh"
+#include "app_filter_checker/default_app_filter_checker.hh"
+#include "app_filter_checker/exec_app_filter_checker.hh"
+#include "app_filter_checker/hw_acceleration_app_filter_checker.hh"
+#include "app_filter_checker/icon_app_filter_checker.hh"
+#include "app_filter_checker/launch_condition_app_filter_checker.hh"
+#include "app_filter_checker/mime_app_filter_checker.hh"
+#include "app_filter_checker/multiple_app_filter_checker.hh"
+#include "app_filter_checker/nodisplay_app_filter_checker.hh"
+#include "app_filter_checker/onboot_app_filter_checker.hh"
+#include "app_filter_checker/operation_app_filter_checker.hh"
+#include "app_filter_checker/pkg_disable_app_filter_checker.hh"
+#include "app_filter_checker/pkgid_app_filter_checker.hh"
+#include "app_filter_checker/privilege_app_filter_checker.hh"
+#include "app_filter_checker/screen_reader_app_filter_checker.hh"
+#include "app_filter_checker/storage_app_filter_checker.hh"
+#include "app_filter_checker/support_disable_app_filter_checker.hh"
+#include "app_filter_checker/support_mode_app_filter_checker.hh"
+#include "app_filter_checker/task_manage_app_filter_checker.hh"
+#include "app_filter_checker/type_app_filter_checker.hh"
+#include "app_filter_checker/ui_gadget_app_filter_checker.hh"
+#include "app_filter_checker/uri_app_filter_checker.hh"
+
+#include "pkg_filter_checker/app_setting_pkg_filter_checker.hh"
+#include "pkg_filter_checker/author_email_pkg_filter_checker.hh"
+#include "pkg_filter_checker/author_href_pkg_filter_checker.hh"
+#include "pkg_filter_checker/author_name_pkg_filter_checker.hh"
+#include "pkg_filter_checker/check_storage_pkg_filter_checker.hh"
+#include "pkg_filter_checker/default_pkg_filter_checker.hh"
+#include "pkg_filter_checker/disable_pkg_filter_checker.hh"
+#include "pkg_filter_checker/install_location_pkg_filter_checker.hh"
+#include "pkg_filter_checker/installed_storage_pkg_filter_checker.hh"
+#include "pkg_filter_checker/nodisplay_pkg_filter_checker.hh"
+#include "pkg_filter_checker/pkg_size_pkg_filter_checker.hh"
+#include "pkg_filter_checker/pkgid_pkg_filter_checker.hh"
+#include "pkg_filter_checker/pkgtype_pkg_filter_checker.hh"
+#include "pkg_filter_checker/preload_pkg_filter_checker.hh"
+#include "pkg_filter_checker/privilege_pkg_filter_checker.hh"
+#include "pkg_filter_checker/read_only_pkg_filter_checker.hh"
+#include "pkg_filter_checker/removable_pkg_filter_checker.hh"
+#include "pkg_filter_checker/restype_pkg_filter_checker.hh"
+#include "pkg_filter_checker/support_disable_pkg_filter_checker.hh"
+#include "pkg_filter_checker/system_pkg_filter_checker.hh"
+#include "pkg_filter_checker/update_pkg_filter_checker.hh"
+#include "pkg_filter_checker/version_pkg_filter_checker.hh"
+
+#endif // FILTER_CHECKER_LIST_HH_
--- /dev/null
+/*
+ * Copyright (c) 2021 - 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.
+ */
+
+#include "filter_checker_provider.hh"
+
+#include <memory>
+
+#include "filter_checker_list.hh"
+#include "pkgmgrinfo_debug.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+FilterCheckerProvider::FilterCheckerProvider() {
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_ID] =
+ std::make_unique<PkgIdPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_TYPE] =
+ std::make_unique<PkgTypePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_VERSION] =
+ std::make_unique<VersionPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALL_LOCATION] =
+ std::make_unique<InstallLocationPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_INSTALLED_STORAGE] =
+ std::make_unique<InstalledStorageFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_NAME] =
+ std::make_unique<AuthorNamePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_EMAIL] =
+ std::make_unique<AuthorEmailPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_AUTHOR_HREF] =
+ std::make_unique<AuthorHrefPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_PRIVILEGE] =
+ std::make_unique<PrivilegePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_REMOVABLE] =
+ std::make_unique<RemovablePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_PRELOAD] =
+ std::make_unique<PreloadPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_DISABLE] =
+ std::make_unique<DisablePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_RES_TYPE] =
+ std::make_unique<ResTypePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_CHECK_STORAGE] =
+ std::make_unique<CheckStoragePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_SIZE] =
+ std::make_unique<PkgSizePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_READONLY] =
+ std::make_unique<ReadOnlyPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_UPDATE] =
+ std::make_unique<UpdatePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_APPSETTING] =
+ std::make_unique<AppSettingPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_NODISPLAY_SETTING] =
+ std::make_unique<NoDisplayPkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_SUPPORT_DISABLE] =
+ std::make_unique<SupportDisablePkgFilterChecker>();
+ pkg_checker_map_[E_PMINFO_PKGINFO_PROP_PACKAGE_SYSTEM] =
+ std::make_unique<SystemPkgFilterChecker>();
+
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_ID] =
+ std::make_unique<AppIdAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_COMPONENT] =
+ std::make_unique<ComponentAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_EXEC] =
+ std::make_unique<ExecAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_TYPE] =
+ std::make_unique<TypeAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_OPERATION] =
+ std::make_unique<OperationAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_CATEGORY] =
+ std::make_unique<CategoryAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_PACKAGE] =
+ std::make_unique<PkgIdAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_INSTALLED_STORAGE] =
+ std::make_unique<StorageAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_PRIVILEGE] =
+ std::make_unique<PrivilegeAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_NODISPLAY] =
+ std::make_unique<NoDisplayAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_DISABLE] =
+ std::make_unique<AppDisableAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_PKG_DISABLE] =
+ std::make_unique<PkgDisableAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_ICON] =
+ std::make_unique<IconAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_URI] =
+ std::make_unique<URIAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_MIME] =
+ std::make_unique<MimeAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_MULTIPLE] =
+ std::make_unique<MultipleAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_ONBOOT] =
+ std::make_unique<OnBootAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_AUTORESTART] =
+ std::make_unique<AutoRestartAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_TASKMANAGE] =
+ std::make_unique<TaskManageAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_HWACCELERATION] =
+ std::make_unique<HWAccelerationAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_SCREENREADER] =
+ std::make_unique<ScreenReaderAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_LAUNCHCONDITION] =
+ std::make_unique<LaunchConditionAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_UI_GADGET] =
+ std::make_unique<UIGadgetAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_SUPPORT_DISABLE] =
+ std::make_unique<SupportDisableAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_SUPPORT_MODE] =
+ std::make_unique<SupportModeAppFilterChecker>();
+ app_checker_map_[E_PMINFO_APPINFO_PROP_APP_CHECK_STORAGE] =
+ std::make_unique<CheckStorageAppFilterChecker>();
+
+ default_pkg_checker = std::make_unique<DefaultPkgFilterChecker>();
+ default_app_checker = std::make_unique<DefaultAppFilterChecker>();
+}
+
+FilterCheckerProvider& FilterCheckerProvider::GetInst() {
+ static FilterCheckerProvider inst;
+ return inst;
+}
+
+IPkgFilterChecker* FilterCheckerProvider::GetPkgFilterChecker(int id) {
+ auto it = pkg_checker_map_.find(id);
+ if (it == pkg_checker_map_.end()) {
+ _LOGE("Invalid filter id %d", id);
+ return default_pkg_checker.get();
+ }
+ return it->second.get();
+}
+
+IAppFilterChecker* FilterCheckerProvider::GetAppFilterChecker(int id) {
+ auto it = app_checker_map_.find(id);
+ if (it == app_checker_map_.end()) {
+ _LOGE("Invalid filter id %d", id);
+ return default_app_checker.get();
+ }
+ return it->second.get();
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef FILTER_CHECKER_FACTORY_HH_
+#define FILTER_CHECKER_FACTORY_HH_
+
+#include <memory>
+#include <unordered_map>
+
+#include "pkg_filter_checker_base.hh"
+#include "app_filter_checker_base.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+class FilterCheckerProvider {
+ public:
+ static FilterCheckerProvider& GetInst();
+ ~FilterCheckerProvider() = default;
+ IPkgFilterChecker* GetPkgFilterChecker(int id);
+ IAppFilterChecker* GetAppFilterChecker(int id);
+
+ private:
+ FilterCheckerProvider();
+ std::unordered_map<int, std::unique_ptr<IPkgFilterChecker>> pkg_checker_map_;
+ std::unordered_map<int, std::unique_ptr<IAppFilterChecker>> app_checker_map_;
+
+ std::unique_ptr<IPkgFilterChecker> default_pkg_checker;
+ std::unique_ptr<IAppFilterChecker> default_app_checker;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // FILTER_CHECKER_BASE_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "app_setting_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AppSettingPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->appsetting != nullptr &&
+ strcasecmp(node->value, info->appsetting) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 APP_SETTING_PKG_FILTER_CHECKER_HH_
+#define APP_SETTING_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AppSettingPkgFilterChecker : public IPkgFilterChecker {
+ public:
+ AppSettingPkgFilterChecker() = default;
+ ~AppSettingPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // APP_SETTING_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "author_email_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AuthorEmailPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr &&
+ static_cast<author_x*>(info->author->data)->email != nullptr &&
+ strcmp(node->value,
+ (static_cast<author_x*>(info->author->data))->email) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 AUTHOR_EMAIL_PKG_FILTER_CHECKER_HH_
+#define AUTHOR_EMAIL_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AuthorEmailPkgFilterChecker : public IPkgFilterChecker {
+ public:
+ AuthorEmailPkgFilterChecker() = default;
+ ~AuthorEmailPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // AUTHOR_EMAIL_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "author_href_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AuthorHrefPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr &&
+ static_cast<author_x*>(info->author->data)->href != nullptr &&
+ strcmp(node->value,
+ (static_cast<author_x*>(info->author->data))->href) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 AUTHOR_HREF_PKG_FILTER_CHECKER_HH_
+#define AUTHOR_HREF_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AuthorHrefPkgFilterChecker : public IPkgFilterChecker {
+ public:
+ AuthorHrefPkgFilterChecker() = default;
+ ~AuthorHrefPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // AUTHOR_HREF_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "author_name_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool AuthorNamePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr &&
+ static_cast<author_x*>(info->author->data)->text != nullptr &&
+ strcmp(node->value,
+ (static_cast<author_x*>(info->author->data))->text) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 AUTHOR_NAME_PKG_FILTER_CHECKER_HH_
+#define AUTHOR_NAME_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class AuthorNamePkgFilterChecker : public IPkgFilterChecker {
+ public:
+ AuthorNamePkgFilterChecker() = default;
+ ~AuthorNamePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // AUTHOR_NAME_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "check_storage_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool CheckStoragePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value == nullptr || strcasecmp(node->value, "true") != 0 ||
+ __pkginfo_check_installed_storage(info) == PMINFO_R_OK);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
+#define CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class CheckStoragePkgFilterChecker : public IPkgFilterChecker {
+ public:
+ CheckStoragePkgFilterChecker() = default;
+ ~CheckStoragePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // CHECK_STORAGE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "default_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool DefaultPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return true;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef DEFAULT_PKG_FILTER_CHECKER_HH_
+#define DEFAULT_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class DefaultPkgFilterChecker: public IPkgFilterChecker {
+ public:
+ DefaultPkgFilterChecker() = default;
+ ~DefaultPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // DEFAULT_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "disable_pkg_filter_checker.hh"
+
+#include "utils/logging.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool DisablePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ if (node->value == nullptr || info->is_disabled == nullptr)
+ return false;
+
+ if (strcasecmp(node->value, info->is_disabled) != 0) {
+ if (strcasecmp(info->is_disabled, "true") == 0)
+ LOG(WARNING) << "The package [" << info->package << "] is disabled";
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef DISABLE_PKG_FILTER_CHECKER_HH_
+#define DISABLE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class DisablePkgFilterChecker: public IPkgFilterChecker {
+ public:
+ DisablePkgFilterChecker() = default;
+ ~DisablePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // DISABLE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "install_location_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool InstallLocationPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->installlocation != nullptr &&
+ strcmp(node->value, info->installlocation) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 INSTALL_LOCATION_PKG_FILTER_CHECKER_HH_
+#define INSTALL_LOCATION_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class InstallLocationPkgFilterChecker : public IPkgFilterChecker {
+ public:
+ InstallLocationPkgFilterChecker() = default;
+ ~InstallLocationPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // INSTALL_LOCATION_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "installed_storage_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool InstalledStorageFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->installed_storage != nullptr &&
+ strcmp(node->value, info->installed_storage) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 INSTALLED_STORAGE_PKG_FILTER_CHECKER_HH_
+#define INSTALLED_STORAGE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class InstalledStorageFilterChecker : public IPkgFilterChecker {
+ public:
+ InstalledStorageFilterChecker() = default;
+ ~InstalledStorageFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // INSTALLED_STORAGE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "nodisplay_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool NoDisplayPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->nodisplay_setting != nullptr &&
+ strcasecmp(node->value, info->nodisplay_setting) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 NODISPLAY_PKG_FILTER_CHECKER_HH_
+#define NODISPLAY_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class NoDisplayPkgFilterChecker : public IPkgFilterChecker {
+ public:
+ NoDisplayPkgFilterChecker() = default;
+ ~NoDisplayPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // NODISPLAY_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "pkg_size_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PkgSizePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->package_size != nullptr &&
+ strcmp(node->value, info->package_size) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 PKG_SIZE_PKG_FILTER_CHECKER_HH_
+#define PKG_SIZE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PkgSizePkgFilterChecker : public IPkgFilterChecker {
+ public:
+ PkgSizePkgFilterChecker() = default;
+ ~PkgSizePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKG_SIZE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "pkgid_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PkgIdPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->package != nullptr &&
+ strcmp(node->value, info->package) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef PKGID_PKG_FILTER_CHECKER_HH_
+#define PKGID_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PkgIdPkgFilterChecker: public IPkgFilterChecker {
+ public:
+ PkgIdPkgFilterChecker() = default;
+ ~PkgIdPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKGID_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "pkgtype_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PkgTypePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->type != nullptr &&
+ strcasecmp(node->value, info->type) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 PKGYPTE_PKG_FILTER_CHECKER_HH_
+#define PKGYPTE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PkgTypePkgFilterChecker : public IPkgFilterChecker {
+ public:
+ PkgTypePkgFilterChecker() = default;
+ ~PkgTypePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKGYPTE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "preload_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PreloadPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->preload != nullptr &&
+ strcasecmp(node->value, info->preload) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef PRELOAD_PKG_FILTER_CHECKER_HH_
+#define PRELOAD_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PreloadPkgFilterChecker: public IPkgFilterChecker {
+ public:
+ PreloadPkgFilterChecker() = default;
+ ~PreloadPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PRELOAD_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "privilege_pkg_filter_checker.hh"
+
+#include <glib.h>
+
+namespace pkgmgr_server {
+namespace database {
+
+bool PrivilegePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ for (auto* it = info->privileges; it != nullptr; it = g_list_next(it)) {
+ char* value = reinterpret_cast<privilege_x*>(it->data)->value;
+ if (value != nullptr && strcmp(value, node->value) == 0)
+ return true;
+ }
+
+ return false;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef PRIVILEGE_PKG_FILTER_CHECKER_HH_
+#define PRIVILEGE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class PrivilegePkgFilterChecker: public IPkgFilterChecker {
+ public:
+ PrivilegePkgFilterChecker() = default;
+ ~PrivilegePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PRIVILEGE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "read_only_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool ReadOnlyPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->readonly != nullptr &&
+ strcasecmp(node->value, info->readonly) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 READ_ONLY_PKG_FILTER_CHECKER_HH_
+#define READ_ONLY_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class ReadOnlyPkgFilterChecker : public IPkgFilterChecker {
+ public:
+ ReadOnlyPkgFilterChecker() = default;
+ ~ReadOnlyPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // READ_ONLY_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "removable_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool RemovablePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->removable != nullptr &&
+ strcasecmp(node->value, info->removable) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef REMOVABLE_PKG_FILTER_CHECKER_HH_
+#define REMOVABLE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class RemovablePkgFilterChecker: public IPkgFilterChecker {
+ public:
+ RemovablePkgFilterChecker() = default;
+ ~RemovablePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // REMOVABLE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "restype_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool ResTypePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ if (!info->res_type)
+ return false;
+
+ if (node->value == nullptr || strlen(node->value) == 0)
+ return info->res_type != nullptr;
+
+ return strcmp(node->value, info->res_type) == 0;
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef RESTYPE_PKG_FILTER_CHECKER_HH_
+#define RESTYPE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class ResTypePkgFilterChecker: public IPkgFilterChecker {
+ public:
+ ResTypePkgFilterChecker() = default;
+ ~ResTypePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // RESTYPE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "support_disable_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool SupportDisablePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->support_disable != nullptr &&
+ strcasecmp(node->value, info->support_disable) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 SUPPORT_DISABLE_PKG_FILTER_CHECKER_HH_
+#define SUPPORT_DISABLE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class SupportDisablePkgFilterChecker : public IPkgFilterChecker {
+ public:
+ SupportDisablePkgFilterChecker() = default;
+ ~SupportDisablePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // SUPPORT_DISABLE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "system_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool SystemPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->system != nullptr &&
+ strcasecmp(node->value, info->system) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 SYSTEM_PKG_FILTER_CHECKER_HH_
+#define SYSTEM_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class SystemPkgFilterChecker : public IPkgFilterChecker {
+ public:
+ SystemPkgFilterChecker() = default;
+ ~SystemPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // SYSTEM_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "update_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool UpdatePkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->update != nullptr &&
+ strcasecmp(node->value, info->update) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 UPDATE_PKG_FILTER_CHECKER_HH_
+#define UPDATE_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class UpdatePkgFilterChecker : public IPkgFilterChecker {
+ public:
+ UpdatePkgFilterChecker() = default;
+ ~UpdatePkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // UPDATE_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "version_pkg_filter_checker.hh"
+
+namespace pkgmgr_server {
+namespace database {
+
+bool VersionPkgFilterChecker::CheckFilter(pkgmgrinfo_node_x* node,
+ package_x* info) {
+ return (node->value != nullptr && info->version != nullptr &&
+ strcmp(node->value, info->version) == 0);
+}
+
+} // namespace database
+} // namespace pkgmgr_server
--- /dev/null
+/*
+ * 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 VERSION_PKG_FILTER_CHECKER_HH_
+#define VERSION_PKG_FILTER_CHECKER_HH_
+
+#include "pkg_filter_checker_base.hh"
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class VersionPkgFilterChecker : public IPkgFilterChecker {
+ public:
+ VersionPkgFilterChecker() = default;
+ ~VersionPkgFilterChecker() = default;
+ bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) override;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // VERSION_PKG_FILTER_CHECKER_HH_
--- /dev/null
+/*
+ * 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.
+ */
+
+#ifndef PKG_FILTER_CHECKER_BASE_HH_
+#define PKG_FILTER_CHECKER_BASE_HH_
+
+#include "pkgmgrinfo_basic.h"
+#include "pkgmgrinfo_private.h"
+
+namespace pkgmgr_server {
+namespace database {
+
+class IPkgFilterChecker {
+ public:
+ IPkgFilterChecker() = default;
+ virtual ~IPkgFilterChecker() = default;
+ virtual bool CheckFilter(pkgmgrinfo_node_x* node, package_x* info) = 0;
+};
+
+} // namespace database
+} // namespace pkgmgr_server
+
+#endif // PKG_FILTER_CHECKER_BASE_HH_
std::string sql = "PRAGMA user_version=" + version;
try {
- db.OneStepExec({ std::move(sql) });
+ db.OneStepExec({ sql });
} catch (const tizen_base::DbException& e) {
_LOGE("OneStepExec failed: %s", e.msg());
return -1;
#include <glib.h>
#include <system_info.h>
-#include <optional>
#include <queue>
-#include <map>
#include <set>
#include <string>
#include <string_view>
#include "pkgmgrinfo_private.h"
#include "pkgmgrinfo_debug.h"
#include "pkgmgr-info.h"
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgr_info_handle_writer.hh"
namespace {
-using LocalizedInfo =
- std::tuple<const char*, const char*, const char*, const char*, std::pair<const char*, std::optional<std::string>>>;
-
constexpr const char LDPI[] = "ldpi";
constexpr const char MDPI[] = "mdpi";
constexpr const char HDPI[] = "hdpi";
return strdup(str->c_str());
}
-const char* GetCString2(int idx, const tizen_base::Database::Result::Record& rec) {
- return rec.GetCString(idx);
+int _pkginfo_add_description_info_into_list(const char *locale,
+ char *record, GList **description) {
+ description_x *info;
+
+ info = reinterpret_cast<description_x*>(calloc(1, sizeof(description_x)));
+ if (info == NULL) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+ info->lang = strdup(locale);
+ info->text = record;
+ *description = g_list_prepend(*description, info);
+
+ return PMINFO_R_OK;
}
int GetPluginExecutionInfo(const tizen_base::Database& db,
- const char* pkgid, pkgmgr_common::PkgInfoHandleWriter& writer) {
+ const char* pkgid, GList** plugins) {
auto q = std::move(tizen_base::Database::Sql(
- "SELECT pkgid, appid, plugin_type, plugin_name FROM package_plugin_info "
+ "SELECT appid, plugin_type, plugin_name FROM package_plugin_info "
"WHERE pkgid=?")
.Bind(pkgid));
return PMINFO_R_ERROR;
}
- auto& plugin_writer = writer.GetPluginListWriter();
for (const auto& rec : r) {
- plugin_writer.AddItem()
- .WritePkgid(GetCString2(0, rec))
- .WriteAppid(GetCString2(1, rec))
- .WritePluginType(GetCString2(2, rec))
- .WritePluginName(GetCString2(3, rec));
+ plugin_x* plugin = reinterpret_cast<plugin_x*>(
+ calloc(1, sizeof(plugin_x)));
+ if (!plugin) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ plugin->pkgid = strdup(pkgid);
+ plugin->appid = GetCString(0, rec);
+ plugin->plugin_type = GetCString(1, rec);
+ plugin->plugin_name = GetCString(2, rec);
+ *plugins = g_list_prepend(*plugins, (gpointer)plugin);
}
return PMINFO_R_OK;
}
int GetPrivilege(const tizen_base::Database& db, const char* pkgid,
- pkgmgr_common::PkgInfoHandleWriter& writer) {
+ GList** privileges) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT DISTINCT privilege, type FROM package_privilege_info "
"WHERE package=?")
return PMINFO_R_ERROR;
}
- auto& privilege_list_writer = writer.GetPrivilegesListWriter();
for (const auto& rec : r) {
- privilege_list_writer.AddItem()
- .WriteValue(GetCString2(0, rec))
- .WriteType(GetCString2(1, rec));
+ privilege_x* privilege = reinterpret_cast<privilege_x*>(
+ calloc(1, sizeof(privilege_x)));
+ if (!privilege) {
+ LOGE("failed to alloc memory");
+ return PMINFO_R_ERROR;
+ }
+
+ privilege->value = GetCString(0, rec);
+ privilege->type = GetCString(1, rec);
+ *privileges = g_list_prepend(*privileges, (gpointer)privilege);
}
return PMINFO_R_OK;
}
int GetAppdefinedPrivilege(const tizen_base::Database& db,
- const char* pkgid, pkgmgr_common::PkgInfoHandleWriter& writer) {
+ const char* pkgid, GList** privileges) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT DISTINCT privilege, license, type FROM "
"package_appdefined_privilege_info WHERE package=?")
return PMINFO_R_ERROR;
}
- auto& privilege_writer = writer.GetAppdefinedPrivilegesListWriter();
for (const auto& rec : r) {
- privilege_writer.AddItem()
- .WriteType(GetCString2(2, rec))
- .WriteValue(GetCString2(0, rec))
- .WriteLicense(GetCString2(1, rec));
+ appdefined_privilege_x* privilege = reinterpret_cast<
+ appdefined_privilege_x*>(calloc(1, sizeof(appdefined_privilege_x)));
+ if (!privilege) {
+ LOGE("failed to alloc memory");
+ return PMINFO_R_ERROR;
+ }
+
+ privilege->value = GetCString(0, rec);
+ privilege->license = GetCString(1, rec);
+ privilege->type = GetCString(2, rec);
+ *privileges = g_list_prepend(*privileges, (gpointer)privilege);
}
return PMINFO_R_OK;
}
int GetDependency(const tizen_base::Database& db, const char* pkgid,
- pkgmgr_common::PkgInfoHandleWriter& writer) {
+ GList** dependencies) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT DISTINCT depends_on, type, required_version "
"FROM package_dependency_info WHERE package=?")
return PMINFO_R_ERROR;
}
- auto& dependency_writer = writer.GetDependenciesListWriter();
for (const auto& rec : r) {
- dependency_writer.AddItem()
- .WriteDependsOn(GetCString2(0, rec))
- .WriteType(GetCString2(1, rec))
- .WriteRequiredVersion(GetCString2(2, rec));
+ dependency_x* dependency = reinterpret_cast<
+ dependency_x*>(calloc(1, sizeof(dependency_x)));
+ if (!dependency) {
+ LOGE("failed to alloc memory");
+ return PMINFO_R_ERROR;
+ }
+
+ dependency->depends_on = GetCString(0, rec);
+ dependency->type = GetCString(1, rec);
+ dependency->required_version = GetCString(2, rec);
+ *dependencies = g_list_prepend(*dependencies, (gpointer)dependency);
}
return PMINFO_R_OK;
}
int GetResAllowedPackages(const tizen_base::Database& db, const char* pkgid,
- pkgmgr_common::PkgInfoHandleWriter& writer) {
+ GList** allowed_packages) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT DISTINCT allowed_package, required_privilege "
"FROM package_res_allowed_package WHERE package=?")
return PMINFO_R_ERROR;
}
- std::map<std::string, std::vector<std::string>> allowed_packages_map;
for (const auto& rec : r) {
- const char* package = nullptr;
- const char* privilege = nullptr;
+ res_allowed_package_x* allowed_package_x = nullptr;
+ char* package = nullptr;
+ char* privilege = nullptr;
- package = GetCString2(0, rec);
+ package = GetCString(0, rec);
if (!package)
continue;
- auto& required_privileges = allowed_packages_map[package];
- privilege = GetCString2(1, rec);
+ for (GList* l = *allowed_packages; l; l = l->next) {
+ allowed_package_x = (res_allowed_package_x *)l->data;
+ if (!strcmp(package, allowed_package_x->allowed_package))
+ break;
+ allowed_package_x = nullptr;
+ }
+
+ if (allowed_package_x) {
+ free(package);
+ } else {
+ allowed_package_x = reinterpret_cast<res_allowed_package_x*>(calloc(1,
+ sizeof(res_allowed_package_x)));
+ if (allowed_package_x == nullptr) {
+ LOGE("failed to alloc memory");
+ free(package);
+ return PMINFO_R_ERROR;
+ }
+ allowed_package_x->allowed_package = package;
+ *allowed_packages = g_list_prepend(*allowed_packages,
+ (gpointer)allowed_package_x);
+ }
+
+ privilege = GetCString(1, rec);
if (!privilege)
continue;
- required_privileges.emplace_back(privilege);
- }
-
- auto& res_allowed_package_list_writer = writer.GetResAllowedPackagesListWriter();
- for (auto& it : allowed_packages_map) {
- auto& res_allowed_package_writer = res_allowed_package_list_writer.AddItem();
- res_allowed_package_writer.WriteAllowedPackage(it.first.c_str());
- for (const std::string& priv : it.second)
- res_allowed_package_writer.GetRequiredPrivilegeWriter()
- .Write(priv.c_str());
+ allowed_package_x->required_privileges = g_list_prepend(
+ allowed_package_x->required_privileges,
+ privilege);
}
return PMINFO_R_OK;
}
int GetResInfo(const tizen_base::Database& db, const char* pkgid,
- pkgmgr_common::PkgInfoHandleWriter& writer) {
+ char** res_type, char** res_version, char** lib,
+ GList** res_allowed_packages) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT DISTINCT res_type, res_version, lib "
"FROM package_res_info WHERE package=?")
if (!rec)
return PMINFO_R_OK;
- if (GetResAllowedPackages(db, pkgid, writer) != PMINFO_R_OK)
+ if (GetResAllowedPackages(db, pkgid, res_allowed_packages) != PMINFO_R_OK)
return PMINFO_R_ERROR;
- writer.WriteResType(GetCString2(0, *rec));
- writer.WriteResVersion(GetCString2(1, *rec));
- writer.WriteLib(GetCString2(2, *rec));
+ *res_type = GetCString(0, *rec);
+ *res_version = GetCString(1, *rec);
+ *lib = GetCString(2, *rec);
return PMINFO_R_OK;
}
int GetPackageMetadata(const tizen_base::Database& db,
- const char* pkgid, pkgmgr_common::PkgInfoHandleWriter& writer) {
+ const char* pkgid, GList** metadata) {
auto q = std::move(tizen_base::Database::Sql(
"SELECT md_key, md_value "
"FROM package_metadata WHERE package=?")
return PMINFO_R_ERROR;
}
- auto& metadata_writer = writer.GetMetadataListWriter();
for (const auto& rec : r) {
- metadata_writer.AddItem()
- .WriteKey(GetCString2(0, rec))
- .WriteValue(GetCString2(1, rec));
+ metadata_x* info = static_cast<metadata_x*>(
+ calloc(1, sizeof(metadata_x)));
+ if (info == nullptr) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ int idx = 0;
+ info->key = GetCString(idx++, rec);
+ info->value = GetCString(idx++, rec);
+ *metadata = g_list_prepend(*metadata, info);
}
return PMINFO_R_OK;
}
bool CheckPackageDisableFilter(const pkgmgrinfo_filter_x* filter,
- const char* pkgid, const char* is_disabled) {
+ const package_x* pkg_info) {
GSList* tmp_list = nullptr;
pkgmgrinfo_node_x* tmp_node = nullptr;
int property = -1;
if (property != tmp_node->prop)
continue;
- if (strcasecmp(tmp_node->value, is_disabled) == 0)
+ if (strcasecmp(tmp_node->value, pkg_info->is_disabled) == 0)
return true;
- if (strcasecmp(is_disabled, "true") == 0)
- LOGW("The package [%s] is disabled", pkgid);
+ if (strcasecmp(pkg_info->is_disabled, "true") == 0)
+ LOGW("The package [%s] is disabled", pkg_info->package);
return false;
}
int DoGetPkgInfo(const tizen_base::Database& db, uid_t uid,
const std::string& locale, pkgmgrinfo_filter_x* filter, int flag,
- std::vector<pkgmgr_common::PkgInfoHandle>& pkginfo_list) {
+ std::map<std::string, std::shared_ptr<package_x>>& packages) {
static const char query_raw[] =
"SELECT DISTINCT pi.package, pi.installed_storage, pi.external_path, "
"pi.package_disable";
static const char query_res_lib[] =
", (SELECT lib FROM package_res_info WHERE pi.package=package)";
static const char query_from_clause[] = " FROM package_info as pi";
+ char* tmp_record = nullptr;
std::vector<std::string> bind_params;
bool is_check_storage = true;
const uid_t global_user_uid = GLOBAL_USER;
}
for (const auto& rec : r) {
- pkgmgr_common::PkgInfoHandleWriter writer;
- writer.WriteLocale(locale.c_str());
+ package_x* info = reinterpret_cast<package_x*>(calloc(1, sizeof(package_x)));
+ if (info == nullptr) {
+ LOGE("out of memory");
+ return PMINFO_R_ERROR;
+ }
+
+ std::shared_ptr<package_x> pkg(info, pkgmgrinfo_basic_free_package);
+ info->locale = strdup(locale.c_str());
+ if (info->locale == nullptr) {
+ LOGE("Out of memory");
+ return PMINFO_R_ERROR;
+ }
+
int idx = 0;
- const char* package = nullptr;
- const char* installed_storage = nullptr;
- const char* external_path = nullptr;
- const char* is_disabled = nullptr;
- writer.WritePackage(package = GetCString2(idx++, rec));
- writer.WriteInstalledStorage(installed_storage = GetCString2(idx++, rec));
- writer.WriteExternalPath(external_path = GetCString2(idx++, rec));
- is_disabled = GetCString2(idx++, rec);
+ // Temp impl
+ info->package = GetCString(idx++, rec);
+ info->installed_storage = GetCString(idx++, rec);
+ info->external_path = GetCString(idx++, rec);
+ info->is_disabled = GetCString(idx++, rec);
if (flag & PMINFO_APPINFO_GET_BASICINFO) {
- writer.WriteIsDisabled(is_disabled);
- writer.WriteVersion(GetCString2(idx++, rec));
- writer.WriteInstallLocation(GetCString2(idx++, rec));
- writer.WriteRemovable(GetCString2(idx++, rec));
- writer.WritePreload(GetCString2(idx++, rec));
- writer.WriteReadonly(GetCString2(idx++, rec));
- writer.WriteUpdate(GetCString2(idx++, rec));
- writer.WriteAppSetting(GetCString2(idx++, rec));
- writer.WriteSystem(GetCString2(idx++, rec));
- writer.WriteType(GetCString2(idx++, rec));
- writer.WritePackageSize(GetCString2(idx++, rec));
- writer.WriteInstalledTime(GetCString2(idx++, rec));
- writer.WriteStoreClientId(GetCString2(idx++, rec));
- writer.WriteMainAppId(GetCString2(idx++, rec));
- writer.WritePackageUrl(GetCString2(idx++, rec));
- writer.WriteRootPath(GetCString2(idx++, rec));
- writer.WriteCscPath(GetCString2(idx++, rec));
- writer.WriteNoDisplaySetting(GetCString2(idx++, rec));
- writer.WriteApiVersion(GetCString2(idx++, rec));
- writer.WriteSupportDisable(GetCString2(idx++, rec));
- writer.WriteTepName(GetCString2(idx++, rec));
- writer.WriteZipMountFile(GetCString2(idx++, rec));
- writer.WriteSupportMode(GetCString2(idx++, rec));
- writer.WriteLightUserSwitchMode(GetCString2(idx++, rec));
+ info->version = GetCString(idx++, rec);
+ info->installlocation = GetCString(idx++, rec);
+ info->removable = GetCString(idx++, rec);
+ info->preload = GetCString(idx++, rec);
+ info->readonly = GetCString(idx++, rec);
+ info->update = GetCString(idx++, rec);
+ info->appsetting = GetCString(idx++, rec);
+ info->system = GetCString(idx++, rec);
+ info->type = GetCString(idx++, rec);
+ info->package_size = GetCString(idx++, rec);
+ info->installed_time = GetCString(idx++, rec);
+ info->storeclient_id = GetCString(idx++, rec);
+ info->mainapp_id = GetCString(idx++, rec);
+ info->package_url = GetCString(idx++, rec);
+ info->root_path = GetCString(idx++, rec);
+ info->csc_path = GetCString(idx++, rec);
+ info->nodisplay_setting = GetCString(idx++, rec);
+ info->api_version = GetCString(idx++, rec);
+ info->support_disable = GetCString(idx++, rec);
+ info->tep_name = GetCString(idx++, rec);
+ info->zip_mount_file = GetCString(idx++, rec);
+ info->support_mode = GetCString(idx++, rec);
+ info->light_user_switch_mode = GetCString(idx++, rec);
}
- writer.WriteForAllUsers((uid != global_user_uid) ? "false" : "true");
+ info->for_all_users =
+ strdup((uid != global_user_uid) ? "false" : "true");
- if (GetPluginExecutionInfo(db, package, writer))
+ if (GetPluginExecutionInfo(db, info->package, &info->plugin))
return PMINFO_R_ERROR;
if (flag & PMINFO_PKGINFO_GET_AUTHOR) {
- auto& author_list_writer = writer.GetAuthorListWriter();
- author_list_writer.AddItem()
- .WriteText(GetCString2(idx, rec))
- .WriteEmail(GetCString2(idx + 1, rec))
- .WriteHref(GetCString2(idx + 2, rec));
- idx += 3;
+ author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
+ if (author == nullptr) {
+ return PMINFO_R_ERROR;
+ }
+ author->text = GetCString(idx++, rec);
+ author->email = GetCString(idx++, rec);
+ author->href = GetCString(idx++, rec);
+ info->author = g_list_prepend(info->author, author);
}
if (flag & PMINFO_PKGINFO_GET_LABEL) {
- auto& label_list_writer = writer.GetLabelListWriter();
- label_list_writer.AddItem()
- .WriteText(GetCString2(idx++, rec))
- .WriteLang(locale.c_str());
+ tmp_record = GetCString(idx++, rec);
+ if (_add_label_info_into_list(locale.c_str(),
+ tmp_record, &info->label)) {
+ return PMINFO_R_ERROR;
+ }
}
if (flag & PMINFO_PKGINFO_GET_ICON) {
- auto& icon_list_writer = writer.GetIconListWriter();
- icon_list_writer.AddItem()
- .WriteText(GetCString2(idx++, rec))
- .WriteLang(locale.c_str());
+ tmp_record = GetCString(idx++, rec);
+ if (_add_icon_info_into_list(locale.c_str(),
+ tmp_record, &info->icon)) {
+ return PMINFO_R_ERROR;
+ }
}
if (flag & PMINFO_PKGINFO_GET_DESCRIPTION) {
- auto& description_writer = writer.GetDescriptionListWriter();
- description_writer.AddItem()
- .WriteText(GetCString2(idx++, rec))
- .WriteLang(locale.c_str());
+ tmp_record = GetCString(idx++, rec);
+ if (_pkginfo_add_description_info_into_list(locale.c_str(),
+ tmp_record, &info->description)) {
+ return PMINFO_R_ERROR;
+ }
}
if (flag & PMINFO_PKGINFO_GET_PRIVILEGE) {
- if (GetPrivilege(db, package, writer))
+ if (GetPrivilege(db, info->package, &info->privileges))
return PMINFO_R_ERROR;
}
if (flag & PMINFO_PKGINFO_GET_APPDEFINED_PRIVILEGE) {
- if (GetAppdefinedPrivilege(db, package, writer)) {
+ if (GetAppdefinedPrivilege(db, info->package,
+ &info->appdefined_privileges)) {
return PMINFO_R_ERROR;
}
}
if (flag & PMINFO_PKGINFO_GET_DEPENDENCY) {
- if (GetDependency(db, package, writer))
+ if (GetDependency(db, info->package, &info->dependencies))
return PMINFO_R_ERROR;
}
if (flag & PMINFO_PKGINFO_GET_RES_INFO) {
- if (GetResInfo(db, package, writer) < 0) {
+ if (GetResInfo(db, info->package, &info->res_type,
+ &info->res_version, &info->lib, &info->res_allowed_packages) < 0) {
return PMINFO_R_ERROR;
}
}
if (flag & PMINFO_PKGINFO_GET_METADATA) {
- if (GetPackageMetadata(db, package, writer) < 0)
+ if (GetPackageMetadata(db, info->package, &info->metadata) < 0)
return PMINFO_R_ERROR;
}
- if (is_check_storage && __pkginfo_check_installed_storage(
- package, installed_storage, external_path) != PMINFO_R_OK)
+ if (is_check_storage && __pkginfo_check_installed_storage(info) !=
+ PMINFO_R_OK)
continue;
- if (!CheckPackageDisableFilter(filter, package, is_disabled))
+ if (!CheckPackageDisableFilter(filter, info))
continue;
- pkgmgr_common::PkgInfoHandle handle = writer.ExtractPkgInfo();
- pkginfo_list.emplace_back(std::move(handle));
+ if (!(flag & PMINFO_APPINFO_GET_BASICINFO) && info->is_disabled) {
+ free(info->is_disabled);
+ info->is_disabled = nullptr;
+ }
+
+ packages[info->package] = std::move(pkg);
}
return PMINFO_R_OK;
int GetPkgInfo(const tizen_base::Database& db,
pkgmgrinfo_pkginfo_filter_h filter, uid_t uid,
const std::string& locale,
- std::vector<pkgmgr_common::PkgInfoHandle>& pkginfo_list) {
+ std::map<std::string, std::shared_ptr<package_x>>& pkginfo_list) {
if (!static_cast<bool>(db) || filter == nullptr) {
LOGE("Invalid argument");
return PMINFO_R_EINVAL;
#include "pkgmgrinfo_type.h"
#include "pkgmgr-info.h"
-#include "pkgmgr_info_handle.hh"
namespace pkgmgr_server::internal {
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<pkgmgr_common::AppInfoHandle>& appinfo_list);
+ 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::vector<pkgmgr_common::PkgInfoHandle>& pkginfo_list);
+ 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);
#include "pkgmgrinfo_debug.h"
#include "utils/logging.hh"
-namespace pc = pkgmgr_common;
namespace pcp = pkgmgr_common::parcel;
namespace psd = pkgmgr_server::database;
if (abstract_parcel == nullptr ||
abstract_parcel->GetType() != pcp::ParcelableType::Filter) {
LOG(ERROR) << "Invalid parcel or type";
- result_ = std::make_shared<pcp::ROAppInfoParcelable>(
- PMINFO_R_ERROR, std::vector<pc::AppInfoHandle>{});
+ result_ = std::make_shared<pcp::AppInfoParcelable>(
+ PMINFO_R_ERROR, std::vector<std::shared_ptr<application_x>>{});
return false;
}
auto* parcel = dynamic_cast<pcp::FilterParcelable*>(abstract_parcel.get());
if (parcel == nullptr) {
LOG(ERROR) << "Parcel is empty";
- result_ = std::make_shared<pcp::ROAppInfoParcelable>(
- PMINFO_R_ERROR, std::vector<pc::AppInfoHandle>{});
+ result_ = std::make_shared<pcp::AppInfoParcelable>(
+ PMINFO_R_ERROR, std::vector<std::shared_ptr<application_x>>{});
return false;
}
db.SetFilter(const_cast<pkgmgrinfo_filter_x*>(parcel->GetFilter()));
int ret = db.Execute();
- result_ = std::make_shared<pcp::ROAppInfoParcelable>(ret, db.DetachAppHandle());
+ result_ = std::make_shared<pcp::AppInfoParcelable>(ret, db.DetachAppHandle());
return true;
}
#define SERVER_GET_APPINFO_REQUEST_HANDLER_HH_
#include "abstract_request_handler.hh"
-#include "ro_appinfo_parcelable.hh"
+#include "appinfo_parcelable.hh"
#include <string>
#include "pkgmgrinfo_debug.h"
#include "utils/logging.hh"
-namespace pc = pkgmgr_common;
namespace pcp = pkgmgr_common::parcel;
namespace psd = pkgmgr_server::database;
if (abstract_parcel == nullptr ||
abstract_parcel->GetType() != pcp::ParcelableType::Filter) {
LOG(ERROR) << "Invalid parcel or type";
- result_ = std::make_shared<pcp::ROPkgInfoParcelable>(
- PMINFO_R_ERROR, std::vector<pc::PkgInfoHandle>{});
+ result_ = std::make_shared<pcp::PkgInfoParcelable>(
+ PMINFO_R_ERROR, std::vector<std::shared_ptr<package_x>>{});
return false;
}
auto* parcel = dynamic_cast<pcp::FilterParcelable*>(abstract_parcel.get());
if (parcel == nullptr) {
LOG(ERROR) << "Parcel is empty";
- result_ = std::make_shared<pcp::ROPkgInfoParcelable>(
- PMINFO_R_ERROR, std::vector<pc::PkgInfoHandle>{});
+ result_ = std::make_shared<pcp::PkgInfoParcelable>(
+ PMINFO_R_ERROR, std::vector<std::shared_ptr<package_x>>{});
return false;
}
db.SetFilter(const_cast<pkgmgrinfo_filter_x*>(parcel->GetFilter()));
int ret = db.Execute();
- result_ = std::make_shared<pcp::ROPkgInfoParcelable>(ret, db.GetPkgHandle());
+ result_ = std::make_shared<pcp::PkgInfoParcelable>(ret, db.GetPkgHandle());
return true;
}
#define SERVER_GET_PKGINFO_REQUEST_HANDLER_HH_
#include "abstract_request_handler.hh"
-#include "ro_pkginfo_parcelable.hh"
+#include "pkginfo_parcelable.hh"
#include <string>
+++ /dev/null
-/*
- * Copyright (c) 2025 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.
- */
-
-#include "shm_manager.hh"
-
-#include <fcntl.h>
-#include <glib.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <tzplatform_config.h>
-
-#include <algorithm>
-#include <string>
-#include <vector>
-
-#include "cache_flag.hh"
-#include "utils/logging.hh"
-
-#include "pkgmgr-info.h"
-#include "pkgmgrinfo_debug.h"
-#include "pkgmgrinfo_internal.h"
-#include "pkgmgrinfo_private.h"
-#include "pkgmgr_info_handle.hh"
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "PKGMGR_INFO"
-
-namespace {
-
-uid_t GetGlobalUID() {
- const static uid_t globaluser_uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
- return globaluser_uid;
-}
-
-uid_t ConvertUID(uid_t uid) {
- if (uid < REGULAR_USER)
- return GetGlobalUID();
- else
- return uid;
-}
-
-} // namespace
-
-namespace pkgmgr_server {
-namespace shared_memory {
-
-std::unordered_map<uid_t, std::unique_ptr<ShmManager>>
- ShmManager::shm_manager_map_;
-std::unordered_set<pid_t> ShmManager::writer_pid_list_;
-std::shared_mutex ShmManager::pid_list_lock_;
-
-ShmManager::ShmManager(uid_t uid) : uid_(uid),
- pkg_writer_(
- ps::ShmNameProvider::PkgConfig(uid),
- ps::ShmNameProvider::PkgHandle(uid),
- ps::ShmNameProvider::PkgIndexs(uid),
- ps::ShmNameProvider::PkgKeys(uid)
- ),
- app_writer_(
- ps::ShmNameProvider::AppConfig(uid),
- ps::ShmNameProvider::AppHandle(uid),
- ps::ShmNameProvider::AppIndexs(uid),
- ps::ShmNameProvider::AppKeys(uid)
- ) {}
-
-ShmManager& ShmManager::GetInst(uid_t uid) {
- static std::shared_mutex singleton_lock_;
- std::shared_lock<std::shared_mutex> s(singleton_lock_);
-
- uid_t conv_uid = ConvertUID(uid);
- auto it = shm_manager_map_.find(conv_uid);
- if (it != shm_manager_map_.end())
- return *(it->second);
-
- s.unlock();
- std::unique_lock<std::shared_mutex> u(singleton_lock_);
- auto& prov = shm_manager_map_[conv_uid];
- if (prov == nullptr)
- prov.reset(new ShmManager(conv_uid));
-
- return *prov;
-}
-
-std::unordered_set<pid_t> ShmManager::CrashedWriteRequestPIDs() {
- std::unique_lock<std::shared_mutex> u(pid_list_lock_);
-
- if (writer_pid_list_.empty())
- return {};
-
- LOG(DEBUG) << "Check process count : " << writer_pid_list_.size();
- std::unordered_set<pid_t> remove_pids;
- for (pid_t pid : writer_pid_list_) {
- std::string status_path = "/proc/" + std::to_string(pid) + "/status";
-
- int fd = open(status_path.c_str(), O_RDONLY);
- if (fd < 0) {
- LOG(ERROR) << "Process is crashed : " << pid;
- remove_pids.emplace(pid);
- } else {
- close(fd);
- }
- }
-
- return remove_pids;
-}
-
-bool ShmManager::IsWriter(pid_t pid) {
- std::unique_lock<std::shared_mutex> s(pid_list_lock_);
- return writer_pid_list_.find(pid) != writer_pid_list_.end();
-}
-
-int ShmManager::CreateSharedMemory(const tizen_base::Database& db,
- uid_t uid, const std::string& locale) {
- pkgmgrinfo_filter_x tmp_filter = { 0, };
- tmp_filter.cache_flag = true;
-
- std::vector<pkgmgr_common::PkgInfoHandle> pkgs;
- int ret = internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
- if (ret != PMINFO_R_OK) {
- LOG(ERROR) << "Failed to get pkg info, " << ret;
- return ret;
- }
- std::vector<pkgmgr_common::AppInfoHandle> apps;
- ret = internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, apps);
- if (ret != PMINFO_R_OK) {
- LOG(ERROR) << "Failed to get app info, " << ret;
- return ret;
- }
-
- std::sort(pkgs.begin(), pkgs.end());
- std::sort(apps.begin(), apps.end());
-
- if (!pkg_writer_.Init()) {
- LOG(ERROR) << "pkg_writer init fail";
- return PMINFO_R_ERROR;
- }
-
- if (!app_writer_.Init()) {
- LOG(ERROR) << "pkg_writer init fail";
- return PMINFO_R_ERROR;
- }
-
- auto p_lock = pkg_writer_.GetLock();
- auto a_lock = app_writer_.GetLock();
-
- if (!pkg_writer_.CreateSharedMemory(pkgs)) {
- LOG(ERROR) << "Failed to create pkg shared memory";
- return PMINFO_R_ERROR;
- }
-
- if (!app_writer_.CreateSharedMemory(apps)) {
- LOG(ERROR) << "Failed to create app shared memory";
- return PMINFO_R_ERROR;
- }
-
- pkg_app_map_.clear();
- for (const auto& pkg : pkgs)
- pkg_app_map_[pkg.GetPackage()];
-
- for (const auto& app : apps)
- pkg_app_map_[app.GetPackage()].emplace(app.GetAppId());
-
- released_ = false;
-
- return PMINFO_R_OK;
-}
-
-void ShmManager::InsertWriterPID(pid_t pid) {
- std::unique_lock<std::shared_mutex> u(pid_list_lock_);
- LOGD("InsertWriterPID %d", pid);
-
- writer_pid_list_.insert(pid);
-}
-
-bool ShmManager::EraseWriterPID(pid_t pid) {
- std::unique_lock<std::shared_mutex> u(pid_list_lock_);
- LOGD("EraseWriterPID %d", pid);
-
- return writer_pid_list_.erase(pid) == 1;
-}
-
-void ShmManager::RegisterPendingPackageInfo(
- const tizen_base::Database& db, package_x* info,
- pid_t pid, uid_t uid, const std::string& locale,
- pkgmgr_common::PkgWriteType write_type) {
- if (!info || !info->package) {
- LOGW("register pending package info(%p), info->package(%p)",
- info, info == nullptr ? nullptr : info->package);
- return;
- }
-
- LOGD("register pending package info : %s", info->package);
- InsertWriterPID(pid);
- pending_pkg_[info->package] = pid;
-}
-
-bool ShmManager::AddPkg(const pkgmgr_common::PkgInfoHandle& handle) {
- return pkg_writer_.Insert(handle);
-}
-
-bool ShmManager::AddApp(const pkgmgr_common::AppInfoHandle& handle) {
- pkg_app_map_[handle.GetPackage()].emplace(handle.GetAppId());
- return app_writer_.Insert(handle);
-}
-
-void ShmManager::ErasePkg(const std::string& pkgid) {
- auto it = pkg_app_map_.find(pkgid);
- if (it != pkg_app_map_.end()) {
- for (const auto& app : it->second)
- app_writer_.Erase(app);
- pkg_app_map_.erase(it);
- }
-
- pkg_writer_.Erase(pkgid);
-}
-
-void ShmManager::UpdatePendingPackageInfo(const tizen_base::Database& db,
- uid_t uid, const std::string& locale,
- const std::vector<std::string>& pkgids) {
- pkgmgrinfo_filter_x tmp_filter = { 0, };
- pkgmgrinfo_node_x node = { 0, };
- tmp_filter.cache_flag = true;
- tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
-
- auto p_lock = pkg_writer_.GetLock();
- auto a_lock = app_writer_.GetLock();
-
- for (const auto& pkgid : pkgids) {
- auto pkg_it = pending_pkg_.find(pkgid);
- if (pkg_it == pending_pkg_.end())
- continue;
-
- LOG(WARNING) << "Update package : " << pkgid;
-
- ErasePkg(pkgid);
- std::vector<pkgmgr_common::PkgInfoHandle> pkgs;
-
- node.prop = E_PMINFO_PKGINFO_PROP_PACKAGE_ID;
- node.value = const_cast<char*>(pkgid.c_str());
- internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
- node.prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE;
- for (const auto& pkg : pkgs) {
- std::vector<pkgmgr_common::AppInfoHandle> apps;
- internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, apps);
-
- for (const auto& app : apps)
- AddApp(app);
-
- AddPkg(pkg);
- }
-
- EraseWriterPID(pkg_it->second);
- pending_pkg_.erase(pkg_it);
- }
-
- g_slist_free(tmp_filter.list);
-}
-
-void ShmManager::TrimCache() {
- LOGD("TrimCache");
- if (!released_)
- ReleaseCache();
-}
-
-void ShmManager::ReleaseCache() {
- LOGD("ReleaseCache");
- pending_pkg_.clear();
-
- released_ = true;
-}
-
-void ShmManager::UpdateCrashedWriterPackageInfo(
- const tizen_base::Database& db,
- uid_t uid, const std::string& locale,
- const std::unordered_set<pid_t>& pids) {
- LOGD("UpdateCrashedWriterPackageInfo");
- std::vector<std::string> pkgids;
- for (const auto& [pkgid, pid] : pending_pkg_) {
- if (pids.find(pid) == pids.end())
- continue;
-
- EraseWriterPID(pid);
- pkgids.emplace_back(pkgid);
- }
-
- UpdatePendingPackageInfo(db, uid, locale, pkgids);
-}
-
-bool ShmManager::UpdatePkg(const tizen_base::Database& db, uid_t uid,
- const std::string& pkgid, const std::string& locale) {
- pkgmgrinfo_filter_x tmp_filter = { 0, };
- pkgmgrinfo_node_x node = {
- .prop = E_PMINFO_PKGINFO_PROP_PACKAGE_ID,
- .value = const_cast<char*>(pkgid.c_str())
- };
- tmp_filter.cache_flag = true;
- tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
- std::vector<pkgmgr_common::PkgInfoHandle> pkgs;
- internal::GetPkgInfo(db, &tmp_filter, uid_, locale, pkgs);
- auto p_lock = pkg_writer_.GetLock();
- auto a_lock = app_writer_.GetLock();
- for (const auto& pkg : pkgs) {
- std::string pkgid = pkg.GetPackage();
- if (!pkg_writer_.Erase(pkgid))
- return false;
- if (!AddPkg(pkg))
- return false;
- for (auto& appid : pkg_app_map_[pkgid]) {
- if (!app_writer_.Erase(appid))
- return false;
- }
-
- pkg_app_map_.erase(pkgid);
- std::vector<pkgmgr_common::AppInfoHandle> app_list;
- node.prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE;
- node.value = const_cast<char*>(pkgid.c_str());
- internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
- for (const auto& app : app_list) {
- if (!AddApp(app))
- return false;
- }
- }
-
- return true;
-}
-
-bool ShmManager::UpdateApp(const tizen_base::Database& db, uid_t uid,
- const std::string& appid, const std::string& locale) {
- pkgmgrinfo_filter_x tmp_filter = { 0, };
- pkgmgrinfo_node_x node = {
- .prop = E_PMINFO_APPINFO_PROP_APP_ID,
- .value = const_cast<char*>(appid.c_str())
- };
- tmp_filter.cache_flag = true;
- tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
-
- std::vector<pkgmgr_common::AppInfoHandle> app_list;
- internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
- g_slist_free(tmp_filter.list);
-
- auto a_lock = app_writer_.GetLock();
- if (!app_writer_.Erase(appid))
- return false;
-
- for (const auto& app : app_list)
- if (!AddApp(app))
- return false;
-
- return true;
-}
-
-bool ShmManager::UpdateAppByPkgid(const tizen_base::Database& db,
- uid_t uid, const std::string& pkgid, const std::string& locale) {
- pkgmgrinfo_filter_x tmp_filter = { 0, };
- pkgmgrinfo_node_x node = {
- .prop = E_PMINFO_APPINFO_PROP_APP_PACKAGE,
- .value = const_cast<char*>(pkgid.c_str())
- };
-
- tmp_filter.cache_flag = true;
- tmp_filter.list = g_slist_append(tmp_filter.list, (gpointer)&node);
-
- std::vector<pkgmgr_common::AppInfoHandle> app_list;
- internal::GetAppInfo(db, &tmp_filter, uid_, uid, locale, app_list);
-
- auto a_lock = app_writer_.GetLock();
- for (const auto& appid : pkg_app_map_[pkgid])
- if (!app_writer_.Erase(appid))
- return false;
- pkg_app_map_.erase(pkgid);
-
- for (const auto& app : app_list)
- if (!AddApp(app))
- return false;
-
- g_slist_free(tmp_filter.list);
- return true;
-}
-
-} // namespace shared_memory
-} // namespace pkgmgr_server
+++ /dev/null
-/*
- * Copyright (c) 2025 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 SHM_MANAGER_HH_
-#define SHM_MANAGER_HH_
-
-#include <memory>
-#include <shared_mutex>
-#include <string>
-#include <unordered_map>
-#include <unordered_set>
-#include <vector>
-
-#include <database.hpp>
-
-#include "pkg_write_type.hh"
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-
-#include "shm_writer.hh"
-
-namespace pkgmgr_server {
-namespace shared_memory {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-class EXPORT_API ShmManager {
- public:
- ~ShmManager() = default;
- static ShmManager& GetInst(uid_t uid);
- static std::unordered_set<pid_t> CrashedWriteRequestPIDs();
- static bool IsWriter(pid_t pid);
-
- int CreateSharedMemory(const tizen_base::Database& db, uid_t uid,
- const std::string& locale);
- void RegisterPendingPackageInfo(const tizen_base::Database& db,
- package_x* info, pid_t pid, uid_t uid, const std::string& locale,
- pkgmgr_common::PkgWriteType write_type);
- void TrimCache();
- void UpdateCrashedWriterPackageInfo(const tizen_base::Database& db,
- uid_t uid, const std::string& locale,
- const std::unordered_set<pid_t>& pids);
- void UpdatePendingPackageInfo(const tizen_base::Database& db,
- uid_t uid, const std::string& locale,
- const std::vector<std::string>& pkgids);
- bool UpdatePkg(const tizen_base::Database& db, uid_t uid,
- const std::string& pkgid, const std::string& locale);
- bool UpdateApp(const tizen_base::Database& db, uid_t uid,
- const std::string& appid, const std::string& locale);
- bool UpdateAppByPkgid(const tizen_base::Database& db, uid_t uid,
- const std::string& pkgid, const std::string& locale);
-
- private:
- explicit ShmManager(uid_t uid);
- void ReleaseCache();
- void InsertWriterPID(pid_t pid);
- bool EraseWriterPID(pid_t pid);
- void ErasePkg(const std::string& pkgid);
- bool AddPkg(const pkgmgr_common::PkgInfoHandle& handle);
- bool AddApp(const pkgmgr_common::AppInfoHandle& handle);
-
- static std::unordered_map<uid_t,
- std::unique_ptr<ShmManager>> shm_manager_map_;
- static std::unordered_set<pid_t> writer_pid_list_;
- static std::shared_mutex pid_list_lock_;
-
- uid_t uid_;
- ShmWriter<pc::PkgInfoHandle> pkg_writer_;
- ShmWriter<pc::AppInfoHandle> app_writer_;
- bool released_ = true;
-
- std::unordered_map<std::string, std::unordered_set<std::string>> pkg_app_map_;
- std::unordered_map<std::string, pid_t> pending_pkg_;
-};
-
-} // namespace shared_memory
-} // namespace pkgmgr_server
-
-#endif // SHM_MANAGER_HH_
+++ /dev/null
-/*
- * Copyright (c) 2024 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.
- */
-
-#include "shm_writer.hh"
-
-#include <algorithm>
-#include <vector>
-
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include "db_handle_provider.hh"
-
-#include "pkgmgrinfo_debug.h"
-#include "pkgmgrinfo_internal.h"
-
-#ifndef OWNER_ROOT
-#define OWNER_ROOT 0
-#endif
-#ifndef GLOBAL_USER
-#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
-#endif
-
-#include <fstream>
-
-namespace pkgmgr_server {
-namespace shared_memory {
-
-namespace pc = pkgmgr_common;
-namespace ps = pkgmgr_common::shared_memory;
-
-template<typename T>
-bool ShmWriter<T>::Init() {
- if (!config_handler_.Create()) {
- LOGE("Failed to create config handler");
- return false;
- }
-
- return true;
-}
-
-template<typename T>
-bool ShmWriter<T>::CreateSharedMemory(const std::vector<T>& handles) {
- WriteHandles(handles);
-
- config_handler_.SetMemSize(handle_mapper_.GetSize());
- config_handler_.SetIndexMemSize(index_mapper_.GetSize());
- config_handler_.SetKeyMemSize(key_mapper_.GetSize());
-
- if (config_handler_.Unlock() != 0)
- LOGE("Failed to unlock of config writer");
-
- return true;
-}
-
-template<typename T>
-bool ShmWriter<T>::WriteHandles(const std::vector<T>& handles) {
- size_t handle_mem_size = 0;
- size_t key_mem_size = 0;
- std::vector<size_t> key_sizes;
- for (const auto& it : handles) {
- size_t key_size = strlen(it.GetKey()) + 1;
- handle_mem_size += it.GetDataSize();
- key_mem_size += key_size;
- key_sizes.emplace_back(key_size);
- }
- LOGD("handle_mem_size : %zu", handle_mem_size);
-
- if (!handle_mapper_.Init(handle_mem_size)) {
- LOGE("handle_mapper_ init fail");
- return false;
- }
-
- if (!key_mapper_.Init(key_mem_size)) {
- LOGE("key_mapper_ init fail");
- return false;
- }
-
- int index = 0;
- int key_index = 0;
- std::vector<ps::HandleMappingData> indexs;
- for (size_t i = 0; i < handles.size(); ++i) {
- WriteKey(handles[i].GetKey(), key_sizes[i], key_index);
- WriteHandle(handles[i], index);
- indexs.emplace_back(ps::HandleMappingData {
- .key_index = static_cast<uint32_t>(key_index),
- .index = static_cast<uint32_t>(index),
- .len = handles[i].GetDataSize()
- });
- key_index += key_sizes[i];
- index += handles[i].GetDataSize();
- }
-
- if (!WriteIndexs(indexs)) {
- LOGE("WriteIndexs fail");
- return false;
- }
-
- LOGW("Success to write handles size : %zu", handles.size());
-
- return true;
-}
-
-template<typename T>
-bool ShmWriter<T>::Erase(const std::string& key) {
- auto [index, key_index] = GetHandleIndex(key.c_str());
- if (index == -1 || key_index == -1) {
- LOGD("key : %s doesn't already exist", key.c_str());
- return true;
- }
-
- LOGD("Erase key %s, index : %d, key_index : %d", key.c_str(), index, key_index);
-
- if (!RemoveKey(key_index)) {
- LOGE("Failed to remove key");
- return false;
- }
-
- if (!RemoveIndex(index, key.length() + 1)) {
- LOGE("Failed to remove index");
- return false;
- }
-
- return true;
-}
-
-template<typename T>
-bool ShmWriter<T>::Insert(const T& handle) {
- auto [index, key_index] = GetHandleInsertIndex(handle.GetKey());
- if (index == -1) {
- LOGE("GetHandleInsertIndex fail");
- return false;
- }
-
- return InsertHandle(handle, index, key_index);
-}
-
-template<typename T>
-bool ShmWriter<T>::WriteIndexs(
- const std::vector<ps::HandleMappingData>& indexs) {
- size_t mem_size = sizeof(ps::HandleMappingData) * indexs.size();
- if (!index_mapper_.Init(mem_size)) {
- LOGE("index_mapper_ init fail");
- return false;
- }
-
- auto* ptr = (ps::HandleMappingData*)index_mapper_.GetPtr();
- for (const auto& it : indexs) {
- memcpy(ptr, &it, sizeof(it));
- ptr++;
- }
-
- return true;
-}
-
-template<typename T>
-std::pair<int, int> ShmWriter<T>::GetHandleIndex(const char* key) const {
- int l = 0;
- int r = GetHandleSize();
- auto* ptr = (ps::HandleMappingData*)index_mapper_.GetPtr();
-
- while (l < r) {
- int mid = (l + r) / 2;
- const char* key_ptr = reinterpret_cast<const char*>(key_mapper_.GetPtr() + ptr[mid].key_index);
- int result = strcmp(key, key_ptr);
- if (result == 0)
- return std::make_pair(mid, ptr[mid].key_index);
- else if (result < 0)
- r = mid;
- else
- l = mid + 1;
- }
-
- return std::make_pair(-1, -1);
-}
-
-template<typename T>
-std::pair<int, int> ShmWriter<T>::GetHandleInsertIndex(const char* key) const {
- int l = 0;
- int r = GetHandleSize();
- auto* ptr = (ps::HandleMappingData*)index_mapper_.GetPtr();
-
- while (l < r) {
- int mid = (l + r) / 2;
- const char* key_ptr = reinterpret_cast<const char*>(key_mapper_.GetPtr() + ptr[mid].key_index);
- int result = strcmp(key, key_ptr);
- if (result == 0) {
- LOGE("The package[%s] to insert already exists", key);
- return std::make_pair(-1, -1);
- } else if (result < 0) {
- r = mid;
- } else {
- l = mid + 1;
- }
- }
-
- return std::make_pair(l, ptr[l].key_index);
-}
-
-template<typename T>
-bool ShmWriter<T>::RemoveIndex(size_t index, size_t key_size) {
- auto* ptr = reinterpret_cast<ps::HandleMappingData*>(index_mapper_.GetPtr());
- size_t handle_size = GetHandleSize();
-
- free_space_.emplace(ptr[index].len, ptr[index].index);
-
- int moved_num = handle_size - index - 1;
- if (moved_num > 0)
- memmove((void*)&ptr[index],
- (void*)&ptr[index + 1],
- moved_num * sizeof(ps::HandleMappingData));
-
- index_mapper_.Resize(
- index_mapper_.GetSize() - sizeof(ps::HandleMappingData));
- config_handler_.SetIndexMemSize(index_mapper_.GetSize());
-
- // Resize may change real ptr
- ptr = reinterpret_cast<ps::HandleMappingData*>(index_mapper_.GetPtr());
- for (size_t i = index; i < GetHandleSize(); ++i)
- ptr[i].key_index -= key_size;
-
- return true;
-}
-
-template<typename T>
-bool ShmWriter<T>::RemoveKey(int index) {
- if (index < 0) {
- LOGE("invalid index : %d", index);
- return false;
- }
-
- const char* ptr = reinterpret_cast<const char*>(key_mapper_.GetPtr());
- size_t handle_size = key_mapper_.GetSize();
- LOGE("remove key : %s", ptr + index);
-
- size_t key_size = strlen(ptr + index) + 1;
- size_t moved_num = handle_size - index - key_size;
- if (moved_num > 0)
- memmove((void*)(ptr + index), (void*)(ptr + index + key_size), moved_num);
-
- LOGE("key_mapper size from : %zu", key_mapper_.GetSize());
- key_mapper_.Resize(
- key_mapper_.GetSize() - key_size);
- config_handler_.SetKeyMemSize(key_mapper_.GetSize());
- LOGE("key_mapper size to : %zu", key_mapper_.GetSize());
-
- return true;
-}
-
-template<typename T>
-bool ShmWriter<T>::InsertHandle(const T& handle, int index, int key_index) {
- if (!InsertKey(handle.GetKey(), key_index)) {
- LOGE("Failed to insert key");
- return false;
- }
-
- int insert_index = PrepareHandleSpace(handle.GetDataSize());
- if (index < 0) {
- LOGE("Failed to prepare handle space");
- return false;
- }
-
- ps::HandleMappingData data {
- .key_index = static_cast<uint32_t>(key_index),
- .index = static_cast<uint32_t>(insert_index),
- .len = handle.GetDataSize(),
- };
- if (!InsertIndex(data, index, strlen(handle.GetKey()) + 1)) {
- LOGE("Failed to insert index");
- return false;
- }
-
- WriteHandle(handle, insert_index);
-
- return true;
-}
-
-template<typename T>
-bool ShmWriter<T>::InsertIndex(const ps::HandleMappingData& data, size_t index, size_t key_size) {
- LOGD("index : %zu", index);
- int moved_num = GetHandleSize() - index;
- if (!index_mapper_.Resize(index_mapper_.GetSize() + sizeof(ps::HandleMappingData))) {
- LOGE("Failed to resize index mapper");
- return false;
- }
- config_handler_.SetIndexMemSize(index_mapper_.GetSize());
-
- auto* ptr = (ps::HandleMappingData*)index_mapper_.GetPtr();
- if (moved_num > 0)
- memmove((void*)&ptr[index + 1], (void*)&ptr[index], moved_num * sizeof(ps::HandleMappingData));
-
- for (size_t i = index + 1; i < GetHandleSize(); ++i)
- ptr[i].key_index += key_size;
- ptr[index] = data;
-
- return true;
-}
-
-template<typename T>
-bool ShmWriter<T>::InsertKey(const char* key, int index) {
- char* ptr = reinterpret_cast<char*>(key_mapper_.GetPtr());
- size_t key_size = strlen(key) + 1;
- LOGE("insert key %s", ptr + index);
- LOGE("key size : %zu\n", key_size);
- int moved_num = key_mapper_.GetSize() - index;
- if (!key_mapper_.Resize(key_mapper_.GetSize() + key_size)) {
- LOGE("Failed to resize index mapper");
- return false;
- }
- config_handler_.SetKeyMemSize(key_mapper_.GetSize());
-
- // Resize may change real ptr
- ptr = reinterpret_cast<char*>(key_mapper_.GetPtr());
- if (moved_num > 0)
- memmove((void*)(ptr + index + key_size), (void*)(ptr + index), moved_num);
- memcpy(ptr + index, key, key_size);
-
- return true;
-}
-
-template<typename T>
-void ShmWriter<T>::WriteKey(const char* key, size_t size, int index) {
- uint8_t* ptr = key_mapper_.GetPtr();
- memcpy(ptr + index, key, size);
-}
-
-template<typename T>
-void ShmWriter<T>::WriteHandle(const T& handle, int index) {
- uint8_t* ptr = handle_mapper_.GetPtr();
- memcpy(ptr + index, handle.GetData(), handle.GetDataSize());
-}
-
-template<typename T>
-int ShmWriter<T>::PrepareHandleSpace(size_t size) {
- LOGD("Try to prepare handle space, size(%zu)", size);
- auto it = free_space_.begin();
- while (it != free_space_.end()) {
- if (it->first >= size) {
- LOGD("Find free mem space (%zu, %zu)", it->first, it->second);
- break;
- }
- it++;
- }
-
- if (it != free_space_.end()) {
- LOGD("there is free space");
- size_t new_len = it->first - size;
- size_t index = it->second + size;
- int result = it->second;
- free_space_.erase(it);
-
- if (new_len > 0) {
- LOGD("new len : %zu", new_len);
- free_space_.emplace(new_len, index);
- }
-
- return result;
- }
-
- LOGD("need to resize handle");
- int result = handle_mapper_.GetSize();
- if (!handle_mapper_.Resize(handle_mapper_.GetSize() + size)) {
- LOGE("Failed to resize handle mapper");
- return -1;
- }
- config_handler_.SetMemSize(handle_mapper_.GetSize());
- LOGD("handle size from[%d] to [%zu]", result, handle_mapper_.GetSize());
-
- return result;
-}
-
-template<typename T>
-size_t ShmWriter<T>::GetHandleSize() const {
- return index_mapper_.GetSize() / sizeof(ps::HandleMappingData);
-}
-
-template<typename T>
-LockGuard ShmWriter<T>::GetLock() {
- return LockGuard(config_handler_);
-}
-
-} // namespace shared_memory
-} // namespace pkgmgr_server
+++ /dev/null
-/*
- * Copyright (c) 2024 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 SHM_WRITER_HH_
-#define SHM_WRITER_HH_
-
-#include <map>
-#include <optional>
-#include <set>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include <sys/types.h>
-
-#include "abstract_db_handler.hh"
-#include "db_type.hh"
-#include "pkgmgrinfo_basic.h"
-#include "pkgmgrinfo_private.h"
-#include "pkgmgr_info_handle.hh"
-#include "shm_config.hh"
-
-namespace pkgmgr_server {
-namespace shared_memory {
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-namespace pc = pkgmgr_common;
-namespace ps = pkgmgr_common::shared_memory;
-
-class LockGuard {
- public:
- LockGuard(ps::ShmConfigHandler& config_handler) : config_handler_(config_handler) {
- config_handler_.GetWriteLock();
- }
-
- ~LockGuard() {
- config_handler_.Unlock();
- }
-
- private:
- ps::ShmConfigHandler& config_handler_;
-};
-
-template <typename T>
-class ShmWriter {
- public:
- ShmWriter(const char* config_shm_name,
- const char* handle_shm_name, const char* index_shm_name,
- const char* key_shm_name) :
- config_handler_(config_shm_name),
- handle_mapper_(handle_shm_name),
- index_mapper_(index_shm_name),
- key_mapper_(key_shm_name) {}
- bool Init();
- bool CreateSharedMemory(const std::vector<T>& handles);
- bool Erase(const std::string& key);
- bool Insert(const T& handle);
- LockGuard GetLock();
-
- private:
- bool WriteHandles(const std::vector<T>& handles);
- bool WriteIndexs(
- const std::vector<ps::HandleMappingData>& indexs);
- bool RemoveIndex(size_t index, size_t key_size);
- bool RemoveKey(int index);
- bool InsertHandle(const T& pkg, int index, int key_index);
- bool InsertIndex(const ps::HandleMappingData& data, size_t index, size_t key_size);
- bool InsertKey(const char* key, int index);
- void WriteKey(const char* key, size_t size, int index);
- void WriteHandle(const T& pkg, int index);
- int PrepareHandleSpace(size_t size);
- std::pair<int, int> GetHandleIndex(const char* pkgid) const;
- std::pair<int, int> GetHandleInsertIndex(const char* pkgid) const;
- size_t GetHandleSize() const;
-
- ps::ShmConfigHandler config_handler_;
- ps::ShmWriteMapper handle_mapper_;
- ps::ShmWriteMapper index_mapper_;
- ps::ShmWriteMapper key_mapper_;
-
- std::set<std::pair<size_t, size_t>> free_space_;
-};
-
-template class ShmWriter<pc::PkgInfoHandle>;
-template class ShmWriter<pc::AppInfoHandle>;
-
-} // namespace shared_memory
-} // namespace pkgmgr_server
-
-#endif // SHM_WRITER_HH_
-
#include "request_handler_factory.hh"
#include "server/database/db_handle_provider.hh"
#include "server/database/update_pending_cache_handler.hh"
-#include "server/shared_memory/shm_manager.hh"
#include "utils/logging.hh"
#include "pkgmgrinfo_debug.h"
}
auto crashed_writer_pids =
- shared_memory::ShmManager::CrashedWriteRequestPIDs();
+ database::DBHandleProvider::CrashedWriteRequestPIDs();
if (!crashed_writer_pids.empty()) {
database::UpdatePendingCacheHandler db(getuid(), std::move(crashed_writer_pids), {});
db.SetLocale(h->locale_.GetObject());
TARGET_LINK_LIBRARIES(${TARGET_PKGMGR_INFO_UNIT_TEST} PRIVATE ${libpkgs_LDFLAGS})
TARGET_LINK_LIBRARIES(${TARGET_PKGMGR_INFO_UNIT_TEST} PRIVATE ${libpkgmgr-parser_LDFLAGS})
TARGET_LINK_LIBRARIES(${TARGET_PKGMGR_INFO_UNIT_TEST} PUBLIC pkgmgr-info)
-TARGET_LINK_LIBRARIES(${TARGET_PKGMGR_INFO_UNIT_TEST} PUBLIC rt)
SET_TARGET_PROPERTIES(${TARGET_PKGMGR_INFO_UNIT_TEST} PROPERTIES COMPILE_FLAGS ${CFLAGS} "-fPIE -fpic")
SET_TARGET_PROPERTIES(${TARGET_PKGMGR_INFO_UNIT_TEST} PROPERTIES LINK_FLAGS "-pie")
set_target_properties(${TARGET_PKGMGR_INFO_UNIT_TEST} PROPERTIES COMPILE_FLAGS "${unit_test_pkgs_CFLAGS_str}")
#include <iostream>
#include "pkgmgrinfo_basic.h"
-#include "pkgmgr_info_handle.hh"
-#include "pkgmgr-info.h"
bool IS_STR_EQ(const char* a, const char* b) {
if (a == nullptr && b == nullptr)
} \
} while (0);
-#define STRDUP_IF_NOT_NULL(x) x ? strdup(x) : nullptr
-
application_x* GetTestApplication(std::string appid) {
- application_x* application =
+ application_x* application;
+ application =
reinterpret_cast<application_x*>(calloc(1, sizeof(application_x)));
- if (!application)
- return nullptr;
- std::unique_ptr<application_x,
- decltype(pkgmgrinfo_basic_free_application)*> application_auto(
- application, pkgmgrinfo_basic_free_application);
-
- application->appid = STRDUP_IF_NOT_NULL(appid.c_str());
- application->exec = STRDUP_IF_NOT_NULL("test_exec");
- application->nodisplay = STRDUP_IF_NOT_NULL("test_nodisplay");
- application->multiple = STRDUP_IF_NOT_NULL("test_multiple");
- application->taskmanage = STRDUP_IF_NOT_NULL("test_taskmanage");
- application->type = STRDUP_IF_NOT_NULL("test_type");
- application->hwacceleration = STRDUP_IF_NOT_NULL("test_hwacceleration");
- application->screenreader = STRDUP_IF_NOT_NULL("test_screenreader");
- application->mainapp = STRDUP_IF_NOT_NULL("test_mainapp");
- application->package = STRDUP_IF_NOT_NULL("test_package");
- application->recentimage = STRDUP_IF_NOT_NULL("test_recentimage");
- application->launchcondition = STRDUP_IF_NOT_NULL("test_launchcondition");
- application->indicatordisplay = STRDUP_IF_NOT_NULL("test_indicatordisplay");
- application->portraitimg = STRDUP_IF_NOT_NULL("test_portraitimg");
- application->landscapeimg = STRDUP_IF_NOT_NULL("test_landscapeimg");
- application->guestmode_visibility = STRDUP_IF_NOT_NULL("test_guestmode_visibility");
- application->component = STRDUP_IF_NOT_NULL("test_component");
- application->permission_type = STRDUP_IF_NOT_NULL("test_permission_type");
- application->component_type = STRDUP_IF_NOT_NULL("test_component");
- application->preload = STRDUP_IF_NOT_NULL("test_preload");
- application->submode = STRDUP_IF_NOT_NULL("test_submode");
- application->submode_mainid = STRDUP_IF_NOT_NULL("test_submode_mainid");
- application->process_pool = STRDUP_IF_NOT_NULL("test_process_pool");
- application->installed_storage = STRDUP_IF_NOT_NULL("test_installed_storage");
- application->autorestart = STRDUP_IF_NOT_NULL("test_autorestart");
- application->onboot = STRDUP_IF_NOT_NULL("test_onboot");
- application->support_disable = STRDUP_IF_NOT_NULL("test_support_disable");
- application->ui_gadget = STRDUP_IF_NOT_NULL("test_ui_gadget");
- application->launch_mode = STRDUP_IF_NOT_NULL("test_launch_mode");
- application->support_ambient = STRDUP_IF_NOT_NULL("test_support_ambient");
- application->setup_appid = STRDUP_IF_NOT_NULL("test_setup_appid");
- application->package_type = STRDUP_IF_NOT_NULL("test_type");
- application->tep_name = STRDUP_IF_NOT_NULL("test_tep_name");
- application->zip_mount_file = STRDUP_IF_NOT_NULL("test_zip_mount_file");
- application->root_path = STRDUP_IF_NOT_NULL("test_root_path");
- application->api_version = STRDUP_IF_NOT_NULL("test_api_version");
- application->for_all_users = STRDUP_IF_NOT_NULL("false");
- application->is_disabled = STRDUP_IF_NOT_NULL("false");
- application->splash_screen_display = STRDUP_IF_NOT_NULL("test_splash_screen_display");
- application->external_path = STRDUP_IF_NOT_NULL("test_external_path");
- application->package_system = STRDUP_IF_NOT_NULL("test_system");
- application->removable = STRDUP_IF_NOT_NULL("test_removable");
- application->package_installed_time = STRDUP_IF_NOT_NULL("test_installed_time");
- application->support_mode = STRDUP_IF_NOT_NULL("test_support_mode");
+
+ application->appid = strdup(appid.c_str());
+ application->exec = strdup("test_exec");
+ application->nodisplay = strdup("test_nodisplay");
+ application->multiple = strdup("test_multiple");
+ application->taskmanage = strdup("test_taskmanage");
+ application->type = strdup("test_type");
+ application->hwacceleration = strdup("test_hwacceleration");
+ application->screenreader = strdup("test_screenreader");
+ application->mainapp = strdup("test_mainapp");
+ application->package = strdup("test_package");
+ application->recentimage = strdup("test_recentimage");
+ application->launchcondition = strdup("test_launchcondition");
+ application->indicatordisplay = strdup("test_indicatordisplay");
+ application->portraitimg = strdup("test_portraitimg");
+ application->landscapeimg = strdup("test_landscapeimg");
+ application->guestmode_visibility = strdup("test_guestmode_visibility");
+ application->component = strdup("test_component");
+ application->permission_type = strdup("test_permission_type");
+ application->component_type = strdup("test_component");
+ application->preload = strdup("test_preload");
+ application->submode = strdup("test_submode");
+ application->submode_mainid = strdup("test_submode_mainid");
+ application->process_pool = strdup("test_process_pool");
+ application->installed_storage = strdup("test_installed_storage");
+ application->autorestart = strdup("test_autorestart");
+ application->onboot = strdup("test_onboot");
+ application->support_disable = strdup("test_support_disable");
+ application->ui_gadget = strdup("test_ui_gadget");
+ application->launch_mode = strdup("test_launch_mode");
+ application->support_ambient = strdup("test_support_ambient");
+ application->setup_appid = strdup("test_setup_appid");
+ application->package_type = strdup("test_type");
+ application->tep_name = strdup("test_tep_name");
+ application->zip_mount_file = strdup("test_zip_mount_file");
+ application->root_path = strdup("test_root_path");
+ application->api_version = strdup("test_api_version");
+ application->for_all_users = strdup("false");
+ application->is_disabled = strdup("false");
+ application->splash_screen_display = strdup("test_splash_screen_display");
+ application->external_path = strdup("test_external_path");
+ application->package_system = strdup("test_system");
+ application->removable = strdup("test_removable");
+ application->package_installed_time = strdup("test_installed_time");
+ application->support_mode = strdup("test_support_mode");
label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- if (!label)
- return nullptr;
- label->lang = STRDUP_IF_NOT_NULL("test_lang");
- label->name = STRDUP_IF_NOT_NULL("test_name");
- label->text = STRDUP_IF_NOT_NULL("test_text");
+ label->lang = strdup("test_lang");
+ label->name = strdup("test_name");
+ label->text = strdup("test_text");
application->label = g_list_append(application->label, label);
icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
- if (!icon)
- return nullptr;
- icon->text = STRDUP_IF_NOT_NULL("test_text");
- icon->lang = STRDUP_IF_NOT_NULL("test_lang");
- icon->section = STRDUP_IF_NOT_NULL("test_section");
- icon->size = STRDUP_IF_NOT_NULL("test_size");
- icon->resolution = STRDUP_IF_NOT_NULL("test_resolution");
- icon->dpi = STRDUP_IF_NOT_NULL("ldpi");
+ icon->text = strdup("test_text");
+ icon->lang = strdup("test_lang");
+ icon->section = strdup("test_section");
+ icon->size = strdup("test_size");
+ icon->resolution = strdup("test_resolution");
+ icon->dpi = strdup("ldpi");
application->icon = g_list_append(application->icon, icon);
application->category =
- g_list_append(application->category, STRDUP_IF_NOT_NULL("test_category"));
+ g_list_append(application->category, strdup("test_category"));
metadata_x* metadata =
reinterpret_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
- if (!metadata)
- return nullptr;
- metadata->key = STRDUP_IF_NOT_NULL("test_key");
- metadata->value = STRDUP_IF_NOT_NULL("test_value");
+ metadata->key = strdup("test_key");
+ metadata->value = strdup("test_value");
application->metadata = g_list_append(application->metadata, metadata);
datacontrol_x* datacontrol =
reinterpret_cast<datacontrol_x*>(calloc(1, sizeof(datacontrol_x)));
- if (!datacontrol)
- return nullptr;
- datacontrol->providerid = STRDUP_IF_NOT_NULL(appid.c_str());
- datacontrol->access = STRDUP_IF_NOT_NULL("test_access");
- datacontrol->type = STRDUP_IF_NOT_NULL("test_type");
- datacontrol->trusted = STRDUP_IF_NOT_NULL("test_trusted");
+ datacontrol->providerid = strdup(appid.c_str());
+ datacontrol->access = strdup("test_access");
+ datacontrol->type = strdup("test_type");
+ datacontrol->trusted = strdup("test_trusted");
datacontrol->privileges = g_list_append(datacontrol->privileges,
- STRDUP_IF_NOT_NULL("test_datacontrol_privilege"));
+ strdup("test_datacontrol_privilege"));
application->datacontrol =
g_list_append(application->datacontrol, datacontrol);
application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("enable"));
+ application->background_category, strdup("enable"));
application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("media"));
+ application->background_category, strdup("media"));
application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("download"));
+ application->background_category, strdup("download"));
application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("background-network"));
+ application->background_category, strdup("background-network"));
application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("location"));
+ application->background_category, strdup("location"));
application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("sensor"));
+ application->background_category, strdup("sensor"));
application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("iot-communication"));
+ application->background_category, strdup("iot-communication"));
application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("system"));
+ application->background_category, strdup("system"));
appcontrol_x* appcontrol =
reinterpret_cast<appcontrol_x*>(calloc(1, sizeof(appcontrol_x)));
- if (!appcontrol)
- return nullptr;
- appcontrol->operation = STRDUP_IF_NOT_NULL("test_operation");
- appcontrol->uri = STRDUP_IF_NOT_NULL("test_uri");
- appcontrol->mime = STRDUP_IF_NOT_NULL("test_mime");
- appcontrol->visibility = STRDUP_IF_NOT_NULL("test_visibility");
- appcontrol->id = STRDUP_IF_NOT_NULL("test_id");
+ appcontrol->operation = strdup("test_operation");
+ appcontrol->uri = strdup("test_uri");
+ appcontrol->mime = strdup("test_mime");
+ appcontrol->visibility = strdup("test_visibility");
+ appcontrol->id = strdup("test_id");
appcontrol->privileges = g_list_append(
- appcontrol->privileges, STRDUP_IF_NOT_NULL("test_appcontrol_privilege"));
+ appcontrol->privileges, strdup("test_appcontrol_privilege"));
application->appcontrol = g_list_append(application->appcontrol, appcontrol);
splashscreen_x* splashscreen =
reinterpret_cast<splashscreen_x*>(calloc(1, sizeof(splashscreen_x)));
- if (!splashscreen)
- return nullptr;
- splashscreen->src = STRDUP_IF_NOT_NULL("test_src");
- splashscreen->type = STRDUP_IF_NOT_NULL("ttest_type");
- splashscreen->dpi = STRDUP_IF_NOT_NULL("ldpi");
- splashscreen->orientation = STRDUP_IF_NOT_NULL("portrait");
+ splashscreen->src = strdup("test_src");
+ splashscreen->type = strdup("ttest_type");
+ splashscreen->dpi = strdup("ldpi");
+ splashscreen->orientation = strdup("portrait");
splashscreen->indicatordisplay =
- STRDUP_IF_NOT_NULL("indicatordisptest_indicatordisplay");
- splashscreen->operation = STRDUP_IF_NOT_NULL("operattest_operation");
- splashscreen->color_depth = STRDUP_IF_NOT_NULL("color_detest_color_depth");
+ strdup("indicatordisptest_indicatordisplay");
+ splashscreen->operation = strdup("operattest_operation");
+ splashscreen->color_depth = strdup("color_detest_color_depth");
application->splashscreens =
g_list_append(application->splashscreens, splashscreen);
res_control_x* res_control =
reinterpret_cast<res_control_x*>(calloc(1, sizeof(res_control_x)));
- if (!res_control)
- return nullptr;
- res_control->res_type = STRDUP_IF_NOT_NULL("test_res_type");
- res_control->min_res_version = STRDUP_IF_NOT_NULL("1.0.0");
- res_control->max_res_version = STRDUP_IF_NOT_NULL("2.0.0");
- res_control->auto_close = STRDUP_IF_NOT_NULL("true");
+ res_control->res_type = strdup("test_res_type");
+ res_control->min_res_version = strdup("1.0.0");
+ res_control->max_res_version = strdup("2.0.0");
+ res_control->auto_close = strdup("true");
application->res_control =
g_list_append(application->res_control, res_control);
- return application_auto.release();
+ return application;
}
bool IsEqualApplicationExtraInfo(application_x* applicationA,
return true;
}
-application_x* AppInfoHandleToApplicationX(const pkgmgr_common::AppInfoHandle& handle) {
- application_x* application;
- application =
- reinterpret_cast<application_x*>(calloc(1, sizeof(application_x)));
- if (!application)
- return nullptr;
- std::unique_ptr<application_x,
- decltype(pkgmgrinfo_basic_free_application)*> application_auto(
- application, pkgmgrinfo_basic_free_application);
-
- application->appid = STRDUP_IF_NOT_NULL(handle.GetAppId());
- application->exec = STRDUP_IF_NOT_NULL(handle.GetExec());
- application->nodisplay = STRDUP_IF_NOT_NULL(handle.GetNodisplay());
- application->multiple = STRDUP_IF_NOT_NULL(handle.GetMultiple());
- application->taskmanage = STRDUP_IF_NOT_NULL(handle.GetTaskManage());
- application->type = STRDUP_IF_NOT_NULL(handle.GetType());
- application->hwacceleration = STRDUP_IF_NOT_NULL(handle.GetHwAcceleration());
- application->screenreader = STRDUP_IF_NOT_NULL(handle.GetScreenReader());
- application->mainapp = STRDUP_IF_NOT_NULL(handle.GetMainApp());
- application->package = STRDUP_IF_NOT_NULL(handle.GetPackage());
- application->recentimage = STRDUP_IF_NOT_NULL(handle.GetRecentimage());
- application->launchcondition = STRDUP_IF_NOT_NULL(handle.GetLaunchCondition());
- application->indicatordisplay = STRDUP_IF_NOT_NULL(handle.GetIndicatorDisplay());
- application->portraitimg = STRDUP_IF_NOT_NULL(handle.GetPortraitImg());
- application->landscapeimg = STRDUP_IF_NOT_NULL(handle.GetLandscapeImg());
- application->guestmode_visibility = STRDUP_IF_NOT_NULL(handle.GetGuestModeVisibility());
- application->component = STRDUP_IF_NOT_NULL(handle.GetComponent());
- application->permission_type = STRDUP_IF_NOT_NULL(handle.GetPermissionType());
- application->component_type = STRDUP_IF_NOT_NULL(handle.GetComponentType());
- application->preload = STRDUP_IF_NOT_NULL(handle.GetPreload());
- application->submode = STRDUP_IF_NOT_NULL(handle.GetSubmode());
- application->submode_mainid = STRDUP_IF_NOT_NULL(handle.GetSubmodeMainId());
- application->process_pool = STRDUP_IF_NOT_NULL(handle.GetProcessPool());
- application->installed_storage = STRDUP_IF_NOT_NULL(handle.GetInstalledStorage());
- application->autorestart = STRDUP_IF_NOT_NULL(handle.GetAutoRestart());
- application->onboot = STRDUP_IF_NOT_NULL(handle.GetOnboot());
- application->support_disable = STRDUP_IF_NOT_NULL(handle.GetSupportDisable());
- application->ui_gadget = STRDUP_IF_NOT_NULL(handle.GetUiGadget());
- application->launch_mode = STRDUP_IF_NOT_NULL(handle.GetLaunchMode());
- application->support_ambient = STRDUP_IF_NOT_NULL(handle.GetSupportAmbient());
- application->setup_appid = STRDUP_IF_NOT_NULL(handle.GetSetupAppId());
- application->package_type = STRDUP_IF_NOT_NULL(handle.GetPackageType());
- application->tep_name = STRDUP_IF_NOT_NULL(handle.GetTepName());
- application->zip_mount_file = STRDUP_IF_NOT_NULL(handle.GetZipMountFile());
- application->root_path = STRDUP_IF_NOT_NULL(handle.GetRootPath());
- application->api_version = STRDUP_IF_NOT_NULL(handle.GetApiVersion());
- application->for_all_users = STRDUP_IF_NOT_NULL(handle.GetForAllUsers());
- application->is_disabled = STRDUP_IF_NOT_NULL(handle.GetIsDisabled());
- application->splash_screen_display = STRDUP_IF_NOT_NULL(handle.GetSplashScreenDisplay());
- application->external_path = STRDUP_IF_NOT_NULL(handle.GetExternalPath());
- application->package_system = STRDUP_IF_NOT_NULL(handle.GetPackageSystem());
- application->removable = STRDUP_IF_NOT_NULL(handle.GetRemovable());
- application->package_installed_time = STRDUP_IF_NOT_NULL(handle.GetPackageInstalledTime());
- application->support_mode = STRDUP_IF_NOT_NULL(handle.GetSupportMode());
-
- for (auto item : handle.GetLabel()) {
- label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- if (!label)
- return nullptr;
- label->lang = STRDUP_IF_NOT_NULL(item.Lang());
- label->name = STRDUP_IF_NOT_NULL(item.Name());
- label->text = STRDUP_IF_NOT_NULL(item.Text());
- application->label = g_list_append(application->label, label);
- }
-
- for (auto item : handle.GetIcon()) {
- icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
- if (!icon)
- return nullptr;
- icon->text = STRDUP_IF_NOT_NULL(item.Text());
- icon->lang = STRDUP_IF_NOT_NULL(item.Lang());
- icon->section = STRDUP_IF_NOT_NULL(item.Section());
- icon->size = STRDUP_IF_NOT_NULL(item.Size());
- icon->resolution = STRDUP_IF_NOT_NULL(item.Resolution());
- icon->dpi = STRDUP_IF_NOT_NULL(item.Dpi());
- application->icon = g_list_append(application->icon, icon);
- }
-
- for (auto item : handle.GetCategory()) {
- application->category =
- g_list_append(application->category, STRDUP_IF_NOT_NULL(item));
- }
-
- for (auto item : handle.GetMetadata()) {
- metadata_x* metadata =
- reinterpret_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
- if (!metadata)
- return nullptr;
- metadata->key = STRDUP_IF_NOT_NULL(item.Key());
- metadata->value = STRDUP_IF_NOT_NULL(item.Value());
- application->metadata = g_list_append(application->metadata, metadata);
- }
-
- datacontrol_x* datacontrol =
- reinterpret_cast<datacontrol_x*>(calloc(1, sizeof(datacontrol_x)));
- if (!datacontrol)
- return nullptr;
- datacontrol->providerid = STRDUP_IF_NOT_NULL(handle.GetAppId());
- datacontrol->access = STRDUP_IF_NOT_NULL("test_access");
- datacontrol->type = STRDUP_IF_NOT_NULL("test_type");
- datacontrol->trusted = STRDUP_IF_NOT_NULL("test_trusted");
- datacontrol->privileges = g_list_append(datacontrol->privileges,
- STRDUP_IF_NOT_NULL("test_datacontrol_privilege"));
- application->datacontrol =
- g_list_append(application->datacontrol, datacontrol);
-
- application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("enable"));
- application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("media"));
- application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("download"));
- application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("background-network"));
- application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("location"));
- application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("sensor"));
- application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("iot-communication"));
- application->background_category = g_list_prepend(
- application->background_category, STRDUP_IF_NOT_NULL("system"));
-
- for (auto item : handle.GetAppcontrol()) {
- appcontrol_x* appcontrol =
- reinterpret_cast<appcontrol_x*>(calloc(1, sizeof(appcontrol_x)));
- if (!appcontrol)
- return nullptr;
- appcontrol->operation = STRDUP_IF_NOT_NULL(item.Operation());
- appcontrol->uri = STRDUP_IF_NOT_NULL(item.Uri());
- appcontrol->mime = STRDUP_IF_NOT_NULL(item.Mime());
- appcontrol->visibility = STRDUP_IF_NOT_NULL(item.Visibility());
- appcontrol->id = STRDUP_IF_NOT_NULL(item.Id());
- for (auto priv : item.Privileges())
- appcontrol->privileges = g_list_append(
- appcontrol->privileges, STRDUP_IF_NOT_NULL(priv));
- application->appcontrol = g_list_append(application->appcontrol, appcontrol);
- }
-
- for (auto item : handle.GetSplashscreens()) {
- splashscreen_x* splashscreen =
- reinterpret_cast<splashscreen_x*>(calloc(1, sizeof(splashscreen_x)));
- if (!splashscreen)
- return nullptr;
- splashscreen->src = STRDUP_IF_NOT_NULL(item.Src());
- splashscreen->type = STRDUP_IF_NOT_NULL(item.Type());
- splashscreen->dpi = STRDUP_IF_NOT_NULL(item.Dpi());
- splashscreen->orientation = STRDUP_IF_NOT_NULL(item.Orientation());
- splashscreen->indicatordisplay =
- STRDUP_IF_NOT_NULL(item.Indicatordisplay());
- splashscreen->operation = STRDUP_IF_NOT_NULL(item.Operation());
- splashscreen->color_depth = STRDUP_IF_NOT_NULL(item.ColorDepth());
- application->splashscreens =
- g_list_append(application->splashscreens, splashscreen);
- }
-
- for (auto item : handle.GetResControl()) {
- res_control_x* res_control =
- reinterpret_cast<res_control_x*>(calloc(1, sizeof(res_control_x)));
- if (!res_control)
- return nullptr;
- res_control->res_type = STRDUP_IF_NOT_NULL(item.ResType());
- res_control->min_res_version = STRDUP_IF_NOT_NULL(item.MinResVersion());
- res_control->max_res_version = STRDUP_IF_NOT_NULL(item.MaxResVersion());
- res_control->auto_close = STRDUP_IF_NOT_NULL(item.AutoClose());
- application->res_control =
- g_list_append(application->res_control, res_control);
- }
-
- return application_auto.release();
-}
-
bool IsEqualApplicationsInfo(
- const std::vector<pkgmgr_common::AppInfoHandle>& applicationsA,
+ const std::vector<std::shared_ptr<application_x>>& applicationsA,
const std::vector<std::shared_ptr<application_x>>& applicationsB) {
for (unsigned int i = 0; i < applicationsA.size(); ++i) {
- std::unique_ptr<application_x, decltype(pkgmgrinfo_basic_free_application)*> ptr(
- AppInfoHandleToApplicationX(applicationsA[i]), pkgmgrinfo_basic_free_application);
- if (!IsEqualApplication(ptr.get(), applicationsB[i].get()))
+ if (!IsEqualApplication(applicationsA[i].get(), applicationsB[i].get()))
return false;
}
package_x* GetTestPackage(std::string pkgid) {
package_x* package;
package = reinterpret_cast<package_x*>(calloc(1, sizeof(package_x)));
- if (!package)
- return nullptr;
- std::unique_ptr<package_x,
- decltype(pkgmgrinfo_basic_free_package)*> package_auto(
- package, pkgmgrinfo_basic_free_package);
-
- package->for_all_users = STRDUP_IF_NOT_NULL("false");
- package->package = STRDUP_IF_NOT_NULL(pkgid.c_str());
- package->version = STRDUP_IF_NOT_NULL("test_version");
- package->installlocation = STRDUP_IF_NOT_NULL("test_installlocation");
- package->ns = STRDUP_IF_NOT_NULL("test_ns");
- package->removable = STRDUP_IF_NOT_NULL("test_removable");
- package->preload = STRDUP_IF_NOT_NULL("test_preload");
- package->readonly = STRDUP_IF_NOT_NULL("test_readonly");
- package->update = STRDUP_IF_NOT_NULL("test_update");
- package->appsetting = STRDUP_IF_NOT_NULL("test_appsetting");
- package->system = STRDUP_IF_NOT_NULL("test_system");
- package->type = STRDUP_IF_NOT_NULL("test_type");
- package->package_size = STRDUP_IF_NOT_NULL("test_package_size");
- package->installed_time = STRDUP_IF_NOT_NULL("test_installed_time");
- package->installed_storage = STRDUP_IF_NOT_NULL("test_installed_storage");
- package->storeclient_id = STRDUP_IF_NOT_NULL("test_storeclient_id");
- package->mainapp_id = STRDUP_IF_NOT_NULL("test_mainapp_id");
- package->package_url = STRDUP_IF_NOT_NULL("test_package_url");
- package->root_path = STRDUP_IF_NOT_NULL("test_root_path");
- package->csc_path = STRDUP_IF_NOT_NULL("test_csc_path");
- package->nodisplay_setting = STRDUP_IF_NOT_NULL("test_nodisplay_setting");
- package->support_mode = STRDUP_IF_NOT_NULL("test_support_mode");
- package->support_disable = STRDUP_IF_NOT_NULL("test_support_disable");
- package->api_version = STRDUP_IF_NOT_NULL("test_api_version");
- package->tep_name = STRDUP_IF_NOT_NULL("test_tep_name");
- package->zip_mount_file = STRDUP_IF_NOT_NULL("test_zip_mount_file");
- package->backend_installer = STRDUP_IF_NOT_NULL("test_backend_installer");
- package->external_path = STRDUP_IF_NOT_NULL("test_external_path");
- package->use_system_certs = STRDUP_IF_NOT_NULL("test_use_system_certs");
- package->res_type = STRDUP_IF_NOT_NULL("test_res_type");
- package->res_version = STRDUP_IF_NOT_NULL("test_res_version");
- package->lib = STRDUP_IF_NOT_NULL("false");
- package->light_user_switch_mode = STRDUP_IF_NOT_NULL("default");
+
+ package->for_all_users = strdup("false");
+ package->package = strdup(pkgid.c_str());
+ package->version = strdup("test_version");
+ package->installlocation = strdup("test_installlocation");
+ package->ns = strdup("test_ns");
+ package->removable = strdup("test_removable");
+ package->preload = strdup("test_preload");
+ package->readonly = strdup("test_readonly");
+ package->update = strdup("test_update");
+ package->appsetting = strdup("test_appsetting");
+ package->system = strdup("test_system");
+ package->type = strdup("test_type");
+ package->package_size = strdup("test_package_size");
+ package->installed_time = strdup("test_installed_time");
+ package->installed_storage = strdup("test_installed_storage");
+ package->storeclient_id = strdup("test_storeclient_id");
+ package->mainapp_id = strdup("test_mainapp_id");
+ package->package_url = strdup("test_package_url");
+ package->root_path = strdup("test_root_path");
+ package->csc_path = strdup("test_csc_path");
+ package->nodisplay_setting = strdup("test_nodisplay_setting");
+ package->support_mode = strdup("test_support_mode");
+ package->support_disable = strdup("test_support_disable");
+ package->api_version = strdup("test_api_version");
+ package->tep_name = strdup("test_tep_name");
+ package->zip_mount_file = strdup("test_zip_mount_file");
+ package->backend_installer = strdup("test_backend_installer");
+ package->external_path = strdup("test_external_path");
+ package->use_system_certs = strdup("test_use_system_certs");
+ package->res_type = strdup("test_res_type");
+ package->res_version = strdup("test_res_version");
+ package->lib = strdup("false");
+ package->light_user_switch_mode = strdup("default");
icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
- if (!icon)
- return nullptr;
- icon->text = STRDUP_IF_NOT_NULL("test_text");
- icon->lang = STRDUP_IF_NOT_NULL("test_lang");
- icon->section = STRDUP_IF_NOT_NULL("test_section");
- icon->size = STRDUP_IF_NOT_NULL("test_size");
- icon->resolution = STRDUP_IF_NOT_NULL("test_resolution");
- icon->dpi = STRDUP_IF_NOT_NULL("ldpi");
+ icon->text = strdup("test_text");
+ icon->lang = strdup("test_lang");
+ icon->section = strdup("test_section");
+ icon->size = strdup("test_size");
+ icon->resolution = strdup("test_resolution");
+ icon->dpi = strdup("ldpi");
package->icon = g_list_append(package->icon, icon);
label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- if (!label)
- return nullptr;
- label->lang = STRDUP_IF_NOT_NULL("test_lang");
- label->name = STRDUP_IF_NOT_NULL("test_name");
- label->text = STRDUP_IF_NOT_NULL("test_text");
+ label->lang = strdup("test_lang");
+ label->name = strdup("test_name");
+ label->text = strdup("test_text");
package->label = g_list_append(package->label, label);
author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
- if (!author)
- return nullptr;
- author->email = STRDUP_IF_NOT_NULL("test_email");
- author->href = STRDUP_IF_NOT_NULL("test_href");
- author->text = STRDUP_IF_NOT_NULL("test_text");
- author->lang = STRDUP_IF_NOT_NULL("test_lang");
+ author->email = strdup("test_email");
+ author->href = strdup("test_href");
+ author->text = strdup("test_text");
+ author->lang = strdup("test_lang");
package->author = g_list_append(package->author, author);
description_x* description =
reinterpret_cast<description_x*>(calloc(1, sizeof(description_x)));
- if (!description)
- return nullptr;
- description->name = STRDUP_IF_NOT_NULL("test_name");
- description->text = STRDUP_IF_NOT_NULL("test_text");
- description->lang = STRDUP_IF_NOT_NULL("test_lang");
+ description->name = strdup("test_name");
+ description->text = strdup("test_text");
+ description->lang = strdup("test_lang");
package->description = g_list_append(package->description, description);
privilege_x* privilege =
reinterpret_cast<privilege_x*>(calloc(1, sizeof(privilege_x)));
- if (!privilege)
- return nullptr;
- privilege->type = STRDUP_IF_NOT_NULL("test_type");
- privilege->value = STRDUP_IF_NOT_NULL("test_value");
+ privilege->type = strdup("test_type");
+ privilege->value = strdup("test_value");
package->privileges = g_list_append(package->privileges, privilege);
appdefined_privilege_x* appdefined_privilege =
reinterpret_cast<appdefined_privilege_x*>(
calloc(1, sizeof(appdefined_privilege_x)));
- if (!appdefined_privilege)
- return nullptr;
- appdefined_privilege->type = STRDUP_IF_NOT_NULL("test_type");
- appdefined_privilege->value = STRDUP_IF_NOT_NULL("test_value");
- appdefined_privilege->license = STRDUP_IF_NOT_NULL("test_license");
+ appdefined_privilege->type = strdup("test_type");
+ appdefined_privilege->value = strdup("test_value");
+ appdefined_privilege->license = strdup("test_license");
package->appdefined_privileges =
g_list_append(package->appdefined_privileges, appdefined_privilege);
appdefined_privilege_x* provides_appdefined_privileges =
reinterpret_cast<appdefined_privilege_x*>(
calloc(1, sizeof(appdefined_privilege_x)));
- if (!provides_appdefined_privileges)
- return nullptr;
- provides_appdefined_privileges->type = STRDUP_IF_NOT_NULL("test_type");
- provides_appdefined_privileges->value = STRDUP_IF_NOT_NULL("test_value");
- provides_appdefined_privileges->license = STRDUP_IF_NOT_NULL("test_license");
+ provides_appdefined_privileges->type = strdup("test_type");
+ provides_appdefined_privileges->value = strdup("test_value");
+ provides_appdefined_privileges->license = strdup("test_license");
package->provides_appdefined_privileges =
g_list_append(package->provides_appdefined_privileges,
GetTestDepInfo(pkgid));
plugin_x* plugin = reinterpret_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
- if (!plugin)
- return nullptr;
- plugin->pkgid = STRDUP_IF_NOT_NULL(pkgid.c_str());
- plugin->appid = STRDUP_IF_NOT_NULL("test_appid");
- plugin->plugin_type = STRDUP_IF_NOT_NULL("test_plugin_type");
- plugin->plugin_name = STRDUP_IF_NOT_NULL("test_plugin_name");
+ plugin->pkgid = strdup(pkgid.c_str());
+ plugin->appid = strdup("test_appid");
+ plugin->plugin_type = strdup("test_plugin_type");
+ plugin->plugin_name = strdup("test_plugin_name");
package->plugin = g_list_append(package->plugin, plugin);
res_allowed_package_x* allowed_package =
reinterpret_cast<res_allowed_package_x*>(calloc(1,
sizeof(res_allowed_package_x)));
- if (!allowed_package)
- return nullptr;
- allowed_package->allowed_package = STRDUP_IF_NOT_NULL("test_allowed_package");
+ allowed_package->allowed_package = strdup("test_allowed_package");
allowed_package->required_privileges = g_list_append(
allowed_package->required_privileges,
- STRDUP_IF_NOT_NULL("test_required_privilege1"));
+ strdup("test_required_privilege1"));
package->res_allowed_packages =
g_list_append(package->res_allowed_packages, allowed_package);
package->application = g_list_append(package->application,
GetTestApplication("test_app2"));
- return package_auto.release();
+ return package;
}
package_x* GetUpdatedTestPackage(std::string pkgid) {
auto package = GetTestPackage(pkgid);
free(package->version);
- package->version = STRDUP_IF_NOT_NULL("2.0.0");
+ package->version = strdup("2.0.0");
return package;
}
return true;
}
-package_x* PkgInfoHandleToPackageX(const pkgmgr_common::PkgInfoHandle& handle) {
- package_x* package =
- reinterpret_cast<package_x*>(calloc(1, sizeof(package_x)));
- if (!package)
- return nullptr;
- std::unique_ptr<package_x,
- decltype(pkgmgrinfo_basic_free_package)*> package_auto(
- package, pkgmgrinfo_basic_free_package);
-
- package->for_all_users = STRDUP_IF_NOT_NULL(handle.GetForAllUsers());
- package->package = STRDUP_IF_NOT_NULL(handle.GetPackage());
- package->version = STRDUP_IF_NOT_NULL(handle.GetVersion());
- package->installlocation = STRDUP_IF_NOT_NULL(handle.GetInstallLocation());
- package->ns = handle.GetNameSpace() ? STRDUP_IF_NOT_NULL(handle.GetNameSpace()) : nullptr;
- package->removable = STRDUP_IF_NOT_NULL(handle.GetRemovable());
- package->preload = STRDUP_IF_NOT_NULL(handle.GetPreload());
- package->readonly = STRDUP_IF_NOT_NULL(handle.GetReadonly());
- package->update = STRDUP_IF_NOT_NULL(handle.GetUpdate());
- package->appsetting = STRDUP_IF_NOT_NULL(handle.GetAppSetting());
- package->system = STRDUP_IF_NOT_NULL(handle.GetSystem());
- package->type = STRDUP_IF_NOT_NULL(handle.GetType());
- package->package_size = STRDUP_IF_NOT_NULL(handle.GetPackageSize());
- package->installed_time = STRDUP_IF_NOT_NULL(handle.GetInstalledTime());
- package->installed_storage = STRDUP_IF_NOT_NULL(handle.GetInstalledStorage());
- package->storeclient_id = STRDUP_IF_NOT_NULL(handle.GetStoreClientId());
- package->mainapp_id = STRDUP_IF_NOT_NULL(handle.GetMainAppId());
- package->package_url = STRDUP_IF_NOT_NULL(handle.GetPackageUrl());
- package->root_path = STRDUP_IF_NOT_NULL(handle.GetRootPath());
- package->csc_path = STRDUP_IF_NOT_NULL(handle.GetCscPath());
- package->nodisplay_setting = STRDUP_IF_NOT_NULL(handle.GetNoDisplaySetting());
- package->support_mode = STRDUP_IF_NOT_NULL(handle.GetSupportMode());
- package->support_disable = STRDUP_IF_NOT_NULL(handle.GetSupportDisable());
- package->api_version = STRDUP_IF_NOT_NULL(handle.GetApiVersion());
- package->tep_name = STRDUP_IF_NOT_NULL(handle.GetTepName());
- package->zip_mount_file = STRDUP_IF_NOT_NULL(handle.GetZipMountFile());
- package->backend_installer = STRDUP_IF_NOT_NULL(handle.GetBackendInstaller());
- package->external_path = STRDUP_IF_NOT_NULL(handle.GetExternalPath());
- package->use_system_certs = STRDUP_IF_NOT_NULL(handle.GetUseSystemCerts());
- package->res_type = STRDUP_IF_NOT_NULL(handle.GetResType());
- package->res_version = STRDUP_IF_NOT_NULL(handle.GetResVersion());
- package->lib = STRDUP_IF_NOT_NULL(handle.GetLib());
- package->light_user_switch_mode = STRDUP_IF_NOT_NULL(handle.GetLightUserSwitchMode());
-
- for (auto item : handle.GetIcon()) {
- icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
- if (!icon)
- return nullptr;
- icon->text = STRDUP_IF_NOT_NULL(item.Text());
- icon->lang = STRDUP_IF_NOT_NULL(item.Lang());
- icon->section = STRDUP_IF_NOT_NULL(item.Section());
- icon->size = STRDUP_IF_NOT_NULL(item.Size());
- icon->resolution = STRDUP_IF_NOT_NULL(item.Resolution());
- icon->dpi = STRDUP_IF_NOT_NULL(item.Dpi());
- package->icon = g_list_append(package->icon, icon);
- }
-
- for (auto item : handle.GetLabel()) {
- label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
- if (!label)
- return nullptr;
- label->lang = STRDUP_IF_NOT_NULL(item.Lang());
- label->name = STRDUP_IF_NOT_NULL(item.Name());
- label->text = STRDUP_IF_NOT_NULL(item.Text());
- package->label = g_list_append(package->label, label);
- }
-
- for (auto item : handle.GetAuthor()) {
- author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
- if (!author)
- return nullptr;
- author->email = STRDUP_IF_NOT_NULL(item.Email());
- author->href = STRDUP_IF_NOT_NULL(item.Href());
- author->text = STRDUP_IF_NOT_NULL(item.Text());
- author->lang = STRDUP_IF_NOT_NULL(item.Lang());
- package->author = g_list_append(package->author, author);
- }
-
- for (auto item : handle.GetDescription()) {
- description_x* description =
- reinterpret_cast<description_x*>(calloc(1, sizeof(description_x)));
- if (!description)
- return nullptr;
- description->name = STRDUP_IF_NOT_NULL(item.Name());
- description->text = STRDUP_IF_NOT_NULL(item.Text());
- description->lang = STRDUP_IF_NOT_NULL(item.Lang());
- package->description = g_list_append(package->description, description);
- }
-
- for (auto item : handle.GetPrivileges()) {
- privilege_x* privilege =
- reinterpret_cast<privilege_x*>(calloc(1, sizeof(privilege_x)));
- if (!privilege)
- return nullptr;
- privilege->type = STRDUP_IF_NOT_NULL(item.Type());
- privilege->value = STRDUP_IF_NOT_NULL(item.Value());
- package->privileges = g_list_append(package->privileges, privilege);
- }
-
- for (auto item : handle.GetAppdefinedPrivileges()) {
- appdefined_privilege_x* appdefined_privilege =
- reinterpret_cast<appdefined_privilege_x*>(
- calloc(1, sizeof(appdefined_privilege_x)));
- if (!appdefined_privilege)
- return nullptr;
- appdefined_privilege->type = STRDUP_IF_NOT_NULL(item.Type());
- appdefined_privilege->value = STRDUP_IF_NOT_NULL(item.Value());
- appdefined_privilege->license = STRDUP_IF_NOT_NULL(item.License());
- package->appdefined_privileges =
- g_list_append(package->appdefined_privileges, appdefined_privilege);
- }
-
- for (auto item : handle.GetProvidesAppDefinedPrivileges()) {
- appdefined_privilege_x* provides_appdefined_privileges =
- reinterpret_cast<appdefined_privilege_x*>(
- calloc(1, sizeof(appdefined_privilege_x)));
- if (!provides_appdefined_privileges)
- return nullptr;
- provides_appdefined_privileges->type = STRDUP_IF_NOT_NULL(item.Type());
- provides_appdefined_privileges->value = STRDUP_IF_NOT_NULL(item.Value());
- provides_appdefined_privileges->license = STRDUP_IF_NOT_NULL(item.License());
- package->provides_appdefined_privileges =
- g_list_append(package->provides_appdefined_privileges,
- provides_appdefined_privileges);
- }
-
- for (auto item : handle.GetDependencies()) {
- dependency_x* dependency =
- reinterpret_cast<dependency_x*>(
- calloc(1, sizeof(dependency_x)));
- if (!dependency)
- return nullptr;
- dependency->pkgid = STRDUP_IF_NOT_NULL(item.Pkgid());
- dependency->depends_on = STRDUP_IF_NOT_NULL(item.DependsOn());
- dependency->type = STRDUP_IF_NOT_NULL(item.Type());
- dependency->required_version = STRDUP_IF_NOT_NULL(item.RequiredVersion());
- package->dependencies = g_list_append(package->dependencies, dependency);
- }
-
- for (auto item : handle.GetPlugin()) {
- plugin_x* plugin = reinterpret_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
- if (!plugin)
- return nullptr;
- plugin->pkgid = STRDUP_IF_NOT_NULL(item.Pkgid());
- plugin->appid = STRDUP_IF_NOT_NULL(item.Appid());
- plugin->plugin_type = STRDUP_IF_NOT_NULL(item.PluginType());
- plugin->plugin_name = STRDUP_IF_NOT_NULL(item.PluginName());
- package->plugin = g_list_append(package->plugin, plugin);
- }
-
- for (auto item : handle.GetResAllowedPackages()) {
- res_allowed_package_x* allowed_package =
- reinterpret_cast<res_allowed_package_x*>(calloc(1,
- sizeof(res_allowed_package_x)));
- if (!allowed_package)
- return nullptr;
- allowed_package->allowed_package = STRDUP_IF_NOT_NULL(item.AllowedPackage());
- for (auto required_privilege : item.GetRequiredPrivileges())
- allowed_package->required_privileges = g_list_append(
- allowed_package->required_privileges,
- STRDUP_IF_NOT_NULL(required_privilege));
-
- package->res_allowed_packages =
- g_list_append(package->res_allowed_packages, allowed_package);
- }
-
- return package_auto.release();
-}
-
bool IsEqualPackagesInfo(
- const std::vector<pkgmgr_common::PkgInfoHandle>& packagesA,
+ const std::vector<std::shared_ptr<package_x>>& packagesA,
const std::vector<std::shared_ptr<package_x>>& packagesB) {
if (packagesA.size() != packagesB.size())
return false;
for (unsigned int i = 0; i < packagesA.size(); ++i) {
- std::unique_ptr<package_x, decltype(pkgmgrinfo_basic_free_package)*> ptr(
- PkgInfoHandleToPackageX(packagesA[i]), pkgmgrinfo_basic_free_package);
- if (!IsEqualPackage(ptr.get(), packagesB[i].get()))
+ if (!IsEqualPackage(packagesA[i].get(), packagesB[i].get()))
return false;
}
pkgmgrinfo_metadata_node_x* metadata_node;
filter = reinterpret_cast<pkgmgrinfo_filter_x*>(
calloc(1, sizeof(pkgmgrinfo_filter_x)));
- if (!filter)
- return nullptr;
- std::unique_ptr<pkgmgrinfo_filter_x,
- decltype(pkgmgrinfo_pkginfo_filter_destroy)*> filter_auto(
- filter, pkgmgrinfo_pkginfo_filter_destroy);
filter->uid = 1234;
node = reinterpret_cast<pkgmgrinfo_node_x*>(
calloc(1, sizeof(pkgmgrinfo_node_x)));
- if (!node)
- return nullptr;
node->prop = 4321;
- node->key = STRDUP_IF_NOT_NULL("test_key1");
- node->value = STRDUP_IF_NOT_NULL("test_value1");
+ node->key = strdup("test_key1");
+ node->value = strdup("test_value1");
filter->list = g_slist_append(filter->list, node);
node = reinterpret_cast<pkgmgrinfo_node_x*>(
calloc(1, sizeof(pkgmgrinfo_node_x)));
- if (!node)
- return nullptr;
node->prop = 4321;
- node->key = STRDUP_IF_NOT_NULL("test_key2");
- node->value = STRDUP_IF_NOT_NULL("test_value2");
+ node->key = strdup("test_key2");
+ node->value = strdup("test_value2");
filter->list = g_slist_append(filter->list, node);
metadata_node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(
calloc(1, sizeof(pkgmgrinfo_metadata_node_x)));
- if (!metadata_node)
- return nullptr;
- metadata_node->key = STRDUP_IF_NOT_NULL("test_metadata_key1");
- metadata_node->value = STRDUP_IF_NOT_NULL("test_metadata_value1");
+ metadata_node->key = strdup("test_metadata_key1");
+ metadata_node->value = strdup("test_metadata_value1");
filter->list_metadata = g_slist_append(filter->list_metadata, metadata_node);
metadata_node = reinterpret_cast<pkgmgrinfo_metadata_node_x*>(
calloc(1, sizeof(pkgmgrinfo_metadata_node_x)));
- if (!metadata_node)
- return nullptr;
- metadata_node->key = STRDUP_IF_NOT_NULL("test_metadata_key2");
- metadata_node->value = STRDUP_IF_NOT_NULL("test_metadata_value2");
+ metadata_node->key = strdup("test_metadata_key2");
+ metadata_node->value = strdup("test_metadata_value2");
filter->list_metadata = g_slist_append(filter->list_metadata, metadata_node);
- return filter_auto.release();
+ return filter;
}
bool IsEqualFilter(const pkgmgrinfo_filter_x* filterA,
pkgmgr_certinfo_x* cert_info;
cert_info = reinterpret_cast<pkgmgr_certinfo_x*>(
calloc(1, sizeof(pkgmgr_certinfo_x)));
- if (!cert_info)
- return nullptr;
- std::unique_ptr<pkgmgr_certinfo_x,
- decltype(pkgmgrinfo_pkginfo_destroy_certinfo)*> cert_info_auto(
- cert_info, pkgmgrinfo_pkginfo_destroy_certinfo);
cert_info->for_all_users = 1;
- cert_info->pkgid = STRDUP_IF_NOT_NULL("test_pkgid");
- cert_info->cert_value = STRDUP_IF_NOT_NULL("test_cert_value");
+ cert_info->pkgid = strdup("test_pkgid");
+ cert_info->cert_value = strdup("test_cert_value");
for (int i = 0; i < MAX_CERT_TYPE; ++i) {
char buf[1024] = { 0, };
snprintf(buf, sizeof(buf), "test_cert_info_%d", i);
- cert_info->cert_info[i] = STRDUP_IF_NOT_NULL(buf);
+ cert_info->cert_info[i] = strdup(buf);
}
for (int i = 0; i < MAX_CERT_TYPE; ++i) {
cert_info->cert_id[i] = i + 1000;
}
- return cert_info_auto.release();
+ return cert_info;
}
bool IsEqualCertInfoStructure(const pkgmgr_certinfo_x* certA,
dependency_x* dependency;
dependency = reinterpret_cast<dependency_x*>(
calloc(1, sizeof(dependency_x)));
- if (!dependency)
- return nullptr;
- dependency->pkgid = STRDUP_IF_NOT_NULL(pkgid.c_str());
- dependency->depends_on = STRDUP_IF_NOT_NULL("depends_on_pkgid");
- dependency->required_version = STRDUP_IF_NOT_NULL("test_required_version");
- dependency->type = STRDUP_IF_NOT_NULL("test_type");
+ dependency->pkgid = strdup(pkgid.c_str());
+ dependency->depends_on = strdup("depends_on_pkgid");
+ dependency->required_version = strdup("test_required_version");
+ dependency->type = strdup("test_type");
return dependency;
}
pkgmgr_certinfo_x* GetTestCertificate() {
pkgmgr_certinfo_x* cert_info = reinterpret_cast<pkgmgr_certinfo_x*>(
calloc(1, sizeof(pkgmgr_certinfo_x)));
- if (!cert_info)
- return nullptr;
cert_info->for_all_users = 1;
- cert_info->pkgid = STRDUP_IF_NOT_NULL("test_pkgid");
- cert_info->cert_value = STRDUP_IF_NOT_NULL("test_certvalue");
+ cert_info->pkgid = strdup("test_pkgid");
+ cert_info->cert_value = strdup("test_certvalue");
for (int i = 0; i < MAX_CERT_TYPE; i++) {
std::string cert_value(std::to_string(i));
cert_value += "test_cert_value";
- cert_info->cert_info[i] = STRDUP_IF_NOT_NULL(cert_value.c_str());
+ cert_info->cert_info[i] = strdup(cert_value.c_str());
cert_info->cert_id[i] = i + 1;
}
#include "pkgmgrinfo_basic.h"
#include "pkgmgrinfo_private.h"
-#include "pkgmgr_info_handle.hh"
-
application_x *GetTestApplication(std::string appid);
bool IsEqualApplicationsStructure(const std::vector<std::shared_ptr<application_x>>& applicationsA,
const std::vector<std::shared_ptr<application_x>>& applicationsB);
-bool IsEqualApplicationsInfo(const std::vector<pkgmgr_common::AppInfoHandle>& applicationsA,
+bool IsEqualApplicationsInfo(const std::vector<std::shared_ptr<application_x>>& applicationsA,
const std::vector<std::shared_ptr<application_x>>& applicationsB);
package_x *GetTestPackage(std::string pkgid);
bool IsEqualPackagesStructure(const std::vector<std::shared_ptr<package_x>>& packagesA,
const std::vector<std::shared_ptr<package_x>>&packagesB);
-bool IsEqualPackagesInfo(const std::vector<pkgmgr_common::PkgInfoHandle>& packagesA,
+bool IsEqualPackagesInfo(const std::vector<std::shared_ptr<package_x>>& packagesA,
const std::vector<std::shared_ptr<package_x>>& packagesB);
pkgmgrinfo_filter_x *GetTestFilter();
tizen_base::Parcel parcel;
std::vector<std::shared_ptr<application_x>> origin_applications;
- origin_applications.emplace_back(GetTestApplication("test_appid1"), pkgmgrinfo_basic_free_application);
- origin_applications.emplace_back(GetTestApplication("test_appid2"), pkgmgrinfo_basic_free_application);
+ origin_applications.emplace_back(GetTestApplication("test_appid1"), std::free);
+ origin_applications.emplace_back(GetTestApplication("test_appid2"), std::free);
pp::AppInfoParcelable origin_parcelable(0, std::move(origin_applications));
pp::AppInfoParcelable new_parcelable;
parcel.WriteParcelable(origin_parcelable);
tizen_base::Parcel parcel;
std::vector<std::shared_ptr<package_x>> origin_packages;
- origin_packages.emplace_back(GetTestPackage("test_pkgid1"), pkgmgrinfo_basic_free_package);
- origin_packages.emplace_back(GetTestPackage("test_pkgid2"), pkgmgrinfo_basic_free_package);
+ origin_packages.emplace_back(GetTestPackage("test_pkgid1"), std::free);
+ origin_packages.emplace_back(GetTestPackage("test_pkgid2"), std::free);
pp::PkgInfoParcelable origin_parcelable(0, std::move(origin_packages));
pp::PkgInfoParcelable new_parcelable;
parcel.WriteParcelable(origin_parcelable);
auto test_appinfo = GetTestApplication(appid);
std::vector<std::shared_ptr<application_x>> rappinfo_list;
- rappinfo_list.emplace_back(test_appinfo, pkgmgrinfo_basic_free_application);
+ rappinfo_list.emplace_back(test_appinfo, std::free);
ASSERT_EQ(IsEqualApplicationsInfo(lappinfo_list, rappinfo_list), true);
}
# Recovery tool for pkg db corruption
# By Junghyun Yeon <jungh.yeon@samsung.com>
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
### Get required CFLAGS, LDFLAGS from pkg-config