2022-09-26 20:55:58 +02:00
|
|
|
#ifndef C_NGC_HS1_H
|
|
|
|
#define C_NGC_HS1_H
|
|
|
|
|
|
|
|
// this is a c header
|
|
|
|
|
|
|
|
// outline:
|
2022-09-28 20:40:49 +02:00
|
|
|
// i am disgusting
|
2022-09-26 20:55:58 +02:00
|
|
|
|
|
|
|
//#include <stdbool.h>
|
|
|
|
//#include <stddef.h>
|
|
|
|
//#include <stdint.h>
|
|
|
|
|
|
|
|
#include <tox/tox.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// copy from tox.h:
|
|
|
|
#ifndef TOX_DEFINED
|
|
|
|
#define TOX_DEFINED
|
|
|
|
typedef struct Tox Tox;
|
|
|
|
#endif /* TOX_DEFINED */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ========== struct / typedef ==========
|
|
|
|
|
|
|
|
typedef struct NGC_HS1 NGC_HS1;
|
|
|
|
|
|
|
|
struct NGC_HS1_options {
|
|
|
|
// (and up)
|
|
|
|
// 0 all
|
|
|
|
// 1 users
|
|
|
|
// 2 mods
|
|
|
|
// 3 founders
|
|
|
|
// 4 no one (above founder)
|
2022-09-29 02:39:54 +02:00
|
|
|
uint8_t default_trust_level /*= 2*/;
|
2022-09-26 20:55:58 +02:00
|
|
|
|
2022-09-30 02:04:25 +02:00
|
|
|
bool record_others;
|
2022-10-01 02:32:34 +02:00
|
|
|
|
|
|
|
float query_interval_per_peer; // 15.f
|
|
|
|
|
|
|
|
size_t last_msg_ids_count; // 5
|
2022-09-26 20:55:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// ========== init / kill ==========
|
|
|
|
// (see tox api)
|
|
|
|
NGC_HS1* NGC_HS1_new(const struct NGC_HS1_options* options);
|
|
|
|
void NGC_HS1_kill(NGC_HS1* ngc_hs1_ctx);
|
|
|
|
|
|
|
|
// ========== iterate ==========
|
|
|
|
void NGC_HS1_iterate(Tox *tox, NGC_HS1* ngc_hs1_ctx/*, void *user_data*/);
|
|
|
|
|
2022-09-30 02:04:25 +02:00
|
|
|
// ========== peer online/offline ==========
|
|
|
|
|
|
|
|
void NGC_HS1_peer_online(Tox* tox, NGC_HS1* ngc_hs1_ctx, uint32_t group_number, uint32_t peer_number, bool online);
|
|
|
|
|
2022-09-26 20:55:58 +02:00
|
|
|
// ========== send ==========
|
|
|
|
|
|
|
|
// shim (same interface)
|
|
|
|
// NGC_HS1_record_own_message()
|
|
|
|
bool NGC_HS1_shim_group_send_message(
|
|
|
|
const Tox *tox,
|
|
|
|
NGC_HS1* ngc_hs1_ctx,
|
|
|
|
|
|
|
|
uint32_t group_number,
|
|
|
|
|
|
|
|
Tox_Message_Type type, const uint8_t *message, size_t length,
|
|
|
|
|
|
|
|
uint32_t *message_id,
|
|
|
|
Tox_Err_Group_Send_Message *error
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// record own msg
|
|
|
|
void NGC_HS1_record_own_message(
|
|
|
|
const Tox *tox,
|
|
|
|
NGC_HS1* ngc_hs1_ctx,
|
|
|
|
|
|
|
|
uint32_t group_number,
|
|
|
|
|
|
|
|
Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id
|
|
|
|
);
|
|
|
|
|
|
|
|
// ========== receive message ==========
|
|
|
|
|
2022-09-30 02:04:25 +02:00
|
|
|
// !!! no shim, whould require global state !!!
|
2022-09-26 20:55:58 +02:00
|
|
|
// shim (same interface)
|
2022-09-28 20:40:49 +02:00
|
|
|
//typedef void tox_group_message_cb(Tox *tox, uint32_t group_number, uint32_t peer_id, Tox_Message_Type type,
|
|
|
|
//const uint8_t *message, size_t length, uint32_t message_id, void *user_data);
|
2022-09-30 02:04:25 +02:00
|
|
|
//void NGC_HS1_callback_group_message(Tox *tox, NGC_HS1* ngc_hs1_ctx, tox_group_message_cb *callback);
|
|
|
|
|
|
|
|
// record others msg
|
|
|
|
void NGC_HS1_record_message(
|
|
|
|
const Tox *tox,
|
|
|
|
NGC_HS1* ngc_hs1_ctx,
|
2022-09-28 20:40:49 +02:00
|
|
|
|
2022-09-30 02:04:25 +02:00
|
|
|
uint32_t group_number,
|
|
|
|
uint32_t peer_number,
|
|
|
|
|
|
|
|
Tox_Message_Type type, const uint8_t *message, size_t length, uint32_t message_id
|
|
|
|
);
|
|
|
|
|
|
|
|
// ========== receive custom ==========
|
|
|
|
|
|
|
|
// "callback"
|
|
|
|
void NGC_HS1_handle_group_custom_packet(
|
|
|
|
Tox* tox,
|
|
|
|
NGC_HS1* ngc_hs1_ctx,
|
|
|
|
|
|
|
|
uint32_t group_number,
|
|
|
|
uint32_t peer_number,
|
|
|
|
|
|
|
|
const uint8_t *data,
|
|
|
|
size_t length
|
|
|
|
//void *user_data
|
|
|
|
);
|
2022-09-26 20:55:58 +02:00
|
|
|
|
|
|
|
// ========== receive request ==========
|
|
|
|
|
2022-09-30 02:04:25 +02:00
|
|
|
//void NGC_HS1_custom_packet(
|
|
|
|
|
2022-09-26 20:55:58 +02:00
|
|
|
// ========== receive answer ==========
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // C_NGC_HS1_H
|
|
|
|
|