some sanity checks
Some checks failed
ContinuousDelivery / windows (push) Has been cancelled
ContinuousIntegration / windows (push) Has been cancelled
ContinuousDelivery / release (push) Has been cancelled

This commit is contained in:
Green Sky 2024-06-21 13:20:24 +02:00
parent f5e7e7de5a
commit be2885e31d
No known key found for this signature in database
2 changed files with 20 additions and 5 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.9...3.24 FATAL_ERROR) cmake_minimum_required(VERSION 3.9...3.24 FATAL_ERROR)
add_library(plugin_message_n10n SHARED add_library(plugin_message_n10n MODULE
./plugin_message_n10n.cpp ./plugin_message_n10n.cpp
) )
@ -9,8 +9,9 @@ target_link_libraries(plugin_message_n10n PUBLIC
solanaceae_message_n10n solanaceae_message_n10n
) )
set_target_properties(plugin_message_n10n PROPERTIES
C_VISIBILITY_PRESET hidden
)
# probably not enough # probably not enough
target_compile_definitions(plugin_message_n10n PUBLIC ENTT_API_IMPORT) target_compile_definitions(plugin_message_n10n PUBLIC ENTT_API_IMPORT)
set_target_properties(plugin_message_n10n PROPERTIES POSITION_INDEPENDENT_CODE ON)

View File

@ -10,7 +10,7 @@
class OurHandler : public WinToastLib::IWinToastHandler { class OurHandler : public WinToastLib::IWinToastHandler {
public: public:
virtual ~OurHandler(void) { virtual ~OurHandler(void) override {
} }
protected: // wintoast protected: // wintoast
@ -58,16 +58,30 @@ bool MessageN10n::onEvent(const Message::Events::MessageConstruct& e) {
return false; return false;
} }
const auto& text = e.e.get<Message::Components::MessageText>().text;
if (text.empty()) {
return false;
}
const auto sender_c = e.e.get<Message::Components::ContactFrom>().c; const auto sender_c = e.e.get<Message::Components::ContactFrom>().c;
if (_cr.all_of<Contact::Components::TagSelfStrong>(sender_c)) { if (_cr.all_of<Contact::Components::TagSelfStrong>(sender_c)) {
return false; return false;
} }
if (!_cr.all_of<
Contact::Components::Name
>(sender_c)) {
return false;
}
std::string title { std::string title {
_cr.get<Contact::Components::Name>(sender_c).name _cr.get<Contact::Components::Name>(sender_c).name
}; };
if (title.empty()) {
return false;
}
auto templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02); auto templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02);
templ.setTextField( templ.setTextField(
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.from_bytes( std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.from_bytes(
@ -77,7 +91,7 @@ bool MessageN10n::onEvent(const Message::Events::MessageConstruct& e) {
); );
templ.setTextField( templ.setTextField(
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.from_bytes( std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.from_bytes(
e.e.get<Message::Components::MessageText>().text text
), ),
WinToastLib::WinToastTemplate::SecondLine WinToastLib::WinToastTemplate::SecondLine
); );