[agent] Add initial commit for "model_register" method to the daemon
authorYongjoo Ahn <yongjoo1.ahn@samsung.com>
Mon, 13 Feb 2023 06:27:51 +0000 (15:27 +0900)
committerSangjung Woo <again4you@gmail.com>
Fri, 17 Feb 2023 05:43:48 +0000 (14:43 +0900)
- Add initial commit of "model_register" method.

Signed-off-by: Yongjoo Ahn <yongjoo1.ahn@samsung.com>
daemon/includes/dbus-interface.h
daemon/model-dbus-impl.cc

index 8267837..970554d 100644 (file)
@@ -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__ */
index eec4a91..ccbc2be 100644 (file)
@@ -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.