Refactor to fill plugin function structure rather than just give structure 76/322376/2 accepted/tizen/unified/20250410.014250 accepted/tizen/unified/x/20250410.025400
authorSangYoun Kwak <sy.kwak@samsung.com>
Tue, 8 Apr 2025 07:25:13 +0000 (16:25 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Tue, 8 Apr 2025 07:48:38 +0000 (16:48 +0900)
To support ABI compatibility, the plugin api allocates the plugin
function structure and gives its pointer to backend. According to this
change, update-control-generic backend fills required functions rather
than just hand over the plugin function structure.

Change-Id: I6077e0abda1542fbc24de83e0ea29dbdc3fe4651
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
src/plugin.c

index 904eca3b56371cf771516c7616f97ead1dcf08a6..679f3651f49fc23a7e1c63b91e1ee7e5512d76e2 100644 (file)
@@ -665,20 +665,29 @@ static int update_control_get_property(syscommon_update_control_property_e prope
        return ret;
 }
 
-static syscommon_plugin_backend_update_control_funcs plugin_funcs = {
-       .update_control_initialize = update_control_initialize,
-       .update_control_deinitialize = update_control_deinitialize,
-       .update_control_check_new_version = update_control_check_new_version,
-       .update_control_download_package = update_control_download_package,
-       .update_control_do_update = update_control_do_update,
-       .update_control_make_reservation = update_control_make_reservation,
-       .update_control_cancel_reservation = update_control_cancel_reservation,
-       .update_control_get_property = update_control_get_property,
-};
-
 static int update_control_init(void **data)
 {
-       *data = (void *)&plugin_funcs;
+       syscommon_plugin_backend_update_control_funcs *plugin_funcs = NULL;
+
+       if (!data) {
+               _E("Invalid parameter: data is NULL");
+               return -EINVAL;
+       }
+
+       plugin_funcs = *((syscommon_plugin_backend_update_control_funcs **)data);
+       if (!plugin_funcs) {
+               _E("Invalid parameter: plugin_funcs is NULL");
+               return -EINVAL;
+       }
+
+       plugin_funcs->update_control_initialize = update_control_initialize;
+       plugin_funcs->update_control_deinitialize = update_control_deinitialize;
+       plugin_funcs->update_control_check_new_version = update_control_check_new_version;
+       plugin_funcs->update_control_download_package = update_control_download_package;
+       plugin_funcs->update_control_do_update = update_control_do_update;
+       plugin_funcs->update_control_make_reservation = update_control_make_reservation;
+       plugin_funcs->update_control_cancel_reservation = update_control_cancel_reservation;
+       plugin_funcs->update_control_get_property = update_control_get_property;
 
        return 0;
 }