Просмотр исходного кода

FlipStore - v0.5

- Add app versioning
- Add app descriptions
- Prep firmware downloads
jblanked 1 год назад
Родитель
Сommit
9d1106f245

+ 22 - 5
alloc/flip_store_alloc.c

@@ -105,11 +105,19 @@ FlipStoreApp *flip_store_app_alloc()
     app->variable_item_pass = variable_item_list_add(app->variable_item_list, "Password", 0, NULL, NULL);
 
     // Submenu
-    if (!easy_flipper_set_submenu(&app->submenu, FlipStoreViewSubmenu, "FlipStore v0.4", callback_exit_app, &app->view_dispatcher))
+    if (!easy_flipper_set_submenu(&app->submenu_main, FlipStoreViewSubmenu, "FlipStore v0.5", callback_exit_app, &app->view_dispatcher))
     {
         return NULL;
     }
-    if (!easy_flipper_set_submenu(&app->submenu_app_list, FlipStoreViewAppList, "App Catalog", callback_to_submenu, &app->view_dispatcher))
+    if (!easy_flipper_set_submenu(&app->submenu_options, FlipStoreViewSubmenuOptions, "Browse", callback_to_submenu, &app->view_dispatcher))
+    {
+        return NULL;
+    }
+    if (!easy_flipper_set_submenu(&app->submenu_app_list, FlipStoreViewAppList, "App Catalog", callback_to_submenu_options, &app->view_dispatcher))
+    {
+        return NULL;
+    }
+    if (!easy_flipper_set_submenu(&app->submenu_firmwares, FlipStoreViewFirmwares, "ESP32 Firmwares", callback_to_submenu_options, &app->view_dispatcher))
     {
         return NULL;
     }
@@ -157,9 +165,18 @@ FlipStoreApp *flip_store_app_alloc()
     {
         return NULL;
     }
-    submenu_add_item(app->submenu, "Catalog", FlipStoreSubmenuIndexAppList, callback_submenu_choices, app);
-    submenu_add_item(app->submenu, "About", FlipStoreSubmenuIndexAbout, callback_submenu_choices, app);
-    submenu_add_item(app->submenu, "Settings", FlipStoreSubmenuIndexSettings, callback_submenu_choices, app);
+    //
+    submenu_add_item(app->submenu_main, "Browse", FlipStoreSubmenuIndexOptions, callback_submenu_choices, app);
+    submenu_add_item(app->submenu_main, "About", FlipStoreSubmenuIndexAbout, callback_submenu_choices, app);
+    submenu_add_item(app->submenu_main, "Settings", FlipStoreSubmenuIndexSettings, callback_submenu_choices, app);
+    //
+    submenu_add_item(app->submenu_options, "App Catalog", FlipStoreSubmenuIndexAppList, callback_submenu_choices, app);
+    submenu_add_item(app->submenu_options, "ESP32 Firmwares", FlipStoreSubmenuIndexFirmwares, callback_submenu_choices, app);
+    //
+    for (int i = 0; i < 3; i++)
+    {
+        submenu_add_item(app->submenu_firmwares, firmwares[i], FlipStoreSubmenuIndexStartFirmwares + i, callback_submenu_choices, app);
+    }
     //
     submenu_add_item(app->submenu_app_list, "Bluetooth", FlipStoreSubmenuIndexAppListBluetooth, callback_submenu_choices, app);
     submenu_add_item(app->submenu_app_list, "Games", FlipStoreSubmenuIndexAppListGames, callback_submenu_choices, app);

+ 2 - 0
app.c

@@ -1,5 +1,6 @@
 #include <flip_store.h>
 #include <alloc/flip_store_alloc.h>
+#include <apps/flip_store_apps.h>
 
 // Entry point for the Hello World application
 int32_t main_flip_store(void *p)
@@ -26,6 +27,7 @@ int32_t main_flip_store(void *p)
 
     // Free the resources used by the Hello World application
     flip_store_app_free(app);
+    flip_catalog_free();
 
     // Return 0 to indicate success
     return 0;

+ 1 - 1
application.fam

@@ -10,5 +10,5 @@ App(
     fap_description="Download apps via WiFi directly to your Flipper Zero",
     fap_author="JBlanked",
     fap_weburl="https://github.com/jblanked/FlipStore",
-    fap_version="0.3",
+    fap_version="0.5",
 )

+ 171 - 210
apps/flip_store_apps.c

@@ -37,6 +37,18 @@ FlipStoreAppInfo *flip_catalog_alloc()
             FURI_LOG_E(TAG, "Failed to allocate memory for app_build_id.");
             return NULL;
         }
+        app_catalog[i].app_version = (char *)malloc(MAX_APP_VERSION_LENGTH * sizeof(char));
+        if (!app_catalog[i].app_version)
+        {
+            FURI_LOG_E(TAG, "Failed to allocate memory for app_version.");
+            return NULL;
+        }
+        app_catalog[i].app_description = (char *)malloc(MAX_APP_DESCRIPTION_LENGTH * sizeof(char));
+        if (!app_catalog[i].app_description)
+        {
+            FURI_LOG_E(TAG, "Failed to allocate memory for app_description.");
+            return NULL;
+        }
     }
     return app_catalog;
 }
@@ -60,13 +72,20 @@ void flip_catalog_free()
         {
             free(flip_catalog[i].app_build_id);
         }
+        if (flip_catalog[i].app_version)
+        {
+            free(flip_catalog[i].app_version);
+        }
+        if (flip_catalog[i].app_description)
+        {
+            free(flip_catalog[i].app_description);
+        }
     }
 }
 
-// Utility function to parse JSON incrementally from a file
 bool flip_store_process_app_list()
 {
-    // initialize the flip_catalog
+    // Initialize the flip_catalog
     flip_catalog = flip_catalog_alloc();
     if (!flip_catalog)
     {
@@ -74,26 +93,34 @@ bool flip_store_process_app_list()
         return false;
     }
 
-    Storage *_storage = NULL;
-    File *_file = NULL;
-    char buffer[BUFFER_SIZE];
-    size_t bytes_read;
+    FuriString *feed_data = flipper_http_load_from_file(fhttp.file_path);
+    if (feed_data == NULL)
+    {
+        FURI_LOG_E(TAG, "Failed to load received data from file.");
+        return false;
+    }
+
+    char *data_cstr = (char *)furi_string_get_cstr(feed_data);
+    if (data_cstr == NULL)
+    {
+        FURI_LOG_E(TAG, "Failed to get C-string from FuriString.");
+        furi_string_free(feed_data);
+        return false;
+    }
+
+    // Parser state variables
     bool in_string = false;
     bool is_escaped = false;
     bool reading_key = false;
     bool reading_value = false;
     bool inside_app_object = false;
-    bool found_name = false;
-    bool found_id = false;
-    bool found_build_id = false;
+    bool found_name = false, found_id = false, found_build_id = false, found_version = false, found_description = false;
     char current_key[MAX_KEY_LENGTH] = {0};
     size_t key_index = 0;
     char current_value[MAX_VALUE_LENGTH] = {0};
     size_t value_index = 0;
     int app_count = 0;
-    enum ObjectState object_state = OBJECT_EXPECT_KEY; // Initialize object_state
-
-    // Initialize parser state
+    enum ObjectState object_state = OBJECT_EXPECT_KEY;
     enum
     {
         STATE_SEARCH_APPS_KEY,
@@ -102,235 +129,169 @@ bool flip_store_process_app_list()
         STATE_DONE
     } state = STATE_SEARCH_APPS_KEY;
 
-    // Open storage and file
-    _storage = furi_record_open(RECORD_STORAGE);
-    if (!_storage)
-    {
-        FURI_LOG_E(TAG, "Failed to open storage.");
-        return false;
-    }
-
-    _file = storage_file_alloc(_storage);
-    if (!_file)
+    // Iterate through the data
+    for (size_t i = 0; data_cstr[i] != '\0' && state != STATE_DONE; ++i)
     {
-        FURI_LOG_E(TAG, "Failed to allocate file.");
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
+        char c = data_cstr[i];
 
-    if (!storage_file_open(_file, fhttp.file_path, FSAM_READ, FSOM_OPEN_EXISTING))
-    {
-        FURI_LOG_E(TAG, "Failed to open JSON file for reading.");
-        storage_file_free(_file);
-        furi_record_close(RECORD_STORAGE);
-        return false;
-    }
+        if (is_escaped)
+        {
+            is_escaped = false;
+            if (reading_key && key_index < MAX_KEY_LENGTH - 1)
+            {
+                current_key[key_index++] = c;
+            }
+            else if (reading_value && value_index < MAX_VALUE_LENGTH - 1)
+            {
+                current_value[value_index++] = c;
+            }
+            continue;
+        }
 
-    while ((bytes_read = storage_file_read(_file, buffer, BUFFER_SIZE)) > 0 && state != STATE_DONE)
-    {
-        for (size_t i = 0; i < bytes_read; ++i)
+        if (c == '\\')
         {
-            char c = buffer[i];
+            is_escaped = true;
+            continue;
+        }
 
-            if (is_escaped)
+        if (c == '\"')
+        {
+            in_string = !in_string;
+            if (in_string)
             {
-                is_escaped = false;
-                if (reading_key)
+                if (!reading_key && !reading_value)
                 {
-                    if (key_index < MAX_KEY_LENGTH - 1)
+                    if (state == STATE_SEARCH_APPS_KEY || object_state == OBJECT_EXPECT_KEY)
                     {
-                        current_key[key_index++] = c;
+                        reading_key = true;
+                        key_index = 0;
+                        current_key[0] = '\0';
                     }
-                }
-                else if (reading_value)
-                {
-                    if (value_index < MAX_VALUE_LENGTH - 1)
+                    else if (object_state == OBJECT_EXPECT_VALUE)
                     {
-                        current_value[value_index++] = c;
+                        reading_value = true;
+                        value_index = 0;
+                        current_value[0] = '\0';
                     }
                 }
-                continue;
             }
-
-            if (c == '\\')
-            {
-                is_escaped = true;
-                continue;
-            }
-
-            if (c == '\"')
+            else
             {
-                in_string = !in_string;
-
-                if (in_string)
+                if (reading_key)
                 {
-                    // Start of a string
-                    if (!reading_key && !reading_value)
+                    reading_key = false;
+                    current_key[key_index] = '\0';
+                    if (state == STATE_SEARCH_APPS_KEY && strcmp(current_key, "apps") == 0)
                     {
-                        if (state == STATE_SEARCH_APPS_KEY)
-                        {
-                            reading_key = true;
-                            key_index = 0;
-                            current_key[0] = '\0';
-                        }
-                        else if (inside_app_object)
-                        {
-                            if (object_state == OBJECT_EXPECT_KEY)
-                            {
-                                reading_key = true;
-                                key_index = 0;
-                                current_key[0] = '\0';
-                            }
-                            else if (object_state == OBJECT_EXPECT_VALUE)
-                            {
-                                reading_value = true;
-                                value_index = 0;
-                                current_value[0] = '\0';
-                            }
-                        }
+                        state = STATE_SEARCH_ARRAY_START;
+                    }
+                    else if (inside_app_object)
+                    {
+                        object_state = OBJECT_EXPECT_COLON;
                     }
                 }
-                else
+                else if (reading_value)
                 {
-                    // End of a string
-                    if (reading_key)
-                    {
-                        reading_key = false;
-                        current_key[key_index] = '\0';
+                    reading_value = false;
+                    current_value[value_index] = '\0';
 
-                        if (state == STATE_SEARCH_APPS_KEY && strcmp(current_key, "apps") == 0)
+                    if (inside_app_object)
+                    {
+                        if (strcmp(current_key, "name") == 0)
                         {
-                            state = STATE_SEARCH_ARRAY_START;
+                            snprintf(flip_catalog[app_count].app_name, MAX_APP_NAME_LENGTH, "%.31s", current_value);
+                            found_name = true;
                         }
-                        else if (inside_app_object)
+                        else if (strcmp(current_key, "id") == 0)
                         {
-                            object_state = OBJECT_EXPECT_COLON;
+                            snprintf(flip_catalog[app_count].app_id, MAX_ID_LENGTH, "%.31s", current_value);
+                            found_id = true;
+                        }
+                        else if (strcmp(current_key, "build_id") == 0)
+                        {
+                            snprintf(flip_catalog[app_count].app_build_id, MAX_ID_LENGTH, "%.31s", current_value);
+                            found_build_id = true;
+                        }
+                        else if (strcmp(current_key, "version") == 0)
+                        {
+                            snprintf(flip_catalog[app_count].app_version, MAX_APP_VERSION_LENGTH, "%.3s", current_value);
+                            found_version = true;
+                        }
+                        else if (strcmp(current_key, "description") == 0)
+                        {
+                            snprintf(flip_catalog[app_count].app_description, MAX_APP_DESCRIPTION_LENGTH, "%.99s", current_value);
+                            found_description = true;
                         }
-                    }
-                    else if (reading_value)
-                    {
-                        reading_value = false;
-                        current_value[value_index] = '\0';
 
-                        if (inside_app_object)
+                        if (found_name && found_id && found_build_id && found_version && found_description)
                         {
-                            if (strcmp(current_key, "name") == 0)
-                            {
-                                snprintf(flip_catalog[app_count].app_name, MAX_APP_NAME_LENGTH, "%.31s", current_value);
-                                found_name = true;
-                            }
-                            else if (strcmp(current_key, "id") == 0)
-                            {
-                                snprintf(flip_catalog[app_count].app_id, MAX_ID_LENGTH, "%.31s", current_value);
-                                found_id = true;
-                            }
-                            else if (strcmp(current_key, "build_id") == 0)
+                            app_count++;
+                            if (app_count >= MAX_APP_COUNT)
                             {
-                                snprintf(flip_catalog[app_count].app_build_id, MAX_ID_LENGTH, "%.31s", current_value);
-                                found_build_id = true;
+                                FURI_LOG_I(TAG, "Reached maximum app count.");
+                                state = STATE_DONE;
+                                break;
                             }
 
-                            // After processing value, expect comma or end
-                            object_state = OBJECT_EXPECT_COMMA_OR_END;
-
-                            // Check if both name and id are found
-                            if (found_name && found_id && found_build_id)
-                            {
-                                app_count++;
-                                if (app_count >= MAX_APP_COUNT)
-                                {
-                                    FURI_LOG_I(TAG, "Reached maximum app count.");
-                                    state = STATE_DONE;
-                                    break;
-                                }
-
-                                // Reset for next app
-                                found_name = false;
-                                found_id = false;
-                                found_build_id = false;
-                            }
+                            found_name = found_id = found_build_id = found_version = found_description = false;
                         }
+
+                        object_state = OBJECT_EXPECT_COMMA_OR_END;
                     }
                 }
-                continue;
             }
+            continue;
+        }
 
-            if (in_string)
+        if (in_string)
+        {
+            if (reading_key && key_index < MAX_KEY_LENGTH - 1)
             {
-                if (reading_key)
-                {
-                    if (key_index < MAX_KEY_LENGTH - 1)
-                    {
-                        current_key[key_index++] = c;
-                    }
-                }
-                else if (reading_value)
-                {
-                    if (value_index < MAX_VALUE_LENGTH - 1)
-                    {
-                        current_value[value_index++] = c;
-                    }
-                }
-                continue;
+                current_key[key_index++] = c;
+            }
+            else if (reading_value && value_index < MAX_VALUE_LENGTH - 1)
+            {
+                current_value[value_index++] = c;
             }
+            continue;
+        }
 
-            // Not inside a string
+        if (state == STATE_SEARCH_ARRAY_START && c == '[')
+        {
+            state = STATE_READ_ARRAY_ELEMENTS;
+            continue;
+        }
 
-            if (state == STATE_SEARCH_ARRAY_START)
+        if (state == STATE_READ_ARRAY_ELEMENTS)
+        {
+            if (c == '{')
             {
-                if (c == '[')
-                {
-                    state = STATE_READ_ARRAY_ELEMENTS;
-                }
-                continue;
+                inside_app_object = true;
+                object_state = OBJECT_EXPECT_KEY;
             }
-
-            if (state == STATE_READ_ARRAY_ELEMENTS)
+            else if (c == '}')
             {
-                if (c == '{')
-                {
-                    inside_app_object = true;
-                    found_name = false;
-                    found_id = false;
-                    found_build_id = false;
-                    object_state = OBJECT_EXPECT_KEY;
-                }
-                else if (c == '}')
-                {
-                    inside_app_object = false;
-                    object_state = OBJECT_EXPECT_KEY;
-                }
-                else if (c == ']')
-                {
-                    state = STATE_DONE;
-                    break;
-                }
-                else if (c == ':')
-                {
-                    if (inside_app_object && object_state == OBJECT_EXPECT_COLON)
-                    {
-                        object_state = OBJECT_EXPECT_VALUE;
-                    }
-                }
-                else if (c == ',')
-                {
-                    if (inside_app_object && object_state == OBJECT_EXPECT_COMMA_OR_END)
-                    {
-                        object_state = OBJECT_EXPECT_KEY;
-                    }
-                    // Else, separator between objects or values
-                }
-                // Ignore other characters like whitespace, etc.
-                continue;
+                inside_app_object = false;
+            }
+            else if (c == ':')
+            {
+                object_state = OBJECT_EXPECT_VALUE;
+            }
+            else if (c == ',')
+            {
+                object_state = OBJECT_EXPECT_KEY;
+            }
+            else if (c == ']')
+            {
+                state = STATE_DONE;
+                break;
             }
         }
     }
 
     // Clean up
-    storage_file_close(_file);
-    storage_file_free(_file);
-    furi_record_close(RECORD_STORAGE);
-
+    furi_string_free(feed_data);
+    free(data_cstr);
     return app_count > 0;
 }
 
@@ -392,10 +353,10 @@ bool flip_store_install_app(Canvas *canvas, char *category)
     storage_common_mkdir(storage, directory_path);
 
     // Adjusted to access flip_catalog as an array of structures
-    char installing_text[64];
-    snprintf(installing_text, sizeof(installing_text), "Installing %s", flip_catalog[app_selected_index].app_name);
+    char installation_text[64];
+    snprintf(installation_text, sizeof(installation_text), "Installing %s", flip_catalog[app_selected_index].app_name);
     snprintf(fhttp.file_path, sizeof(fhttp.file_path), STORAGE_EXT_PATH_PREFIX "/apps/%s/%s.fap", category, flip_catalog[app_selected_index].app_id);
-    canvas_draw_str(canvas, 0, 10, installing_text);
+    canvas_draw_str(canvas, 0, 10, installation_text);
     canvas_draw_str(canvas, 0, 20, "Sending request..");
     uint8_t target = furi_hal_version_get_hw_target();
     uint16_t api_major, api_minor;
@@ -404,7 +365,6 @@ bool flip_store_install_app(Canvas *canvas, char *category)
     {
         canvas_draw_str(canvas, 0, 30, "Request sent.");
         fhttp.state = RECEIVING;
-        // furi_timer_start(fhttp.get_timeout_timer, TIMEOUT_DURATION_TICKS);
         canvas_draw_str(canvas, 0, 40, "Receiving...");
     }
     else
@@ -440,34 +400,31 @@ int32_t flip_store_handle_app_list(FlipStoreApp *app, int32_t success_view, char
         FURI_LOG_E(TAG, "FlipStoreApp is NULL");
         return FlipStoreViewPopup;
     }
-    char url[128];
     snprintf(
         fhttp.file_path,
         sizeof(fhttp.file_path),
-        STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/apps.txt");
+        STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/%s.json", category);
 
     fhttp.save_received_data = true;
     fhttp.is_bytes_request = false;
-    snprintf(url, sizeof(url), "https://www.flipsocial.net/api/flipper/apps/%s/extended/", category);
-    char *headers = jsmn("Content-Type", "application/json");
+    char url[128];
+    snprintf(url, sizeof(url), "https://www.flipsocial.net/api/flipper/apps/%s/max/", category);
     // async call to the app list with timer
-    if (fhttp.state != INACTIVE && flipper_http_get_request_with_headers(url, headers))
+    if (fhttp.state != INACTIVE && flipper_http_get_request_with_headers(url, "{\"Content-Type\":\"application/json\"}"))
     {
         furi_timer_start(fhttp.get_timeout_timer, TIMEOUT_DURATION_TICKS);
-        free(headers);
         fhttp.state = RECEIVING;
     }
     else
     {
         FURI_LOG_E(TAG, "Failed to send the request");
-        free(headers);
         fhttp.state = ISSUE;
         return FlipStoreViewPopup;
     }
     while (fhttp.state == RECEIVING && furi_timer_is_running(fhttp.get_timeout_timer) > 0)
     {
         // Wait for the feed to be received
-        furi_delay_ms(100);
+        furi_delay_ms(10);
     }
     furi_timer_stop(fhttp.get_timeout_timer);
     if (fhttp.state == ISSUE)
@@ -487,7 +444,7 @@ int32_t flip_store_handle_app_list(FlipStoreApp *app, int32_t success_view, char
                 }
                 else
                 {
-                    popup_set_text(app->popup, fhttp.last_response, 0, 10, AlignLeft, AlignTop);
+                    popup_set_text(app->popup, fhttp.last_response, 0, 50, AlignLeft, AlignTop);
                 }
             }
             else
@@ -498,14 +455,14 @@ int32_t flip_store_handle_app_list(FlipStoreApp *app, int32_t success_view, char
         }
         else
         {
-            popup_set_text(app->popup, "Failed to received data.", 0, 10, AlignLeft, AlignTop);
+            popup_set_text(app->popup, "Failed to received data.", 0, 50, AlignLeft, AlignTop);
             return FlipStoreViewPopup;
         }
     }
     else
     {
         // process the app list
-        if (flip_store_process_app_list())
+        if (flip_store_process_app_list() && submenu && flip_catalog)
         {
             submenu_reset(*submenu);
             // add each app name to submenu
@@ -515,6 +472,10 @@ int32_t flip_store_handle_app_list(FlipStoreApp *app, int32_t success_view, char
                 {
                     submenu_add_item(*submenu, flip_catalog[i].app_name, FlipStoreSubmenuIndexStartAppList + i, callback_submenu_choices, app);
                 }
+                else
+                {
+                    break;
+                }
             }
             return success_view;
         }

+ 4 - 0
apps/flip_store_apps.h

@@ -9,12 +9,16 @@
 #define MAX_APP_NAME_LENGTH 32
 #define MAX_ID_LENGTH 32
 #define MAX_APP_COUNT 100
+#define MAX_APP_DESCRIPTION_LENGTH 100
+#define MAX_APP_VERSION_LENGTH 5
 
 typedef struct
 {
     char *app_name;
     char *app_id;
     char *app_build_id;
+    char *app_version;
+    char *app_description;
 } FlipStoreAppInfo;
 
 extern FlipStoreAppInfo *flip_catalog;

+ 3 - 0
assets/CHANGELOG.md

@@ -1,3 +1,6 @@
+## v0.5
+- Added app descriptions and versioning.
+
 ## v0.4
 - Added an option to delete apps
 - Edit by Willy-JL

+ 115 - 2
callback/flip_store_callback.c

@@ -57,12 +57,77 @@ void flip_store_view_draw_callback_main(Canvas *canvas, void *model)
     }
 }
 
+// Function to draw the message on the canvas with word wrapping
+void draw_description(Canvas *canvas, const char *description, int x, int y)
+{
+    if (description == NULL || strlen(description) == 0)
+    {
+        FURI_LOG_E(TAG, "User message is NULL.");
+        return;
+    }
+    if (!canvas)
+    {
+        FURI_LOG_E(TAG, "Canvas is NULL.");
+        return;
+    }
+
+    size_t msg_length = strlen(description);
+    size_t start = 0;
+    int line_num = 0;
+    char line[MAX_LINE_LENGTH + 1]; // Buffer for the current line (+1 for null terminator)
+
+    while (start < msg_length && line_num < 4)
+    {
+        size_t remaining = msg_length - start;
+        size_t len = (remaining > MAX_LINE_LENGTH) ? MAX_LINE_LENGTH : remaining;
+
+        if (remaining > MAX_LINE_LENGTH)
+        {
+            // Find the last space within the first 'len' characters
+            size_t last_space = len;
+            while (last_space > 0 && description[start + last_space - 1] != ' ')
+            {
+                last_space--;
+            }
+
+            if (last_space > 0)
+            {
+                len = last_space; // Adjust len to the position of the last space
+            }
+        }
+
+        // Copy the substring to 'line' and null-terminate it
+        memcpy(line, description + start, len);
+        line[len] = '\0'; // Ensure the string is null-terminated
+
+        // Draw the string on the canvas
+        // Adjust the y-coordinate based on the line number
+        canvas_draw_str_aligned(canvas, x, y + line_num * 10, AlignLeft, AlignTop, line);
+
+        // Update the start position for the next line
+        start += len;
+
+        // Skip any spaces to avoid leading spaces on the next line
+        while (start < msg_length && description[start] == ' ')
+        {
+            start++;
+        }
+
+        // Increment the line number
+        line_num++;
+    }
+}
+
 void flip_store_view_draw_callback_app_list(Canvas *canvas, void *model)
 {
     UNUSED(model);
     canvas_clear(canvas);
     canvas_set_font(canvas, FontPrimary);
-    canvas_draw_str(canvas, 0, 10, flip_catalog[app_selected_index].app_name);
+    char title[30];
+    snprintf(title, 30, "%s (v.%s)", flip_catalog[app_selected_index].app_name, flip_catalog[app_selected_index].app_version);
+    canvas_draw_str(canvas, 0, 10, title);
+    canvas_set_font(canvas, FontSecondary);
+    draw_description(canvas, flip_catalog[app_selected_index].app_description, 0, 13);
     if (flip_store_app_does_exist)
     {
         canvas_draw_icon(canvas, 0, 53, &I_ButtonLeft_4x7);
@@ -201,6 +266,17 @@ uint32_t callback_to_submenu(void *context)
     return FlipStoreViewSubmenu;
 }
 
+uint32_t callback_to_submenu_options(void *context)
+{
+    if (!context)
+    {
+        FURI_LOG_E(TAG, "Context is NULL");
+        return VIEW_NONE;
+    }
+    UNUSED(context);
+    return FlipStoreViewSubmenuOptions;
+}
+
 uint32_t callback_to_app_list(void *context)
 {
     if (!context)
@@ -313,11 +389,17 @@ void callback_submenu_choices(void *context, uint32_t index)
     case FlipStoreSubmenuIndexSettings:
         view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSettings);
         break;
+    case FlipStoreSubmenuIndexOptions:
+        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewSubmenuOptions);
+        break;
     case FlipStoreSubmenuIndexAppList:
         flip_store_category_index = 0;
         flip_store_app_does_exist = false;
         view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewAppList);
         break;
+    case FlipStoreSubmenuIndexFirmwares:
+        view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewFirmwares);
+        break;
     case FlipStoreSubmenuIndexAppListBluetooth:
         flip_store_category_index = 0;
         flip_store_app_does_exist = false;
@@ -374,8 +456,39 @@ void callback_submenu_choices(void *context, uint32_t index)
         view_dispatcher_switch_to_view(app->view_dispatcher, flip_store_handle_app_list(app, FlipStoreViewAppListUSB, "USB", &app->submenu_app_list_usb));
         break;
     default:
+        // Check if the index is within the firmwares list range
+        if (index >= FlipStoreSubmenuIndexStartFirmwares && index < FlipStoreSubmenuIndexStartFirmwares + 3)
+        {
+            // Get the firmware index
+            uint32_t firmware_index = index - FlipStoreSubmenuIndexStartFirmwares;
+
+            // Check if the firmware index is valid
+            if ((int)firmware_index >= 0 && firmware_index < 3)
+            {
+                // Get the firmware name
+                char *firmware_name = firmwares[firmware_index];
+
+                // Check if the firmware name is valid
+                if (firmware_name != NULL && strlen(firmware_name) > 0)
+                {
+                    // do nothing for now
+                    popup_set_header(app->popup, firmware_name, 0, 0, AlignLeft, AlignTop);
+                    popup_set_text(app->popup, "Not implemented yet :D", 0, 50, AlignLeft, AlignTop);
+
+                    view_dispatcher_switch_to_view(app->view_dispatcher, FlipStoreViewPopup);
+                }
+                else
+                {
+                    FURI_LOG_E(TAG, "Invalid firmware name");
+                }
+            }
+            else
+            {
+                FURI_LOG_E(TAG, "Invalid firmware index");
+            }
+        }
         // Check if the index is within the app list range
-        if (index >= FlipStoreSubmenuIndexStartAppList && index < FlipStoreSubmenuIndexStartAppList + MAX_APP_COUNT)
+        else if (index >= FlipStoreSubmenuIndexStartAppList && index < FlipStoreSubmenuIndexStartAppList + MAX_APP_COUNT)
         {
             // Get the app index
             uint32_t app_index = index - FlipStoreSubmenuIndexStartAppList;

+ 7 - 0
callback/flip_store_callback.h

@@ -9,11 +9,16 @@
 #include <apps/flip_store_apps.h>
 #include <flip_storage/flip_store_storage.h>
 
+#define MAX_LINE_LENGTH 30
+
 extern bool flip_store_app_does_exist;
 
 // Callback for drawing the main screen
 void flip_store_view_draw_callback_main(Canvas *canvas, void *model);
 
+// Function to draw the description on the canvas with word wrapping
+void draw_description(Canvas *canvas, const char *user_message, int x, int y);
+
 void flip_store_view_draw_callback_app_list(Canvas *canvas, void *model);
 
 bool flip_store_input_callback(InputEvent *event, void *context);
@@ -24,6 +29,8 @@ void flip_store_text_updated_pass(void *context);
 
 uint32_t callback_to_submenu(void *context);
 
+uint32_t callback_to_submenu_options(void *context);
+
 uint32_t callback_to_app_list(void *context);
 
 void settings_item_selected(void *context, uint32_t index);

+ 2 - 2
flip_storage/flip_store_storage.h

@@ -7,8 +7,8 @@
 
 #define SETTINGS_PATH STORAGE_EXT_PATH_PREFIX "/apps_data/flip_store/settings.bin"
 #define BUFFER_SIZE 64
-#define MAX_KEY_LENGTH 32
-#define MAX_VALUE_LENGTH 64
+#define MAX_KEY_LENGTH 16
+#define MAX_VALUE_LENGTH 100
 
 void save_settings(
     const char *ssid,

+ 18 - 2
flip_store.c

@@ -15,6 +15,12 @@ char *categories[] = {
     "USB",
 };
 
+char *firmwares[] = {
+    "Black Magic",
+    "FlipperHTTP",
+    "Marauder",
+};
+
 // Function to free the resources used by FlipStoreApp
 void flip_store_app_free(FlipStoreApp *app)
 {
@@ -37,16 +43,26 @@ void flip_store_app_free(FlipStoreApp *app)
     }
 
     // Free Submenu(s)
-    if (app->submenu)
+    if (app->submenu_main)
     {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewSubmenu);
-        submenu_free(app->submenu);
+        submenu_free(app->submenu_main);
+    }
+    if (app->submenu_options)
+    {
+        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewSubmenuOptions);
+        submenu_free(app->submenu_options);
     }
     if (app->submenu_app_list)
     {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewAppList);
         submenu_free(app->submenu_app_list);
     }
+    if (app->submenu_firmwares)
+    {
+        view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewFirmwares);
+        submenu_free(app->submenu_firmwares);
+    }
     if (app->submenu_app_list_bluetooth)
     {
         view_dispatcher_remove_view(app->view_dispatcher, FlipStoreViewAppListBluetooth);

+ 20 - 6
flip_store.h

@@ -17,6 +17,7 @@
 
 // define the list of categories
 extern char *categories[];
+extern char *firmwares[];
 
 // Define the submenu items for our FlipStore application
 typedef enum
@@ -24,7 +25,11 @@ typedef enum
     FlipStoreSubmenuIndexMain, // Click to start downloading the selected app
     FlipStoreSubmenuIndexAbout,
     FlipStoreSubmenuIndexSettings,
+    //
+    FlipStoreSubmenuIndexOptions, // Click to view the options
+    //
     FlipStoreSubmenuIndexAppList,
+    FlipStoreSubmenuIndexFirmwares,
     //
     FlipStoreSubmenuIndexAppListBluetooth,
     FlipStoreSubmenuIndexAppListGames,
@@ -38,14 +43,19 @@ typedef enum
     FlipStoreSubmenuIndexAppListTools,
     FlipStoreSubmenuIndexAppListUSB,
     //
-    FlipStoreSubmenuIndexStartAppList
+    FlipStoreSubmenuIndexStartFirmwares,
+    //
+    FlipStoreSubmenuIndexStartAppList = 100,
 } FlipStoreSubmenuIndex;
 
 // Define a single view for our FlipStore application
 typedef enum
 {
-    FlipStoreViewMain,          // The main screen
-    FlipStoreViewSubmenu,       // The submenu
+    FlipStoreViewMain, // The main screen
+    //
+    FlipStoreViewSubmenu,        // The submenu
+    FlipStoreViewSubmenuOptions, // The submenu options
+    //
     FlipStoreViewAbout,         // The about screen
     FlipStoreViewSettings,      // The settings screen
     FlipStoreViewTextInputSSID, // The text input screen for SSID
@@ -53,7 +63,9 @@ typedef enum
     //
     FlipStoreViewPopup, // The popup screen
     //
-    FlipStoreViewAppList,     // The app list screen
+    FlipStoreViewAppList,   // The app list screen
+    FlipStoreViewFirmwares, // The firmwares screen
+    //
     FlipStoreViewAppInfo,     // The app info screen (widget) of the selected app
     FlipStoreViewAppDownload, // The app download screen (widget) of the selected app
     FlipStoreViewAppDelete,   // The app delete screen (DialogEx) of the selected app
@@ -77,9 +89,11 @@ typedef struct
     ViewDispatcher *view_dispatcher; // Switches between our views
     View *view_main;                 // The main screen for downloading apps
     View *view_app_info;             // The app info screen (view) of the selected app
-    Submenu *submenu;                // The submenu (main)
+    Submenu *submenu_main;           // The submenu (main)
     //
-    Submenu *submenu_app_list; // The submenu (app list) for the selected category
+    Submenu *submenu_options;   // The submenu (options)
+    Submenu *submenu_app_list;  // The submenu (app list) for the selected category
+    Submenu *submenu_firmwares; // The submenu (firmwares)
     //
     Submenu *submenu_app_list_bluetooth; // The submenu (app list) for Bluetooth
     Submenu *submenu_app_list_games;     // The submenu (app list) for Games

+ 0 - 1
flipper_http/flipper_http.c

@@ -180,7 +180,6 @@ int32_t flipper_http_worker(void *context)
                     // Write to file if buffer is full
                     if (file_buffer_len >= FILE_BUFFER_SIZE)
                     {
-                        // remove [POST/END] and/or [GET/END] from the file
                         if (!flipper_http_append_to_file(
                                 file_buffer, file_buffer_len, false, fhttp.file_path))
                         {