From: Yongjoo Ahn Date: Mon, 13 Feb 2023 06:27:51 +0000 (+0900) Subject: [agent] Add initial commit for "model_register" method to the daemon X-Git-Tag: accepted/tizen/unified/20230223.162150~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9a498c984ad7b3454917e5024e6d01cdc9b935c7;p=platform%2Fcore%2Fapi%2Fmachine-learning.git [agent] Add initial commit for "model_register" method to the daemon - Add initial commit of "model_register" method. Signed-off-by: Yongjoo Ahn --- diff --git a/daemon/includes/dbus-interface.h b/daemon/includes/dbus-interface.h index 8267837..970554d 100644 --- a/daemon/includes/dbus-interface.h +++ b/daemon/includes/dbus-interface.h @@ -44,4 +44,6 @@ #define DBUS_MODEL_I_HANDLER_GET_PATH "handle-get-path" #define DBUS_MODEL_I_HANDLER_DELETE "handle-delete" +#define DBUS_MODEL_I_HANDLER_REGISTER "handle-register" + #endif /* __GDBUS_INTERFACE_H__ */ diff --git a/daemon/model-dbus-impl.cc b/daemon/model-dbus-impl.cc index eec4a91..ccbc2be 100644 --- a/daemon/model-dbus-impl.cc +++ b/daemon/model-dbus-impl.cc @@ -41,9 +41,51 @@ gdbus_put_model_instance (MachinelearningServiceModel ** instance) } /** + * @brief The callback function of Register method + * + * @param obj Proxy instance. + * @param invoc Method invocation handle. + * @param name The name of target model. + * @param path The file path of target. + * @return @c TRUE if the request is handled. FALSE if the service is not available. + */ +static gboolean +gdbus_cb_model_register (MachinelearningServiceModel *obj, + GDBusMethodInvocation *invoc, + const gchar *name, + const gchar *path) +{ + int ret = 0; + guint version = 0U; + MLServiceDB & db = MLServiceDB::getInstance (); + + try { + /** + * @todo register the given model to the DB, and get the version of the model. + */ + version = 1U; + } catch (...) { + g_critical ("DB error occurred. Failed to register the model: %s", name); + ret = -EIO; + } + + db.disconnectDB (); + machinelearning_service_model_complete_register (obj, invoc, version, ret); + + return TRUE; +} + +/** * @brief Event handler list of Model interface */ -static struct gdbus_signal_info handler_infos[] = { }; +static struct gdbus_signal_info handler_infos[] = { + { + .signal_name = DBUS_MODEL_I_HANDLER_REGISTER, + .cb = G_CALLBACK (gdbus_cb_model_register), + .cb_data = NULL, + .handler_id = 0, + }, +}; /** * @brief The callback function for probing Model Interface module.