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.
45 lines
1.6 KiB
45 lines
1.6 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] */ |
|
#define GUI_EVT_NEW_PEER 3 /* data: [node_id:8] */ |
|
#define GUI_EVT_CHANNEL_UPDATED 4 /* data: [ch_id_len:1][ch_id:var] */ |
|
|
|
/* ── 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); |
|
|
|
/* Callback для результатов подключения (вызывается из GUI-потока) */ |
|
typedef void (*gui_connect_result_fn)(uint64_t node_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); |
|
|
|
#ifdef __cplusplus |
|
} |
|
#endif |
|
#endif /* GUI_BRIDGE_H */
|
|
|