M*LIB: non-inlined strings, FuriString primitive (#1795)

* Quicksave 1
* Header stage complete
* Source stage complete
* Lint & merge fixes
* Includes
* Documentation step 1
* FBT: output free size considering BT STACK
* Documentation step 2
* py lint
* Fix music player plugin
* unit test stage 1: string allocator, mem, getters, setters, appends, compare, search.
* unit test: string equality
* unit test: string replace
* unit test: string start_with, end_with
* unit test: string trim
* unit test: utf-8
* Rename
* Revert fw_size changes
* Simplify CLI backspace handling
* Simplify CLI character insert
* Merge fixes
* Furi: correct filenaming and spelling
* Bt: remove furi string include

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Sergey Gavrilov
2022-10-06 01:15:23 +10:00
committed by GitHub
parent 0f9ea925d3
commit 4bf29827f8
370 changed files with 5597 additions and 3963 deletions

View File

@@ -14,21 +14,24 @@ typedef struct {
Storage* storage;
DialogsApp* dialogs;
Gui* gui;
string_t fap_path;
FuriString* fap_path;
ViewDispatcher* view_dispatcher;
Loading* loading;
} FapLoader;
static bool
fap_loader_item_callback(string_t path, void* context, uint8_t** icon_ptr, string_t item_name) {
static bool fap_loader_item_callback(
FuriString* path,
void* context,
uint8_t** icon_ptr,
FuriString* item_name) {
FapLoader* loader = context;
furi_assert(loader);
FlipperApplication* app = flipper_application_alloc(loader->storage, &hashtable_api_interface);
FlipperApplicationPreloadStatus preload_res =
flipper_application_preload_manifest(app, string_get_cstr(path));
flipper_application_preload_manifest(app, furi_string_get_cstr(path));
bool load_success = false;
@@ -37,10 +40,10 @@ static bool
if(manifest->has_icon) {
memcpy(*icon_ptr, manifest->icon, FAP_MANIFEST_MAX_ICON_SIZE);
}
string_set_str(item_name, manifest->name);
furi_string_set(item_name, manifest->name);
load_success = true;
} else {
FURI_LOG_E(TAG, "FAP Loader failed to preload %s", string_get_cstr(path));
FURI_LOG_E(TAG, "FAP Loader failed to preload %s", furi_string_get_cstr(path));
load_success = false;
}
@@ -51,9 +54,9 @@ static bool
static bool fap_loader_run_selected_app(FapLoader* loader) {
furi_assert(loader);
string_t error_message;
FuriString* error_message;
string_init_set(error_message, "unknown error");
error_message = furi_string_alloc_set("unknown error");
bool file_selected = false;
bool show_error = true;
@@ -61,17 +64,17 @@ static bool fap_loader_run_selected_app(FapLoader* loader) {
file_selected = true;
loader->app = flipper_application_alloc(loader->storage, &hashtable_api_interface);
FURI_LOG_I(TAG, "FAP Loader is loading %s", string_get_cstr(loader->fap_path));
FURI_LOG_I(TAG, "FAP Loader is loading %s", furi_string_get_cstr(loader->fap_path));
FlipperApplicationPreloadStatus preload_res =
flipper_application_preload(loader->app, string_get_cstr(loader->fap_path));
flipper_application_preload(loader->app, furi_string_get_cstr(loader->fap_path));
if(preload_res != FlipperApplicationPreloadStatusSuccess) {
const char* err_msg = flipper_application_preload_status_to_string(preload_res);
string_printf(error_message, "Preload failed: %s", err_msg);
furi_string_printf(error_message, "Preload failed: %s", err_msg);
FURI_LOG_E(
TAG,
"FAP Loader failed to preload %s: %s",
string_get_cstr(loader->fap_path),
furi_string_get_cstr(loader->fap_path),
err_msg);
break;
}
@@ -80,11 +83,11 @@ static bool fap_loader_run_selected_app(FapLoader* loader) {
FlipperApplicationLoadStatus load_status = flipper_application_map_to_memory(loader->app);
if(load_status != FlipperApplicationLoadStatusSuccess) {
const char* err_msg = flipper_application_load_status_to_string(load_status);
string_printf(error_message, "Load failed: %s", err_msg);
furi_string_printf(error_message, "Load failed: %s", err_msg);
FURI_LOG_E(
TAG,
"FAP Loader failed to map to memory %s: %s",
string_get_cstr(loader->fap_path),
furi_string_get_cstr(loader->fap_path),
err_msg);
break;
}
@@ -106,19 +109,19 @@ static bool fap_loader_run_selected_app(FapLoader* loader) {
dialog_message_set_header(message, "Error", 64, 0, AlignCenter, AlignTop);
dialog_message_set_buttons(message, NULL, NULL, NULL);
string_t buffer;
string_init(buffer);
string_printf(buffer, "%s", string_get_cstr(error_message));
string_replace_str(buffer, ":", "\n");
FuriString* buffer;
buffer = furi_string_alloc();
furi_string_printf(buffer, "%s", furi_string_get_cstr(error_message));
furi_string_replace(buffer, ":", "\n");
dialog_message_set_text(
message, string_get_cstr(buffer), 64, 32, AlignCenter, AlignCenter);
message, furi_string_get_cstr(buffer), 64, 32, AlignCenter, AlignCenter);
dialog_message_show(loader->dialogs, message);
dialog_message_free(message);
string_clear(buffer);
furi_string_free(buffer);
}
string_clear(error_message);
furi_string_free(error_message);
if(file_selected) {
flipper_application_free(loader->app);
@@ -155,10 +158,10 @@ int32_t fap_loader_app(void* p) {
view_dispatcher_add_view(loader->view_dispatcher, 0, loading_get_view(loader->loading));
if(p) {
string_init_set(loader->fap_path, (const char*)p);
loader->fap_path = furi_string_alloc_set((const char*)p);
fap_loader_run_selected_app(loader);
} else {
string_init_set(loader->fap_path, EXT_PATH("apps"));
loader->fap_path = furi_string_alloc_set(EXT_PATH("apps"));
while(fap_loader_select_app(loader)) {
view_dispatcher_switch_to_view(loader->view_dispatcher, 0);
@@ -170,7 +173,7 @@ int32_t fap_loader_app(void* p) {
loading_free(loader->loading);
view_dispatcher_free(loader->view_dispatcher);
string_clear(loader->fap_path);
furi_string_free(loader->fap_path);
furi_record_close(RECORD_GUI);
furi_record_close(RECORD_DIALOGS);
furi_record_close(RECORD_STORAGE);