[Image Viewer] Update to use new file server to read files
#include <libimg/libimg.h>
#include <libamc/libamc.h>
#include <file_manager/file_manager_messages.h>
+#include <file_server/file_server_messages.h>
#include "image_viewer_messages.h"
@@ -44,22 +45,23 @@ static Rect _window_resized(gui_view_t* view, Size window_size) {
static void _amc_message_received(amc_message_t* msg) {
const char* source_service = msg->source;
+ printf("Received message from %s!\n", source_service);
image_viewer_load_image_request_t* load_image_req = (image_viewer_load_image_request_t*)&msg->body;
assert(load_image_req->event == IMAGE_VIEWER_LOAD_IMAGE, "Expected load image message");
+ printf("Image viewer received load image request for %s\n", load_image_req->path);
- file_manager_read_file_request_t req = {0};
- req.event = FILE_MANAGER_READ_FILE;
- snprintf(req.path, sizeof(req.path), "%s", load_image_req->path);
- amc_message_send(FILE_MANAGER_SERVICE_NAME, &req, sizeof(file_manager_read_file_request_t));
+ printf("Image viewer sending read file request for %s...\n", load_image_req->path);
+ file_server_read_t read = {0};
+ read.event = FILE_SERVER_READ_FILE_EVENT;
+ snprintf(read.path, sizeof(read.path), "%s", load_image_req->path);
+ amc_message_send(FILE_SERVER_SERVICE_NAME, &read, sizeof(file_server_read_t));
- printf("Requested file %s\n", req.path);
amc_message_t* file_data_msg;
- printf("Awaiting response...\n");
- amc_message_await__u32_event(FILE_MANAGER_SERVICE_NAME, FILE_MANAGER_READ_FILE_RESPONSE, &file_data_msg);
- printf("Got response...\n");
- file_manager_read_file_response_t* resp = (file_manager_read_file_response_t*)&file_data_msg->body;
- uint8_t* b = &resp->file_data;
+ amc_message_await__u32_event(FILE_SERVER_SERVICE_NAME, FILE_SERVER_READ_FILE_EVENT, &file_data_msg);
+
+ file_server_read_response_t* resp = (file_server_read_response_t*)&file_data_msg->body;
+ uint8_t* b = &resp->data;
if (_g_image != NULL) {
printf("Freeing previous image...\n");
@@ -71,7 +73,7 @@ static void _amc_message_received(amc_message_t* msg) {
raw_image_info_t* raw_image = calloc(1, sizeof(raw_image_info_t));
raw_image->image_name = strdup(load_image_req->path);
- raw_image->image = image_parse(resp->file_size, resp->file_data);
+ raw_image->image = image_parse(resp->len, resp->data);
_g_image = raw_image;
_render_image(array_lookup(_g_window->views, 0));
