mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-10-17 19:05:07 +00:00
app-module: - Implement `AppStartContext` to reduce amount of `app_start_` and `app_exec` functions: replace them with `app_start_with_context()` - Add support for environment variables when starting apps - Implement support for environment variables for apps graphics-module: - Add this new module - Move font-module code into this module - Implement pixel_buffer apps: - Terminal app: reduce memory usage by only buffering a single row of characters, and try to buffer in IRAM when possible. Implement new pixel_buffer. - App List: Mark apps as favourite to pin them on top. Use touch or press "x" key. - App List: Add toolbar button that shows alert dialog with info about using favourites
85 lines
3.4 KiB
C++
85 lines
3.4 KiB
C++
// SPDX-License-Identifier: Apache-2.0
|
|
#include <app/execute.h>
|
|
|
|
#include <app/loader.h>
|
|
#include <app/location.h>
|
|
#include <app/start.h>
|
|
#include <app/private/manager_internal.h>
|
|
|
|
#include <service/instance.h>
|
|
#include <service/manager.h>
|
|
|
|
namespace {
|
|
|
|
// Same lookup as scheduler.cpp's own (private) find_loader_api() - duplicated rather than
|
|
// shared since it's a handful of lines and neither file depends on the other.
|
|
const char* loader_service_id_for(AppLocationType type) {
|
|
return (type == APP_LOCATION_MEMORY) ? APP_LOADER_MEMORY_SERVICE_ID : APP_LOADER_PATH_SERVICE_ID;
|
|
}
|
|
|
|
const AppLoaderApi* find_loader_api(AppLocationType type) {
|
|
ServiceInstance* instance = service_manager_find_instance(loader_service_id_for(type));
|
|
if (instance == nullptr) {
|
|
return nullptr;
|
|
}
|
|
return static_cast<const AppLoaderApi*>(service_instance_get_data(instance));
|
|
}
|
|
|
|
} // namespace
|
|
|
|
extern "C" {
|
|
|
|
error_t app_execute(AppLocation location, AppStackConfig stack, int argc, const char* const argv[], AppInstanceId* out_app_instance_id) {
|
|
AppStartContext context = app_start_context_for_location(location);
|
|
context.stack = stack;
|
|
app_start_context_set_arguments_ext(&context, argc, argv);
|
|
return app_manager_start_internal(&context, out_app_instance_id);
|
|
}
|
|
|
|
error_t app_execute_for_result(AppLocation location, AppStackConfig stack, int argc, const char* const argv[], AppInstanceId parent_instance_id, AppInstanceId* out_app_instance_id) {
|
|
AppStartContext context = app_start_context_for_location(location);
|
|
context.stack = stack;
|
|
app_start_context_set_arguments_ext(&context, argc, argv);
|
|
app_start_context_set_parent(&context, parent_instance_id);
|
|
return app_manager_start_internal(&context, out_app_instance_id);
|
|
}
|
|
|
|
error_t app_execute_with_streams(AppLocation location, AppStackConfig stack, int argc, const char* const argv[], const AppStreamBinding* bindings, size_t binding_count, AppInstanceId* out_app_instance_id) {
|
|
AppStartContext context = app_start_context_for_location(location);
|
|
context.stack = stack;
|
|
app_start_context_set_arguments_ext(&context, argc, argv);
|
|
app_start_context_set_streams(&context, bindings, binding_count);
|
|
return app_manager_start_internal(&context, out_app_instance_id);
|
|
}
|
|
|
|
error_t app_execute_for_result_with_streams(AppLocation location, AppStackConfig stack, int argc, const char* const argv[], const AppStreamBinding* bindings, size_t binding_count, AppInstanceId parent_instance_id, AppInstanceId* out_app_instance_id) {
|
|
AppStartContext context = app_start_context_for_location(location);
|
|
context.stack = stack;
|
|
app_start_context_set_arguments_ext(&context, argc, argv);
|
|
app_start_context_set_streams(&context, bindings, binding_count);
|
|
app_start_context_set_parent(&context, parent_instance_id);
|
|
return app_manager_start_internal(&context, out_app_instance_id);
|
|
}
|
|
|
|
bool app_is_executable_path(const char* path) {
|
|
const AppLoaderApi* loader = find_loader_api(APP_LOCATION_PATH);
|
|
if (loader == nullptr || loader->is_executable == nullptr) {
|
|
return false;
|
|
}
|
|
AppLocation location = {
|
|
.type = APP_LOCATION_PATH,
|
|
.location = (void*)path,
|
|
};
|
|
return loader->is_executable(location);
|
|
}
|
|
|
|
bool app_is_executable(AppLocation location) {
|
|
const AppLoaderApi* loader = find_loader_api(location.type);
|
|
if (loader == nullptr || loader->is_executable == nullptr) {
|
|
return false;
|
|
}
|
|
return loader->is_executable(location);
|
|
}
|
|
|
|
} // extern "C"
|