2 * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "multi_target_resolver.h"
20 #include "ni_common.h"
21 #include "profile_common.h"
22 #include "launcher_env.h"
25 #include <app-runtime.h>
30 #define LOG_TAG "DOTNET_INSTALLER_PLUGIN"
32 typedef struct _xmlDoc xmlDoc;
33 typedef xmlDoc* xmlDocPtr;
35 bool pluginInstalled = false;
36 static const char* INTERNET_PRIVILEGE = "http://tizen.org/privilege/internet";
37 static int UID_OWNER = 5001;
39 static void checkPrivilegeAndDisableIPv6(const char* pkgId, const std::string& rootPath)
42 if (security_manager_app_has_privilege(pkgId, INTERNET_PRIVILEGE, UID_OWNER, &res) == SECURITY_MANAGER_SUCCESS) {
44 std::string filePath = rootPath + "/bin/" + DISABLE_IPV6_FILE;
45 std::ofstream output(filePath);
46 if (exist(filePath)) {
47 _INFO("File to disable IPv6 is created successfully");
49 _ERR("Failed to create file to disable IPv6 [%s]", pkgId);
56 extern "C" int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr doc, const char* pkgId)
58 // Can be multiple apps in one package
59 if (pluginInstalled) {
60 _INFO("Plugin already installed");
63 pluginInstalled = true;
65 std::string appType = getAppType(pkgId);
66 if (appType.empty()) {
67 _ERR("Failed to get app type from [%s]", pkgId);
71 if (appType.find("dotnet") == std::string::npos) {
75 std::string rootPath = getRootPath(pkgId);
76 if (rootPath.empty()) {
77 _ERR("Failed to get root path from [%s]", pkgId);
81 if (removeAppProfileData(pkgId) != PROFILE_ERROR_NONE) {
82 _ERR("Failed to remove [%s] profile data", pkgId);
85 if (resolvePlatformSpecificFiles(rootPath) != 0) {
86 _ERR("Failed to resolve platform specific resources of nuget");
89 checkPrivilegeAndDisableIPv6(pkgId, rootPath);
93 extern "C" int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr doc, const char* pkgId)
95 return PKGMGR_PARSER_PLUGIN_INSTALL(doc, pkgId);
97 extern "C" int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr doc, const char* pkgId)
101 extern "C" int PKGMGR_PARSER_PLUGIN_REMOVED(xmlDocPtr doc, const char* pkgId)
105 extern "C" int PKGMGR_PARSER_PLUGIN_CLEAN(xmlDocPtr doc, const char* pkgId)
109 extern "C" int PKGMGR_PARSER_PLUGIN_UNDO(xmlDocPtr doc, const char* pkgId)
113 extern "C" int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *pkgId)
117 extern "C" int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *pkgId)
121 extern "C" int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *pkgId)
125 extern "C" int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *pkgId)
129 extern "C" int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *pkgId)
133 extern "C" int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *pkgId)