diff --git a/src/configs.c b/src/configs.c index 4bab4696b7d560beaa452a9bc9eeb4af4ba4361a..c7f836fb16a34605da355822e8ed5491ce6b0c80 100644 --- a/src/configs.c +++ b/src/configs.c @@ -52,7 +52,7 @@ static int dmmap_synchronizeVcfInst(struct dmctx *dmctx, DMNODE *parent_node, vo return 0; } -static int bbf_config_backup(const char *url, const char *username, const char *password, +static int bbf_config_backup(struct ubus_context *ctx, const char *url, const char *username, const char *password, char *config_name, const char *command, const char *obj_path) { int res = 0; @@ -79,7 +79,7 @@ static int bbf_config_backup(const char *url, const char *username, const char * end: // Send the transfer complete event - send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Upload"); + send_transfer_complete_event(ctx, command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Upload"); // Remove temporary file if (file_exists(CONFIG_BACKUP) && remove(CONFIG_BACKUP)) @@ -89,7 +89,7 @@ end: } -static int bbf_config_restore(const char *url, const char *username, const char *password, +static int bbf_config_restore(struct ubus_context *ctx, const char *url, const char *username, const char *password, const char *file_size, const char *checksum_algorithm, const char *checksum, const char *command, const char *obj_path) { @@ -134,7 +134,7 @@ static int bbf_config_restore(const char *url, const char *username, const char end: // Send the transfer complete event - send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Download"); + send_transfer_complete_event(ctx, command, obj_path, url, fault_msg, start_time, complete_time, NULL, "Download"); // Remove temporary file if (file_exists(config_restore) && strncmp(url, FILE_URI, strlen(FILE_URI)) && remove(config_restore)) @@ -274,7 +274,7 @@ static int operate_DeviceInfoVendorConfigFile_Backup(char *refparam, struct dmct dmuci_get_value_by_section_string(((struct dm_data *)data)->config_section, "name", &vcf_name); - int res = bbf_config_backup(url, user, pass, vcf_name, backup_command, backup_path); + int res = bbf_config_backup(ctx->ubus_ctx, url, user, pass, vcf_name, backup_command, backup_path); return res ? USP_FAULT_COMMAND_FAILURE : 0; } @@ -320,7 +320,7 @@ static int operate_DeviceInfoVendorConfigFile_Restore(char *refparam, struct dmc char *checksum_algorithm = dmjson_get_value((json_object *)value, 1, "CheckSumAlgorithm"); char *checksum = dmjson_get_value((json_object *)value, 1, "CheckSum"); - int res = bbf_config_restore(url, user, pass, file_size, checksum_algorithm, checksum, restore_command, restore_path); + int res = bbf_config_restore(ctx->ubus_ctx, url, user, pass, file_size, checksum_algorithm, checksum, restore_command, restore_path); return res ? USP_FAULT_COMMAND_FAILURE : 0; } diff --git a/src/fw_images.c b/src/fw_images.c index 51dcf712f2195fefbcb6bf63f1d836f5ba0dd7f8..98769283e057db939ca57e14e2e748683139b438 100644 --- a/src/fw_images.c +++ b/src/fw_images.c @@ -183,7 +183,7 @@ static void dmubus_receive_sysupgrade(struct ubus_context *ctx, struct ubus_even return; } -static int bbf_fw_image_download(const char *url, const char *auto_activate, const char *username, const char *password, +static int bbf_fw_image_download(struct ubus_context *ctx, const char *url, const char *auto_activate, const char *username, const char *password, const char *file_size, const char *checksum_algorithm, const char *checksum, const char *bank_id, const char *command, const char *obj_path, const char *commandKey, const char *keep) { @@ -280,7 +280,7 @@ static int bbf_fw_image_download(const char *url, const char *auto_activate, con end: // Send the transfer complete event - send_transfer_complete_event(command, obj_path, url, fault_msg, start_time, complete_time, commandKey, "Download"); + send_transfer_complete_event(ctx, command, obj_path, url, fault_msg, start_time, complete_time, commandKey, "Download"); // Remove temporary file if ubus upgrade failed and file exists if (file_exists(fw_image_path) && strncmp(url, FILE_URI, strlen(FILE_URI))) @@ -563,7 +563,7 @@ static int operate_DeviceInfoFirmwareImage_Download(char *refparam, struct dmctx #endif char *bank_id = get_fwbank_option_value(data, "id"); - int res = bbf_fw_image_download(url, auto_activate, username, password, file_size, checksum_algorithm, checksum, bank_id, command, obj_path, commandKey, keep_config); + int res = bbf_fw_image_download(ctx->ubus_ctx, url, auto_activate, username, password, file_size, checksum_algorithm, checksum, bank_id, command, obj_path, commandKey, keep_config); if (res == 1) { bbfdm_set_fault_message(ctx, "Firmware validation failed"); diff --git a/src/memory.c b/src/memory.c index 9cbc4be2526ede3d52a0bfc91028cb2a402e9f44..ef06150ae599571c920d15435de6149e34d3aef7 100644 --- a/src/memory.c +++ b/src/memory.c @@ -114,7 +114,8 @@ static void send_memory_critical_state_event(unsigned int mem_utilization) blobmsg_close_array(&bb, arr); - BBFDM_UBUS_INVOKE_SYNC("bbfdm", "notify_event", bb.head, 5000, NULL, NULL); + BBFDM_UBUS_SEND_EVENT("bbfdm.event", bb.head); + BBFDM_DEBUG("'MemoryCriticalState!' event sent successfully with utilization at %u%%.", mem_utilization); blob_buf_free(&bb); diff --git a/src/processes.c b/src/processes.c index f1a1dc0f99bbc4b61c8c00775276002d6632c0fd..6ef7ed387a4ef7aa44ad57d0df1f6abfa7b8ab73 100644 --- a/src/processes.c +++ b/src/processes.c @@ -414,7 +414,8 @@ static void send_cpu_critical_state_event(unsigned int cpu_utilization) blobmsg_close_array(&bb, arr); - BBFDM_UBUS_INVOKE_SYNC("bbfdm", "notify_event", bb.head, 5000, NULL, NULL); + BBFDM_UBUS_SEND_EVENT("bbfdm.event", bb.head); + BBFDM_DEBUG("'CPUCriticalState!' event sent successfully with utilization at %u%%.", cpu_utilization); blob_buf_free(&bb); diff --git a/src/utils.c b/src/utils.c index fb17a4b744f59cdf4395c7e9f7b903149269562e..4c8afffb6bdcb42bdcdf6ea261a1c928b62ee2aa 100644 --- a/src/utils.c +++ b/src/utils.c @@ -107,7 +107,7 @@ bool validate_file_system_size(const char *file_size) return true; } -void send_transfer_complete_event(const char *command, const char *obj_path, const char *transfer_url, +void send_transfer_complete_event(struct ubus_context *ubus_ctx, const char *command, const char *obj_path, const char *transfer_url, char *fault_string, time_t start_t, time_t complete_t, const char *commandKey, const char *transfer_type) { char start_time[32] = {0}; @@ -145,7 +145,8 @@ void send_transfer_complete_event(const char *command, const char *obj_path, con fill_blob_param(&bb, "FaultString", fault_string, DMT_TYPE[DMT_STRING], 0); blobmsg_close_array(&bb, arr); - dmubus_call_blob_msg_set("bbfdm", "notify_event", &bb); + + ubus_send_event(ubus_ctx, "bbfdm.event", bb.head); blob_buf_free(&bb); } diff --git a/src/utils.h b/src/utils.h index d4ff5e319c580112e9e2694b220bea0da9a0a1ae..22ee3fc60fd7f3ff2658d36b470b7fd3efda9b97 100644 --- a/src/utils.h +++ b/src/utils.h @@ -18,7 +18,7 @@ bool validate_checksum_value(const char *file_path, const char *checksum_algorit bool validate_file_system_size(const char *file_size); bool validate_server_response_code(const char *url, int response_code); -void send_transfer_complete_event(const char *command, const char *obj_path, const char *transfer_url, +void send_transfer_complete_event(struct ubus_context *ubus_ctx, const char *command, const char *obj_path, const char *transfer_url, char *fault_string, time_t start_t, time_t complete_t, const char *commandKey, const char *transfer_type); int sysmngr_get_uptime(void);