Compare commits

...

2 Commits

Author SHA1 Message Date
e4eaf91a68
use sr 2024-10-24 14:56:26 +02:00
7973c7a320
parent for tree 2024-10-24 14:15:25 +02:00
4 changed files with 24 additions and 16 deletions

View File

@ -19,19 +19,21 @@ IRCClientContactModel::IRCClientContactModel(
Contact3Registry& cr,
ConfigModelI& conf,
IRCClient1& ircc
) : _cr(cr), _conf(conf), _ircc(ircc) {
_ircc.subscribe(this, IRCClient_Event::CONNECT);
) : _cr(cr), _conf(conf), _ircc(ircc), _ircc_sr(_ircc.newSubRef(this)) {
_ircc_sr
.subscribe(IRCClient_Event::CONNECT)
_ircc.subscribe(this, IRCClient_Event::NUMERIC);
.subscribe(IRCClient_Event::NUMERIC)
_ircc.subscribe(this, IRCClient_Event::JOIN);
_ircc.subscribe(this, IRCClient_Event::PART);
_ircc.subscribe(this, IRCClient_Event::TOPIC);
_ircc.subscribe(this, IRCClient_Event::QUIT);
.subscribe(IRCClient_Event::JOIN)
.subscribe(IRCClient_Event::PART)
.subscribe(IRCClient_Event::TOPIC)
.subscribe(IRCClient_Event::QUIT)
_ircc.subscribe(this, IRCClient_Event::CTCP_REQ);
.subscribe(IRCClient_Event::CTCP_REQ)
_ircc.subscribe(this, IRCClient_Event::DISCONNECT);
.subscribe(IRCClient_Event::DISCONNECT)
;
// dont create server self etc until connect event comes
@ -415,6 +417,7 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Join& e) {
}
channel.emplace_or_replace<Contact::Components::ContactModel>(this);
channel.emplace_or_replace<Contact::Components::Parent>(_server);
_cr.get_or_emplace<Contact::Components::ParentOf>(_server).subs.push_back(channel);
channel.emplace_or_replace<Contact::Components::ParentOf>(); // start empty
channel.emplace_or_replace<Contact::Components::IRC::ServerName>(std::string{_ircc.getServerName()});
channel.emplace_or_replace<Contact::Components::IRC::ChannelName>(std::string{joined_channel_name});

View File

@ -16,6 +16,7 @@ class IRCClientContactModel : public IRCClientEventI, public ContactModel3I {
Contact3Registry& _cr;
ConfigModelI& _conf;
IRCClient1& _ircc;
IRCClient1::SubscriptionReference _ircc_sr;
// cm needs the connect event to happen
bool _connected {false};

View File

@ -22,14 +22,16 @@ IRCClientMessageManager::IRCClientMessageManager(
ConfigModelI& conf,
IRCClient1& ircc,
IRCClientContactModel& ircccm
) : _rmm(rmm), _cr(cr), _conf(conf), _ircc(ircc), _ircccm(ircccm) {
_ircc.subscribe(this, IRCClient_Event::CHANNEL);
_ircc.subscribe(this, IRCClient_Event::PRIVMSG);
_ircc.subscribe(this, IRCClient_Event::NOTICE);
_ircc.subscribe(this, IRCClient_Event::CHANNELNOTICE);
_ircc.subscribe(this, IRCClient_Event::CTCP_ACTION);
) : _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _cr(cr), _conf(conf), _ircc(ircc), _ircc_sr(_ircc.newSubRef(this)), _ircccm(ircccm) {
_ircc_sr
.subscribe(IRCClient_Event::CHANNEL)
.subscribe(IRCClient_Event::PRIVMSG)
.subscribe(IRCClient_Event::NOTICE)
.subscribe(IRCClient_Event::CHANNELNOTICE)
.subscribe(IRCClient_Event::CTCP_ACTION)
;
_rmm.subscribe(this, RegistryMessageModel_Event::send_text);
_rmm_sr.subscribe(RegistryMessageModel_Event::send_text);
}
IRCClientMessageManager::~IRCClientMessageManager(void) {

View File

@ -7,9 +7,11 @@
class IRCClientMessageManager : public IRCClientEventI, public RegistryMessageModelEventI {
protected:
RegistryMessageModelI& _rmm;
RegistryMessageModelI::SubscriptionReference _rmm_sr;
Contact3Registry& _cr;
ConfigModelI& _conf;
IRCClient1& _ircc;
IRCClient1::SubscriptionReference _ircc_sr;
IRCClientContactModel& _ircccm;
public: