From 3647ff3d54f0759d0bd2bc5359518df655ee336f Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 7 Jan 2025 21:30:40 +0100 Subject: [PATCH] update deps and last seen first seen --- external/solanaceae_contact | 2 +- external/solanaceae_message3 | 2 +- external/solanaceae_message_serializer | 2 +- external/solanaceae_tox | 2 +- external/solanaceae_util | 2 +- src/bitset_image_loader.cpp | 7 +------ src/chat_gui/contact_list.cpp | 19 +++++++++++++++++++ src/chat_gui/send_image_popup.cpp | 11 ++++------- src/chat_gui4.cpp | 12 ++++++------ src/debug_video_tap.cpp | 13 +++++-------- src/message_image_loader.cpp | 7 +------ src/texture_cache.cpp | 3 +-- src/texture_cache.hpp | 9 +++------ src/tox_av_voip_model.cpp | 8 ++------ src/tox_avatar_loader.cpp | 11 +++-------- src/tox_friend_faux_offline_messaging.cpp | 8 +++++--- 16 files changed, 55 insertions(+), 63 deletions(-) diff --git a/external/solanaceae_contact b/external/solanaceae_contact index 2401079..e2917c4 160000 --- a/external/solanaceae_contact +++ b/external/solanaceae_contact @@ -1 +1 @@ -Subproject commit 2401079c1daaa4b8fdae378a8cad8d429c619565 +Subproject commit e2917c497c91f91f8febcd1f43e462fad8359305 diff --git a/external/solanaceae_message3 b/external/solanaceae_message3 index 3e6c857..e55fb46 160000 --- a/external/solanaceae_message3 +++ b/external/solanaceae_message3 @@ -1 +1 @@ -Subproject commit 3e6c857c8ad509a94e5a309a5061c5729fbcc439 +Subproject commit e55fb46027f16a1bc078f797ae9fcc7609d15659 diff --git a/external/solanaceae_message_serializer b/external/solanaceae_message_serializer index c5ee5ac..b1becb2 160000 --- a/external/solanaceae_message_serializer +++ b/external/solanaceae_message_serializer @@ -1 +1 @@ -Subproject commit c5ee5ac3f9f0f9239d8b05be9c2d392f439dfa30 +Subproject commit b1becb2128224fe63b7dff2218ecc66e9b92bc5b diff --git a/external/solanaceae_tox b/external/solanaceae_tox index cd19656..8ad1097 160000 --- a/external/solanaceae_tox +++ b/external/solanaceae_tox @@ -1 +1 @@ -Subproject commit cd196562aff9b39e11a415bfb7a33f2066bf86c4 +Subproject commit 8ad10978b96837eb7949f32ef433c5b37c2aa458 diff --git a/external/solanaceae_util b/external/solanaceae_util index 85bbbb0..6cbcc94 160000 --- a/external/solanaceae_util +++ b/external/solanaceae_util @@ -1 +1 @@ -Subproject commit 85bbbb0e5a572b61067f3db188f3cfbda0948e7e +Subproject commit 6cbcc9463ce3c4344e06d74d7df67175ada83b5f diff --git a/src/bitset_image_loader.cpp b/src/bitset_image_loader.cpp index f9d47bf..49da3a3 100644 --- a/src/bitset_image_loader.cpp +++ b/src/bitset_image_loader.cpp @@ -11,11 +11,6 @@ #include -// fwd -namespace Message { -uint64_t getTimeMS(void); -} - std::optional BitsetImageLoader::haveToTexture(TextureUploaderI& tu, BitSet& have, ObjectHandle o) { assert(have.size_bits() > 0); @@ -50,7 +45,7 @@ std::optional BitsetImageLoader::haveToTexture(TextureUploaderI& t SDL_LockSurface(conv_surf); TextureEntry new_entry; - new_entry.timestamp_last_rendered = Message::getTimeMS(); + new_entry.timestamp_last_rendered = getTimeMS(); new_entry.width = have.size_bits(); new_entry.height = 1; diff --git a/src/chat_gui/contact_list.cpp b/src/chat_gui/contact_list.cpp index 10e8b6e..8640a28 100644 --- a/src/chat_gui/contact_list.cpp +++ b/src/chat_gui/contact_list.cpp @@ -2,6 +2,7 @@ #include #include +#include #include //#include @@ -12,6 +13,8 @@ #include "./icons/person.hpp" #include "./icons/group.hpp" +#include + void renderAvatar( const Theme& th, ContactTextureCache& contact_tc, @@ -114,6 +117,22 @@ bool renderContactBig( ImGui::TextUnformatted("Connection state: unknown"); } + // TODO: better time formatter + const int64_t ts_now = getTimeMS(); + + if (const auto* cfirst = c.try_get(); cfirst != nullptr) { + ImGui::Text("First seen: %" PRId64 "s ago", (ts_now - int64_t(cfirst->ts))/1000); + } + + // TODO: fill with useful values periodically, maybe only show if not online? + //if (const auto* clast = c.try_get(); clast != nullptr) { + // ImGui::Text("Last seen: %" PRId64 "s ago", (ts_now - int64_t(clast->ts))/1000); + //} + + if (const auto* clasta = c.try_get(); clasta != nullptr) { + ImGui::Text("Last Activity: %" PRId64 "s ago", (ts_now - int64_t(clasta->ts))/1000); + } + if ( const auto* slt = c.try_get(); slt != nullptr && diff --git a/src/chat_gui/send_image_popup.cpp b/src/chat_gui/send_image_popup.cpp index 799126b..1764606 100644 --- a/src/chat_gui/send_image_popup.cpp +++ b/src/chat_gui/send_image_popup.cpp @@ -6,6 +6,8 @@ #include "../image_loader_qoi.hpp" #include "../image_loader_sdl_image.hpp" +#include + #include #include @@ -13,11 +15,6 @@ #include -// fwd -namespace Message { -uint64_t getTimeMS(void); -} - SendImagePopup::SendImagePopup(TextureUploaderI& tu) : _tu(tu) { _image_loaders.push_back(std::make_unique()); _image_loaders.push_back(std::make_unique()); @@ -90,7 +87,7 @@ bool SendImagePopup::load(void) { } assert(preview_image.textures.empty()); - preview_image.timestamp_last_rendered = Message::getTimeMS(); + preview_image.timestamp_last_rendered = getTimeMS(); preview_image.current_texture = 0; for (const auto& [ms, data] : original_image.frames) { const auto n_t = _tu.upload(data.data(), original_image.width, original_image.height); @@ -226,7 +223,7 @@ void SendImagePopup::render(float time_delta) { //const auto TEXT_BASE_WIDTH = ImGui::CalcTextSize("A").x; const auto TEXT_BASE_HEIGHT = ImGui::GetTextLineHeightWithSpacing(); - preview_image.doAnimation(Message::getTimeMS()); + preview_image.doAnimation(getTimeMS()); time += time_delta; time = fmod(time, 1.f); // fract() diff --git a/src/chat_gui4.cpp b/src/chat_gui4.cpp index 9b69c84..6a0ea49 100644 --- a/src/chat_gui4.cpp +++ b/src/chat_gui4.cpp @@ -694,7 +694,7 @@ float ChatGui4::render(float time_delta) { if (ImGui::BeginItemTooltip()) { std::string synced_by_text {"delivery confirmed by:"}; - const int64_t now_ts_s = int64_t(Message::getTimeMS() / 1000u); + const int64_t now_ts_s = int64_t(getTimeMS() / 1000u); size_t other_contacts {0}; for (const auto& [c, syned_ts] : list) { @@ -737,7 +737,7 @@ float ChatGui4::render(float time_delta) { if (ImGui::BeginItemTooltip()) { std::string synced_by_text {"read confirmed by:"}; - const int64_t now_ts_s = int64_t(Message::getTimeMS() / 1000u); + const int64_t now_ts_s = int64_t(getTimeMS() / 1000u); for (const auto& [c, syned_ts] : list) { if (_cr.all_of(c)) { @@ -823,8 +823,8 @@ float ChatGui4::render(float time_delta) { cg_view.begin.emplace_or_replace(cg_view.end); cg_view.end.emplace_or_replace(cg_view.begin); - cg_view.begin.get_or_emplace().ts = Message::getTimeMS(); - cg_view.end.get_or_emplace().ts = Message::getTimeMS(); + cg_view.begin.get_or_emplace().ts = getTimeMS(); + cg_view.end.get_or_emplace().ts = getTimeMS(); std::cout << "CG: created view FRONT begin ts\n"; _rmm.throwEventConstruct(cg_view.begin); @@ -1546,7 +1546,7 @@ void ChatGui4::renderMessageExtra(Message3Registry& reg, const Message3 e) { if (reg.all_of(e)) { std::string synced_by_text {"syncedBy:"}; - const int64_t now_ts_s = int64_t(Message::getTimeMS() / 1000u); + const int64_t now_ts_s = int64_t(getTimeMS() / 1000u); for (const auto& [c, syned_ts] : reg.get(e).ts) { if (_cr.all_of(c)) { @@ -1566,7 +1566,7 @@ void ChatGui4::renderMessageExtra(Message3Registry& reg, const Message3 e) { // TODO: remove? if (reg.all_of(e)) { std::string synced_by_text {"receivedBy:"}; - const int64_t now_ts_s = int64_t(Message::getTimeMS() / 1000u); + const int64_t now_ts_s = int64_t(getTimeMS() / 1000u); for (const auto& [c, syned_ts] : reg.get(e).ts) { if (_cr.all_of(c)) { diff --git a/src/debug_video_tap.cpp b/src/debug_video_tap.cpp index 89935c7..9d5fb1f 100644 --- a/src/debug_video_tap.cpp +++ b/src/debug_video_tap.cpp @@ -1,5 +1,7 @@ #include "./debug_video_tap.hpp" +#include + #include #include @@ -24,11 +26,6 @@ #include -// fwd -namespace Message { -uint64_t getTimeMS(void); -} - struct DebugVideoTapSink : public FrameStream2SinkI { TextureUploaderI& _tu; @@ -102,12 +99,12 @@ struct DebugVideoTestSource : public FrameStream2SourceI { auto* surf = SDL_CreateSurface(960, 720, SDL_PIXELFORMAT_RGBA32); // color - static auto start_time = Message::getTimeMS(); - const float time = (Message::getTimeMS() - start_time)/1000.f; + static auto start_time = getTimeMS(); + const float time = (getTimeMS() - start_time)/1000.f; SDL_ClearSurface(surf, std::sin(time), std::cos(time), 0.5f, 1.f); SDLVideoFrame frame{ // non-owning - Message::getTimeMS()*1000, + getTimeMS()*1000, surf, }; diff --git a/src/message_image_loader.cpp b/src/message_image_loader.cpp index c8be17c..b8ca579 100644 --- a/src/message_image_loader.cpp +++ b/src/message_image_loader.cpp @@ -18,11 +18,6 @@ #include -// fwd -namespace Message { -uint64_t getTimeMS(void); -} - MessageImageLoader::MessageImageLoader(void) { _image_loaders.push_back(std::make_unique()); _image_loaders.push_back(std::make_unique()); @@ -104,7 +99,7 @@ TextureLoaderResult MessageImageLoader::load(TextureUploaderI& tu, Message3Handl } TextureEntry new_entry; - new_entry.timestamp_last_rendered = Message::getTimeMS(); + new_entry.timestamp_last_rendered = getTimeMS(); new_entry.current_texture = 0; for (const auto& [ms, data] : res.frames) { const auto n_t = tu.upload(data.data(), res.width, res.height); diff --git a/src/texture_cache.cpp b/src/texture_cache.cpp index 658effb..fa9ab08 100644 --- a/src/texture_cache.cpp +++ b/src/texture_cache.cpp @@ -1,6 +1,5 @@ #include "./texture_cache.hpp" -#include #include #include @@ -24,7 +23,7 @@ int64_t TextureEntry::doAnimation(const int64_t ts_now) { TextureEntry generateTestAnim(TextureUploaderI& tu) { TextureEntry new_entry; - new_entry.timestamp_last_rendered = Message::getTimeMS(); + new_entry.timestamp_last_rendered = getTimeMS(); new_entry.current_texture = 0; for (size_t i = 0; i < 4; i++) { // hack diff --git a/src/texture_cache.hpp b/src/texture_cache.hpp index 7bdefd0..302a679 100644 --- a/src/texture_cache.hpp +++ b/src/texture_cache.hpp @@ -5,6 +5,8 @@ #include #include +#include + #include #include #include @@ -81,11 +83,6 @@ struct TextureLoaderResult { TextureEntry generateTestAnim(TextureUploaderI& tu); -// fwd -namespace Message { -uint64_t getTimeMS(void); -} - template struct TextureCache { static_assert( @@ -157,7 +154,7 @@ struct TextureCache { } float update(void) { - const uint64_t ts_now = Message::getTimeMS(); + const uint64_t ts_now = getTimeMS(); uint64_t ts_min_next = ts_now + ms_before_purge; std::vector to_purge; diff --git a/src/tox_av_voip_model.cpp b/src/tox_av_voip_model.cpp index 85f738f..555314b 100644 --- a/src/tox_av_voip_model.cpp +++ b/src/tox_av_voip_model.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "./frame_streams/stream_manager.hpp" #include "./frame_streams/audio_stream2.hpp" @@ -16,11 +17,6 @@ #include -// fwd -namespace Message { -uint64_t getTimeMS(void); -} // Message - namespace Components { struct ToxAVIncomingAV { bool incoming_audio {false}; @@ -771,7 +767,7 @@ bool ToxAVVoIPModel::onEvent(const Events::FriendVideoFrame& e) { // ms -> us // would be nice if we had been giving this from toxcore // TODO: make more precise - Message::getTimeMS() * 1000, + getTimeMS() * 1000, new_surf }); diff --git a/src/tox_avatar_loader.cpp b/src/tox_avatar_loader.cpp index 85fe0aa..595fe5d 100644 --- a/src/tox_avatar_loader.cpp +++ b/src/tox_avatar_loader.cpp @@ -16,11 +16,6 @@ #include #include -// fwd -namespace Message { -uint64_t getTimeMS(void); -} - ToxAvatarLoader::ToxAvatarLoader(Contact3Registry& cr) : _cr(cr) { _image_loaders.push_back(std::make_unique()); _image_loaders.push_back(std::make_unique()); @@ -129,7 +124,7 @@ TextureLoaderResult ToxAvatarLoader::load(TextureUploaderI& tu, Contact3 c) { const auto& a_m = _cr.get(c); TextureEntry new_entry; - new_entry.timestamp_last_rendered = Message::getTimeMS(); + new_entry.timestamp_last_rendered = getTimeMS(); new_entry.current_texture = 0; new_entry.width = a_m.width; @@ -167,7 +162,7 @@ TextureLoaderResult ToxAvatarLoader::load(TextureUploaderI& tu, Contact3 c) { } TextureEntry new_entry; - new_entry.timestamp_last_rendered = Message::getTimeMS(); + new_entry.timestamp_last_rendered = getTimeMS(); new_entry.current_texture = 0; for (const auto& [ms, data] : res.frames) { const auto n_t = tu.upload(data.data(), res.width, res.height); @@ -210,7 +205,7 @@ TextureLoaderResult ToxAvatarLoader::load(TextureUploaderI& tu, Contact3 c) { } TextureEntry new_entry; - new_entry.timestamp_last_rendered = Message::getTimeMS(); + new_entry.timestamp_last_rendered = getTimeMS(); new_entry.current_texture = 0; const auto n_t = tu.upload(pixels.data(), 5, 5, TextureUploaderI::RGBA, TextureUploaderI::NEAREST); diff --git a/src/tox_friend_faux_offline_messaging.cpp b/src/tox_friend_faux_offline_messaging.cpp index 10f2f19..0c4ce98 100644 --- a/src/tox_friend_faux_offline_messaging.cpp +++ b/src/tox_friend_faux_offline_messaging.cpp @@ -1,5 +1,7 @@ #include "./tox_friend_faux_offline_messaging.hpp" +#include + #include #include @@ -43,7 +45,7 @@ float ToxFriendFauxOfflineMessaging::tick(float time_delta) { _interval_timer = 60.f; - const uint64_t ts_now = Message::getTimeMS(); + const uint64_t ts_now = getTimeMS(); // check ALL // for each online tox friend @@ -105,7 +107,7 @@ ToxFriendFauxOfflineMessaging::dfmc_Ret ToxFriendFauxOfflineMessaging::doFriendM return dfmc_Ret::NO_MSG; } - const uint64_t ts_now = Message::getTimeMS(); + const uint64_t ts_now = getTimeMS(); if (!_cr.all_of(c)) { return dfmc_Ret::NO_MSG; // error @@ -220,7 +222,7 @@ bool ToxFriendFauxOfflineMessaging::onToxEvent(const Tox_Event_Friend_Connection return false; } - _cr.emplace_or_replace(c, Message::getTimeMS() + uint64_t(_delay_after_cc*1000)); // wait before first message is sent + _cr.emplace_or_replace(c, getTimeMS() + uint64_t(_delay_after_cc*1000)); // wait before first message is sent _interval_timer = 0.f;