track message of file transfer, and call update on completion
This commit is contained in:
parent
2e34ad2100
commit
a0c3336f37
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <solanaceae/object_store/meta_components_file.hpp> // contains the alias
|
#include <solanaceae/object_store/meta_components_file.hpp> // contains the alias
|
||||||
|
|
||||||
|
#include <solanaceae/message3/registry_message_model.hpp>
|
||||||
|
|
||||||
#include <solanaceae/toxcore/tox_key.hpp>
|
#include <solanaceae/toxcore/tox_key.hpp>
|
||||||
|
|
||||||
namespace ObjectStore::Components {
|
namespace ObjectStore::Components {
|
||||||
@ -34,6 +36,12 @@ namespace ObjectStore::Components {
|
|||||||
uint32_t transfer_number;
|
uint32_t transfer_number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: replace this with something generic
|
||||||
|
struct ToxMessage {
|
||||||
|
// the message, if the ft is visible as a message
|
||||||
|
Message3Handle m;
|
||||||
|
};
|
||||||
|
|
||||||
} // Ephemeral
|
} // Ephemeral
|
||||||
|
|
||||||
} // ObjectStore::Components
|
} // ObjectStore::Components
|
||||||
|
@ -26,6 +26,7 @@ DEFINE_COMP_ID(ObjComp::Tox::TagIncomming)
|
|||||||
DEFINE_COMP_ID(ObjComp::Tox::TagOutgoing)
|
DEFINE_COMP_ID(ObjComp::Tox::TagOutgoing)
|
||||||
|
|
||||||
DEFINE_COMP_ID(ObjComp::Ephemeral::ToxTransferFriend)
|
DEFINE_COMP_ID(ObjComp::Ephemeral::ToxTransferFriend)
|
||||||
|
DEFINE_COMP_ID(ObjComp::Ephemeral::ToxMessage)
|
||||||
|
|
||||||
#undef DEFINE_COMP_ID
|
#undef DEFINE_COMP_ID
|
||||||
|
|
||||||
|
@ -532,6 +532,8 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv* e) {
|
|||||||
}
|
}
|
||||||
msg.emplace<Message::Components::MessageFileObject>(o);
|
msg.emplace<Message::Components::MessageFileObject>(o);
|
||||||
|
|
||||||
|
o.emplace<ObjComp::Ephemeral::ToxMessage>(msg);
|
||||||
|
|
||||||
_os.throwEventConstruct(o);
|
_os.throwEventConstruct(o);
|
||||||
_rmm.throwEventConstruct(msg);
|
_rmm.throwEventConstruct(msg);
|
||||||
|
|
||||||
@ -611,7 +613,12 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv_Chunk* e) {
|
|||||||
|
|
||||||
o.emplace_or_replace<ObjComp::F::TagLocalHaveAll>();
|
o.emplace_or_replace<ObjComp::F::TagLocalHaveAll>();
|
||||||
|
|
||||||
#if 0 // TODO: track back msg
|
_os.throwEventUpdate(o);
|
||||||
|
|
||||||
|
// TODO: move out generic? do we want to update on EVERY chunk?
|
||||||
|
if (const auto* msg_ptr = o.try_get<ObjComp::Ephemeral::ToxMessage>(); msg_ptr != nullptr && static_cast<bool>(msg_ptr->m)) {
|
||||||
|
const auto& msg = msg_ptr->m;
|
||||||
|
|
||||||
// re-unread a finished transfer
|
// re-unread a finished transfer
|
||||||
msg.emplace_or_replace<Message::Components::TagUnread>();
|
msg.emplace_or_replace<Message::Components::TagUnread>();
|
||||||
msg.remove<Message::Components::Read>();
|
msg.remove<Message::Components::Read>();
|
||||||
@ -622,11 +629,9 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv_Chunk* e) {
|
|||||||
auto& rb = msg.get_or_emplace<Message::Components::ReceivedBy>().ts;
|
auto& rb = msg.get_or_emplace<Message::Components::ReceivedBy>().ts;
|
||||||
rb.try_emplace(self_c, ts); // on completion
|
rb.try_emplace(self_c, ts); // on completion
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
_os.throwEventUpdate(o);
|
_rmm.throwEventUpdate(msg);
|
||||||
|
}
|
||||||
//_rmm.throwEventUpdate(msg);
|
|
||||||
} else if (!o.all_of<Components::TFTFile2>() || !o.get<Components::TFTFile2>().file || !o.get<Components::TFTFile2>().file->isGood()) {
|
} else if (!o.all_of<Components::TFTFile2>() || !o.get<Components::TFTFile2>().file || !o.get<Components::TFTFile2>().file->isGood()) {
|
||||||
std::cerr << "TTM error: file not good f" << friend_number << " t" << file_number << ", closing\n";
|
std::cerr << "TTM error: file not good f" << friend_number << " t" << file_number << ", closing\n";
|
||||||
_t.toxFileControl(friend_number, file_number, Tox_File_Control::TOX_FILE_CONTROL_CANCEL);
|
_t.toxFileControl(friend_number, file_number, Tox_File_Control::TOX_FILE_CONTROL_CANCEL);
|
||||||
|
Loading…
Reference in New Issue
Block a user