mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-27 06:50:21 +00:00
f4122a924a
* Abstract primitive type from main logic in FuriEventLoop * Remove message_queue_i.h * Add stream buffer support for event loop * Add semaphore support for event loop * Add temporary unit test workaround * Make the linter happy * Add mutex support for event loop * Implement event subscription and unsubscription while the event loop is running * Implement edge events * Fix leftover logical errors * Add event loop timer example application * Implement flag-based edge trigger and one-shot mode * Add event loop mutex example application * Only notify the event loop if stream buffer is at or above its trigger level * Reformat comments * Add event loop stream buffer example application * Add event loop multiple elements example application * Improve event loop flag names * Remove redundant signal handler as it is already handled by the event loop * Refactor Power service, improve ViewHolder * Use ViewHolder instead of ViewDispatcher in About app * Enable ViewDispatcher queue on construction, deprecate view_dispatcher_enable_queue() * Remove all invocations of view_dispatcher_enable_queue() * Remove app-scened-template * Remove missing library from target.json * Port Accessor app to ViewHolder * Make the linter happy * Add example_view_holder application, update ViewHolder docs * Add example_view_dispatcher application, update ViewDispatcher docs * Replace FuriSemaphore with FuriApiLock, remove workaround delay * Fix logical error * Fix another logical error * Use the sources directive to speed up compilation * Use constant define macro * Improve FuriEventLoop documentation * Improve FuriEventLoop documentation once more * Bump API Version * Gui: remove redundant checks from ViewDispatcher * Gui: remove dead ifs from ViewDispatcher Co-authored-by: Silent <CookiePLMonster@users.noreply.github.com> Co-authored-by: hedger <hedger@users.noreply.github.com> Co-authored-by: あく <alleteam@gmail.com>
65 lines
2.2 KiB
C
65 lines
2.2 KiB
C
#include "dialogs_message.h"
|
|
#include <gui/modules/file_browser.h>
|
|
#include <toolbox/api_lock.h>
|
|
|
|
typedef struct {
|
|
FuriApiLock lock;
|
|
bool result;
|
|
} DialogsAppFileBrowserContext;
|
|
|
|
static void dialogs_app_file_browser_back_callback(void* context) {
|
|
furi_assert(context);
|
|
DialogsAppFileBrowserContext* file_browser_context = context;
|
|
file_browser_context->result = false;
|
|
api_lock_unlock(file_browser_context->lock);
|
|
}
|
|
|
|
static void dialogs_app_file_browser_callback(void* context) {
|
|
furi_assert(context);
|
|
DialogsAppFileBrowserContext* file_browser_context = context;
|
|
file_browser_context->result = true;
|
|
api_lock_unlock(file_browser_context->lock);
|
|
}
|
|
|
|
bool dialogs_app_process_module_file_browser(const DialogsAppMessageDataFileBrowser* data) {
|
|
bool ret = false;
|
|
Gui* gui = furi_record_open(RECORD_GUI);
|
|
|
|
DialogsAppFileBrowserContext* file_browser_context =
|
|
malloc(sizeof(DialogsAppFileBrowserContext));
|
|
file_browser_context->lock = api_lock_alloc_locked();
|
|
|
|
ViewHolder* view_holder = view_holder_alloc();
|
|
view_holder_attach_to_gui(view_holder, gui);
|
|
view_holder_set_back_callback(
|
|
view_holder, dialogs_app_file_browser_back_callback, file_browser_context);
|
|
|
|
FileBrowser* file_browser = file_browser_alloc(data->result_path);
|
|
file_browser_set_callback(
|
|
file_browser, dialogs_app_file_browser_callback, file_browser_context);
|
|
file_browser_configure(
|
|
file_browser,
|
|
data->extension,
|
|
data->base_path,
|
|
data->skip_assets,
|
|
data->hide_dot_files,
|
|
data->file_icon,
|
|
data->hide_ext);
|
|
file_browser_set_item_callback(file_browser, data->item_callback, data->item_callback_context);
|
|
file_browser_start(file_browser, data->preselected_filename);
|
|
|
|
view_holder_set_view(view_holder, file_browser_get_view(file_browser));
|
|
api_lock_wait_unlock(file_browser_context->lock);
|
|
|
|
ret = file_browser_context->result;
|
|
|
|
view_holder_set_view(view_holder, NULL);
|
|
view_holder_free(view_holder);
|
|
file_browser_stop(file_browser);
|
|
file_browser_free(file_browser);
|
|
api_lock_free(file_browser_context->lock);
|
|
free(file_browser_context);
|
|
furi_record_close(RECORD_GUI);
|
|
|
|
return ret;
|
|
}
|