start with receiving file message
This commit is contained in:
parent
05d55139f5
commit
c61824d95f
@ -109,6 +109,7 @@ SHA1_NGCFT1::SHA1_NGCFT1(
|
|||||||
_nft.subscribe(this, NGCFT1_Event::send_data);
|
_nft.subscribe(this, NGCFT1_Event::send_data);
|
||||||
_nft.subscribe(this, NGCFT1_Event::recv_done);
|
_nft.subscribe(this, NGCFT1_Event::recv_done);
|
||||||
_nft.subscribe(this, NGCFT1_Event::send_done);
|
_nft.subscribe(this, NGCFT1_Event::send_done);
|
||||||
|
_nft.subscribe(this, NGCFT1_Event::recv_message);
|
||||||
|
|
||||||
//_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
|
//_rmm.subscribe(this, RegistryMessageModel_Event::message_construct);
|
||||||
//_rmm.subscribe(this, RegistryMessageModel_Event::message_updated);
|
//_rmm.subscribe(this, RegistryMessageModel_Event::message_updated);
|
||||||
@ -378,6 +379,60 @@ bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_send_done& e) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SHA1_NGCFT1::onEvent(const Events::NGCFT1_recv_message& e) {
|
||||||
|
if (e.file_kind != NGCFT1_file_kind::HASH_SHA1_INFO) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t ts = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||||
|
|
||||||
|
const auto c = _tcm.getContactGroupPeer(e.group_number, e.peer_number);
|
||||||
|
const auto self_c = c.get<Contact::Components::Self>().self;
|
||||||
|
|
||||||
|
auto* reg_ptr = _rmm.get(c);
|
||||||
|
if (reg_ptr == nullptr) {
|
||||||
|
std::cerr << "SHA1_NGCFT1 error: cant find reg\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Message3Registry& reg = *reg_ptr;
|
||||||
|
// TODO: check for existence, hs or other syncing mechanics might have sent it already (or like, it arrived 2x or whatever)
|
||||||
|
auto new_msg_e = reg.create();
|
||||||
|
|
||||||
|
{ // contact
|
||||||
|
// from
|
||||||
|
reg.emplace<Message::Components::ContactFrom>(new_msg_e, c);
|
||||||
|
|
||||||
|
// to
|
||||||
|
reg.emplace<Message::Components::ContactTo>(new_msg_e, c.get<Contact::Components::Parent>().parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
reg.emplace<Message::Components::ToxGroupMessageID>(new_msg_e, e.message_id);
|
||||||
|
|
||||||
|
reg.emplace<Message::Components::Transfer::TagReceiving>(new_msg_e); // add sending?
|
||||||
|
|
||||||
|
//reg_ptr->emplace<Components::FT1InfoSHA1>(e, sha1_info);
|
||||||
|
//reg_ptr->emplace<Components::FT1InfoSHA1Data>(e, sha1_info_data); // keep around? or file?
|
||||||
|
reg.emplace<Components::FT1InfoSHA1Hash>(new_msg_e, std::vector<uint8_t>{e.file_id, e.file_id+e.file_id_size});
|
||||||
|
// TODO: queue info dl
|
||||||
|
|
||||||
|
reg.emplace<Message::Components::TimestampProcessed>(new_msg_e, ts);
|
||||||
|
//reg.emplace<Components::TimestampWritten>(new_msg_e, 0);
|
||||||
|
reg.emplace<Message::Components::Timestamp>(new_msg_e, ts); // reactive?
|
||||||
|
|
||||||
|
{ // by whom
|
||||||
|
auto& synced_by = reg.get_or_emplace<Message::Components::SyncedBy>(new_msg_e).list;
|
||||||
|
synced_by.emplace(self_c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: queue info/check if we already have info
|
||||||
|
|
||||||
|
_rmm.throwEventConstruct(reg, new_msg_e);
|
||||||
|
|
||||||
|
return true; // false?
|
||||||
|
}
|
||||||
|
|
||||||
bool SHA1_NGCFT1::sendFilePath(const Contact3 c, std::string_view file_name, std::string_view file_path) {
|
bool SHA1_NGCFT1::sendFilePath(const Contact3 c, std::string_view file_name, std::string_view file_path) {
|
||||||
if (
|
if (
|
||||||
// TODO: add support of offline queuing
|
// TODO: add support of offline queuing
|
||||||
|
@ -79,6 +79,7 @@ class SHA1_NGCFT1 : public RegistryMessageModelEventI, public NGCFT1EventI {
|
|||||||
bool onEvent(const Events::NGCFT1_send_data&) override; // const?
|
bool onEvent(const Events::NGCFT1_send_data&) override; // const?
|
||||||
bool onEvent(const Events::NGCFT1_recv_done&) override;
|
bool onEvent(const Events::NGCFT1_recv_done&) override;
|
||||||
bool onEvent(const Events::NGCFT1_send_done&) override;
|
bool onEvent(const Events::NGCFT1_send_done&) override;
|
||||||
|
bool onEvent(const Events::NGCFT1_recv_message&) override;
|
||||||
|
|
||||||
bool sendFilePath(const Contact3 c, std::string_view file_name, std::string_view file_path) override;
|
bool sendFilePath(const Contact3 c, std::string_view file_name, std::string_view file_path) override;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user