Bug-fix: fix target dll searching logic
[platform/core/dotnet/launcher.git] / NativeLauncher / installer-plugin / dotnet_apptype_plugin.cc
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "log.h"
18 #include "utils.h"
19 #include "multi_target_resolver.h"
20 #include "ni_common.h"
21 #include "profile_common.h"
22 #include "privilege_common.h"
23 #include "launcher_env.h"
24
25 #ifdef  LOG_TAG
26 #undef  LOG_TAG
27 #endif
28 #define LOG_TAG "DOTNET_INSTALLER_PLUGIN"
29
30 typedef struct _xmlDoc xmlDoc;
31 typedef xmlDoc* xmlDocPtr;
32
33 static std::string prevInstallPkgId = std::string("");
34
35 extern "C" int PKGMGR_PARSER_PLUGIN_INSTALL(xmlDocPtr doc, const char* pkgId)
36 {
37         if (pkgId == NULL) {
38                 return 0;
39         }
40
41         // Can be multiple apps in one package
42         if (strcmp(pkgId, prevInstallPkgId.c_str()) == 0) {
43                 _INFO("AppType Plugin already run for same pkgId (%s)", pkgId);
44                 return 0;
45         }
46         prevInstallPkgId = pkgId;
47
48         std::string appType = getAppType(pkgId);
49         if (appType.empty()) {
50                 _ERR("Failed to get app type from [%s]", pkgId);
51                 return 0;
52         }
53
54         if (appType.find("dotnet") == std::string::npos) {
55                 return 0;
56         }
57
58         std::string rootPath = getRootPath(pkgId);
59         if (rootPath.empty()) {
60                 _ERR("Failed to get root path from [%s]", pkgId);
61                 return 0;
62         }
63
64         if (removeAppProfileData(pkgId) != PROFILE_ERROR_NONE) {
65                 _ERR("Failed to remove [%s] profile data", pkgId);
66         }
67
68         if (resolvePlatformSpecificFiles(rootPath) != 0) {
69                 _ERR("Failed to resolve platform specific resources of nuget");
70         }
71
72         checkInternetPrivilegeAndDisableIPv6(pkgId, rootPath);
73
74         return 0;
75 }
76 extern "C" int PKGMGR_PARSER_PLUGIN_UPGRADE(xmlDocPtr doc, const char* pkgId)
77 {
78         return PKGMGR_PARSER_PLUGIN_INSTALL(doc, pkgId);
79 }
80 extern "C" int PKGMGR_PARSER_PLUGIN_UNINSTALL(xmlDocPtr doc, const char* pkgId)
81 {
82         return 0;
83 }
84 extern "C" int PKGMGR_PARSER_PLUGIN_REMOVED(xmlDocPtr doc, const char* pkgId)
85 {
86         return 0;
87 }
88 extern "C" int PKGMGR_PARSER_PLUGIN_CLEAN(xmlDocPtr doc, const char* pkgId)
89 {
90         return 0;
91 }
92 extern "C" int PKGMGR_PARSER_PLUGIN_UNDO(xmlDocPtr doc, const char* pkgId)
93 {
94         return 0;
95 }
96 extern "C" int PKGMGR_PARSER_PLUGIN_PRE_INSTALL(const char *pkgId)
97 {
98         return 0;
99 }
100 extern "C" int PKGMGR_PARSER_PLUGIN_PRE_UPGRADE(const char *pkgId)
101 {
102         return 0;
103 }
104 extern "C" int PKGMGR_PARSER_PLUGIN_PRE_UNINSTALL(const char *pkgId)
105 {
106         return 0;
107 }
108 extern "C" int PKGMGR_PARSER_PLUGIN_POST_INSTALL(const char *pkgId)
109 {
110         return 0;
111 }
112 extern "C" int PKGMGR_PARSER_PLUGIN_POST_UPGRADE(const char *pkgId)
113 {
114         return 0;
115 }
116 extern "C" int PKGMGR_PARSER_PLUGIN_POST_UNINSTALL(const char *pkgId)
117 {
118         return 0;
119 }