add title + self check

This commit is contained in:
Tha_14 2024-05-17 17:35:48 -07:00
parent 3fc6b82ac0
commit a68496857d
3 changed files with 28 additions and 14 deletions

View File

@ -26,12 +26,12 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
} }
try { try {
//auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1"); auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModel); auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModel);
// static store, could be anywhere tho // static store, could be anywhere tho
// construct with fetched dependencies // construct with fetched dependencies
g_mn10n = std::make_unique<MessageN10n>(*rmm); g_mn10n = std::make_unique<MessageN10n>(*cr, *rmm);
// register types // register types
PLUG_PROVIDE_INSTANCE(MessageN10n, plugin_name, g_mn10n.get()); PLUG_PROVIDE_INSTANCE(MessageN10n, plugin_name, g_mn10n.get());

View File

@ -1,6 +1,7 @@
#include "./message_n10n.hpp" #include "./message_n10n.hpp"
#include <solanaceae/message3/components.hpp> #include <solanaceae/message3/components.hpp>
#include <solanaceae/contact/components.hpp>
#include <wintoastlib.h> #include <wintoastlib.h>
@ -29,7 +30,7 @@ class OurHandler : public WinToastLib::IWinToastHandler {
}; };
MessageN10n::MessageN10n(RegistryMessageModel& rmm) : _rmm(rmm) { MessageN10n::MessageN10n(Contact3Registry& cr, RegistryMessageModel& rmm) : _cr(cr), _rmm(rmm) {
// Register WinToast App User Model // Register WinToast App User Model
WinToastLib::WinToast::instance()->setAppName(L"Tomato"); WinToastLib::WinToast::instance()->setAppName(L"Tomato");
const auto aumi = WinToastLib::WinToast::configureAUMI(L"green", L"solanaceae", L"solanaceae_message_n10n", L"20240517"); const auto aumi = WinToastLib::WinToast::configureAUMI(L"green", L"solanaceae", L"solanaceae_message_n10n", L"20240517");
@ -49,12 +50,31 @@ MessageN10n::~MessageN10n(void) {
bool MessageN10n::onEvent(const Message::Events::MessageConstruct& e) { bool MessageN10n::onEvent(const Message::Events::MessageConstruct& e) {
std::cout << "message constructed called\n"; std::cout << "message constructed called\n";
if (!e.e.all_of<Message::Components::MessageText>()) { if (!e.e.all_of<
Message::Components::MessageText,
Message::Components::ContactFrom,
Message::Components::ContactTo
>()) {
return false; return false;
} }
const auto sender_c = e.e.get<Message::Components::ContactFrom>().c;
if (_cr.all_of<Contact::Components::TagSelfStrong>(sender_c)) {
return false;
}
std::string title {
_cr.get<Contact::Components::Name>(sender_c).name
};
auto templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02); auto templ = WinToastLib::WinToastTemplate(WinToastLib::WinToastTemplate::Text02);
templ.setTextField(L"title", WinToastLib::WinToastTemplate::FirstLine); templ.setTextField(
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>>{}.from_bytes(
title
),
WinToastLib::WinToastTemplate::FirstLine
);
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 e.e.get<Message::Components::MessageText>().text

View File

@ -2,21 +2,15 @@
#include <solanaceae/message3/registry_message_model.hpp> #include <solanaceae/message3/registry_message_model.hpp>
class MessageN10n : public RegistryMessageModelEventI {//, public WinToastLib::IWinToastHandler { class MessageN10n : public RegistryMessageModelEventI {
Contact3Registry& _cr;
RegistryMessageModel& _rmm; RegistryMessageModel& _rmm;
public: public:
MessageN10n(RegistryMessageModel& rmm); MessageN10n(Contact3Registry& cr, RegistryMessageModel& rmm);
virtual ~MessageN10n(void); virtual ~MessageN10n(void);
protected: // rmm protected: // rmm
bool onEvent(const Message::Events::MessageConstruct& e) override; bool onEvent(const Message::Events::MessageConstruct& e) override;
/*
protected: // wintoast
void toastActivated(void) const override;
void toastActivated(int actionIndex) const override;
void toastDismissed(WinToastDismissalReason state) const override;
void toastFailed(void) const override;
*/
}; };