67 lines
2.1 KiB
C
67 lines
2.1 KiB
C
#ifndef CHAT_SYNC_H
|
|
#define CHAT_SYNC_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <stddef.h>
|
|
|
|
struct UTUN_INSTANCE;
|
|
struct UASYNC;
|
|
|
|
/* etcp_router service ID */
|
|
#define ETCP_RT_ID_CHAT_SYNC 0x30
|
|
#define ETCP_RT_ID_MEMBER_SYNC 0x31
|
|
|
|
/* 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
|
|
#define CS_MSG_ERROR 0x07
|
|
#define CS_MSG_CHANNEL_INFO_REQ 0x09
|
|
#define CS_MSG_CHANNEL_INFO_RESP 0x0A
|
|
#define CS_MSG_CHANNEL_JOIN 0x0B
|
|
#define CS_MSG_WELCOME 0x0C
|
|
#define CS_MSG_PEER_UPSERT 0x0D
|
|
#define CS_MSG_PEER_REMOVE 0x0E
|
|
|
|
/* 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 channel_id, uint64_t node_id,
|
|
const uint8_t* pubkey_bin,
|
|
const uint8_t* addrs_data, int addr_count);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif /* CHAT_SYNC_H */
|