This repository has been archived on 2023-01-13. You can view files and clone it, but cannot push or open issues or pull requests.
NGC_HS1/ngc_ft1.h

109 lines
2.8 KiB
C
Raw Normal View History

2022-10-03 01:15:49 +02:00
#ifndef C_NGC_FT1_H
#define C_NGC_FT1_H
// this is a c header
#include <tox/tox.h>
#include "ngc_ext_common.h"
2022-10-03 01:15:49 +02:00
#ifdef __cplusplus
extern "C" {
#endif
// ========== struct / typedef ==========
typedef struct NGC_FT1 NGC_FT1;
struct NGC_FT1_options {
int tmp;
};
2022-10-03 23:33:08 +02:00
// uint16_t ?
// ffs c does not allow types
typedef enum NGC_FT1_file_kind /*: uint8_t*/ {
//INVALID = 0u,
// id:
// group (implicit)
// peer pub key + msg_id
NGC_HS1_MESSAGE_BY_ID = 1u, // history sync PoC 1
// :)
// draft for fun and profit
2022-10-06 02:24:23 +02:00
// TODO: should we even support v1?
// TODO: design the same thing again for tox? (msg_pack instead of bencode?)
2022-10-03 23:33:08 +02:00
// id: infohash
2022-10-06 02:24:23 +02:00
TORRENT_V1_METAINFO = 8u,
2022-10-03 23:33:08 +02:00
// id: sha1
TORRENT_V1_CHUNK,
2022-10-06 02:24:23 +02:00
// id: infohash
TORRENT_V2_METAINFO,
2022-10-03 23:33:08 +02:00
// id: sha256
TORRENT_V2_CHUNK,
} NGC_FT1_file_kind;
2022-10-03 01:15:49 +02:00
// ========== init / kill ==========
// (see tox api)
bool NGC_FT1_init(NGC_EXT_CTX* ngc_ext_ctx, const struct NGC_FT1_options* options);
void NGC_FT1_kill(NGC_EXT_CTX* ngc_ext_ctx);
// ========== iterate ==========
2022-10-03 23:33:08 +02:00
void NGC_FT1_iterate(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx/*, void *user_data*/);
// ========== request ==========
// TODO: remove?
void NGC_FT1_request(
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
uint32_t group_number,
NGC_FT1_file_kind file_kind,
2022-10-06 02:24:23 +02:00
const uint8_t* file_id, size_t file_id_size
2022-10-03 23:33:08 +02:00
);
2022-10-06 02:24:23 +02:00
void NGC_FT1_send_request_private(
2022-10-03 23:33:08 +02:00
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
2022-10-06 02:24:23 +02:00
uint32_t group_number, uint32_t peer_number,
NGC_FT1_file_kind file_kind,
const uint8_t* file_id, size_t file_id_size
);
2022-10-03 23:33:08 +02:00
2022-10-06 02:24:23 +02:00
typedef void NGC_FT1_recv_request_cb(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_number, uint32_t peer_number, const uint8_t* file_id, size_t file_id_size);
2022-10-03 23:33:08 +02:00
2022-10-06 02:24:23 +02:00
void NGC_FT1_register_callback_recv_request(NGC_EXT_CTX* ngc_ext_ctx, NGC_FT1_file_kind file_kind, NGC_FT1_recv_request_cb* callback);
// ========== send/accept ==========
2022-10-03 23:33:08 +02:00
2022-10-06 02:24:23 +02:00
bool NGC_FT1_send_init_private(
Tox *tox, NGC_EXT_CTX* ngc_ext_ctx,
uint32_t group_number, uint32_t peer_number,
NGC_FT1_file_kind file_kind,
const uint8_t* file_id, size_t file_id_size,
size_t file_size
2022-10-03 23:33:08 +02:00
);
2022-10-03 01:15:49 +02:00
2022-10-06 02:24:23 +02:00
// return true to accept, false to deny
typedef bool NGC_FT1_recv_init_cb(Tox *tox, NGC_EXT_CTX* ngc_ext_ctx, uint32_t group_number, uint32_t peer_number, const uint8_t* file_id, size_t file_id_size, const uint8_t transfer_id, const size_t file_size);
2022-10-03 01:15:49 +02:00
2022-10-06 02:24:23 +02:00
void NGC_FT1_register_callback_recv_init(NGC_EXT_CTX* ngc_ext_ctx, NGC_FT1_file_kind file_kind, NGC_FT1_recv_init_cb* callback);
// ========== peer online/offline ==========
2022-10-03 01:15:49 +02:00
//void NGC_FT1_peer_online(Tox* tox, NGC_FT1* ngc_hs1_ctx, uint32_t group_number, uint32_t peer_number, bool online);
// "callback"
void NGC_FT1_handle_group_custom_packet(
2022-10-06 02:24:23 +02:00
Tox* tox, NGC_FT1* ngc_hs1_ctx,
uint32_t group_number, uint32_t peer_number,
const uint8_t *data, size_t length
2022-10-03 01:15:49 +02:00
//void *user_data
);
#ifdef __cplusplus
}
#endif
#endif // C_NGC_FT1_H