2024-11-26 17:51:05 +01:00

74 lines
1.5 KiB
C++

#pragma once
#include "app/Manifest.h"
#include "Bundle.h"
#include "Pubsub.h"
#include "service/Manifest.h"
namespace tt::service::loader {
typedef struct Loader Loader;
typedef enum {
LoaderStatusOk,
LoaderStatusErrorAppStarted,
LoaderStatusErrorUnknownApp,
LoaderStatusErrorInternal,
} LoaderStatus;
typedef enum {
LoaderEventTypeApplicationStarted,
LoaderEventTypeApplicationShowing,
LoaderEventTypeApplicationHiding,
LoaderEventTypeApplicationStopped
} LoaderEventType;
typedef struct {
app::App* app;
} LoaderEventAppStarted;
typedef struct {
app::App* app;
} LoaderEventAppShowing;
typedef struct {
app::App* app;
} LoaderEventAppHiding;
typedef struct {
const app::Manifest* manifest;
} LoaderEventAppStopped;
typedef struct {
LoaderEventType type;
union {
LoaderEventAppStarted app_started;
LoaderEventAppShowing app_showing;
LoaderEventAppHiding app_hiding;
LoaderEventAppStopped app_stopped;
};
} LoaderEvent;
/**
* @brief Start an app
* @param[in] id application name or id
* @param[in] blocking application arguments
* @param[in] bundle optional bundle. Ownership is transferred to Loader.
* @return LoaderStatus
*/
LoaderStatus start_app(const std::string& id, bool blocking, const Bundle& bundle);
/**
* @brief Stop the currently showing app. Show the previous app if any app was still running.
*/
void stop_app();
app::App _Nullable get_current_app();
/**
* @brief PubSub for LoaderEvent
*/
PubSub* get_pubsub();
} // namespace