#ifndef CHAT_SYNC_H #define CHAT_SYNC_H #ifdef __cplusplus extern "C" { #endif #include #include struct UTUN_INSTANCE; struct UASYNC; /* etcp_router service ID */ #define ETCP_RT_ID_CHAT_SYNC 0x30 /* Message types */ #define CS_MSG_INIT_SYNC 0x01 #define CS_MSG_INIT_RESP 0x02 #define CS_MSG_SEND_DATA 0x03 #define CS_MSG_PUSH 0x04 #define CS_MSG_ACK_PUSH 0x05 #define CS_MSG_SYNC_DONE 0x06 /* Protocol constants */ #define CS_SEND_DATA_MAX 32 #define CS_MAX_SPARSE 16 #define CS_PEER_TIMEOUT_MS 5000 /* Sync states per channel */ #define CS_SYNC_NONE 0 #define CS_SYNC_IN_PROGRESS 1 #define CS_SYNC_DONE 2 /* ── Public API ── */ int chat_sync_init(struct UTUN_INSTANCE* inst, void (*gui_result_cb)(void*, int, const uint8_t*, int)); void chat_sync_destroy(struct UTUN_INSTANCE* inst); /* Вызывается из GUI (через gui_bridge_post_uasync) при отправке */ int chat_sync_push(struct UTUN_INSTANCE* inst, const char* channel_id, uint64_t node_id, const char* content_type, const uint8_t* data, uint32_t data_len, uint64_t timestamp, uint64_t datahash); /* Прослойка conn_mgr: загрузить nodeinfo из БД и подключиться */ void chat_sync_connect_node(struct UTUN_INSTANCE* inst, uint64_t node_id); /* Подключиться к пиру по данным invite-ссылки (вызывается из GUI-потока) */ void chat_sync_connect_from_invite(uint64_t node_id, const uint8_t* pubkey_bin, const uint8_t* addrs_data, int addr_count, const uint8_t* channel_id, int ch_id_len); #ifdef __cplusplus } #endif #endif /* CHAT_SYNC_H */