LCOV - code coverage report
Current view: top level - mlops-agent-1.8.8/plugin-parser - mlops-plugin-parser.cc (source / functions) Coverage Total Hit
Test: ML-Agent 1.8.8-0 platform/core/ml/mlops-agent#7b658b7dd8532af4825478883945a4c388cff1b4 Lines: 0.0 % 307 0
Test Date: 2026-05-07 08:04:31 Functions: 0.0 % 13 0

            Line data    Source code
       1              : /* SPDX-License-Identifier: Apache-2.0 */
       2              : /**
       3              :  * Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved.
       4              :  *
       5              :  * @file    mlops-plugin-parser.cc
       6              :  * @date    21 Mar 2024
       7              :  * @brief   This file contains the implementation of a plugin parser for Tizen RPK packages.
       8              :  * The plugin parser is responsible for parsing JSON files in RPK and updating the database using daemon.
       9              :  * @see     https://github.com/nnstreamer/deviceMLOps.MLAgent
      10              :  * @author  Yongjoo Ahn <yongjoo1.ahn@samsung.com>
      11              :  * @bug     No known bugs except for NYI items
      12              :  * @todo    Add more unit tests using mocks.
      13              :  * @todo    Support UNINSTALL and UPGRADE.
      14              :  * @todo    Support allowed resource other than global resource.
      15              :  */
      16              : 
      17              : #include <dlog.h>
      18              : #include <glib.h>
      19              : #include <json-glib/json-glib.h>
      20              : #include <mlops-agent-interface.h>
      21              : #include <pkgmgr-info.h>
      22              : 
      23              : #define __TAG_ "ml-agent-plugin-parser"
      24              : #define LOG_V(prio, tag, fmt, arg...)                                                     \
      25              :   ({                                                                                      \
      26              :     do {                                                                                  \
      27              :       dlog_print (prio, tag, "%s: %s(%d) > " fmt, __MODULE__, __func__, __LINE__, ##arg); \
      28              :     } while (0);                                                                          \
      29              :   })
      30              : 
      31              : #define _D(fmt, arg...) LOG_V (DLOG_DEBUG, __TAG_, fmt, ##arg)
      32              : #define _I(fmt, arg...) LOG_V (DLOG_INFO, __TAG_, fmt, ##arg)
      33              : #define _W(fmt, arg...) LOG_V (DLOG_WARN, __TAG_, fmt, ##arg)
      34              : #define _E(fmt, arg...) LOG_V (DLOG_ERROR, __TAG_, fmt, ##arg)
      35              : #define _F(fmt, arg...) LOG_V (DLOG_FATAL, __TAG_, fmt, ##arg)
      36              : #define STR_IS_VALID(s) ((s) && (s)[0] != '\0')
      37              : 
      38              : /**
      39              :  * @brief Struct used to parse metadata tag from xml file.
      40              :  */
      41              : typedef struct _metadata_s {
      42              :   const char *key;
      43              :   const char *value;
      44              : } _metadata_s;
      45              : 
      46              : /**
      47              :  * @brief Make pkg-info json string.
      48              :  */
      49              : static gchar *
      50            0 : _make_pkg_info (const gchar *pkgid, const gchar *appid, const gchar *res_type,
      51              :     const gchar *res_version)
      52              : {
      53            0 :   g_autoptr (JsonBuilder) builder = json_builder_new ();
      54            0 :   json_builder_begin_object (builder);
      55              : 
      56            0 :   json_builder_set_member_name (builder, "is_rpk");
      57            0 :   json_builder_add_string_value (builder, "T");
      58              : 
      59            0 :   json_builder_set_member_name (builder, "pkg_id");
      60            0 :   json_builder_add_string_value (builder, pkgid);
      61              : 
      62            0 :   json_builder_set_member_name (builder, "app_id");
      63            0 :   json_builder_add_string_value (builder, appid ? appid : "");
      64              : 
      65            0 :   json_builder_set_member_name (builder, "res_type");
      66            0 :   json_builder_add_string_value (builder, res_type);
      67              : 
      68            0 :   json_builder_set_member_name (builder, "res_version");
      69            0 :   json_builder_add_string_value (builder, res_version);
      70              : 
      71            0 :   json_builder_end_object (builder);
      72              : 
      73            0 :   g_autoptr (JsonNode) root = json_builder_get_root (builder);
      74            0 :   g_autoptr (JsonGenerator) gen = json_generator_new ();
      75            0 :   json_generator_set_root (gen, root);
      76            0 :   json_generator_set_pretty (gen, TRUE);
      77              : 
      78            0 :   return json_generator_to_data (gen, NULL);
      79            0 : }
      80              : 
      81              : /**
      82              :  * @brief Internal enumeration for data types of json.
      83              :  */
      84              : typedef enum {
      85              :   MLSVC_JSON_MODEL = 0,
      86              :   MLSVC_JSON_PIPELINE = 1,
      87              :   MLSVC_JSON_RESOURCE = 2,
      88              :   MLSVC_JSON_MAX
      89              : } mlsvc_json_type_e;
      90              : 
      91              : /**
      92              :  * @brief Internal enumeration for package manager event types.
      93              :  */
      94              : typedef enum {
      95              :   MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_INSTALL = 0,
      96              :   MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_UNINSTALL = 1,
      97              :   MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_UPGRADE = 2,
      98              :   MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_MAX
      99              : } mlsvc_package_manager_event_type_e;
     100              : 
     101              : /**
     102              :  * @brief Internal function for uninstall models and pipelines.
     103              :  */
     104              : static void
     105            0 : _uninstall_rpk (const gchar *name, const gchar *_info, mlsvc_json_type_e json_type)
     106              : {
     107            0 :   g_autoptr (JsonParser) parser = json_parser_new ();
     108            0 :   g_autoptr (GError) err = NULL;
     109              :   JsonNode *root;
     110              :   JsonObject *object;
     111            0 :   JsonArray *array = NULL;
     112            0 :   guint _info_len = 1U;
     113              : 
     114            0 :   if (!json_parser_load_from_data (parser, _info, -1, &err)) {
     115            0 :     _E ("Failed to load '%s' info data (%s).", name, err ? err->message : "Unknown error");
     116            0 :     return;
     117              :   }
     118              : 
     119            0 :   root = json_parser_get_root (parser);
     120            0 :   if (!root) {
     121            0 :     _E ("Failed to load '%s' info, cannot get the top node from info.", name);
     122            0 :     return;
     123              :   }
     124              : 
     125            0 :   if (JSON_NODE_HOLDS_ARRAY (root)) {
     126            0 :     array = json_node_get_array (root);
     127            0 :     if (!array) {
     128            0 :       _E ("Failed to get root array from '%s' info", name);
     129            0 :       return;
     130              :     }
     131              : 
     132            0 :     _info_len = json_array_get_length (array);
     133              :   }
     134              : 
     135              :   /* Update ML service database. */
     136            0 :   for (guint i = 0; i < _info_len; ++i) {
     137            0 :     int ret = 0;
     138              : 
     139            0 :     if (array)
     140            0 :       object = json_array_get_object_element (array, i);
     141              :     else
     142            0 :       object = json_node_get_object (root);
     143              : 
     144            0 :     const gchar *app_info = json_object_get_string_member (object, "app_info");
     145              : 
     146              :     /* If app info is empty string, it is not installed from rpk. */
     147            0 :     if (!STR_IS_VALID (app_info))
     148            0 :       continue;
     149              : 
     150            0 :     g_autoptr (JsonParser) app_info_parser = json_parser_new ();
     151              : 
     152            0 :     if (!json_parser_load_from_data (app_info_parser, app_info, -1, &err)) {
     153            0 :       _E ("Failed to load '%s' app_info data.", name);
     154            0 :       return;
     155              :     }
     156              : 
     157            0 :     JsonNode *app_info_root = json_parser_get_root (app_info_parser);
     158            0 :     if (!app_info_root) {
     159            0 :       _E ("Failed to load '%s'app_info, cannot get the top node from app_info.", name);
     160            0 :       return;
     161              :     }
     162              : 
     163            0 :     JsonObject *app_info_object = json_node_get_object (app_info_root);
     164            0 :     const gchar *is_rpk = json_object_get_string_member (app_info_object, "is_rpk");
     165              : 
     166            0 :     if (!is_rpk) {
     167            0 :       _E ("Failed to get 'is_rpk' from '%s' app_info.", name);
     168            0 :       return;
     169              :     }
     170            0 :     if (g_ascii_strcasecmp (is_rpk, "F") == 0)
     171            0 :       continue;
     172              : 
     173            0 :     switch (json_type) {
     174            0 :       case MLSVC_JSON_MODEL:
     175              :         {
     176            0 :           const gchar *version = json_object_get_string_member (object, "version");
     177              : 
     178            0 :           ret = ml_agent_model_delete (
     179            0 :               name, (const uint32_t) g_ascii_strtoull (version, NULL, 10), TRUE);
     180              : 
     181            0 :           if (ret == 0) {
     182            0 :             _I ("The model is deleted. - name: %s, version %s", name, version);
     183              :           } else {
     184            0 :             _E ("Failed to delete model return %d. - name: %s, version: %s",
     185              :                 ret, name, version);
     186              :           }
     187              :         }
     188            0 :         break;
     189            0 :       case MLSVC_JSON_RESOURCE:
     190              :         {
     191              :           /** @todo Support delete resource installed by rpk */
     192              :         }
     193            0 :         break;
     194            0 :       default:
     195            0 :         _E ("Unknown json type '%d', internal error?", json_type);
     196            0 :         return;
     197              :     }
     198              :   }
     199              : 
     200            0 :   _I ("All deleted. - name: %s", name);
     201            0 :   return;
     202            0 : }
     203              : 
     204              : /**
     205              :  * @brief Parse json and update ml-service database via invoking daemon.
     206              :  */
     207              : static gboolean
     208            0 : _parse_json (JsonNode *node, const gchar *app_info, mlsvc_json_type_e json_type,
     209              :     mlsvc_package_manager_event_type_e event)
     210              : {
     211            0 :   JsonArray *array = NULL;
     212            0 :   JsonObject *object = NULL;
     213            0 :   guint json_len = 1U;
     214              :   gint ret;
     215              : 
     216            0 :   if (JSON_NODE_HOLDS_ARRAY (node)) {
     217            0 :     array = json_node_get_array (node);
     218            0 :     if (!array) {
     219            0 :       _E ("Failed to get array from json");
     220            0 :       return FALSE;
     221              :     }
     222              : 
     223            0 :     json_len = json_array_get_length (array);
     224              :   }
     225              : 
     226              :   /* Update ML service database. */
     227            0 :   for (guint i = 0; i < json_len; ++i) {
     228            0 :     if (array)
     229            0 :       object = json_array_get_object_element (array, i);
     230              :     else
     231            0 :       object = json_node_get_object (node);
     232              : 
     233            0 :     switch (json_type) {
     234            0 :       case MLSVC_JSON_MODEL:
     235              :         {
     236            0 :           const gchar *name = json_object_get_string_member (object, "name");
     237            0 :           const gchar *model = json_object_get_string_member (object, "model");
     238            0 :           const gchar *desc = json_object_get_string_member (object, "description");
     239            0 :           const gchar *activate = json_object_get_string_member (object, "activate");
     240              : 
     241            0 :           if (!name || !model) {
     242            0 :             _E ("Failed to get name or model from MLSVC_JSON_MODEL.");
     243            0 :             return FALSE;
     244              :           }
     245              : 
     246            0 :           if (event == MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_INSTALL) {
     247              :             guint version;
     248            0 :             bool active = (activate && g_ascii_strcasecmp (activate, "true") == 0);
     249              : 
     250            0 :             ret = ml_agent_model_register (name, model, active,
     251              :                 desc ? desc : "", app_info ? app_info : "", &version);
     252              : 
     253            0 :             if (ret == 0) {
     254            0 :               _I ("The model with name '%s' is registered as version '%u'.", name, version);
     255              :             } else {
     256            0 :               _E ("Failed to register the model with name '%s'.", name);
     257            0 :               return FALSE;
     258              :             }
     259            0 :           } else if (event == MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_UNINSTALL) {
     260            0 :             g_autofree gchar *model_info = NULL;
     261              : 
     262            0 :             ret = ml_agent_model_get_all (name, &model_info);
     263              : 
     264            0 :             if (ret == 0) {
     265            0 :               _uninstall_rpk (name, model_info, json_type);
     266              :             } else {
     267            0 :               _I ("The model with name '%s' is already deleted or not installed.", name);
     268              :             }
     269            0 :           } else {
     270            0 :             _E ("Unknown event type '%d', internal error?", event);
     271            0 :             return FALSE;
     272              :           }
     273              :         }
     274            0 :         break;
     275            0 :       case MLSVC_JSON_PIPELINE:
     276              :         {
     277            0 :           const gchar *name = json_object_get_string_member (object, "name");
     278            0 :           const gchar *pipe = json_object_get_string_member (object, "pipeline");
     279              : 
     280            0 :           if (!name || !pipe) {
     281            0 :             _E ("Failed to get name or pipeline from MLSVC_JSON_PIPELINE.");
     282            0 :             return FALSE;
     283              :           }
     284              : 
     285            0 :           if (event == MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_INSTALL) {
     286            0 :             ret = ml_agent_pipeline_set_description (name, pipe);
     287              : 
     288            0 :             if (ret == 0) {
     289            0 :               _I ("The pipeline description with name '%s' is registered.", name);
     290              :             } else {
     291            0 :               _E ("Failed to register pipeline with name '%s'.", name);
     292            0 :               return FALSE;
     293              :             }
     294            0 :           } else if (event == MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_UNINSTALL) {
     295            0 :             ret = ml_agent_pipeline_delete (name);
     296              : 
     297            0 :             if (ret == 0) {
     298            0 :               _I ("The pipeline description with name '%s' is deleted.", name);
     299              :             } else {
     300            0 :               _E ("Failed to delete pipeline with name '%s'.", name);
     301            0 :               return FALSE;
     302              :             }
     303              :           } else {
     304            0 :             _E ("Unknown event type '%d', internal error?", event);
     305            0 :             return FALSE;
     306              :           }
     307              :         }
     308            0 :         break;
     309            0 :       case MLSVC_JSON_RESOURCE:
     310              :         {
     311            0 :           const gchar *name = json_object_get_string_member (object, "name");
     312            0 :           const gchar *desc = json_object_get_string_member (object, "description");
     313            0 :           JsonNode *path_node = json_object_get_member (object, "path");
     314            0 :           JsonArray *path_array = NULL;
     315              :           guint path_len;
     316              : 
     317            0 :           if (!name) {
     318            0 :             _E ("Failed to get name from MLSVC_JSON_RESOURCE.");
     319            0 :             return FALSE;
     320              :           }
     321              : 
     322            0 :           path_len = 1U;
     323            0 :           if (JSON_NODE_HOLDS_ARRAY (path_node)) {
     324            0 :             path_array = json_node_get_array (path_node);
     325            0 :             path_len = (path_array) ? json_array_get_length (path_array) : 0U;
     326              :           }
     327              : 
     328            0 :           if (path_len == 0U) {
     329            0 :             _E ("Failed to get path from MLSVC_JSON_RESOURCE.");
     330            0 :             return FALSE;
     331              :           }
     332              : 
     333            0 :           if (event == MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_INSTALL) {
     334            0 :             for (guint pidx = 0; pidx < path_len; pidx++) {
     335            0 :               const gchar *path = NULL;
     336              : 
     337            0 :               if (path_array)
     338            0 :                 path = json_array_get_string_element (path_array, pidx);
     339              :               else
     340            0 :                 path = json_node_get_string (path_node);
     341              : 
     342            0 :               if (!path) {
     343            0 :                 _E ("Failed to get path at '%d'th of '%s' from MLSVC_JSON_RESOURCE.",
     344              :                     pidx, name);
     345            0 :                 return FALSE;
     346              :               }
     347              : 
     348            0 :               ret = ml_agent_resource_add (
     349              :                   name, path, desc ? desc : "", app_info ? app_info : "");
     350              : 
     351            0 :               if (ret == 0) {
     352            0 :                 _I ("The resource at '%d'th of name '%s' is registered.", pidx, name);
     353              :               } else {
     354            0 :                 _E ("Failed to register the resource with name '%s'.", name);
     355            0 :                 return FALSE;
     356              :               }
     357              :             }
     358            0 :           } else if (event == MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_UNINSTALL) {
     359            0 :             ret = ml_agent_resource_delete (name);
     360              : 
     361            0 :             if (ret == 0) {
     362            0 :               _I ("The resource is deleted. - name: %s", name);
     363              :             } else {
     364            0 :               _I ("The model with name '%s' is already deleted or not installed", name);
     365              :             }
     366              :           } else {
     367            0 :             _E ("Unknown event type '%d', internal error?", event);
     368            0 :             return FALSE;
     369              :           }
     370              :         }
     371            0 :         break;
     372            0 :       default:
     373            0 :         _E ("Unknown data type '%d', internal error?", json_type);
     374            0 :         return FALSE;
     375              :     }
     376              :   }
     377            0 :   return TRUE;
     378              : }
     379              : 
     380              : /**
     381              :  * @brief Internal function to get json configuration file.
     382              :  */
     383              : static gboolean
     384            0 : _get_json_config (const gchar *json_path, const gchar *app_info,
     385              :     mlsvc_package_manager_event_type_e event)
     386              : {
     387            0 :   g_autofree gchar *json_string = NULL;
     388            0 :   g_autoptr (JsonParser) parser = NULL;
     389            0 :   g_autoptr (GError) err = NULL;
     390            0 :   g_autoptr (GList) members = NULL;
     391              :   GList *iter;
     392              :   JsonNode *root;
     393              :   JsonObject *object;
     394              : 
     395            0 :   if (!g_file_test (json_path, (GFileTest) (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR))) {
     396            0 :     _E ("The parameter, json_path, is invalid. It should be a valid string.");
     397            0 :     return FALSE;
     398              :   }
     399              : 
     400            0 :   if (!g_file_get_contents (json_path, &json_string, NULL, NULL)) {
     401            0 :     _E ("Failed to read configuration file '%s'.", json_path);
     402            0 :     return FALSE;
     403              :   }
     404              : 
     405            0 :   parser = json_parser_new ();
     406            0 :   if (!parser) {
     407            0 :     _E ("Failed to parse configuration file, cannot allocate memory for JsonParser. Out of memory?");
     408            0 :     return FALSE;
     409              :   }
     410              : 
     411            0 :   if (!json_parser_load_from_data (parser, json_string, -1, &err)) {
     412            0 :     _E ("Failed to parse configuration file, cannot load json string (%s).",
     413              :         err ? err->message : "Unknown error");
     414            0 :     return FALSE;
     415              :   }
     416              : 
     417            0 :   root = json_parser_get_root (parser);
     418            0 :   if (!root) {
     419            0 :     _E ("Failed to parse configuration file, cannot get the top node from json string.");
     420            0 :     return FALSE;
     421              :   }
     422              : 
     423            0 :   object = json_node_get_object (root);
     424            0 :   members = json_object_get_members (object);
     425              : 
     426            0 :   for (iter = members; iter != NULL; iter = iter->next) {
     427            0 :     const gchar *name = (const gchar *) iter->data;
     428            0 :     JsonNode *node = json_object_get_member (object, name);
     429              :     mlsvc_json_type_e json_type;
     430              : 
     431            0 :     if (g_ascii_strcasecmp (name, "model") == 0 || g_ascii_strcasecmp (name, "models") == 0) {
     432            0 :       json_type = MLSVC_JSON_MODEL;
     433            0 :     } else if (g_ascii_strcasecmp (name, "pipeline") == 0
     434            0 :                || g_ascii_strcasecmp (name, "pipelines") == 0) {
     435            0 :       json_type = MLSVC_JSON_PIPELINE;
     436            0 :     } else if (g_ascii_strcasecmp (name, "resource") == 0
     437            0 :                || g_ascii_strcasecmp (name, "resources") == 0) {
     438            0 :       json_type = MLSVC_JSON_RESOURCE;
     439              :     } else {
     440            0 :       _E ("Failed to parse '%s' from configuration file, unsupported type.", name);
     441            0 :       return FALSE;
     442              :     }
     443              : 
     444            0 :     if (!_parse_json (node, app_info, json_type, event)) {
     445            0 :       _E ("Failed to parse '%s' from configuration file.", name);
     446            0 :       return FALSE;
     447              :     }
     448              :   }
     449              : 
     450            0 :   return TRUE;
     451            0 : }
     452              : 
     453              : /**
     454              :  * @brief Internal function to set pkg-mgr parser
     455              :  */
     456              : static int
     457            0 : _set_pkgmgr_plugin (const gchar *pkgid, const gchar *appid, GList *metadata,
     458              :     mlsvc_package_manager_event_type_e event)
     459              : {
     460            0 :   GList *list = NULL;
     461            0 :   _metadata_s *detail = NULL;
     462              :   pkgmgrinfo_pkginfo_h handle;
     463            0 :   int ret = 0;
     464              : 
     465            0 :   _I ("pkgid = %s, appid = %s\n", pkgid, appid);
     466              : 
     467              :   /* check metadata key/value */
     468            0 :   list = g_list_first (metadata);
     469            0 :   while (list) {
     470            0 :     detail = (_metadata_s *) list->data;
     471            0 :     _I ("key = %s, value = %s\n", detail->key, detail->value);
     472            0 :     list = g_list_next (list);
     473              :   }
     474              : 
     475            0 :   ret = pkgmgrinfo_pkginfo_get_pkginfo (pkgid, &handle);
     476            0 :   if (ret != PMINFO_R_OK) {
     477            0 :     _E ("Failed to get handle.");
     478            0 :     return -1;
     479              :   }
     480              : 
     481              :   /* Check whether the package is rpk */
     482            0 :   char *pkg_type = NULL;
     483            0 :   ret = pkgmgrinfo_pkginfo_get_type (handle, &pkg_type);
     484            0 :   if (ret != PMINFO_R_OK) {
     485            0 :     _E ("Failed to get package type.");
     486            0 :     pkgmgrinfo_pkginfo_destroy_pkginfo (handle);
     487            0 :     return -1;
     488              :   }
     489            0 :   _I ("pkg_type : %s", pkg_type);
     490              : 
     491            0 :   if (g_strcmp0 (pkg_type, "rpk") != 0) {
     492            0 :     _I ("pkg_type is not rpk. Skip parsing.");
     493            0 :     pkgmgrinfo_pkginfo_destroy_pkginfo (handle);
     494            0 :     return 0;
     495              :   }
     496              : 
     497            0 :   char *root_path = NULL;
     498            0 :   ret = pkgmgrinfo_pkginfo_get_root_path (handle, &root_path);
     499            0 :   if (ret != PMINFO_R_OK) {
     500            0 :     _E ("Failed to get root path.");
     501            0 :     pkgmgrinfo_pkginfo_destroy_pkginfo (handle);
     502            0 :     return -1;
     503              :   }
     504            0 :   _I ("root path: %s", root_path);
     505              : 
     506            0 :   char *res_type = NULL;
     507            0 :   ret = pkgmgrinfo_pkginfo_get_res_type (handle, &res_type);
     508            0 :   if (ret != PMINFO_R_OK) {
     509            0 :     _E ("Failed to get res type.");
     510            0 :     pkgmgrinfo_pkginfo_destroy_pkginfo (handle);
     511            0 :     return -1;
     512              :   }
     513            0 :   _I ("res_type = %s\n", res_type);
     514              : 
     515            0 :   char *res_version = NULL;
     516            0 :   ret = pkgmgrinfo_pkginfo_get_res_version (handle, &res_version);
     517            0 :   if (ret != PMINFO_R_OK) {
     518            0 :     _E ("Failed to get res version.");
     519            0 :     pkgmgrinfo_pkginfo_destroy_pkginfo (handle);
     520            0 :     return -1;
     521              :   }
     522            0 :   _I ("res_version = %s\n", res_version);
     523              : 
     524            0 :   g_autofree gchar *app_info = _make_pkg_info (pkgid, appid, res_type, res_version);
     525            0 :   _I ("app_info = %s\n", app_info);
     526              : 
     527              :   /* check rpk_config.json file */
     528            0 :   g_autofree gchar *json_file = g_build_filename (
     529            0 :       root_path, "res", "global", res_type, "rpk_config.json", NULL);
     530              : 
     531            0 :   if (!_get_json_config (json_file, app_info, event)) {
     532            0 :     _E ("Failed to parse the config file %s", json_file);
     533            0 :     pkgmgrinfo_pkginfo_destroy_pkginfo (handle);
     534            0 :     return -1;
     535              :   }
     536              : 
     537            0 :   _I ("PKGMGR_MDPARSER_PLUGIN finished");
     538            0 :   pkgmgrinfo_pkginfo_destroy_pkginfo (handle);
     539              : 
     540            0 :   return 0;
     541            0 : }
     542              : 
     543              : /**
     544              :  * @brief Handle INSTALL process. Tizen app-installer invoke this function.
     545              :  */
     546              : extern "C" int
     547            0 : PKGMGR_MDPARSER_PLUGIN_INSTALL (const char *pkgid, const char *appid, GList *metadata)
     548              : {
     549            0 :   _I ("PKGMGR_MDPARSER_PLUGIN_INSTALL called");
     550            0 :   return _set_pkgmgr_plugin (
     551            0 :       pkgid, appid, metadata, MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_INSTALL);
     552              : }
     553              : 
     554              : /**
     555              :  * @brief Handle UNINSTALL process. Tizen app-installer invoke this function.
     556              :  */
     557              : extern "C" int
     558            0 : PKGMGR_MDPARSER_PLUGIN_UNINSTALL (const char *pkgid, const char *appid, GList *metadata)
     559              : {
     560            0 :   _I ("PKGMGR_MDPARSER_PLUGIN_UNINSTALL called");
     561            0 :   return _set_pkgmgr_plugin (
     562            0 :       pkgid, appid, metadata, MLSVC_PKGMGR_MDPARSER_PLUGIN_EVENT_TYPE_UNINSTALL);
     563              : }
     564              : 
     565              : /**
     566              :  * @brief Handle UPGRADE process. Tizen app-installer invoke this function.
     567              :  */
     568              : extern "C" int
     569            0 : PKGMGR_MDPARSER_PLUGIN_UPGRADE (const char *pkgid, const char *appid, GList *metadata)
     570              : {
     571            0 :   _I ("PKGMGR_MDPARSER_PLUGIN_UPGRADE called");
     572              : 
     573            0 :   PKGMGR_MDPARSER_PLUGIN_UNINSTALL (pkgid, appid, metadata);
     574            0 :   return PKGMGR_MDPARSER_PLUGIN_INSTALL (pkgid, appid, metadata);
     575              : }
     576              : 
     577              : /**
     578              :  * @brief RECOVERINSTALL is invoked after the INSTALL process failed.
     579              :  */
     580              : extern "C" int
     581            0 : PKGMGR_MDPARSER_PLUGIN_RECOVERINSTALL (const char *pkgid, const char *appid, GList *metadata)
     582              : {
     583            0 :   _I ("PKGMGR_MDPARSER_PLUGIN_RECOVERINSTALL called");
     584            0 :   return PKGMGR_MDPARSER_PLUGIN_UNINSTALL (pkgid, appid, metadata);
     585              : }
     586              : 
     587              : /**
     588              :  * @brief RECOVERUPGRADE is invoked after the UPGRADE process failed.
     589              :  */
     590              : extern "C" int
     591            0 : PKGMGR_MDPARSER_PLUGIN_RECOVERUPGRADE (const char *pkgid, const char *appid, GList *metadata)
     592              : {
     593            0 :   _I ("PKGMGR_MDPARSER_PLUGIN_RECOVERUPGRADE called");
     594            0 :   return PKGMGR_MDPARSER_PLUGIN_UPGRADE (pkgid, appid, metadata);
     595              : }
     596              : 
     597              : /**
     598              :  * @brief RECOVERUNINSTALL is invoked after the UNINSTALL process failed.
     599              :  */
     600              : extern "C" int
     601            0 : PKGMGR_MDPARSER_PLUGIN_RECOVERUNINSTALL (const char *pkgid, const char *appid, GList *metadata)
     602              : {
     603            0 :   _I ("PKGMGR_MDPARSER_PLUGIN_RECOVERUNINSTALL called");
     604            0 :   return PKGMGR_MDPARSER_PLUGIN_INSTALL (pkgid, appid, metadata);
     605              : }
     606              : 
     607              : /**
     608              :  * @brief CLEAN is invoked after the installation process completed.
     609              :  */
     610              : extern "C" int
     611            0 : PKGMGR_MDPARSER_PLUGIN_CLEAN (const char *pkgid, const char *appid, GList *metadata)
     612              : {
     613            0 :   _I ("PKGMGR_MDPARSER_PLUGIN_CLEAN called");
     614            0 :   return 0;
     615              : }
     616              : 
     617              : /**
     618              :  * @brief UNDO is invoked after the installation process failed.
     619              :  */
     620              : extern "C" int
     621            0 : PKGMGR_MDPARSER_PLUGIN_UNDO (const char *pkgid, const char *appid, GList *metadata)
     622              : {
     623            0 :   _I ("PKGMGR_MDPARSER_PLUGIN_UNDO called");
     624            0 :   return 0;
     625              : }
        

Generated by: LCOV version 2.0-1