diff --git a/CMakeLists.txt b/CMakeLists.txt index e50ab5e..80e5d3e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,8 +124,8 @@ endif() add_library(solanaceae_ngchs2 ./solanaceae/ngc_hs2/ts_find_start.hpp - ./solanaceae/ngc_hs2/ngc_hs2_send.hpp - ./solanaceae/ngc_hs2/ngc_hs2_send.cpp + ./solanaceae/ngc_hs2/ngc_hs2_sigma.hpp + ./solanaceae/ngc_hs2/ngc_hs2_sigma.cpp #./solanaceae/ngc_hs2/ngc_hs2_recv.hpp #./solanaceae/ngc_hs2/ngc_hs2_recv.cpp diff --git a/solanaceae/ngc_hs2/ngc_hs2_send.cpp b/solanaceae/ngc_hs2/ngc_hs2_sigma.cpp similarity index 83% rename from solanaceae/ngc_hs2/ngc_hs2_send.cpp rename to solanaceae/ngc_hs2/ngc_hs2_sigma.cpp index 64ca69e..758fbe9 100644 --- a/solanaceae/ngc_hs2/ngc_hs2_send.cpp +++ b/solanaceae/ngc_hs2/ngc_hs2_sigma.cpp @@ -1,4 +1,4 @@ -#include "./ngc_hs2_send.hpp" +#include "./ngc_hs2_sigma.hpp" #include @@ -39,7 +39,7 @@ void IncommingTimeRangeRequestQueue::queueRequest(const TimeRangeRequest& new_re } // Components -NGCHS2Send::NGCHS2Send( +NGCHS2Sigma::NGCHS2Sigma( Contact3Registry& cr, RegistryMessageModelI& rmm, ToxContactModel2& tcm, @@ -58,10 +58,10 @@ NGCHS2Send::NGCHS2Send( ; } -NGCHS2Send::~NGCHS2Send(void) { +NGCHS2Sigma::~NGCHS2Sigma(void) { } -float NGCHS2Send::iterate(float delta) { +float NGCHS2Sigma::iterate(float delta) { // limit how often we update here (new fts usually) if (_iterate_heat > 0.f) { _iterate_heat -= delta; @@ -147,7 +147,7 @@ float NGCHS2Send::iterate(float delta) { } } for (const auto it : to_remove) { - std::cout << "NGCHS2Send warning: timed out ." << (int)it << "\n"; + std::cout << "NGCHS2Sigma warning: timed out ." << (int)it << "\n"; // TODO: need a way to tell ft? irr._list.erase(it); // technically we are not supposed to timeout and instead rely on the done event @@ -173,15 +173,15 @@ static uint64_t deserlSimpleType(ByteSpan bytes) { return value; } -static uint32_t deserlMID(ByteSpan mid_bytes) { - return deserlSimpleType(mid_bytes); -} +//static uint32_t deserlMID(ByteSpan mid_bytes) { +// return deserlSimpleType(mid_bytes); +//} static uint64_t deserlTS(ByteSpan ts_bytes) { return deserlSimpleType(ts_bytes); } -void NGCHS2Send::handleTimeRange(Contact3Handle c, const Events::NGCFT1_recv_request& e) { +void NGCHS2Sigma::handleTimeRange(Contact3Handle c, const Events::NGCFT1_recv_request& e) { ByteSpan fid{e.file_id, e.file_id_size}; // TODO: better size check if (fid.size != sizeof(uint64_t)+sizeof(uint64_t)) { @@ -213,50 +213,7 @@ void NGCHS2Send::handleTimeRange(Contact3Handle c, const Events::NGCFT1_recv_req ); } -#if 0 -void NGCHS2Send::handleSingleMessage(Contact3Handle c, const Events::NGCFT1_recv_request& e) { - ByteSpan fid{e.file_id, e.file_id_size}; - // TODO: better size check - if (fid.size != 32+sizeof(uint32_t)+sizeof(uint64_t)) { - std::cerr << "NGCHS2S error: singlemessage not lange enough\n"; - return; - } - - ByteSpan ppk; - uint32_t mid {0}; - uint64_t ts {0}; // deciseconds - - // parse - try { - // - ppk - // TOX_GROUP_PEER_PUBLIC_KEY_SIZE (32) - ppk = {fid.ptr, 32}; - - // - mid - ByteSpan mid_bytes{fid.ptr+ppk.size, sizeof(uint32_t)}; - mid = deserlMID(mid_bytes); - - // - ts - ByteSpan ts_bytes{mid_bytes.ptr+mid_bytes.size, sizeof(uint64_t)}; - ts = deserlTS(ts_bytes); - } catch (...) { - std::cerr << "NGCHS2S error: failed to parse singlemessage\n"; - return; - } - - - // for queue, we need group, peer, msg_ppk, msg_mid, msg_ts - - // dedupe insert into queue - c.get_or_emplace().queueRequest({ - ppk, - mid, - ts, - }); -} -#endif - -std::vector NGCHS2Send::buildChatLogFileRange(Contact3Handle c, uint64_t ts_start, uint64_t ts_end) { +std::vector NGCHS2Sigma::buildChatLogFileRange(Contact3Handle c, uint64_t ts_start, uint64_t ts_end) { const Message3Registry* reg_ptr = static_cast(_rmm).get(c); if (reg_ptr == nullptr) { return {}; @@ -368,19 +325,19 @@ std::vector NGCHS2Send::buildChatLogFileRange(Contact3Handle c, uint64_ return nlohmann::json::to_msgpack(j_array); } -bool NGCHS2Send::onEvent(const Message::Events::MessageConstruct&) { +bool NGCHS2Sigma::onEvent(const Message::Events::MessageConstruct&) { return false; } -bool NGCHS2Send::onEvent(const Message::Events::MessageUpdated&) { +bool NGCHS2Sigma::onEvent(const Message::Events::MessageUpdated&) { return false; } -bool NGCHS2Send::onEvent(const Message::Events::MessageDestory&) { +bool NGCHS2Sigma::onEvent(const Message::Events::MessageDestory&) { return false; } -bool NGCHS2Send::onEvent(const Events::NGCFT1_recv_request& e) { +bool NGCHS2Sigma::onEvent(const Events::NGCFT1_recv_request& e) { if ( e.file_kind != NGCFT1_file_kind::HS2_RANGE_TIME_MSGPACK ) { @@ -415,7 +372,7 @@ bool NGCHS2Send::onEvent(const Events::NGCFT1_recv_request& e) { return true; } -bool NGCHS2Send::onEvent(const Events::NGCFT1_send_data& e) { +bool NGCHS2Sigma::onEvent(const Events::NGCFT1_send_data& e) { auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number); if (!c) { return false; @@ -432,7 +389,7 @@ bool NGCHS2Send::onEvent(const Events::NGCFT1_send_data& e) { auto& transfer = irr._list.at(e.transfer_id); if (transfer.data.size() < e.data_offset+e.data_size) { - std::cerr << "NGCHS2Send error: ft send data larger then file???\n"; + std::cerr << "NGCHS2Sigma error: ft send data larger then file???\n"; assert(false && "how"); } std::memcpy(e.data, transfer.data.data()+e.data_offset, e.data_size); @@ -441,7 +398,7 @@ bool NGCHS2Send::onEvent(const Events::NGCFT1_send_data& e) { return true; } -bool NGCHS2Send::onEvent(const Events::NGCFT1_send_done& e) { +bool NGCHS2Sigma::onEvent(const Events::NGCFT1_send_done& e) { auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number); if (!c) { return false; @@ -459,7 +416,7 @@ bool NGCHS2Send::onEvent(const Events::NGCFT1_send_done& e) { irr._list.erase(e.transfer_id); // TODO: check if we completed it - std::cout << "NGCHS2Send: sent chatlog to " << e.group_number << ":" << e.peer_number << "." << (int)e.transfer_id << "\n"; + std::cout << "NGCHS2Sigma: sent chatlog to " << e.group_number << ":" << e.peer_number << "." << (int)e.transfer_id << "\n"; return true; } diff --git a/solanaceae/ngc_hs2/ngc_hs2_send.hpp b/solanaceae/ngc_hs2/ngc_hs2_sigma.hpp similarity index 95% rename from solanaceae/ngc_hs2/ngc_hs2_send.hpp rename to solanaceae/ngc_hs2/ngc_hs2_sigma.hpp index c1a0b1a..9750899 100644 --- a/solanaceae/ngc_hs2/ngc_hs2_send.hpp +++ b/solanaceae/ngc_hs2/ngc_hs2_sigma.hpp @@ -47,7 +47,7 @@ namespace Components { }; } // Components -class NGCHS2Send : public RegistryMessageModelEventI, public NGCFT1EventI { +class NGCHS2Sigma : public RegistryMessageModelEventI, public NGCFT1EventI { Contact3Registry& _cr; RegistryMessageModelI& _rmm; ToxContactModel2& _tcm; @@ -72,14 +72,14 @@ class NGCHS2Send : public RegistryMessageModelEventI, public NGCFT1EventI { constexpr static int64_t _max_time_into_past_default {60*15}; // s public: - NGCHS2Send( + NGCHS2Sigma( Contact3Registry& cr, RegistryMessageModelI& rmm, ToxContactModel2& tcm, NGCFT1& nf ); - ~NGCHS2Send(void); + ~NGCHS2Sigma(void); float iterate(float delta);