You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
4.1 KiB
83 lines
4.1 KiB
#ifndef GUI_BRIDGE_H |
|
#define GUI_BRIDGE_H |
|
|
|
#ifdef __cplusplus |
|
extern "C" { |
|
#endif |
|
|
|
#include <stdint.h> |
|
#include <stddef.h> |
|
|
|
struct UASYNC; |
|
|
|
/* ── Типы уведомлений uasync→GUI (fire-and-forget) ── */ |
|
|
|
#define GUI_EVT_MSG_RECEIVED 1 /* data: [ch_id_len:1][ch_id:var] */ |
|
#define GUI_EVT_CONNECT_RESULT 2 /* data: [node_id:8][result:4][channel_id:8] */ |
|
#define GUI_EVT_NEW_PEER 3 /* data: [node_id:8] */ |
|
#define GUI_EVT_CHANNEL_UPDATED 4 /* data: [ch_id_len:1][ch_id:var] */ |
|
#define GUI_EVT_MEMBERS_CHANGED 5 /* data: [ch_id_len:1][ch_id:var] */ |
|
#define GUI_EVT_MY_NODE_ID 6 /* data: [node_id:8] */ |
|
#define GUI_EVT_AUTO_CONNECT_STATUS 7 /* data: [status:1][total_tried:2][node_count:2][success:2] */ |
|
#define GUI_EVT_CHANNEL_PEERS_ONLINE 8 /* data: [ch_id_len:1][ch_id:var][online_count:2] */ |
|
#define GUI_EVT_DB_READY 9 /* data: none — DB is open, tables created */ |
|
#define GUI_EVT_STATUS_REFRESH 10 /* data: status text (null-terminated string) */ |
|
|
|
/* ── API ── */ |
|
|
|
/* Инициализация моста (вызывается из GUI при старте) */ |
|
void gui_bridge_init(void); |
|
|
|
/* Установить uasync (вызывается из UtunNode после создания ua) */ |
|
void gui_bridge_set_uasync(struct UASYNC* ua); |
|
|
|
/* uasync → GUI: уведомление (fire-and-forget, через Qt::QueuedConnection) */ |
|
void gui_bridge_post(int event_type, const uint8_t* data, int data_len); |
|
|
|
/* GUI → uasync: выполнить функцию в uasync-потоке */ |
|
void gui_bridge_post_uasync_fn(void (*fn)(void*), void* arg); |
|
|
|
/* Проверить готовность uasync (g_ua != NULL) */ |
|
int gui_bridge_is_uasync_ready(void); |
|
|
|
/* Callback для результатов подключения (вызывается из GUI-потока) */ |
|
typedef void (*gui_connect_result_fn)(uint64_t node_id, uint64_t channel_id, int result); |
|
void gui_bridge_set_connect_result_cb(gui_connect_result_fn cb); |
|
|
|
/* Callback для входящих сообщений (вызывается из GUI-потока) */ |
|
typedef void (*gui_msg_received_fn)(const char* ch_id, int ch_id_len); |
|
void gui_bridge_set_msg_received_cb(gui_msg_received_fn cb); |
|
|
|
/* Callback для обновления канала (вызывается из GUI-потока) */ |
|
typedef void (*gui_channel_updated_fn)(const char* ch_id, int ch_id_len); |
|
void gui_bridge_set_channel_updated_cb(gui_channel_updated_fn cb); |
|
|
|
/* Callback для изменения списка участников (вызывается из GUI-потока) */ |
|
typedef void (*gui_members_changed_fn)(const char* ch_id, int ch_id_len); |
|
void gui_bridge_set_members_changed_cb(gui_members_changed_fn cb); |
|
|
|
/* Callback для получения своего node_id после инициализации uTun */ |
|
typedef void (*gui_my_node_id_fn)(uint64_t node_id); |
|
void gui_bridge_set_my_node_id_cb(gui_my_node_id_fn cb); |
|
|
|
/* Callback для статуса авто-подключения (вызывается из GUI-потока) |
|
* status: 0=in_progress, 1=done(3+), 2=stopped */ |
|
typedef void (*gui_auto_connect_status_fn)(uint8_t status, uint16_t total_tried, uint16_t node_count, uint16_t connected); |
|
void gui_bridge_set_auto_connect_status_cb(gui_auto_connect_status_fn cb); |
|
|
|
/* Callback для обновления числа онлайн-пиров канала (вызывается из GUI-потока) */ |
|
typedef void (*gui_channel_peers_online_fn)(const char* ch_id, int ch_id_len, uint16_t online_count); |
|
void gui_bridge_set_channel_peers_online_cb(gui_channel_peers_online_fn cb); |
|
|
|
/* Callback: DB открыта, таблицы созданы, можно загружать данные (вызывается из GUI-потока) */ |
|
typedef void (*gui_db_ready_fn)(void); |
|
void gui_bridge_set_db_ready_cb(gui_db_ready_fn cb); |
|
|
|
/* Callback для обновления статуса (NTP + connections) — text без \0, вызывается из GUI-потока */ |
|
typedef void (*gui_status_refresh_fn)(const char* text, int len); |
|
void gui_bridge_set_status_refresh_cb(gui_status_refresh_fn cb); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
#endif /* GUI_BRIDGE_H */
|
|
|