diff --git a/solanaceae/tox_contacts/tox_contact_model2.cpp b/solanaceae/tox_contacts/tox_contact_model2.cpp index 635d2da..c6c3bb1 100644 --- a/solanaceae/tox_contacts/tox_contact_model2.cpp +++ b/solanaceae/tox_contacts/tox_contact_model2.cpp @@ -10,18 +10,18 @@ #include ToxContactModel2::ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep) : _cr(cr), _t(t), _tep(tep) { - _tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_CONNECTION_STATUS); - _tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_STATUS); - _tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_NAME); - _tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_REQUEST); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_STATUS); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_NAME); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_REQUEST); // TODO: conf - _tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_INVITE); - _tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_SELF_JOIN); - _tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_JOIN); - _tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_EXIT); - _tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_NAME); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_INVITE); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_SELF_JOIN); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT); + _tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_NAME); // add self diff --git a/solanaceae/tox_messages/tox_message_manager.cpp b/solanaceae/tox_messages/tox_message_manager.cpp index bcdb453..ed07016 100644 --- a/solanaceae/tox_messages/tox_message_manager.cpp +++ b/solanaceae/tox_messages/tox_message_manager.cpp @@ -17,7 +17,7 @@ ToxMessageManager::ToxMessageManager(RegistryMessageModel& rmm, Contact3Registry // TODO: system messages? //tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_CONNECTION_STATUS); //tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_STATUS); - tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_MESSAGE); + tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_MESSAGE); // TODO: conf @@ -25,8 +25,8 @@ ToxMessageManager::ToxMessageManager(RegistryMessageModel& rmm, Contact3Registry //tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_JOIN); //tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_SELF_JOIN); //tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_NAME); - tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_MESSAGE); - tep.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PRIVATE_MESSAGE); + tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_MESSAGE); + tep.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PRIVATE_MESSAGE); _rmm.subscribe(this, RegistryMessageModel_Event::send_text); } @@ -71,7 +71,7 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo const Contact3 c_self = _cr.get(c).self; // get current time unix epoch utc - uint64_t ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + uint64_t ts = Message::getTimeMS(); auto new_msg_e = reg.create(); reg.emplace(new_msg_e, c_self); @@ -169,7 +169,7 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Friend_Message* e) { Tox_Message_Type type = tox_event_friend_message_get_type(e); // get current time unix epoch utc - uint64_t ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + uint64_t ts = Message::getTimeMS(); std::string_view message {reinterpret_cast(tox_event_friend_message_get_message(e)), tox_event_friend_message_get_message_length(e)}; message = message.substr(0, message.find_first_of('\0')); // trim \0 // hi zoff @@ -215,7 +215,7 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Message* e) { const uint32_t message_id = tox_event_group_message_get_message_id(e); const Tox_Message_Type type = tox_event_group_message_get_type(e); - uint64_t ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + const uint64_t ts = Message::getTimeMS(); auto message = std::string_view{reinterpret_cast(tox_event_group_message_get_message(e)), tox_event_group_message_get_message_length(e)}; std::cout << "TMM group message: " << message << "\n"; @@ -269,7 +269,7 @@ bool ToxMessageManager::onToxEvent(const Tox_Event_Group_Private_Message* e) { const uint32_t peer_number = tox_event_group_private_message_get_peer_id(e); const Tox_Message_Type type = tox_event_group_private_message_get_type(e); - uint64_t ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + const uint64_t ts = Message::getTimeMS(); auto message = std::string_view{reinterpret_cast(tox_event_group_private_message_get_message(e)), tox_event_group_private_message_get_message_length(e)}; std::cout << "TMM group private message: " << message << "\n"; diff --git a/solanaceae/tox_messages/tox_transfer_manager.cpp b/solanaceae/tox_messages/tox_transfer_manager.cpp index 926018e..c3e6019 100644 --- a/solanaceae/tox_messages/tox_transfer_manager.cpp +++ b/solanaceae/tox_messages/tox_transfer_manager.cpp @@ -68,11 +68,11 @@ Message3Handle ToxTransferManager::toxFriendLookupReceiving(const uint32_t frien } ToxTransferManager::ToxTransferManager(RegistryMessageModel& rmm, Contact3Registry& cr, ToxContactModel2& tcm, ToxI& t, ToxEventProviderI& tep) : _rmm(rmm), _cr(cr), _tcm(tcm), _t(t) { - tep.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_CONNECTION_STATUS); - tep.subscribe(this, Tox_Event::TOX_EVENT_FILE_RECV); - tep.subscribe(this, Tox_Event::TOX_EVENT_FILE_RECV_CONTROL); - tep.subscribe(this, Tox_Event::TOX_EVENT_FILE_RECV_CHUNK); - tep.subscribe(this, Tox_Event::TOX_EVENT_FILE_CHUNK_REQUEST); + tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS); + tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FILE_RECV); + tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FILE_RECV_CONTROL); + tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FILE_RECV_CHUNK); + tep.subscribe(this, Tox_Event_Type::TOX_EVENT_FILE_CHUNK_REQUEST); _rmm.subscribe(this, RegistryMessageModel_Event::message_construct); _rmm.subscribe(this, RegistryMessageModel_Event::message_updated); @@ -542,7 +542,7 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv_Chunk* e) { const auto friend_number = tox_event_file_recv_chunk_get_friend_number(e); const auto file_number = tox_event_file_recv_chunk_get_file_number(e); const uint8_t* data = tox_event_file_recv_chunk_get_data(e); - const auto data_size = tox_event_file_recv_chunk_get_length(e); + const auto data_size = tox_event_file_recv_chunk_get_data_length(e); const auto position = tox_event_file_recv_chunk_get_position(e); Message3Handle transfer = toxFriendLookupReceiving(friend_number, file_number);