Compare commits
No commits in common. "54bda18e7cf514596c3229bd503015b4f4896d0c" and "3657634be5864620177504b5961308071991c43d" have entirely different histories.
54bda18e7c
...
3657634be5
21
LICENSE
21
LICENSE
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2025 Erik Scholz
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
@ -34,15 +34,15 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto* cs = PLUG_RESOLVE_INSTANCE(ContactStore4I);
|
auto* cr = PLUG_RESOLVE_INSTANCE_VERSIONED(Contact3Registry, "1");
|
||||||
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModelI);
|
auto* rmm = PLUG_RESOLVE_INSTANCE(RegistryMessageModelI);
|
||||||
auto* conf = PLUG_RESOLVE_INSTANCE(ConfigModelI);
|
auto* conf = PLUG_RESOLVE_INSTANCE(ConfigModelI);
|
||||||
|
|
||||||
// static store, could be anywhere tho
|
// static store, could be anywhere tho
|
||||||
// construct with fetched dependencies
|
// construct with fetched dependencies
|
||||||
g_ircc = std::make_unique<IRCClient1>(*conf);
|
g_ircc = std::make_unique<IRCClient1>(*conf);
|
||||||
g_ircccm = std::make_unique<IRCClientContactModel>(*cs, *conf, *g_ircc);
|
g_ircccm = std::make_unique<IRCClientContactModel>(*cr, *conf, *g_ircc);
|
||||||
g_irccmm = std::make_unique<IRCClientMessageManager>(*rmm, *cs, *conf, *g_ircc, *g_ircccm);
|
g_irccmm = std::make_unique<IRCClientMessageManager>(*rmm, *cr, *conf, *g_ircc, *g_ircccm);
|
||||||
|
|
||||||
// register types
|
// register types
|
||||||
PLUG_PROVIDE_INSTANCE(IRCClient1, plugin_name, g_ircc.get());
|
PLUG_PROVIDE_INSTANCE(IRCClient1, plugin_name, g_ircc.get());
|
||||||
|
@ -2,16 +2,12 @@
|
|||||||
|
|
||||||
#include "./components.hpp"
|
#include "./components.hpp"
|
||||||
|
|
||||||
#include <solanaceae/contact/contact_store_i.hpp>
|
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
#include <solanaceae/util/utils.hpp>
|
#include <solanaceae/util/utils.hpp>
|
||||||
|
|
||||||
#include <libirc_rfcnumeric.h>
|
#include <libirc_rfcnumeric.h>
|
||||||
#include <libircclient.h>
|
#include <libircclient.h>
|
||||||
|
|
||||||
#include <entt/entity/registry.hpp>
|
|
||||||
#include <entt/entity/handle.hpp>
|
|
||||||
|
|
||||||
#include <sodium/crypto_hash_sha256.h>
|
#include <sodium/crypto_hash_sha256.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@ -20,10 +16,10 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
IRCClientContactModel::IRCClientContactModel(
|
IRCClientContactModel::IRCClientContactModel(
|
||||||
ContactStore4I& cs,
|
Contact3Registry& cr,
|
||||||
ConfigModelI& conf,
|
ConfigModelI& conf,
|
||||||
IRCClient1& ircc
|
IRCClient1& ircc
|
||||||
) : _cs(cs), _conf(conf), _ircc(ircc), _ircc_sr(_ircc.newSubRef(this)) {
|
) : _cr(cr), _conf(conf), _ircc(ircc), _ircc_sr(_ircc.newSubRef(this)) {
|
||||||
_ircc_sr
|
_ircc_sr
|
||||||
.subscribe(IRCClient_Event::CONNECT)
|
.subscribe(IRCClient_Event::CONNECT)
|
||||||
|
|
||||||
@ -66,18 +62,6 @@ void IRCClientContactModel::join(const std::string& channel) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRCClientContactModel::addContact(Contact4 c) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IRCClientContactModel::acceptRequest(Contact4 c, std::string_view self_name, std::string_view password) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IRCClientContactModel::leave(Contact4 c, std::string_view reason) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<uint8_t> IRCClientContactModel::getHash(std::string_view value) {
|
std::vector<uint8_t> IRCClientContactModel::getHash(std::string_view value) {
|
||||||
assert(!value.empty());
|
assert(!value.empty());
|
||||||
|
|
||||||
@ -103,35 +87,33 @@ std::vector<uint8_t> IRCClientContactModel::getIDHash(std::string_view name) {
|
|||||||
return getHash(data);
|
return getHash(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactHandle4 IRCClientContactModel::getC(std::string_view channel) {
|
Contact3Handle IRCClientContactModel::getC(std::string_view channel) {
|
||||||
const auto server_name = _ircc.getServerName();
|
const auto server_name = _ircc.getServerName();
|
||||||
const auto& cr = _cs.registry();
|
|
||||||
// TODO: this needs a better way
|
// TODO: this needs a better way
|
||||||
for (const auto e : cr.view<Contact::Components::IRC::ServerName, Contact::Components::IRC::ChannelName>()) {
|
for (const auto e : _cr.view<Contact::Components::IRC::ServerName, Contact::Components::IRC::ChannelName>()) {
|
||||||
if (cr.get<Contact::Components::IRC::ServerName>(e).name == server_name && cr.get<Contact::Components::IRC::ChannelName>(e).name == channel) {
|
if (_cr.get<Contact::Components::IRC::ServerName>(e).name == server_name && _cr.get<Contact::Components::IRC::ChannelName>(e).name == channel) {
|
||||||
return _cs.contactHandle(e);
|
return {_cr, e};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {_cr, entt::null};
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactHandle4 IRCClientContactModel::getU(std::string_view nick) {
|
Contact3Handle IRCClientContactModel::getU(std::string_view nick) {
|
||||||
const auto server_name = _ircc.getServerName();
|
const auto server_name = _ircc.getServerName();
|
||||||
const auto& cr = _cs.registry();
|
|
||||||
// TODO: this needs a better way
|
// TODO: this needs a better way
|
||||||
for (const auto e : cr.view<Contact::Components::IRC::ServerName, Contact::Components::IRC::UserName>()) {
|
for (const auto e : _cr.view<Contact::Components::IRC::ServerName, Contact::Components::IRC::UserName>()) {
|
||||||
if (cr.get<Contact::Components::IRC::ServerName>(e).name == server_name && cr.get<Contact::Components::IRC::UserName>(e).name == nick) {
|
if (_cr.get<Contact::Components::IRC::ServerName>(e).name == server_name && _cr.get<Contact::Components::IRC::UserName>(e).name == nick) {
|
||||||
return _cs.contactHandle(e);
|
return {_cr, e};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {_cr, entt::null};
|
||||||
}
|
}
|
||||||
|
|
||||||
ContactHandle4 IRCClientContactModel::getCU(std::string_view name) {
|
Contact3Handle IRCClientContactModel::getCU(std::string_view name) {
|
||||||
if (name.empty()) {
|
if (name.empty()) {
|
||||||
return {};
|
return {_cr, entt::null};
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr std::string_view channel_prefixes{
|
static constexpr std::string_view channel_prefixes{
|
||||||
@ -155,59 +137,63 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Connect& e) {
|
|||||||
_server_hash = getHash(_ircc.getServerName());
|
_server_hash = getHash(_ircc.getServerName());
|
||||||
_connected = true;
|
_connected = true;
|
||||||
|
|
||||||
auto& cr = _cs.registry();
|
|
||||||
|
|
||||||
bool server_contact_created {false};
|
|
||||||
{ // server
|
{ // server
|
||||||
if (!cr.valid(_server)) {
|
if (!_cr.valid(_server)) {
|
||||||
// check for empty contact by id
|
// check for empty contact by id
|
||||||
_server = _cs.getOneContactByID(ByteSpan{_server_hash});
|
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
||||||
|
if (_cr.get<Contact::Components::ID>(e).data == _server_hash) {
|
||||||
|
_server = e;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!cr.valid(_server)) {
|
if (!_cr.valid(_server)) {
|
||||||
_server = cr.create();
|
_server = _cr.create();
|
||||||
server_contact_created = true;
|
_cr.emplace_or_replace<Contact::Components::ID>(_server, _server_hash);
|
||||||
cr.emplace_or_replace<Contact::Components::ID>(_server, _server_hash);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cr.emplace_or_replace<Contact::Components::ContactModel>(_server, this);
|
_cr.emplace_or_replace<Contact::Components::ContactModel>(_server, this);
|
||||||
cr.emplace_or_replace<Contact::Components::IRC::ServerName>(_server, std::string{_ircc.getServerName()}); // really?
|
_cr.emplace_or_replace<Contact::Components::IRC::ServerName>(_server, std::string{_ircc.getServerName()}); // really?
|
||||||
cr.emplace_or_replace<Contact::Components::Name>(_server, std::string{_ircc.getServerName()}); // TODO: add special string?
|
_cr.emplace_or_replace<Contact::Components::Name>(_server, std::string{_ircc.getServerName()}); // TODO: add special string?
|
||||||
|
|
||||||
// does this make sense ?
|
// does this make sense ?
|
||||||
cr.emplace_or_replace<Contact::Components::ConnectionState>(_server, Contact::Components::ConnectionState::State::direct);
|
_cr.emplace_or_replace<Contact::Components::ConnectionState>(_server, Contact::Components::ConnectionState::State::direct);
|
||||||
|
|
||||||
cr.emplace_or_replace<Contact::Components::TagBig>(_server);
|
_cr.emplace_or_replace<Contact::Components::TagBig>(_server);
|
||||||
// the server connection is also the root contact (ircccm only handles 1 server 1 user)
|
// the server connection is also the root contact (ircccm only handles 1 server 1 user)
|
||||||
cr.emplace_or_replace<Contact::Components::TagRoot>(_server);
|
_cr.emplace_or_replace<Contact::Components::TagRoot>(_server);
|
||||||
// TODO: should this be its own node instead? or should the server node be created on construction?
|
// TODO: should this be its own node instead? or should the server node be created on construction?
|
||||||
}
|
}
|
||||||
|
|
||||||
bool self_contact_created {false};
|
|
||||||
{ // self
|
{ // self
|
||||||
if (!cr.valid(_self)) {
|
if (!_cr.valid(_self)) {
|
||||||
// TODO: this can create self with peexisting id
|
// TODO: this can create self with peexisting id
|
||||||
if (!e.params.empty()) {
|
if (!e.params.empty()) {
|
||||||
const auto self_hash = getIDHash(e.params.front());
|
const auto self_hash = getIDHash(e.params.front());
|
||||||
|
|
||||||
// check for empty contact by id
|
// check for empty contact by id
|
||||||
_server = _cs.getOneContactByID(_server, ByteSpan{self_hash});
|
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
||||||
|
if (_cr.get<Contact::Components::ID>(e).data == self_hash) {
|
||||||
|
_self = e;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!cr.valid(_self)) {
|
if (!_cr.valid(_self)) {
|
||||||
_self = cr.create();
|
_self = _cr.create();
|
||||||
self_contact_created = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cr.emplace_or_replace<Contact::Components::ContactModel>(_self, this);
|
_cr.emplace_or_replace<Contact::Components::ContactModel>(_self, this);
|
||||||
cr.emplace_or_replace<Contact::Components::Parent>(_self, _server);
|
_cr.emplace_or_replace<Contact::Components::Parent>(_self, _server);
|
||||||
cr.emplace_or_replace<Contact::Components::TagSelfStrong>(_self);
|
_cr.emplace_or_replace<Contact::Components::TagSelfStrong>(_self);
|
||||||
cr.emplace_or_replace<Contact::Components::IRC::ServerName>(_self, std::string{_ircc.getServerName()}); // really?
|
_cr.emplace_or_replace<Contact::Components::IRC::ServerName>(_self, std::string{_ircc.getServerName()}); // really?
|
||||||
if (!e.params.empty()) {
|
if (!e.params.empty()) {
|
||||||
cr.emplace_or_replace<Contact::Components::IRC::UserName>(_self, std::string{e.params.front()});
|
_cr.emplace_or_replace<Contact::Components::IRC::UserName>(_self, std::string{e.params.front()});
|
||||||
cr.emplace_or_replace<Contact::Components::Name>(_self, std::string{e.params.front()});
|
_cr.emplace_or_replace<Contact::Components::Name>(_self, std::string{e.params.front()});
|
||||||
// make id hash(hash(ServerName)+UserName)
|
// make id hash(hash(ServerName)+UserName)
|
||||||
// or irc name format, but those might cause collisions
|
// or irc name format, but those might cause collisions
|
||||||
cr.emplace_or_replace<Contact::Components::ID>(_self, getIDHash(e.params.front()));
|
_cr.emplace_or_replace<Contact::Components::ID>(_self, getIDHash(e.params.front()));
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
std::cout << "### created self with"
|
std::cout << "### created self with"
|
||||||
@ -219,16 +205,16 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Connect& e) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
cr.emplace_or_replace<Contact::Components::ConnectionState>(_self, Contact::Components::ConnectionState::State::direct);
|
_cr.emplace_or_replace<Contact::Components::ConnectionState>(_self, Contact::Components::ConnectionState::State::direct);
|
||||||
|
|
||||||
// add self to server
|
// add self to server
|
||||||
cr.emplace_or_replace<Contact::Components::Self>(_server, _self);
|
_cr.emplace_or_replace<Contact::Components::Self>(_server, _self);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for preexisting channels,
|
// check for preexisting channels,
|
||||||
// since this might be a reconnect
|
// since this might be a reconnect
|
||||||
// and reissue joins
|
// and reissue joins
|
||||||
cr.view<Contact::Components::IRC::ServerName, Contact::Components::IRC::ChannelName>().each([this](const auto c, const auto& sn_c, const auto& cn_c) {
|
_cr.view<Contact::Components::IRC::ServerName, Contact::Components::IRC::ChannelName>().each([this](const auto c, const auto& sn_c, const auto& cn_c) {
|
||||||
// HACK: by name
|
// HACK: by name
|
||||||
// should be by parent instead
|
// should be by parent instead
|
||||||
if (sn_c.name != _ircc.getServerName()) {
|
if (sn_c.name != _ircc.getServerName()) {
|
||||||
@ -255,18 +241,6 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Connect& e) {
|
|||||||
_join_queue.pop();
|
_join_queue.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (server_contact_created) {
|
|
||||||
_cs.throwEventConstruct(_server);
|
|
||||||
} else {
|
|
||||||
_cs.throwEventUpdate(_server);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self_contact_created) {
|
|
||||||
_cs.throwEventConstruct(_self);
|
|
||||||
} else {
|
|
||||||
_cs.throwEventUpdate(_self);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +268,7 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Numeric& e) {
|
|||||||
|
|
||||||
const auto& channel_name = e.params.at(2);
|
const auto& channel_name = e.params.at(2);
|
||||||
auto channel = getC(channel_name);
|
auto channel = getC(channel_name);
|
||||||
if (!static_cast<bool>(channel)) {
|
if (!channel.valid()) {
|
||||||
std::cerr << "IRCCCM error: name list for unknown channel\n";
|
std::cerr << "IRCCCM error: name list for unknown channel\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -345,15 +319,17 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Numeric& e) {
|
|||||||
//std::cout << "u: " << user_str << "\n";
|
//std::cout << "u: " << user_str << "\n";
|
||||||
|
|
||||||
auto user = getU(user_str);
|
auto user = getU(user_str);
|
||||||
bool user_throw_event {false};
|
if (!user.valid()) {
|
||||||
bool user_created {false};
|
|
||||||
if (!static_cast<bool>(user)) {
|
|
||||||
const auto user_hash = getIDHash(user_str);
|
const auto user_hash = getIDHash(user_str);
|
||||||
// check for empty contact by id
|
// check for empty contact by id
|
||||||
user = _cs.getOneContactByID(_server, ByteSpan{user_hash});
|
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
||||||
if (!static_cast<bool>(user)) {
|
if (_cr.get<Contact::Components::ID>(e).data == user_hash) {
|
||||||
user = _cs.contactHandle(_cs.registry().create());
|
user = {_cr, e};
|
||||||
user_created = true;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!user.valid()) {
|
||||||
|
user = {_cr, _cr.create()};
|
||||||
user.emplace_or_replace<Contact::Components::ID>(user_hash);
|
user.emplace_or_replace<Contact::Components::ID>(user_hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,15 +339,11 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Numeric& e) {
|
|||||||
// add to channel?
|
// add to channel?
|
||||||
user.emplace_or_replace<Contact::Components::IRC::UserName>(std::string{user_str});
|
user.emplace_or_replace<Contact::Components::IRC::UserName>(std::string{user_str});
|
||||||
user.emplace_or_replace<Contact::Components::Name>(std::string{user_str});
|
user.emplace_or_replace<Contact::Components::Name>(std::string{user_str});
|
||||||
|
|
||||||
user_throw_event = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.entity() != _self) {
|
if (user.entity() != _self) {
|
||||||
user.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::cloud);
|
user.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::cloud);
|
||||||
user.emplace_or_replace<Contact::Components::Self>(_self);
|
user.emplace_or_replace<Contact::Components::Self>(_self);
|
||||||
|
|
||||||
user_throw_event = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // add user to channel
|
{ // add user to channel
|
||||||
@ -379,15 +351,6 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Numeric& e) {
|
|||||||
if (std::find(channel_user_list.begin(), channel_user_list.end(), user) == channel_user_list.end()) {
|
if (std::find(channel_user_list.begin(), channel_user_list.end(), user) == channel_user_list.end()) {
|
||||||
//std::cout << "!!!!!!!! new user in channel!\n";
|
//std::cout << "!!!!!!!! new user in channel!\n";
|
||||||
channel_user_list.push_back(user);
|
channel_user_list.push_back(user);
|
||||||
user_throw_event = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user_throw_event) {
|
|
||||||
if (user_created) {
|
|
||||||
_cs.throwEventConstruct(user);
|
|
||||||
} else {
|
|
||||||
_cs.throwEventUpdate(user);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,14 +381,13 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Numeric& e) {
|
|||||||
|
|
||||||
const auto channel_name = e.params.at(1);
|
const auto channel_name = e.params.at(1);
|
||||||
auto channel = getC(channel_name);
|
auto channel = getC(channel_name);
|
||||||
if (!static_cast<bool>(channel)) {
|
if (!channel.valid()) {
|
||||||
std::cerr << "IRCCCM error: topic for unknown channel\n";
|
std::cerr << "IRCCCM error: topic for unknown channel\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto topic = e.params.at(2);
|
const auto topic = e.params.at(2);
|
||||||
channel.emplace_or_replace<Contact::Components::StatusText>(std::string{topic}).fillFirstLineLength();
|
channel.emplace_or_replace<Contact::Components::StatusText>(std::string{topic}).fillFirstLineLength();
|
||||||
_cs.throwEventUpdate(channel);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -439,23 +401,23 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Join& e) {
|
|||||||
|
|
||||||
//std::cout << "JOIN!!!! " << e.origin << " in " << joined_channel_name << "\n";
|
//std::cout << "JOIN!!!! " << e.origin << " in " << joined_channel_name << "\n";
|
||||||
|
|
||||||
auto& cr = _cs.registry();
|
|
||||||
|
|
||||||
bool channel_created {false};
|
|
||||||
auto channel = getC(e.params.front());
|
auto channel = getC(e.params.front());
|
||||||
if (!static_cast<bool>(channel)) {
|
if (!channel.valid()) {
|
||||||
const auto channel_hash = getIDHash(joined_channel_name);
|
const auto channel_hash = getIDHash(joined_channel_name);
|
||||||
// check for empty contact by id
|
// check for empty contact by id
|
||||||
channel = _cs.getOneContactByID(_server, ByteSpan{channel_hash});
|
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
||||||
if (!static_cast<bool>(channel)) {
|
if (_cr.get<Contact::Components::ID>(e).data == channel_hash) {
|
||||||
//channel = {_cr, _cr.create()};
|
channel = {_cr, e};
|
||||||
channel = _cs.contactHandle(cr.create());
|
break;
|
||||||
channel_created = true;
|
}
|
||||||
|
}
|
||||||
|
if (!channel.valid()) {
|
||||||
|
channel = {_cr, _cr.create()};
|
||||||
channel.emplace_or_replace<Contact::Components::ID>(channel_hash);
|
channel.emplace_or_replace<Contact::Components::ID>(channel_hash);
|
||||||
}
|
}
|
||||||
channel.emplace_or_replace<Contact::Components::ContactModel>(this);
|
channel.emplace_or_replace<Contact::Components::ContactModel>(this);
|
||||||
channel.emplace_or_replace<Contact::Components::Parent>(_server);
|
channel.emplace_or_replace<Contact::Components::Parent>(_server);
|
||||||
cr.get_or_emplace<Contact::Components::ParentOf>(_server).subs.push_back(channel);
|
_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::ParentOf>(); // start empty
|
||||||
channel.emplace_or_replace<Contact::Components::IRC::ServerName>(std::string{_ircc.getServerName()});
|
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});
|
channel.emplace_or_replace<Contact::Components::IRC::ChannelName>(std::string{joined_channel_name});
|
||||||
@ -471,22 +433,18 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Join& e) {
|
|||||||
}
|
}
|
||||||
channel.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::cloud);
|
channel.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::cloud);
|
||||||
|
|
||||||
if (channel_created) {
|
|
||||||
_cs.throwEventConstruct(channel);
|
|
||||||
} else {
|
|
||||||
_cs.throwEventUpdate(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
auto user = getU(e.origin);
|
auto user = getU(e.origin);
|
||||||
bool user_throw_event {false};
|
if (!user.valid()) {
|
||||||
bool user_created {false};
|
|
||||||
if (!static_cast<bool>(user)) {
|
|
||||||
const auto user_hash = getIDHash(e.origin);
|
const auto user_hash = getIDHash(e.origin);
|
||||||
// check for empty contact by id
|
// check for empty contact by id
|
||||||
user = _cs.getOneContactByID(_server, ByteSpan{user_hash});
|
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
||||||
if (!static_cast<bool>(user)) {
|
if (_cr.get<Contact::Components::ID>(e).data == user_hash) {
|
||||||
user = _cs.contactHandle(cr.create());
|
user = {_cr, e};
|
||||||
user_created = true;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!user.valid()) {
|
||||||
|
user = {_cr, _cr.create()};
|
||||||
user.emplace_or_replace<Contact::Components::ID>(user_hash);
|
user.emplace_or_replace<Contact::Components::ID>(user_hash);
|
||||||
std::cerr << "IRCCCM error: had to create joining user (self?)\n";
|
std::cerr << "IRCCCM error: had to create joining user (self?)\n";
|
||||||
}
|
}
|
||||||
@ -499,28 +457,16 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Join& e) {
|
|||||||
user.emplace_or_replace<Contact::Components::IRC::UserName>(std::string{e.origin});
|
user.emplace_or_replace<Contact::Components::IRC::UserName>(std::string{e.origin});
|
||||||
user.emplace_or_replace<Contact::Components::Name>(std::string{e.origin});
|
user.emplace_or_replace<Contact::Components::Name>(std::string{e.origin});
|
||||||
|
|
||||||
user_throw_event = true;
|
|
||||||
|
|
||||||
// ???
|
|
||||||
std::cout << "### created self(?) with"
|
std::cout << "### created self(?) with"
|
||||||
<< " ircn:" << cr.get<Contact::Components::IRC::UserName>(_self).name
|
<< " ircn:" << _cr.get<Contact::Components::IRC::UserName>(_self).name
|
||||||
<< " ircsn:" << cr.get<Contact::Components::IRC::ServerName>(_self).name
|
<< " ircsn:" << _cr.get<Contact::Components::IRC::ServerName>(_self).name
|
||||||
<< " id:" << bin2hex(cr.get<Contact::Components::ID>(_self).data)
|
<< " id:" << bin2hex(_cr.get<Contact::Components::ID>(_self).data)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.entity() != _self) {
|
if (user.entity() != _self) {
|
||||||
user.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::cloud);
|
user.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::cloud);
|
||||||
user.emplace_or_replace<Contact::Components::Self>(_self);
|
user.emplace_or_replace<Contact::Components::Self>(_self);
|
||||||
user_throw_event = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (user_throw_event) {
|
|
||||||
if (user_created) {
|
|
||||||
_cs.throwEventConstruct(user);
|
|
||||||
} else {
|
|
||||||
_cs.throwEventUpdate(user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // add user to channel
|
{ // add user to channel
|
||||||
@ -528,7 +474,6 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Join& e) {
|
|||||||
if (std::find(channel_user_list.begin(), channel_user_list.end(), user) == channel_user_list.end()) {
|
if (std::find(channel_user_list.begin(), channel_user_list.end(), user) == channel_user_list.end()) {
|
||||||
//std::cout << "!!!!!!!! new user in channel!\n";
|
//std::cout << "!!!!!!!! new user in channel!\n";
|
||||||
channel_user_list.push_back(user);
|
channel_user_list.push_back(user);
|
||||||
_cs.throwEventUpdate(channel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,7 +488,7 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Part& e) {
|
|||||||
|
|
||||||
// e.origin // is the parting user
|
// e.origin // is the parting user
|
||||||
auto user = getU(e.origin);
|
auto user = getU(e.origin);
|
||||||
if (!static_cast<bool>(user)) {
|
if (!user.valid()) {
|
||||||
// ignoring unknown users, might be caused by a bug
|
// ignoring unknown users, might be caused by a bug
|
||||||
std::cerr << "ignoring unknown users, might be caused by a bug\n";
|
std::cerr << "ignoring unknown users, might be caused by a bug\n";
|
||||||
return false;
|
return false;
|
||||||
@ -551,7 +496,7 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Part& e) {
|
|||||||
|
|
||||||
// e.params.front() is the channel
|
// e.params.front() is the channel
|
||||||
auto channel = getC(e.params.front());
|
auto channel = getC(e.params.front());
|
||||||
if (!static_cast<bool>(channel)) {
|
if (!channel.valid()) {
|
||||||
// ignoring unknown channel, might be caused by a bug
|
// ignoring unknown channel, might be caused by a bug
|
||||||
std::cerr << "ignoring unknown channel, might be caused by a bug\n";
|
std::cerr << "ignoring unknown channel, might be caused by a bug\n";
|
||||||
return false;
|
return false;
|
||||||
@ -562,14 +507,11 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Part& e) {
|
|||||||
if (auto it = std::find(channel_user_list.begin(), channel_user_list.end(), user); it != channel_user_list.end()) {
|
if (auto it = std::find(channel_user_list.begin(), channel_user_list.end(), user); it != channel_user_list.end()) {
|
||||||
//std::cout << "!!!!!!!! removing user from channel!\n";
|
//std::cout << "!!!!!!!! removing user from channel!\n";
|
||||||
channel_user_list.erase(it);
|
channel_user_list.erase(it);
|
||||||
_cs.throwEventUpdate(channel);
|
|
||||||
} else {
|
} else {
|
||||||
//std::cout << "!!!!!!!! unknown user leaving channel!\n";
|
//std::cout << "!!!!!!!! unknown user leaving channel!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_cs.throwEventUpdate(user); // ??
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -586,14 +528,13 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Topic& e) {
|
|||||||
|
|
||||||
const auto channel_name = e.params.at(0);
|
const auto channel_name = e.params.at(0);
|
||||||
auto channel = getC(channel_name);
|
auto channel = getC(channel_name);
|
||||||
if (!static_cast<bool>(channel)) {
|
if (!channel.valid()) {
|
||||||
std::cerr << "IRCCCM error: new topic for unknown channel\n";
|
std::cerr << "IRCCCM error: new topic for unknown channel\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto topic = e.params.at(1);
|
const auto topic = e.params.at(1);
|
||||||
channel.emplace_or_replace<Contact::Components::StatusText>(std::string{topic}).fillFirstLineLength();
|
channel.emplace_or_replace<Contact::Components::StatusText>(std::string{topic}).fillFirstLineLength();
|
||||||
_cs.throwEventUpdate(channel);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,7 +544,7 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Quit& e) {
|
|||||||
// e.params.front() is the quit reason
|
// e.params.front() is the quit reason
|
||||||
|
|
||||||
auto user = getU(e.origin);
|
auto user = getU(e.origin);
|
||||||
if (!static_cast<bool>(user)) {
|
if (!user.valid()) {
|
||||||
// ignoring unknown users, might be caused by a bug
|
// ignoring unknown users, might be caused by a bug
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -614,8 +555,6 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::Quit& e) {
|
|||||||
|
|
||||||
// should we remove the user from the channel?
|
// should we remove the user from the channel?
|
||||||
|
|
||||||
_cs.throwEventUpdate(user);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,33 +572,23 @@ bool IRCClientContactModel::onEvent(const IRCClient::Events::CTCP_Req& e) {
|
|||||||
|
|
||||||
bool IRCClientContactModel::onEvent(const IRCClient::Events::Disconnect&) {
|
bool IRCClientContactModel::onEvent(const IRCClient::Events::Disconnect&) {
|
||||||
_connected = false;
|
_connected = false;
|
||||||
auto& cr = _cs.registry();
|
if (!_cr.valid(_server)) {
|
||||||
if (!cr.valid(_server)) {
|
|
||||||
// skip if where already offline
|
// skip if where already offline
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
cr.get<Contact::Components::ConnectionState>(_server).state = Contact::Components::ConnectionState::disconnected;
|
_cr.get<Contact::Components::ConnectionState>(_server).state = Contact::Components::ConnectionState::disconnected;
|
||||||
|
|
||||||
// HACK: by name
|
// HACK: by name
|
||||||
ContactHandle4 server;
|
_cr.view<Contact::Components::IRC::ServerName, Contact::Components::ConnectionState>().each([this](const auto c, const auto& sn_c, auto& cs) {
|
||||||
cr.view<Contact::Components::IRC::ServerName, Contact::Components::ConnectionState>().each([this, &server](const auto c, const auto& sn_c, auto&) {
|
|
||||||
// HACK: by name
|
// HACK: by name
|
||||||
// should be by parent instead
|
// should be by parent instead
|
||||||
if (sn_c.name != _ircc.getServerName()) {
|
if (sn_c.name != _ircc.getServerName()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
server = _cs.contactHandle(c);
|
cs.state = Contact::Components::ConnectionState::disconnected;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!static_cast<bool>(server)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
server.get_or_emplace<Contact::Components::ConnectionState>().state = Contact::Components::ConnectionState::disconnected;
|
|
||||||
|
|
||||||
_cs.throwEventUpdate(server);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <solanaceae/contact/contact_model4.hpp>
|
#include <solanaceae/contact/contact_model3.hpp>
|
||||||
#include <solanaceae/util/config_model.hpp>
|
#include <solanaceae/util/config_model.hpp>
|
||||||
|
|
||||||
#include <solanaceae/ircclient/ircclient.hpp>
|
#include <solanaceae/ircclient/ircclient.hpp>
|
||||||
|
|
||||||
#include <entt/entity/entity.hpp>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
@ -14,8 +12,8 @@
|
|||||||
|
|
||||||
#include <iostream> // tmp
|
#include <iostream> // tmp
|
||||||
|
|
||||||
class IRCClientContactModel : public IRCClientEventI, public ContactModel4I {
|
class IRCClientContactModel : public IRCClientEventI, public ContactModel3I {
|
||||||
ContactStore4I& _cs;
|
Contact3Registry& _cr;
|
||||||
ConfigModelI& _conf;
|
ConfigModelI& _conf;
|
||||||
IRCClient1& _ircc;
|
IRCClient1& _ircc;
|
||||||
IRCClient1::SubscriptionReference _ircc_sr;
|
IRCClient1::SubscriptionReference _ircc_sr;
|
||||||
@ -24,15 +22,15 @@ class IRCClientContactModel : public IRCClientEventI, public ContactModel4I {
|
|||||||
bool _connected {false};
|
bool _connected {false};
|
||||||
|
|
||||||
std::vector<uint8_t> _server_hash; // cached for id gen
|
std::vector<uint8_t> _server_hash; // cached for id gen
|
||||||
Contact4 _server {entt::null};
|
Contact3 _server = entt::null;
|
||||||
Contact4 _self {entt::null};
|
Contact3 _self = entt::null;
|
||||||
|
|
||||||
// used if not connected
|
// used if not connected
|
||||||
std::queue<std::string> _join_queue;
|
std::queue<std::string> _join_queue;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IRCClientContactModel(
|
IRCClientContactModel(
|
||||||
ContactStore4I& cs,
|
Contact3Registry& cr,
|
||||||
ConfigModelI& conf,
|
ConfigModelI& conf,
|
||||||
IRCClient1& ircc
|
IRCClient1& ircc
|
||||||
);
|
);
|
||||||
@ -41,11 +39,6 @@ class IRCClientContactModel : public IRCClientEventI, public ContactModel4I {
|
|||||||
|
|
||||||
void join(const std::string& channel);
|
void join(const std::string& channel);
|
||||||
|
|
||||||
protected: // interface
|
|
||||||
bool addContact(Contact4 c) override;
|
|
||||||
bool acceptRequest(Contact4 c, std::string_view self_name, std::string_view password) override;
|
|
||||||
bool leave(Contact4 c, std::string_view reason) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// just the hash algo
|
// just the hash algo
|
||||||
std::vector<uint8_t> getHash(std::string_view value);
|
std::vector<uint8_t> getHash(std::string_view value);
|
||||||
@ -56,10 +49,10 @@ class IRCClientContactModel : public IRCClientEventI, public ContactModel4I {
|
|||||||
// eg: hash(hash(ServerName)+ChannelName)
|
// eg: hash(hash(ServerName)+ChannelName)
|
||||||
std::vector<uint8_t> getIDHash(std::string_view name);
|
std::vector<uint8_t> getIDHash(std::string_view name);
|
||||||
|
|
||||||
ContactHandle4 getC(std::string_view channel);
|
Contact3Handle getC(std::string_view channel);
|
||||||
ContactHandle4 getU(std::string_view nick);
|
Contact3Handle getU(std::string_view nick);
|
||||||
// user or channel using channel prefix
|
// user or channel using channel prefix
|
||||||
ContactHandle4 getCU(std::string_view name);
|
Contact3Handle getCU(std::string_view name);
|
||||||
|
|
||||||
private: // ircclient
|
private: // ircclient
|
||||||
bool onEvent(const IRCClient::Events::Connect& e) override;
|
bool onEvent(const IRCClient::Events::Connect& e) override;
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include <solanaceae/ircclient_contacts/components.hpp>
|
#include <solanaceae/ircclient_contacts/components.hpp>
|
||||||
|
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
#include <solanaceae/contact/contact_store_i.hpp>
|
|
||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
#include <solanaceae/message3/registry_message_model.hpp>
|
#include <solanaceae/message3/registry_message_model.hpp>
|
||||||
|
|
||||||
@ -21,11 +20,11 @@
|
|||||||
|
|
||||||
IRCClientMessageManager::IRCClientMessageManager(
|
IRCClientMessageManager::IRCClientMessageManager(
|
||||||
RegistryMessageModelI& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
ContactStore4I& cs,
|
Contact3Registry& cr,
|
||||||
ConfigModelI& conf,
|
ConfigModelI& conf,
|
||||||
IRCClient1& ircc,
|
IRCClient1& ircc,
|
||||||
IRCClientContactModel& ircccm
|
IRCClientContactModel& ircccm
|
||||||
) : _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _cs(cs), _conf(conf), _ircc(ircc), _ircc_sr(_ircc.newSubRef(this)), _ircccm(ircccm) {
|
) : _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _cr(cr), _conf(conf), _ircc(ircc), _ircc_sr(_ircc.newSubRef(this)), _ircccm(ircccm) {
|
||||||
_ircc_sr
|
_ircc_sr
|
||||||
.subscribe(IRCClient_Event::CHANNEL)
|
.subscribe(IRCClient_Event::CHANNEL)
|
||||||
.subscribe(IRCClient_Event::PRIVMSG)
|
.subscribe(IRCClient_Event::PRIVMSG)
|
||||||
@ -40,7 +39,7 @@ IRCClientMessageManager::IRCClientMessageManager(
|
|||||||
IRCClientMessageManager::~IRCClientMessageManager(void) {
|
IRCClientMessageManager::~IRCClientMessageManager(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRCClientMessageManager::processMessage(ContactHandle4 from, ContactHandle4 to, std::string_view message_text, bool action) {
|
bool IRCClientMessageManager::processMessage(Contact3Handle from, Contact3Handle to, std::string_view message_text, bool action) {
|
||||||
const uint64_t ts = getTimeMS();
|
const uint64_t ts = getTimeMS();
|
||||||
|
|
||||||
Message3Registry* reg_ptr = nullptr;
|
Message3Registry* reg_ptr = nullptr;
|
||||||
@ -82,10 +81,8 @@ bool IRCClientMessageManager::processMessage(ContactHandle4 from, ContactHandle4
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRCClientMessageManager::sendText(const Contact4 c, std::string_view message, bool action) {
|
bool IRCClientMessageManager::sendText(const Contact3 c, std::string_view message, bool action) {
|
||||||
const auto& cr = _cs.registry();
|
if (!_cr.valid(c)) {
|
||||||
|
|
||||||
if (!cr.valid(c)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,21 +92,21 @@ bool IRCClientMessageManager::sendText(const Contact4 c, std::string_view messag
|
|||||||
|
|
||||||
const uint64_t ts = getTimeMS();
|
const uint64_t ts = getTimeMS();
|
||||||
|
|
||||||
if (cr.all_of<Contact::Components::TagSelfStrong>(c)) {
|
if (_cr.all_of<Contact::Components::TagSelfStrong>(c)) {
|
||||||
return false; // message to self? not with irc
|
return false; // message to self? not with irc
|
||||||
}
|
}
|
||||||
|
|
||||||
// test for contact irc specific components
|
// test for contact irc specific components
|
||||||
// TODO: what about commands and server messages?
|
// TODO: what about commands and server messages?
|
||||||
if (!cr.any_of<Contact::Components::IRC::UserName, Contact::Components::IRC::ChannelName>(c)) {
|
if (!_cr.any_of<Contact::Components::IRC::UserName, Contact::Components::IRC::ChannelName>(c)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string to_str;
|
std::string to_str;
|
||||||
if (cr.all_of<Contact::Components::IRC::UserName>(c)) {
|
if (_cr.all_of<Contact::Components::IRC::UserName>(c)) {
|
||||||
to_str = cr.get<Contact::Components::IRC::UserName>(c).name;
|
to_str = _cr.get<Contact::Components::IRC::UserName>(c).name;
|
||||||
} else {
|
} else {
|
||||||
to_str = cr.get<Contact::Components::IRC::ChannelName>(c).name;
|
to_str = _cr.get<Contact::Components::IRC::ChannelName>(c).name;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* reg_ptr = _rmm.get(c);
|
auto* reg_ptr = _rmm.get(c);
|
||||||
@ -117,7 +114,7 @@ bool IRCClientMessageManager::sendText(const Contact4 c, std::string_view messag
|
|||||||
return false; // nope
|
return false; // nope
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!cr.all_of<Contact::Components::Self>(c)) {
|
if (!_cr.all_of<Contact::Components::Self>(c)) {
|
||||||
std::cerr << "IRCCMM error: cant get self\n";
|
std::cerr << "IRCCMM error: cant get self\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -148,7 +145,7 @@ bool IRCClientMessageManager::sendText(const Contact4 c, std::string_view messag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Contact4 c_self = cr.get<Contact::Components::Self>(c).self;
|
const Contact3 c_self = _cr.get<Contact::Components::Self>(c).self;
|
||||||
|
|
||||||
auto new_msg = Message3Handle{*reg_ptr, reg_ptr->create()};
|
auto new_msg = Message3Handle{*reg_ptr, reg_ptr->create()};
|
||||||
|
|
||||||
@ -181,7 +178,7 @@ bool IRCClientMessageManager::onEvent(const IRCClient::Events::Channel& e) {
|
|||||||
|
|
||||||
// e.origin is sender
|
// e.origin is sender
|
||||||
auto sender = _ircccm.getU(e.origin); // assuming its always a user // aka ContactFrom
|
auto sender = _ircccm.getU(e.origin); // assuming its always a user // aka ContactFrom
|
||||||
if (!static_cast<bool>(sender)) {
|
if (!sender.valid()) {
|
||||||
std::cerr << "IRCCMM error: channel event unknown sender\n";
|
std::cerr << "IRCCMM error: channel event unknown sender\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ class IRCClientMessageManager : public IRCClientEventI, public RegistryMessageMo
|
|||||||
protected:
|
protected:
|
||||||
RegistryMessageModelI& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
||||||
ContactStore4I& _cs;
|
Contact3Registry& _cr;
|
||||||
ConfigModelI& _conf;
|
ConfigModelI& _conf;
|
||||||
IRCClient1& _ircc;
|
IRCClient1& _ircc;
|
||||||
IRCClient1::SubscriptionReference _ircc_sr;
|
IRCClient1::SubscriptionReference _ircc_sr;
|
||||||
@ -17,7 +17,7 @@ class IRCClientMessageManager : public IRCClientEventI, public RegistryMessageMo
|
|||||||
public:
|
public:
|
||||||
IRCClientMessageManager(
|
IRCClientMessageManager(
|
||||||
RegistryMessageModelI& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
ContactStore4I& cs,
|
Contact3Registry& cr,
|
||||||
ConfigModelI& conf,
|
ConfigModelI& conf,
|
||||||
IRCClient1& ircc,
|
IRCClient1& ircc,
|
||||||
IRCClientContactModel& ircccm
|
IRCClientContactModel& ircccm
|
||||||
@ -29,10 +29,10 @@ class IRCClientMessageManager : public IRCClientEventI, public RegistryMessageMo
|
|||||||
using IRCClientEventI::onEvent;
|
using IRCClientEventI::onEvent;
|
||||||
using RegistryMessageModelEventI::onEvent;
|
using RegistryMessageModelEventI::onEvent;
|
||||||
private:
|
private:
|
||||||
bool processMessage(ContactHandle4 from, ContactHandle4 to, std::string_view message_text, bool action);
|
bool processMessage(Contact3Handle from, Contact3Handle to, std::string_view message_text, bool action);
|
||||||
|
|
||||||
private: // mm3
|
private: // mm3
|
||||||
bool sendText(const Contact4 c, std::string_view message, bool action = false) override;
|
bool sendText(const Contact3 c, std::string_view message, bool action = false) override;
|
||||||
|
|
||||||
private: // ircclient
|
private: // ircclient
|
||||||
bool onEvent(const IRCClient::Events::Channel& e) override;
|
bool onEvent(const IRCClient::Events::Channel& e) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user