Code style refactorting
[platform/core/dotnet/launcher.git] / NativeLauncher / installer-plugin / prefer_dotnet_aot_plugin.cc
1 /*
2  * Copyright (c) 2016 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 "common.h"
18 #include "log.h"
19 #include "utils.h"
20
21 #ifdef  LOG_TAG
22 #undef  LOG_TAG
23 #endif
24 #define LOG_TAG "NETCORE_INSTALLER_PLUGIN"
25
26 #include <cstring>
27 #include <vector>
28 #include <sstream>
29 #include <glib.h>
30
31 typedef struct Metadata {
32     const char *key;
33     const char *value;
34 } Metadata;
35
36 const std::string VALUE_TRUE = "true";
37 const std::string mdKey = "http://tizen.org/metadata/prefer_dotnet_aot";
38 extern "C" int PKGMGR_MDPARSER_PLUGIN_INSTALL (const char *pkgid, const char *appid, GList *list)
39 {
40   GList *tag = NULL;
41   bool mdValue = false;
42   Metadata *mdInfo = NULL;
43   tag = g_list_first(list);
44   while (tag)
45   {
46     mdInfo = (Metadata*)tag->data;
47     if(mdInfo->key == mdKey && mdInfo->value == VALUE_TRUE)
48     {
49       _DBG("Prefer dotnet application AOT set TRUE");
50       mdValue = true;
51     }
52     tag = g_list_next(tag);
53   }
54
55   if (mdValue)
56   {
57     if (create_ni_under_pkg_root(pkgid) != 0)
58     {
59       _ERR("Failed to get root path from [%s]", pkgid);
60       return -1;
61     }
62     else
63     {
64       _DBG("Complete make application to native image");
65     }
66   }
67   return 0;
68 }
69
70 extern "C" int PKGMGR_MDPARSER_PLUGIN_UPGRADE (const char *pkgid, const char *appid, GList *list)
71 {
72     return PKGMGR_MDPARSER_PLUGIN_INSTALL(pkgid, appid, list);
73 }