commit c2f56539389bb708353b5b057135b8e341912c1c Author: Green Sky Date: Mon Sep 26 20:55:58 2022 +0200 init diff --git a/ngc_hs1.c b/ngc_hs1.c new file mode 100644 index 0000000..9bf51ac --- /dev/null +++ b/ngc_hs1.c @@ -0,0 +1,65 @@ +#include "./ngc_hs1.h" + +#include + +struct NGC_HS1 { + void* temp; + + NGC_HS1_options options; + + // key - key - value store + // peer pubkey - msg_id - message(type + text) +}; + +NGC_HS1* NGC_HS1_new(const struct NGC_HS1_options* options) { + NGC_HS1* context = malloc(sizeof(NGC_HS1)); + + context->options = *options; + + return context; +} + +void NGC_HS1_kill(NGC_HS1* ngc_hs1_ctx) { + free(ngc_hs1_ctx); +} + +void NGC_HS1_iterate(Tox *tox, NGC_HS1* ngc_hs1_ctx/*, void *user_data*/) { +} + +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 +) { + uint32_t* msg_id_ptr = message_id; + uint32_t msg_id_placeholder = 0; + if (msg_id_ptr == NULL) { + msg_id_ptr = &msg_id_placeholder; + } + + bool ret = tox_group_send_message(tox, group_number, type, message, length, msg_id_ptr, error); + + NGC_HS1_record_own_message(tox, group_number, type, message, length, *msg_id_ptr); + + return ret; +} + + +// 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 +) { + printf("record_own_message %u\n", message_id); +} + diff --git a/ngc_hs1.h b/ngc_hs1.h new file mode 100644 index 0000000..8f942f9 --- /dev/null +++ b/ngc_hs1.h @@ -0,0 +1,95 @@ +#ifndef C_NGC_HS1_H +#define C_NGC_HS1_H + +// this is a c header + +// outline: +// + +//#include +//#include +//#include + +#include + +#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) + uint8_t default_trust_level = 2; + + //bool test; +}; + +// ========== 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*/); + +// ========== 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 ========== + +// shim (same interface) + +// ========== receive request ========== + +// ========== receive answer ========== + +#ifdef __cplusplus +} +#endif + +#endif // C_NGC_HS1_H +