port to contact4, does not implement create/leave yet
This commit is contained in:
parent
dd7eb2702f
commit
24bbf2a338
@ -4,9 +4,9 @@
|
|||||||
|
|
||||||
namespace Contact::Components {
|
namespace Contact::Components {
|
||||||
|
|
||||||
// ==========
|
// ====================
|
||||||
// friend
|
// friends
|
||||||
// ==========
|
// ====================
|
||||||
|
|
||||||
struct ToxFriendPersistent {
|
struct ToxFriendPersistent {
|
||||||
ToxKey key;
|
ToxKey key;
|
||||||
@ -17,9 +17,9 @@ namespace Contact::Components {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ==========
|
// ====================
|
||||||
// TODO: conference (old groups)
|
// TODO: conferences (old groups)
|
||||||
// ==========
|
// ====================
|
||||||
|
|
||||||
struct ToxConfPersistent {
|
struct ToxConfPersistent {
|
||||||
ToxKey key;
|
ToxKey key;
|
||||||
@ -30,9 +30,9 @@ namespace Contact::Components {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// ==========
|
// ====================
|
||||||
// groups (ngc)
|
// groups (ngc)
|
||||||
// ==========
|
// ====================
|
||||||
|
|
||||||
struct ToxGroupPersistent {
|
struct ToxGroupPersistent {
|
||||||
ToxKey chat_id;
|
ToxKey chat_id;
|
||||||
@ -43,7 +43,6 @@ namespace Contact::Components {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ToxGroupIncomingRequest {
|
struct ToxGroupIncomingRequest {
|
||||||
//Contact3 friend_c;
|
|
||||||
uint32_t friend_number;
|
uint32_t friend_number;
|
||||||
std::vector<uint8_t> invite_data;
|
std::vector<uint8_t> invite_data;
|
||||||
};
|
};
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <solanaceae/toxcore/tox_interface.hpp>
|
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
|
#include <solanaceae/contact/contact_store_i.hpp>
|
||||||
|
|
||||||
// TODO: move
|
// TODO: move
|
||||||
#include <solanaceae/message3/contact_components.hpp>
|
#include <solanaceae/message3/contact_components.hpp>
|
||||||
@ -16,7 +17,7 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
ToxContactModel2::ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep) : _cr(cr), _t(t), _tep_sr(tep.newSubRef(this)) {
|
ToxContactModel2::ToxContactModel2(ContactStore4I& cs, ToxI& t, ToxEventProviderI& tep) : _cs(cs), _t(t), _tep_sr(tep.newSubRef(this)) {
|
||||||
_tep_sr
|
_tep_sr
|
||||||
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS)
|
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS)
|
||||||
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_STATUS)
|
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_STATUS)
|
||||||
@ -34,19 +35,23 @@ ToxContactModel2::ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProvid
|
|||||||
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_TOPIC)
|
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_TOPIC)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
auto& cr = _cs.registry();
|
||||||
|
|
||||||
// add tox profile root
|
// add tox profile root
|
||||||
_root = _cr.create();
|
_root = cr.create();
|
||||||
_cr.emplace<Contact::Components::TagRoot>(_root);
|
cr.emplace<Contact::Components::TagRoot>(_root);
|
||||||
_cr.emplace<Contact::Components::ContactModel>(_root, this);
|
cr.emplace<Contact::Components::ContactModel>(_root, this);
|
||||||
|
cs.throwEventConstruct(_root);
|
||||||
|
|
||||||
// add self
|
// add self
|
||||||
_friend_self = _cr.create();
|
_friend_self = cr.create();
|
||||||
_cr.emplace<Contact::Components::ContactModel>(_friend_self, this);
|
cr.emplace<Contact::Components::ContactModel>(_friend_self, this);
|
||||||
_cr.emplace<Contact::Components::Parent>(_friend_self, _root);
|
cr.emplace<Contact::Components::Parent>(_friend_self, _root);
|
||||||
_cr.emplace<Contact::Components::TagSelfStrong>(_friend_self);
|
cr.emplace<Contact::Components::TagSelfStrong>(_friend_self);
|
||||||
_cr.emplace<Contact::Components::Name>(_friend_self, _t.toxSelfGetName());
|
cr.emplace<Contact::Components::Name>(_friend_self, _t.toxSelfGetName());
|
||||||
// TODO: can contact with id preexist here?
|
// TODO: can contact with id preexist here?
|
||||||
_cr.emplace<Contact::Components::ID>(_friend_self, _t.toxSelfGetPublicKey());
|
cr.emplace<Contact::Components::ID>(_friend_self, _t.toxSelfGetPublicKey());
|
||||||
|
cs.throwEventConstruct(_friend_self);
|
||||||
|
|
||||||
// fill in contacts
|
// fill in contacts
|
||||||
for (const uint32_t f_id : _t.toxSelfGetFriendList()) {
|
for (const uint32_t f_id : _t.toxSelfGetFriendList()) {
|
||||||
@ -68,76 +73,121 @@ void ToxContactModel2::iterate(float delta) {
|
|||||||
if (_group_status_timer >= 1.f) {
|
if (_group_status_timer >= 1.f) {
|
||||||
_group_status_timer = 0.f;
|
_group_status_timer = 0.f;
|
||||||
|
|
||||||
_cr.view<Contact::Components::ToxGroupPeerEphemeral, Contact::Components::ConnectionState>().each([this](auto c, const auto& tox_peer, auto& con) {
|
std::vector<Contact4> updated;
|
||||||
|
|
||||||
|
_cs.registry().view<Contact::Components::ToxGroupPeerEphemeral, Contact::Components::ConnectionState>().each([this, &updated](auto c, const auto& tox_peer, auto& con) {
|
||||||
auto state_opt = std::get<0>(_t.toxGroupPeerGetConnectionStatus(tox_peer.group_number, tox_peer.peer_number));
|
auto state_opt = std::get<0>(_t.toxGroupPeerGetConnectionStatus(tox_peer.group_number, tox_peer.peer_number));
|
||||||
if (state_opt.has_value()) {
|
if (!state_opt.has_value()) {
|
||||||
if (state_opt.value() == TOX_CONNECTION_UDP) {
|
return;
|
||||||
con.state = Contact::Components::ConnectionState::State::direct;
|
|
||||||
} else if (state_opt.value() == TOX_CONNECTION_TCP) {
|
|
||||||
con.state = Contact::Components::ConnectionState::State::cloud;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Contact::Components::ConnectionState::State new_state{Contact::Components::ConnectionState::State::disconnected};
|
||||||
|
if (state_opt.value() == TOX_CONNECTION_UDP) {
|
||||||
|
new_state = Contact::Components::ConnectionState::State::direct;
|
||||||
|
} else if (state_opt.value() == TOX_CONNECTION_TCP) {
|
||||||
|
new_state = Contact::Components::ConnectionState::State::cloud;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (con.state != new_state) {
|
||||||
|
updated.push_back(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
con.state = new_state;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
for (const auto c : updated) {
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToxContactModel2::acceptRequest(Contact3 c, std::string_view self_name, std::string_view password) {
|
bool ToxContactModel2::addContact(Contact4 c) {
|
||||||
assert(!_cr.any_of<Contact::Components::ToxFriendEphemeral>(c));
|
// TODO: implement me
|
||||||
assert(_cr.all_of<Contact::Components::RequestIncoming>(c));
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (_cr.all_of<Contact::Components::ToxFriendPersistent>(c)) {
|
bool ToxContactModel2::acceptRequest(Contact4 c, std::string_view self_name, std::string_view password) {
|
||||||
const auto& key = _cr.get<Contact::Components::ToxFriendPersistent>(c).key.data;
|
auto& cr = _cs.registry();
|
||||||
|
|
||||||
|
if (
|
||||||
|
cr.any_of<Contact::Components::ToxFriendEphemeral>(c) ||
|
||||||
|
!cr.all_of<Contact::Components::RequestIncoming>(c)
|
||||||
|
) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(!cr.any_of<Contact::Components::ToxFriendEphemeral>(c));
|
||||||
|
assert(cr.all_of<Contact::Components::RequestIncoming>(c));
|
||||||
|
|
||||||
|
if (cr.all_of<Contact::Components::ToxFriendPersistent>(c)) {
|
||||||
|
const auto& key = cr.get<Contact::Components::ToxFriendPersistent>(c).key.data;
|
||||||
auto [friend_number_opt, _] = _t.toxFriendAddNorequest({key.cbegin(), key.cend()});
|
auto [friend_number_opt, _] = _t.toxFriendAddNorequest({key.cbegin(), key.cend()});
|
||||||
if (friend_number_opt.has_value()) {
|
if (friend_number_opt.has_value()) {
|
||||||
_cr.emplace<Contact::Components::ToxFriendEphemeral>(c, friend_number_opt.value());
|
cr.emplace<Contact::Components::ToxFriendEphemeral>(c, friend_number_opt.value());
|
||||||
_cr.remove<Contact::Components::RequestIncoming>(c);
|
cr.remove<Contact::Components::RequestIncoming>(c);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "TCM2 error: failed to accept friend request/invite\n";
|
std::cerr << "TCM2 error: failed to accept friend request/invite\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
} else if (false) { // conf
|
} else if (false) { // conf
|
||||||
} else if (_cr.all_of<Contact::Components::ToxGroupIncomingRequest>(c)) { // group
|
} else if (cr.all_of<Contact::Components::ToxGroupIncomingRequest>(c)) { // group
|
||||||
const auto& ir = _cr.get<Contact::Components::ToxGroupIncomingRequest>(c);
|
const auto& ir = cr.get<Contact::Components::ToxGroupIncomingRequest>(c);
|
||||||
auto [group_number_opt, _] = _t.toxGroupInviteAccept(ir.friend_number, ir.invite_data, self_name, password);
|
auto [group_number_opt, _] = _t.toxGroupInviteAccept(ir.friend_number, ir.invite_data, self_name, password);
|
||||||
if (group_number_opt.has_value()) {
|
if (!group_number_opt.has_value()) {
|
||||||
_cr.emplace<Contact::Components::ToxGroupEphemeral>(c, group_number_opt.value());
|
|
||||||
|
|
||||||
if (auto group_chatid_opt = _t.toxGroupGetChatId(group_number_opt.value()); group_chatid_opt.has_value()) {
|
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupPersistent>(c, group_chatid_opt.value());
|
|
||||||
} else {
|
|
||||||
std::cerr << "TCM2 error: getting chatid for group" << group_number_opt.value() << "!!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (auto self_opt = _t.toxGroupSelfGetPeerId(group_number_opt.value()); self_opt.has_value()) {
|
|
||||||
_cr.emplace_or_replace<Contact::Components::Self>(c, getContactGroupPeer(group_number_opt.value(), self_opt.value()));
|
|
||||||
} else {
|
|
||||||
std::cerr << "TCM2 error: getting self for group" << group_number_opt.value() << "!!\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
_cr.remove<Contact::Components::ToxGroupIncomingRequest>(c);
|
|
||||||
_cr.remove<Contact::Components::RequestIncoming>(c);
|
|
||||||
} else {
|
|
||||||
std::cerr << "TCM2 error: failed to accept group request/invite\n";
|
std::cerr << "TCM2 error: failed to accept group request/invite\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: we are changing the contact there without event, do we just not?
|
||||||
|
cr.emplace<Contact::Components::ToxGroupEphemeral>(c, group_number_opt.value());
|
||||||
|
|
||||||
|
if (auto group_chatid_opt = _t.toxGroupGetChatId(group_number_opt.value()); group_chatid_opt.has_value()) {
|
||||||
|
cr.emplace_or_replace<Contact::Components::ToxGroupPersistent>(c, group_chatid_opt.value());
|
||||||
|
} else {
|
||||||
|
std::cerr << "TCM2 error: getting chatid for group" << group_number_opt.value() << "!!\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto self_opt = _t.toxGroupSelfGetPeerId(group_number_opt.value()); self_opt.has_value()) {
|
||||||
|
cr.emplace_or_replace<Contact::Components::Self>(c, getContactGroupPeer(group_number_opt.value(), self_opt.value()));
|
||||||
|
} else {
|
||||||
|
std::cerr << "TCM2 error: getting self for group" << group_number_opt.value() << "!!\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
cr.remove<Contact::Components::ToxGroupIncomingRequest>(c);
|
||||||
|
cr.remove<Contact::Components::RequestIncoming>(c);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "TCM2 error: failed to accept request (unk)\n";
|
std::cerr << "TCM2 error: failed to accept request (unk)\n";
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact3Handle ToxContactModel2::getContactFriend(uint32_t friend_number) {
|
bool ToxContactModel2::leave(Contact4 c, std::string_view reason) {
|
||||||
Contact3 c = entt::null;
|
// TODO: implement me
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ContactHandle4 ToxContactModel2::getContactFriend(uint32_t friend_number) {
|
||||||
|
auto& cr = _cs.registry();
|
||||||
|
Contact4 c {entt::null};
|
||||||
|
|
||||||
// first check contacts with friend id
|
// first check contacts with friend id
|
||||||
// TODO: lookup table
|
// TODO: lookup table
|
||||||
//_cr.view<Contact::Components::ToxFriendEphemeral>().each([&c, friend_number](const Contact3 e, const Contact::Components::ToxFriendEphemeral& f_id) {
|
//_cr.view<Contact::Components::ToxFriendEphemeral>().each([&c, friend_number](const Contact3 e, const Contact::Components::ToxFriendEphemeral& f_id) {
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxFriendEphemeral>()) {
|
for (const auto e : cr.view<Contact::Components::ToxFriendEphemeral>()) {
|
||||||
if (_cr.get<Contact::Components::ToxFriendEphemeral>(e).friend_number == friend_number) {
|
if (cr.get<Contact::Components::ToxFriendEphemeral>(e).friend_number == friend_number) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
return {_cr, c};
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
// else check by pubkey
|
// else check by pubkey
|
||||||
@ -146,89 +196,94 @@ Contact3Handle ToxContactModel2::getContactFriend(uint32_t friend_number) {
|
|||||||
|
|
||||||
const ToxKey& f_key = f_key_opt.value();
|
const ToxKey& f_key = f_key_opt.value();
|
||||||
//_cr.view<Contact::Components::ToxFriendPersistent>().each([&c, &f_key](const Contact3 e, const Contact::Components::ToxFriendPersistent& f_key_comp) {
|
//_cr.view<Contact::Components::ToxFriendPersistent>().each([&c, &f_key](const Contact3 e, const Contact::Components::ToxFriendPersistent& f_key_comp) {
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxFriendPersistent>()) {
|
for (const auto e : cr.view<Contact::Components::ToxFriendPersistent>()) {
|
||||||
if (f_key == _cr.get<Contact::Components::ToxFriendPersistent>(e).key) {
|
if (f_key == cr.get<Contact::Components::ToxFriendPersistent>(e).key) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
// param friend number matches pubkey in db, add
|
// param friend number matches pubkey in db, add
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxFriendEphemeral>(c, friend_number);
|
cr.emplace_or_replace<Contact::Components::ToxFriendEphemeral>(c, friend_number);
|
||||||
|
|
||||||
return {_cr, c};
|
_cs.throwEventUpdate(c);
|
||||||
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for id (empty contact) and merge
|
// check for id (empty contact) and merge
|
||||||
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
c = _cs.getOneContactByID(_root, ByteSpan{f_key_opt.value()});
|
||||||
if (f_key_opt.value() == _cr.get<Contact::Components::ID>(e).data) {
|
|
||||||
c = e;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_cr.valid(c)) {
|
bool created {false};
|
||||||
|
if (!cr.valid(c)) {
|
||||||
// else, new ent
|
// else, new ent
|
||||||
c = _cr.create();
|
c = cr.create();
|
||||||
_cr.emplace<Contact::Components::ID>(c, f_key_opt.value());
|
created = true;
|
||||||
|
cr.emplace<Contact::Components::ID>(c, f_key_opt.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
_cr.emplace_or_replace<Contact::Components::TagBig>(c);
|
cr.emplace_or_replace<Contact::Components::TagBig>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxFriendEphemeral>(c, friend_number);
|
cr.emplace_or_replace<Contact::Components::ToxFriendEphemeral>(c, friend_number);
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxFriendPersistent>(c, f_key);
|
cr.emplace_or_replace<Contact::Components::ToxFriendPersistent>(c, f_key);
|
||||||
_cr.emplace_or_replace<Contact::Components::Parent>(c, _root);
|
cr.emplace_or_replace<Contact::Components::Parent>(c, _root);
|
||||||
_cr.get_or_emplace<Contact::Components::ParentOf>(_root).subs.push_back(c);
|
cr.get_or_emplace<Contact::Components::ParentOf>(_root).subs.push_back(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::ParentOf>(c).subs.assign({_friend_self, c});
|
cr.emplace_or_replace<Contact::Components::ParentOf>(c).subs.assign({_friend_self, c});
|
||||||
_cr.emplace_or_replace<Contact::Components::TagPrivate>(c);
|
cr.emplace_or_replace<Contact::Components::TagPrivate>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::Self>(c, _friend_self);
|
cr.emplace_or_replace<Contact::Components::Self>(c, _friend_self);
|
||||||
_cr.emplace_or_replace<Contact::Components::Name>(c, _t.toxFriendGetName(friend_number).value_or("<unk>"));
|
cr.emplace_or_replace<Contact::Components::Name>(c, _t.toxFriendGetName(friend_number).value_or("<unk>"));
|
||||||
_cr.emplace_or_replace<Contact::Components::StatusText>(c, _t.toxFriendGetStatusMessage(friend_number).value_or("")).fillFirstLineLength();
|
cr.emplace_or_replace<Contact::Components::StatusText>(c, _t.toxFriendGetStatusMessage(friend_number).value_or("")).fillFirstLineLength();
|
||||||
|
|
||||||
const auto ts = getTimeMS();
|
const auto ts = getTimeMS();
|
||||||
|
|
||||||
if (!_cr.all_of<Contact::Components::LastSeen>(c)) {
|
if (!cr.all_of<Contact::Components::LastSeen>(c)) {
|
||||||
auto lo_opt = _t.toxFriendGetLastOnline(friend_number);
|
auto lo_opt = _t.toxFriendGetLastOnline(friend_number);
|
||||||
if (lo_opt.has_value()) {
|
if (lo_opt.has_value()) {
|
||||||
_cr.emplace_or_replace<Contact::Components::LastSeen>(c, lo_opt.value()*1000ull);
|
cr.emplace_or_replace<Contact::Components::LastSeen>(c, lo_opt.value()*1000ull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_cr.all_of<Contact::Components::FirstSeen>(c)) {
|
if (!cr.all_of<Contact::Components::FirstSeen>(c)) {
|
||||||
if (_cr.all_of<Contact::Components::LastSeen>(c)) {
|
if (cr.all_of<Contact::Components::LastSeen>(c)) {
|
||||||
_cr.emplace_or_replace<Contact::Components::FirstSeen>(c,
|
cr.emplace_or_replace<Contact::Components::FirstSeen>(c,
|
||||||
std::min(
|
std::min(
|
||||||
_cr.get<Contact::Components::LastSeen>(c).ts,
|
cr.get<Contact::Components::LastSeen>(c).ts,
|
||||||
ts
|
ts
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// TODO: did we?
|
// TODO: did we?
|
||||||
_cr.emplace_or_replace<Contact::Components::FirstSeen>(c, ts);
|
cr.emplace_or_replace<Contact::Components::FirstSeen>(c, ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "TCM2: created friend contact " << friend_number << "\n";
|
std::cout << "TCM2: created friend contact " << friend_number << "\n";
|
||||||
|
|
||||||
return {_cr, c};
|
if (created) {
|
||||||
|
_cs.throwEventConstruct(c);
|
||||||
|
} else {
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact3Handle ToxContactModel2::getContactGroup(uint32_t group_number) {
|
ContactHandle4 ToxContactModel2::getContactGroup(uint32_t group_number) {
|
||||||
Contact3 c = entt::null;
|
auto& cr = _cs.registry();
|
||||||
|
Contact4 c = entt::null;
|
||||||
|
|
||||||
// first check contacts with group_number
|
// first check contacts with group_number
|
||||||
// TODO: lookup table
|
// TODO: lookup table
|
||||||
//_cr.view<Contact::Components::ToxGroupEphemeral>().each([&c, group_number](const Contact3 e, const Contact::Components::ToxGroupEphemeral& g_e) {
|
//_cr.view<Contact::Components::ToxGroupEphemeral>().each([&c, group_number](const Contact3 e, const Contact::Components::ToxGroupEphemeral& g_e) {
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxGroupEphemeral>()) {
|
for (const auto e : cr.view<Contact::Components::ToxGroupEphemeral>()) {
|
||||||
if (_cr.get<Contact::Components::ToxGroupEphemeral>(e).group_number == group_number) {
|
if (cr.get<Contact::Components::ToxGroupEphemeral>(e).group_number == group_number) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
return {_cr, c};
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
// else check by pubkey
|
// else check by pubkey
|
||||||
@ -237,45 +292,43 @@ Contact3Handle ToxContactModel2::getContactGroup(uint32_t group_number) {
|
|||||||
|
|
||||||
const ToxKey& g_key = g_key_opt.value();
|
const ToxKey& g_key = g_key_opt.value();
|
||||||
//_cr.view<Contact::Components::ToxGroupPersistent>().each([&c, &g_key](const Contact3 e, const Contact::Components::ToxGroupPersistent& g_key_comp) {
|
//_cr.view<Contact::Components::ToxGroupPersistent>().each([&c, &g_key](const Contact3 e, const Contact::Components::ToxGroupPersistent& g_key_comp) {
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxGroupPersistent>()) {
|
for (const auto e : cr.view<Contact::Components::ToxGroupPersistent>()) {
|
||||||
if (g_key == _cr.get<Contact::Components::ToxGroupPersistent>(e).chat_id) {
|
if (g_key == cr.get<Contact::Components::ToxGroupPersistent>(e).chat_id) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
// param group number matches pubkey in db, add
|
// param group number matches pubkey in db, add
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupEphemeral>(c, group_number);
|
cr.emplace_or_replace<Contact::Components::ToxGroupEphemeral>(c, group_number);
|
||||||
|
|
||||||
return {_cr, c};
|
_cs.throwEventUpdate(c);
|
||||||
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for id (empty contact) and merge
|
// check for id (empty contact) and merge
|
||||||
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
c = _cs.getOneContactByID(_root, ByteSpan{g_key_opt.value()});
|
||||||
if (g_key_opt.value() == _cr.get<Contact::Components::ID>(e).data) {
|
|
||||||
c = e;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_cr.valid(c)) {
|
bool created{false};
|
||||||
|
if (!cr.valid(c)) {
|
||||||
// else, new ent
|
// else, new ent
|
||||||
c = _cr.create();
|
c = cr.create();
|
||||||
_cr.emplace<Contact::Components::ID>(c, g_key_opt.value());
|
created = true;
|
||||||
|
cr.emplace<Contact::Components::ID>(c, g_key_opt.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
_cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
||||||
_cr.emplace_or_replace<Contact::Components::TagBig>(c);
|
cr.emplace_or_replace<Contact::Components::TagBig>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::Parent>(c, _root);
|
cr.emplace_or_replace<Contact::Components::Parent>(c, _root);
|
||||||
_cr.get_or_emplace<Contact::Components::ParentOf>(_root).subs.push_back(c);
|
cr.get_or_emplace<Contact::Components::ParentOf>(_root).subs.push_back(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::ParentOf>(c); // start empty
|
cr.emplace_or_replace<Contact::Components::ParentOf>(c); // start empty
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupEphemeral>(c, group_number);
|
cr.emplace_or_replace<Contact::Components::ToxGroupEphemeral>(c, group_number);
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupPersistent>(c, g_key);
|
cr.emplace_or_replace<Contact::Components::ToxGroupPersistent>(c, g_key);
|
||||||
_cr.emplace_or_replace<Contact::Components::TagGroup>(c);
|
cr.emplace_or_replace<Contact::Components::TagGroup>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::Name>(c, _t.toxGroupGetName(group_number).value_or("<unk>"));
|
cr.emplace_or_replace<Contact::Components::Name>(c, _t.toxGroupGetName(group_number).value_or("<unk>"));
|
||||||
_cr.emplace_or_replace<Contact::Components::StatusText>(c, _t.toxGroupGetTopic(group_number).value_or("")).fillFirstLineLength();
|
cr.emplace_or_replace<Contact::Components::StatusText>(c, _t.toxGroupGetTopic(group_number).value_or("")).fillFirstLineLength();
|
||||||
_cr.emplace_or_replace<Contact::Components::ConnectionState>(
|
cr.emplace_or_replace<Contact::Components::ConnectionState>(
|
||||||
c,
|
c,
|
||||||
_t.toxGroupIsConnected(group_number).value_or(false)
|
_t.toxGroupIsConnected(group_number).value_or(false)
|
||||||
? Contact::Components::ConnectionState::State::cloud
|
? Contact::Components::ConnectionState::State::cloud
|
||||||
@ -283,7 +336,7 @@ Contact3Handle ToxContactModel2::getContactGroup(uint32_t group_number) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// TODO: remove and add OnNewContact
|
// TODO: remove and add OnNewContact
|
||||||
_cr.emplace_or_replace<Contact::Components::MessageIsSame>(c,
|
cr.emplace_or_replace<Contact::Components::MessageIsSame>(c,
|
||||||
[](Message3Handle lh, Message3Handle rh) -> bool {
|
[](Message3Handle lh, Message3Handle rh) -> bool {
|
||||||
if (!lh.all_of<Message::Components::ToxGroupMessageID>() || !rh.all_of<Message::Components::ToxGroupMessageID>()) {
|
if (!lh.all_of<Message::Components::ToxGroupMessageID>() || !rh.all_of<Message::Components::ToxGroupMessageID>()) {
|
||||||
return false; // cant compare
|
return false; // cant compare
|
||||||
@ -312,37 +365,45 @@ Contact3Handle ToxContactModel2::getContactGroup(uint32_t group_number) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// TODO: move after event? throw first if create?
|
||||||
auto self_opt = _t.toxGroupSelfGetPeerId(group_number);
|
auto self_opt = _t.toxGroupSelfGetPeerId(group_number);
|
||||||
if (self_opt.has_value()) {
|
if (self_opt.has_value()) {
|
||||||
_cr.emplace_or_replace<Contact::Components::Self>(c, getContactGroupPeer(group_number, self_opt.value()));
|
cr.emplace_or_replace<Contact::Components::Self>(c, getContactGroupPeer(group_number, self_opt.value()));
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "TCM2 error: getting self for group" << group_number << "!!\n";
|
std::cerr << "TCM2 error: getting self for group" << group_number << "!!\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "TCM2: created group contact " << group_number << "\n";
|
std::cout << "TCM2: created group contact " << group_number << "\n";
|
||||||
|
|
||||||
return {_cr, c};
|
if (created) {
|
||||||
|
_cs.throwEventConstruct(c);
|
||||||
|
} else {
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
Contact3Handle ToxContactModel2::getContactGroupPeer(uint32_t group_number, uint32_t peer_number) {
|
ContactHandle4 ToxContactModel2::getContactGroupPeer(uint32_t group_number, uint32_t peer_number) {
|
||||||
Contact3 c = entt::null;
|
auto& cr = _cs.registry();
|
||||||
|
Contact4 c{entt::null};
|
||||||
|
|
||||||
Contact3Handle group_c = getContactGroup(group_number);
|
ContactHandle4 group_c = getContactGroup(group_number);
|
||||||
|
|
||||||
assert(static_cast<bool>(group_c));
|
assert(static_cast<bool>(group_c));
|
||||||
|
|
||||||
// first check contacts with peer id
|
// first check contacts with peer id
|
||||||
// TODO: lookup table
|
// TODO: lookup table
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxGroupPeerEphemeral>()) {
|
for (const auto e : cr.view<Contact::Components::ToxGroupPeerEphemeral>()) {
|
||||||
const auto& p_comp = _cr.get<Contact::Components::ToxGroupPeerEphemeral>(e);
|
const auto& p_comp = cr.get<Contact::Components::ToxGroupPeerEphemeral>(e);
|
||||||
if (p_comp.group_number == group_number && p_comp.peer_number == peer_number) {
|
if (p_comp.group_number == group_number && p_comp.peer_number == peer_number) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
return {_cr, c};
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& g_key = group_c.get<Contact::Components::ToxGroupPersistent>().chat_id;
|
const auto& g_key = group_c.get<Contact::Components::ToxGroupPersistent>().chat_id;
|
||||||
@ -357,74 +418,83 @@ Contact3Handle ToxContactModel2::getContactGroupPeer(uint32_t group_number, uint
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ToxKey& g_p_key = g_p_key_opt.value();
|
const ToxKey& g_p_key = g_p_key_opt.value();
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxGroupPeerPersistent>()) {
|
for (const auto e : cr.view<Contact::Components::ToxGroupPeerPersistent>()) {
|
||||||
const auto& g_p_key_comp = _cr.get<Contact::Components::ToxGroupPeerPersistent>(e);
|
const auto& g_p_key_comp = cr.get<Contact::Components::ToxGroupPeerPersistent>(e);
|
||||||
if (g_p_key == g_p_key_comp.peer_key && g_key == g_p_key_comp.chat_id) {
|
if (g_p_key == g_p_key_comp.peer_key && g_key == g_p_key_comp.chat_id) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
// param numbers matches pubkey in db, add
|
// param numbers matches pubkey in db, add
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(c, group_number, peer_number);
|
cr.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(c, group_number, peer_number);
|
||||||
|
|
||||||
return {_cr, c};
|
_cs.throwEventUpdate(c);
|
||||||
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for id (empty contact) and merge
|
// check for id (empty contact) and merge
|
||||||
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
//c = _cs.getOneContactByID(_root, ByteSpan{g_p_key_opt.value()});
|
||||||
if (g_p_key_opt.value() == _cr.get<Contact::Components::ID>(e).data) {
|
// technically it should be possible to have multiple contacts with the same ID in the same tox profile
|
||||||
c = e;
|
// since ngcs have their own ids, and someone might have copied the keys and uses them in multiple
|
||||||
break;
|
c = _cs.getOneContactByID(group_c, ByteSpan{g_p_key_opt.value()});
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_cr.valid(c)) {
|
bool created{false};
|
||||||
|
if (!cr.valid(c)) {
|
||||||
// else, new ent
|
// else, new ent
|
||||||
c = _cr.create();
|
c = cr.create();
|
||||||
_cr.emplace<Contact::Components::ID>(c, g_p_key_opt.value());
|
created = true;
|
||||||
|
cr.emplace<Contact::Components::ID>(c, g_p_key_opt.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
_cr.emplace_or_replace<Contact::Components::Parent>(c, group_c);
|
cr.emplace_or_replace<Contact::Components::Parent>(c, group_c);
|
||||||
{ // add sub to parent
|
{ // add sub to parent
|
||||||
auto& parent_sub_list = group_c.get_or_emplace<Contact::Components::ParentOf>().subs;
|
auto& parent_sub_list = group_c.get_or_emplace<Contact::Components::ParentOf>().subs;
|
||||||
if (std::find(parent_sub_list.cbegin(), parent_sub_list.cend(), c) == parent_sub_list.cend()) {
|
if (std::find(parent_sub_list.cbegin(), parent_sub_list.cend(), c) == parent_sub_list.cend()) {
|
||||||
parent_sub_list.push_back(c);
|
parent_sub_list.push_back(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(c, group_number, peer_number);
|
cr.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(c, group_number, peer_number);
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupPeerPersistent>(c, g_key, g_p_key);
|
cr.emplace_or_replace<Contact::Components::ToxGroupPeerPersistent>(c, g_key, g_p_key);
|
||||||
_cr.emplace_or_replace<Contact::Components::TagPrivate>(c);
|
cr.emplace_or_replace<Contact::Components::TagPrivate>(c);
|
||||||
const auto name_opt = std::get<0>(_t.toxGroupPeerGetName(group_number, peer_number));
|
const auto name_opt = std::get<0>(_t.toxGroupPeerGetName(group_number, peer_number));
|
||||||
if (name_opt.has_value()) {
|
if (name_opt.has_value()) {
|
||||||
_cr.emplace_or_replace<Contact::Components::Name>(c, name_opt.value());
|
cr.emplace_or_replace<Contact::Components::Name>(c, name_opt.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // self
|
{ // self
|
||||||
// TODO: this is very flaky
|
// TODO: this is very flaky <- what did i mean with this
|
||||||
|
// since we have the group contact, self is likely working
|
||||||
auto self_number_opt = _t.toxGroupSelfGetPeerId(group_number);
|
auto self_number_opt = _t.toxGroupSelfGetPeerId(group_number);
|
||||||
if (peer_number == self_number_opt.value()) {
|
if (self_number_opt.has_value()) {
|
||||||
_cr.emplace_or_replace<Contact::Components::TagSelfStrong>(c);
|
if (peer_number == self_number_opt.value()) {
|
||||||
|
cr.emplace_or_replace<Contact::Components::TagSelfStrong>(c);
|
||||||
|
} else {
|
||||||
|
cr.emplace_or_replace<Contact::Components::Self>(c, getContactGroupPeer(group_number, self_number_opt.value()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_cr.emplace_or_replace<Contact::Components::Self>(c, getContactGroupPeer(group_number, self_number_opt.value()));
|
std::cerr << "TCM2 error: getting self for group" << group_number << "!!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "TCM2: created group peer contact " << group_number << " " << peer_number << "\n";
|
std::cout << "TCM2: created group peer contact " << group_number << " " << peer_number << "\n";
|
||||||
|
|
||||||
return {_cr, c};
|
if (created) {
|
||||||
|
_cs.throwEventConstruct(c);
|
||||||
|
} else {
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
//Contact3Handle ToxContactModel2::getContactGroupPeer(const ToxKey& group_key, const ToxKey& peer_key) {
|
ContactHandle4 ToxContactModel2::getContactGroupPeer(uint32_t group_number, const ToxKey& peer_key) {
|
||||||
//return {};
|
auto& cr = _cs.registry();
|
||||||
//}
|
Contact4 c{entt::null};
|
||||||
|
|
||||||
Contact3Handle ToxContactModel2::getContactGroupPeer(uint32_t group_number, const ToxKey& peer_key) {
|
auto group_c = getContactGroup(group_number);
|
||||||
Contact3 c = entt::null;
|
|
||||||
|
|
||||||
Contact3Handle group_c = getContactGroup(group_number);
|
|
||||||
|
|
||||||
assert(static_cast<bool>(group_c));
|
assert(static_cast<bool>(group_c));
|
||||||
|
|
||||||
@ -432,57 +502,59 @@ Contact3Handle ToxContactModel2::getContactGroupPeer(uint32_t group_number, cons
|
|||||||
|
|
||||||
// search by key
|
// search by key
|
||||||
//_cr.view<Contact::Components::ToxGroupPeerPersistent>().each([&c, &g_key, &peer_key](const Contact3 e, const Contact::Components::ToxGroupPeerPersistent& g_p_key_comp) {
|
//_cr.view<Contact::Components::ToxGroupPeerPersistent>().each([&c, &g_key, &peer_key](const Contact3 e, const Contact::Components::ToxGroupPeerPersistent& g_p_key_comp) {
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxGroupPeerPersistent>()) {
|
for (const auto e : cr.view<Contact::Components::ToxGroupPeerPersistent>()) {
|
||||||
const auto& g_p_key_comp = _cr.get<Contact::Components::ToxGroupPeerPersistent>(e);
|
const auto& g_p_key_comp = cr.get<Contact::Components::ToxGroupPeerPersistent>(e);
|
||||||
if (peer_key == g_p_key_comp.peer_key && g_key == g_p_key_comp.chat_id) {
|
if (peer_key == g_p_key_comp.peer_key && g_key == g_p_key_comp.chat_id) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
return {_cr, c};
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: maybe not create contacts via history sync
|
// TODO: maybe not create contacts via history sync
|
||||||
// check for id (empty contact) and merge
|
// check for id (empty contact) and merge
|
||||||
const std::vector<uint8_t> peer_key_vec{peer_key.data.cbegin(), peer_key.data.cend()};
|
c = _cs.getOneContactByID(group_c, ByteSpan{peer_key.data});
|
||||||
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
|
||||||
if (peer_key_vec == _cr.get<Contact::Components::ID>(e).data) {
|
|
||||||
c = e;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_cr.valid(c)) {
|
bool created{false};
|
||||||
|
if (!cr.valid(c)) {
|
||||||
// else, new ent
|
// else, new ent
|
||||||
c = _cr.create();
|
c = cr.create();
|
||||||
_cr.emplace<Contact::Components::ID>(c, peer_key_vec);
|
created = true;
|
||||||
|
cr.emplace<Contact::Components::ID>(c, std::vector<uint8_t>(ByteSpan{peer_key.data}));
|
||||||
}
|
}
|
||||||
|
|
||||||
_cr.emplace_or_replace<Contact::Components::Parent>(c, group_c);
|
cr.emplace_or_replace<Contact::Components::Parent>(c, group_c);
|
||||||
{ // add sub to parent
|
{ // add sub to parent
|
||||||
auto& parent_sub_list = group_c.get_or_emplace<Contact::Components::ParentOf>().subs;
|
auto& parent_sub_list = group_c.get_or_emplace<Contact::Components::ParentOf>().subs;
|
||||||
if (std::find(parent_sub_list.cbegin(), parent_sub_list.cend(), c) == parent_sub_list.cend()) {
|
if (std::find(parent_sub_list.cbegin(), parent_sub_list.cend(), c) == parent_sub_list.cend()) {
|
||||||
parent_sub_list.push_back(c);
|
parent_sub_list.push_back(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
||||||
//_cr.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(c, group_number, peer_number);
|
//cr.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(c, group_number, peer_number);
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupPeerPersistent>(c, g_key, peer_key);
|
cr.emplace_or_replace<Contact::Components::ToxGroupPeerPersistent>(c, g_key, peer_key);
|
||||||
_cr.emplace_or_replace<Contact::Components::TagPrivate>(c);
|
cr.emplace_or_replace<Contact::Components::TagPrivate>(c);
|
||||||
//_cr.emplace_or_replace<Contact::Components::Name>(c, "<unk>");
|
//cr.emplace_or_replace<Contact::Components::Name>(c, "<unk>");
|
||||||
//_cr.emplace_or_replace<Contact::Components::Name>(c, std::get<0>(_t.toxGroupPeerGetName(group_number, peer_number)).value_or("<unk>"));
|
//cr.emplace_or_replace<Contact::Components::Name>(c, std::get<0>(_t.toxGroupPeerGetName(group_number, peer_number)).value_or("<unk>"));
|
||||||
|
|
||||||
{ // self
|
{ // self
|
||||||
// TODO: this is very flaky
|
// TODO: this is very flaky
|
||||||
auto self_number_opt = _t.toxGroupSelfGetPeerId(group_number);
|
auto self_number_opt = _t.toxGroupSelfGetPeerId(group_number);
|
||||||
_cr.emplace_or_replace<Contact::Components::Self>(c, getContactGroupPeer(group_number, self_number_opt.value()));
|
cr.emplace_or_replace<Contact::Components::Self>(c, getContactGroupPeer(group_number, self_number_opt.value()));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "TCM2: created group peer contact via pubkey " << group_number << "\n";
|
std::cout << "TCM2: created group peer contact via pubkey " << group_number << "\n";
|
||||||
|
|
||||||
return {_cr, c};
|
if (created) {
|
||||||
|
_cs.throwEventConstruct(c);
|
||||||
|
} else {
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {cr, c};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToxContactModel2::groupPeerCanSpeak(uint32_t group_number, uint32_t peer_number) {
|
bool ToxContactModel2::groupPeerCanSpeak(uint32_t group_number, uint32_t peer_number) {
|
||||||
@ -524,17 +596,20 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Connection_Status* e) {
|
|||||||
} else {
|
} else {
|
||||||
const auto ts = getTimeMS();
|
const auto ts = getTimeMS();
|
||||||
|
|
||||||
_cr.emplace_or_replace<Contact::Components::LastSeen>(c, ts);
|
c.emplace_or_replace<Contact::Components::LastSeen>(ts);
|
||||||
|
|
||||||
if (!_cr.all_of<Contact::Components::FirstSeen>(c)) {
|
if (!c.all_of<Contact::Components::FirstSeen>()) {
|
||||||
_cr.emplace_or_replace<Contact::Components::FirstSeen>(c, ts);
|
c.emplace_or_replace<Contact::Components::FirstSeen>(ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Status* e) {
|
bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Status* e) {
|
||||||
|
// TODO: add status codes (or strings?) and implement me
|
||||||
//tox_event_friend_status_get_status(e);
|
//tox_event_friend_status_get_status(e);
|
||||||
|
|
||||||
//TOX_USER_STATUS_NONE,
|
//TOX_USER_STATUS_NONE,
|
||||||
@ -542,6 +617,9 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Status* e) {
|
|||||||
//TOX_USER_STATUS_BUSY,
|
//TOX_USER_STATUS_BUSY,
|
||||||
|
|
||||||
//auto c = getContactFriend(tox_event_friend_status_get_friend_number(e));
|
//auto c = getContactFriend(tox_event_friend_status_get_friend_number(e));
|
||||||
|
|
||||||
|
//_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -554,6 +632,8 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Name* e) {
|
|||||||
auto c = getContactFriend(tox_event_friend_name_get_friend_number(e));
|
auto c = getContactFriend(tox_event_friend_name_get_friend_number(e));
|
||||||
c.emplace_or_replace<Contact::Components::Name>(std::string{name});
|
c.emplace_or_replace<Contact::Components::Name>(std::string{name});
|
||||||
|
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
return false; // return true?
|
return false; // return true?
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,57 +646,65 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Status_Message* e) {
|
|||||||
auto c = getContactFriend(tox_event_friend_status_message_get_friend_number(e));
|
auto c = getContactFriend(tox_event_friend_status_message_get_friend_number(e));
|
||||||
c.emplace_or_replace<Contact::Components::StatusText>(std::string{status_message}).fillFirstLineLength();
|
c.emplace_or_replace<Contact::Components::StatusText>(std::string{status_message}).fillFirstLineLength();
|
||||||
|
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
return false; // true?
|
return false; // true?
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Request* e) {
|
bool ToxContactModel2::onToxEvent(const Tox_Event_Friend_Request* e) {
|
||||||
const ToxKey pub_key{tox_event_friend_request_get_public_key(e), TOX_PUBLIC_KEY_SIZE};
|
const ToxKey pub_key{tox_event_friend_request_get_public_key(e), TOX_PUBLIC_KEY_SIZE};
|
||||||
|
|
||||||
Contact3 c = entt::null;
|
auto& cr = _cs.registry();
|
||||||
|
Contact4 c{entt::null};
|
||||||
|
|
||||||
// check for existing
|
// check for existing
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxFriendPersistent>()) {
|
for (const auto e : cr.view<Contact::Components::ToxFriendPersistent>()) {
|
||||||
if (pub_key == _cr.get<Contact::Components::ToxFriendPersistent>(e).key) {
|
if (pub_key == cr.get<Contact::Components::ToxFriendPersistent>(e).key) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
_cr.emplace_or_replace<Contact::Components::RequestIncoming>(c);
|
cr.emplace_or_replace<Contact::Components::RequestIncoming>(c);
|
||||||
_cr.remove<Contact::Components::ToxFriendEphemeral>(c);
|
cr.remove<Contact::Components::ToxFriendEphemeral>(c);
|
||||||
|
|
||||||
std::cout << "TCM2: marked friend contact as requested\n";
|
std::cout << "TCM2: marked friend contact as requested\n";
|
||||||
|
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
return false; // return false, so tox_message can handle the message
|
return false; // return false, so tox_message can handle the message
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for id (empty contact) and merge
|
// check for id (empty contact) and merge
|
||||||
const std::vector<uint8_t> pub_key_vec{pub_key.data.cbegin(), pub_key.data.cend()};
|
c = _cs.getOneContactByID(_root, ByteSpan{pub_key.data});
|
||||||
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
|
||||||
if (pub_key_vec == _cr.get<Contact::Components::ID>(e).data) {
|
|
||||||
c = e;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_cr.valid(c)) {
|
bool created{false};
|
||||||
|
if (!cr.valid(c)) {
|
||||||
// else, new ent
|
// else, new ent
|
||||||
c = _cr.create();
|
c = cr.create();
|
||||||
_cr.emplace<Contact::Components::ID>(c, pub_key_vec);
|
created = true;
|
||||||
|
cr.emplace<Contact::Components::ID>(c, static_cast<std::vector<uint8_t>>(ByteSpan{pub_key.data}));
|
||||||
}
|
}
|
||||||
|
|
||||||
_cr.emplace_or_replace<Contact::Components::RequestIncoming>(c);
|
cr.emplace_or_replace<Contact::Components::RequestIncoming>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::TagBig>(c);
|
cr.emplace_or_replace<Contact::Components::TagBig>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxFriendPersistent>(c, pub_key);
|
cr.emplace_or_replace<Contact::Components::ToxFriendPersistent>(c, pub_key);
|
||||||
_cr.emplace_or_replace<Contact::Components::Parent>(c, _root);
|
cr.emplace_or_replace<Contact::Components::Parent>(c, _root);
|
||||||
_cr.get_or_emplace<Contact::Components::ParentOf>(_root).subs.push_back(c);
|
cr.get_or_emplace<Contact::Components::ParentOf>(_root).subs.push_back(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::ParentOf>(c).subs.assign({_friend_self, c});
|
cr.emplace_or_replace<Contact::Components::ParentOf>(c).subs.assign({_friend_self, c});
|
||||||
_cr.emplace_or_replace<Contact::Components::TagPrivate>(c);
|
cr.emplace_or_replace<Contact::Components::TagPrivate>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::Self>(c, _friend_self);
|
cr.emplace_or_replace<Contact::Components::Self>(c, _friend_self);
|
||||||
|
|
||||||
std::cout << "TCM2: created friend contact (requested)\n";
|
std::cout << "TCM2: created friend contact (requested)\n";
|
||||||
|
|
||||||
|
if (created) {
|
||||||
|
_cs.throwEventConstruct(c);
|
||||||
|
} else {
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
}
|
||||||
|
|
||||||
return false; // return false, so tox_message can handle the message
|
return false; // return false, so tox_message can handle the message
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,61 +715,63 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Group_Invite* e) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// HACK: extract chatid
|
// HACK: extract chatid
|
||||||
// TODO: request better api
|
// TODO: request better api // I forgor
|
||||||
assert(tox_event_group_invite_get_invite_data_length(e) == TOX_GROUP_CHAT_ID_SIZE + TOX_GROUP_PEER_PUBLIC_KEY_SIZE);
|
assert(tox_event_group_invite_get_invite_data_length(e) == TOX_GROUP_CHAT_ID_SIZE + TOX_GROUP_PEER_PUBLIC_KEY_SIZE);
|
||||||
const ToxKey chat_id{tox_event_group_invite_get_invite_data(e), TOX_GROUP_CHAT_ID_SIZE};
|
const ToxKey chat_id{tox_event_group_invite_get_invite_data(e), TOX_GROUP_CHAT_ID_SIZE};
|
||||||
|
|
||||||
Contact3 c = entt::null;
|
auto& cr = _cs.registry();
|
||||||
|
Contact4 c{entt::null};
|
||||||
|
|
||||||
// check for existing
|
// check for existing
|
||||||
for (const auto e : _cr.view<Contact::Components::ToxGroupPersistent>()) {
|
for (const auto e : cr.view<Contact::Components::ToxGroupPersistent>()) {
|
||||||
if (chat_id == _cr.get<Contact::Components::ToxGroupPersistent>(e).chat_id) {
|
if (chat_id == cr.get<Contact::Components::ToxGroupPersistent>(e).chat_id) {
|
||||||
c = e;
|
c = e;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.valid(c)) {
|
if (cr.valid(c)) {
|
||||||
std::cout << "TCM2: already in group from invite\n";
|
std::cout << "TCM2: already in group from invite\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for id (empty contact) and merge
|
// check for id (empty contact) and merge
|
||||||
const std::vector<uint8_t> chat_id_vec{chat_id.data.cbegin(), chat_id.data.cend()};
|
c = _cs.getOneContactByID(_root, ByteSpan{chat_id.data});
|
||||||
for (const auto e : _cr.view<Contact::Components::ID>()) {
|
|
||||||
if (chat_id_vec == _cr.get<Contact::Components::ID>(e).data) {
|
|
||||||
c = e;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_cr.valid(c)) {
|
bool created{false};
|
||||||
|
if (!cr.valid(c)) {
|
||||||
// else, new ent
|
// else, new ent
|
||||||
c = _cr.create();
|
c = cr.create();
|
||||||
_cr.emplace<Contact::Components::ID>(c, chat_id_vec);
|
created = true;
|
||||||
|
cr.emplace<Contact::Components::ID>(c, static_cast<std::vector<uint8_t>>(ByteSpan{chat_id.data}));
|
||||||
}
|
}
|
||||||
|
|
||||||
_cr.emplace_or_replace<Contact::Components::RequestIncoming>(c, true, true);
|
cr.emplace_or_replace<Contact::Components::RequestIncoming>(c, true, true);
|
||||||
_cr.emplace_or_replace<Contact::Components::TagBig>(c);
|
cr.emplace_or_replace<Contact::Components::TagBig>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
cr.emplace_or_replace<Contact::Components::ContactModel>(c, this);
|
||||||
_cr.emplace_or_replace<Contact::Components::Parent>(c, _root);
|
cr.emplace_or_replace<Contact::Components::Parent>(c, _root);
|
||||||
_cr.get_or_emplace<Contact::Components::ParentOf>(_root).subs.push_back(c);
|
cr.get_or_emplace<Contact::Components::ParentOf>(_root).subs.push_back(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::ToxGroupPersistent>(c, chat_id);
|
cr.emplace_or_replace<Contact::Components::ToxGroupPersistent>(c, chat_id);
|
||||||
_cr.emplace_or_replace<Contact::Components::TagGroup>(c);
|
cr.emplace_or_replace<Contact::Components::TagGroup>(c);
|
||||||
_cr.emplace_or_replace<Contact::Components::Name>(c, std::string(group_name));
|
cr.emplace_or_replace<Contact::Components::Name>(c, std::string(group_name));
|
||||||
|
|
||||||
auto& ir = _cr.emplace<Contact::Components::ToxGroupIncomingRequest>(c);
|
auto& ir = cr.emplace<Contact::Components::ToxGroupIncomingRequest>(c);
|
||||||
ir.friend_number = tox_event_group_invite_get_friend_number(e);
|
ir.friend_number = tox_event_group_invite_get_friend_number(e);
|
||||||
ir.invite_data = {
|
ir.invite_data = {
|
||||||
tox_event_group_invite_get_invite_data(e),
|
tox_event_group_invite_get_invite_data(e),
|
||||||
tox_event_group_invite_get_invite_data(e) + tox_event_group_invite_get_invite_data_length(e)
|
tox_event_group_invite_get_invite_data(e) + tox_event_group_invite_get_invite_data_length(e)
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: self
|
// there is no self yet
|
||||||
//_cr.emplace<Contact::Components::Self>(c, _friend_self);
|
|
||||||
|
|
||||||
std::cout << "TCM2: created group contact (requested)\n";
|
std::cout << "TCM2: created group contact (requested)\n";
|
||||||
|
|
||||||
|
if (created) {
|
||||||
|
_cs.throwEventConstruct(c);
|
||||||
|
} else {
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -689,6 +779,11 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Group_Self_Join* e) {
|
|||||||
const uint32_t group_number = tox_event_group_self_join_get_group_number(e);
|
const uint32_t group_number = tox_event_group_self_join_get_group_number(e);
|
||||||
if (const auto self_id_opt = _t.toxGroupSelfGetPeerId(group_number); self_id_opt.has_value()) {
|
if (const auto self_id_opt = _t.toxGroupSelfGetPeerId(group_number); self_id_opt.has_value()) {
|
||||||
auto c = getContactGroupPeer(group_number, self_id_opt.value());
|
auto c = getContactGroupPeer(group_number, self_id_opt.value());
|
||||||
|
|
||||||
|
if (!static_cast<bool>(c)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
c.emplace_or_replace<Contact::Components::TagSelfStrong>();
|
c.emplace_or_replace<Contact::Components::TagSelfStrong>();
|
||||||
c.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::direct);
|
c.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::direct);
|
||||||
|
|
||||||
@ -699,6 +794,7 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Group_Self_Join* e) {
|
|||||||
? Contact::Components::ConnectionState::State::cloud
|
? Contact::Components::ConnectionState::State::cloud
|
||||||
: Contact::Components::ConnectionState::State::disconnected
|
: Contact::Components::ConnectionState::State::disconnected
|
||||||
);
|
);
|
||||||
|
_cs.throwEventUpdate(gc);
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
@ -712,6 +808,10 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Group_Peer_Join* e) {
|
|||||||
|
|
||||||
auto c = getContactGroupPeer(group_number, peer_number);
|
auto c = getContactGroupPeer(group_number, peer_number);
|
||||||
|
|
||||||
|
if (!static_cast<bool>(c)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// ensure its set
|
// ensure its set
|
||||||
c.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(group_number, peer_number);
|
c.emplace_or_replace<Contact::Components::ToxGroupPeerEphemeral>(group_number, peer_number);
|
||||||
|
|
||||||
@ -724,18 +824,20 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Group_Peer_Join* e) {
|
|||||||
|
|
||||||
const auto ts = getTimeMS();
|
const auto ts = getTimeMS();
|
||||||
|
|
||||||
_cr.emplace_or_replace<Contact::Components::LastSeen>(c, ts);
|
c.emplace_or_replace<Contact::Components::LastSeen>(ts);
|
||||||
|
|
||||||
if (!_cr.all_of<Contact::Components::FirstSeen>(c)) {
|
if (!c.all_of<Contact::Components::FirstSeen>()) {
|
||||||
_cr.emplace_or_replace<Contact::Components::FirstSeen>(c, ts);
|
c.emplace_or_replace<Contact::Components::FirstSeen>(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// update name
|
// update name
|
||||||
const auto name_opt = std::get<0>(_t.toxGroupPeerGetName(group_number, peer_number));
|
const auto name_opt = std::get<0>(_t.toxGroupPeerGetName(group_number, peer_number));
|
||||||
if (name_opt.has_value()) {
|
if (name_opt.has_value()) {
|
||||||
_cr.emplace_or_replace<Contact::Components::Name>(c, name_opt.value());
|
c.emplace_or_replace<Contact::Components::Name>(name_opt.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -761,6 +863,7 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Group_Peer_Exit* e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::disconnected);
|
c.emplace_or_replace<Contact::Components::ConnectionState>(Contact::Components::ConnectionState::State::disconnected);
|
||||||
|
_cs.throwEventUpdate(c); // HACK: throw update before removing ephemeral ids, so they can be used in the look up (but after setting disconnected)
|
||||||
c.remove<Contact::Components::ToxGroupPeerEphemeral>();
|
c.remove<Contact::Components::ToxGroupPeerEphemeral>();
|
||||||
|
|
||||||
// TODO: produce system message with reason?
|
// TODO: produce system message with reason?
|
||||||
@ -784,9 +887,14 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Group_Peer_Name* e) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto c = getContactGroupPeer(group_number, peer_number);
|
auto c = getContactGroupPeer(group_number, peer_number);
|
||||||
|
if (!static_cast<bool>(c)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
c.emplace_or_replace<Contact::Components::Name>(std::string{name});
|
c.emplace_or_replace<Contact::Components::Name>(std::string{name});
|
||||||
|
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -799,8 +907,14 @@ bool ToxContactModel2::onToxEvent(const Tox_Event_Group_Topic* e) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
auto c = getContactGroup(group_number);
|
auto c = getContactGroup(group_number);
|
||||||
|
if (!static_cast<bool>(c)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
c.emplace_or_replace<Contact::Components::StatusText>(std::string{topic}).fillFirstLineLength();
|
c.emplace_or_replace<Contact::Components::StatusText>(std::string{topic}).fillFirstLineLength();
|
||||||
|
|
||||||
|
_cs.throwEventUpdate(c);
|
||||||
|
|
||||||
return false; // message model needs to produce a system message
|
return false; // message model needs to produce a system message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,45 +1,49 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <solanaceae/toxcore/tox_event_interface.hpp>
|
#include <solanaceae/toxcore/tox_event_interface.hpp>
|
||||||
#include <solanaceae/contact/contact_model3.hpp>
|
#include <solanaceae/contact/contact_model4.hpp>
|
||||||
|
|
||||||
#include <solanaceae/toxcore/tox_key.hpp>
|
#include <solanaceae/toxcore/tox_key.hpp>
|
||||||
|
|
||||||
// fwd
|
// fwd
|
||||||
struct ToxI;
|
struct ToxI;
|
||||||
|
|
||||||
// tox contact model for ContactModel3I
|
// tox contact model for ContactModel4I
|
||||||
class ToxContactModel2 : public ContactModel3I, public ToxEventI {
|
class ToxContactModel2 : public ContactModel4I, public ToxEventI {
|
||||||
Contact3Registry& _cr;
|
ContactStore4I& _cs;
|
||||||
ToxI& _t;
|
ToxI& _t;
|
||||||
ToxEventProviderI::SubscriptionReference _tep_sr;
|
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||||
|
|
||||||
Contact3 _root;
|
Contact4 _root;
|
||||||
Contact3 _friend_self;
|
Contact4 _friend_self;
|
||||||
|
|
||||||
float _group_status_timer {0.f};
|
float _group_status_timer {0.f};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr const char* version {"3"};
|
static constexpr const char* version {"4"};
|
||||||
|
|
||||||
ToxContactModel2(Contact3Registry& cr, ToxI& t, ToxEventProviderI& tep);
|
ToxContactModel2(ContactStore4I& cs, ToxI& t, ToxEventProviderI& tep);
|
||||||
virtual ~ToxContactModel2(void);
|
virtual ~ToxContactModel2(void);
|
||||||
|
|
||||||
// TODO: continually fetch group peer connection state, since JF does not want to add cb/event
|
// TODO: continually fetch group peer connection state, since JF does not want to add cb/event
|
||||||
void iterate(float delta);
|
void iterate(float delta);
|
||||||
|
|
||||||
protected: // mmi
|
protected: // mmi
|
||||||
|
bool addContact(Contact4 c) override;
|
||||||
|
|
||||||
// accept incoming request
|
// accept incoming request
|
||||||
void acceptRequest(Contact3 c, std::string_view self_name, std::string_view password) override;
|
bool acceptRequest(Contact4 c, std::string_view self_name, std::string_view password) override;
|
||||||
|
|
||||||
|
bool leave(Contact4 c, std::string_view reason) override;
|
||||||
|
|
||||||
public: // util for tox code
|
public: // util for tox code
|
||||||
// also creates if non existant
|
// also creates if non existant
|
||||||
Contact3Handle getContactFriend(uint32_t friend_number);
|
ContactHandle4 getContactFriend(uint32_t friend_number);
|
||||||
|
|
||||||
Contact3Handle getContactGroup(uint32_t group_number);
|
ContactHandle4 getContactGroup(uint32_t group_number);
|
||||||
Contact3Handle getContactGroupPeer(uint32_t group_number, uint32_t peer_number);
|
ContactHandle4 getContactGroupPeer(uint32_t group_number, uint32_t peer_number);
|
||||||
//Contact3Handle getContactGroupPeer(const ToxKey& group_key, const ToxKey& peer_key);
|
//ContactHandle4 getContactGroupPeer(const ToxKey& group_key, const ToxKey& peer_key);
|
||||||
Contact3Handle getContactGroupPeer(uint32_t group_number, const ToxKey& peer_key);
|
ContactHandle4 getContactGroupPeer(uint32_t group_number, const ToxKey& peer_key);
|
||||||
|
|
||||||
// TODO: add proper perm api to contacts
|
// TODO: add proper perm api to contacts
|
||||||
bool groupPeerCanSpeak(uint32_t group_number, uint32_t peer_number);
|
bool groupPeerCanSpeak(uint32_t group_number, uint32_t peer_number);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <solanaceae/contact/contact_model3.hpp>
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace Message::Components {
|
namespace Message::Components {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <solanaceae/util/time.hpp>
|
#include <solanaceae/util/time.hpp>
|
||||||
|
|
||||||
#include <solanaceae/toxcore/tox_interface.hpp>
|
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||||
|
#include <solanaceae/contact/contact_store_i.hpp>
|
||||||
|
|
||||||
#include <solanaceae/contact/components.hpp>
|
#include <solanaceae/contact/components.hpp>
|
||||||
#include <solanaceae/tox_contacts/components.hpp>
|
#include <solanaceae/tox_contacts/components.hpp>
|
||||||
@ -17,14 +18,14 @@
|
|||||||
|
|
||||||
ToxMessageManager::ToxMessageManager(
|
ToxMessageManager::ToxMessageManager(
|
||||||
RegistryMessageModelI& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
Contact3Registry& cr,
|
ContactStore4I& cs,
|
||||||
ToxContactModel2& tcm,
|
ToxContactModel2& tcm,
|
||||||
ToxI& t,
|
ToxI& t,
|
||||||
ToxEventProviderI& tep
|
ToxEventProviderI& tep
|
||||||
) :
|
) :
|
||||||
_rmm(rmm),
|
_rmm(rmm),
|
||||||
_rmm_sr(_rmm.newSubRef(this)),
|
_rmm_sr(_rmm.newSubRef(this)),
|
||||||
_cr(cr),
|
_cs(cs),
|
||||||
_tcm(tcm),
|
_tcm(tcm),
|
||||||
_t(t),
|
_t(t),
|
||||||
_tep_sr(tep.newSubRef(this))
|
_tep_sr(tep.newSubRef(this))
|
||||||
@ -52,8 +53,9 @@ ToxMessageManager::ToxMessageManager(
|
|||||||
ToxMessageManager::~ToxMessageManager(void) {
|
ToxMessageManager::~ToxMessageManager(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, bool action) {
|
bool ToxMessageManager::sendText(const Contact4 c, std::string_view message, bool action) {
|
||||||
if (!_cr.valid(c)) {
|
const auto& cr = _cs.registry();
|
||||||
|
if (!cr.valid(c)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,12 +63,12 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
|
|||||||
return false; // TODO: empty messages allowed?
|
return false; // TODO: empty messages allowed?
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cr.all_of<Contact::Components::TagSelfStrong>(c)) {
|
if (cr.all_of<Contact::Components::TagSelfStrong>(c)) {
|
||||||
return false; // message to self? not with tox
|
return false; // message to self? not with tox
|
||||||
}
|
}
|
||||||
|
|
||||||
// testing for persistent is enough
|
// testing for persistent is enough
|
||||||
if (!_cr.any_of<
|
if (!cr.any_of<
|
||||||
Contact::Components::ToxFriendPersistent,
|
Contact::Components::ToxFriendPersistent,
|
||||||
// TODO: conf
|
// TODO: conf
|
||||||
Contact::Components::ToxGroupPersistent,
|
Contact::Components::ToxGroupPersistent,
|
||||||
@ -82,11 +84,11 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
|
|||||||
|
|
||||||
Message3Registry& reg = *reg_ptr;
|
Message3Registry& reg = *reg_ptr;
|
||||||
|
|
||||||
if (!_cr.all_of<Contact::Components::Self>(c)) {
|
if (!cr.all_of<Contact::Components::Self>(c)) {
|
||||||
std::cerr << "TMM error: cant get self\n";
|
std::cerr << "TMM error: cant get self\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const Contact3 c_self = _cr.get<Contact::Components::Self>(c).self;
|
const Contact4 c_self = cr.get<Contact::Components::Self>(c).self;
|
||||||
|
|
||||||
// get current time unix epoch utc
|
// get current time unix epoch utc
|
||||||
uint64_t ts = getTimeMS();
|
uint64_t ts = getTimeMS();
|
||||||
@ -114,8 +116,8 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
|
|||||||
|
|
||||||
reg.emplace<Message::Components::ReceivedBy>(new_msg_e).ts[c_self] = ts;
|
reg.emplace<Message::Components::ReceivedBy>(new_msg_e).ts[c_self] = ts;
|
||||||
|
|
||||||
if (_cr.any_of<Contact::Components::ToxFriendEphemeral>(c)) {
|
if (cr.any_of<Contact::Components::ToxFriendEphemeral>(c)) {
|
||||||
const uint32_t friend_number = _cr.get<Contact::Components::ToxFriendEphemeral>(c).friend_number;
|
const uint32_t friend_number = cr.get<Contact::Components::ToxFriendEphemeral>(c).friend_number;
|
||||||
|
|
||||||
auto [res, _] = _t.toxFriendSendMessage(
|
auto [res, _] = _t.toxFriendSendMessage(
|
||||||
friend_number,
|
friend_number,
|
||||||
@ -132,16 +134,16 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
|
|||||||
} else {
|
} else {
|
||||||
reg.emplace<Message::Components::ToxFriendMessageID>(new_msg_e, res.value());
|
reg.emplace<Message::Components::ToxFriendMessageID>(new_msg_e, res.value());
|
||||||
}
|
}
|
||||||
} else if (_cr.any_of<Contact::Components::ToxFriendPersistent>(c)) {
|
} else if (cr.any_of<Contact::Components::ToxFriendPersistent>(c)) {
|
||||||
// here we just assume friend not online (no ephemeral id)
|
// here we just assume friend not online (no ephemeral id)
|
||||||
// set manually, so it can still be synced
|
// set manually, so it can still be synced
|
||||||
const uint32_t msg_id = randombytes_random();
|
const uint32_t msg_id = randombytes_random();
|
||||||
reg.emplace<Message::Components::ToxFriendMessageID>(new_msg_e, msg_id);
|
reg.emplace<Message::Components::ToxFriendMessageID>(new_msg_e, msg_id);
|
||||||
std::cerr << "TMM: failed to send friend message, offline and not in tox profile\n";
|
std::cerr << "TMM: failed to send friend message, offline and not in tox profile\n";
|
||||||
} else if (
|
} else if (
|
||||||
_cr.any_of<Contact::Components::ToxGroupEphemeral>(c)
|
cr.any_of<Contact::Components::ToxGroupEphemeral>(c)
|
||||||
) {
|
) {
|
||||||
const uint32_t group_number = _cr.get<Contact::Components::ToxGroupEphemeral>(c).group_number;
|
const uint32_t group_number = cr.get<Contact::Components::ToxGroupEphemeral>(c).group_number;
|
||||||
|
|
||||||
auto [message_id_opt, _] = _t.toxGroupSendMessage(
|
auto [message_id_opt, _] = _t.toxGroupSendMessage(
|
||||||
group_number,
|
group_number,
|
||||||
@ -164,7 +166,7 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
|
|||||||
}
|
}
|
||||||
} else if (
|
} else if (
|
||||||
// non online group
|
// non online group
|
||||||
_cr.any_of<Contact::Components::ToxGroupPersistent>(c)
|
cr.any_of<Contact::Components::ToxGroupPersistent>(c)
|
||||||
) {
|
) {
|
||||||
// create msg_id
|
// create msg_id
|
||||||
const uint32_t msg_id = randombytes_random();
|
const uint32_t msg_id = randombytes_random();
|
||||||
@ -173,9 +175,9 @@ bool ToxMessageManager::sendText(const Contact3 c, std::string_view message, boo
|
|||||||
// TODO: generalize?
|
// TODO: generalize?
|
||||||
reg.emplace<Message::Components::SyncedBy>(new_msg_e).ts.emplace(c_self, ts);
|
reg.emplace<Message::Components::SyncedBy>(new_msg_e).ts.emplace(c_self, ts);
|
||||||
} else if (
|
} else if (
|
||||||
_cr.any_of<Contact::Components::ToxGroupPeerEphemeral>(c)
|
cr.any_of<Contact::Components::ToxGroupPeerEphemeral>(c)
|
||||||
) {
|
) {
|
||||||
const auto& numbers = _cr.get<Contact::Components::ToxGroupPeerEphemeral>(c);
|
const auto& numbers = cr.get<Contact::Components::ToxGroupPeerEphemeral>(c);
|
||||||
|
|
||||||
auto [message_id_opt, _] = _t.toxGroupSendPrivateMessage(
|
auto [message_id_opt, _] = _t.toxGroupSendPrivateMessage(
|
||||||
numbers.group_number,
|
numbers.group_number,
|
||||||
|
@ -11,19 +11,20 @@ class ToxMessageManager : public RegistryMessageModelEventI, public ToxEventI {
|
|||||||
protected:
|
protected:
|
||||||
RegistryMessageModelI& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
||||||
Contact3Registry& _cr;
|
ContactStore4I& _cs;
|
||||||
ToxContactModel2& _tcm;
|
ToxContactModel2& _tcm;
|
||||||
ToxI& _t;
|
ToxI& _t;
|
||||||
ToxEventProviderI::SubscriptionReference _tep_sr;
|
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ToxMessageManager(RegistryMessageModelI& rmm, Contact3Registry& cr, ToxContactModel2& tcm, ToxI& t, ToxEventProviderI& tep);
|
ToxMessageManager(RegistryMessageModelI& rmm, ContactStore4I& cs, ToxContactModel2& tcm, ToxI& t, ToxEventProviderI& tep);
|
||||||
virtual ~ToxMessageManager(void);
|
virtual ~ToxMessageManager(void);
|
||||||
|
|
||||||
public: // mm3
|
public: // mm3
|
||||||
bool sendText(const Contact3 c, std::string_view message, bool action = false) override;
|
bool sendText(const Contact4 c, std::string_view message, bool action = false) override;
|
||||||
|
|
||||||
protected: // tox events
|
protected: // tox events
|
||||||
|
// TODO: add friend request message handling
|
||||||
bool onToxEvent(const Tox_Event_Friend_Message* e) override;
|
bool onToxEvent(const Tox_Event_Friend_Message* e) override;
|
||||||
bool onToxEvent(const Tox_Event_Friend_Read_Receipt* e) override;
|
bool onToxEvent(const Tox_Event_Friend_Read_Receipt* e) override;
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <solanaceae/util/time.hpp>
|
#include <solanaceae/util/time.hpp>
|
||||||
|
|
||||||
#include <solanaceae/toxcore/tox_interface.hpp>
|
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||||
|
#include <solanaceae/contact/contact_store_i.hpp>
|
||||||
|
|
||||||
#include <solanaceae/file/file2_std.hpp>
|
#include <solanaceae/file/file2_std.hpp>
|
||||||
|
|
||||||
@ -11,8 +12,6 @@
|
|||||||
#include <solanaceae/message3/components.hpp>
|
#include <solanaceae/message3/components.hpp>
|
||||||
#include "./msg_components.hpp"
|
#include "./msg_components.hpp"
|
||||||
#include "./obj_components.hpp"
|
#include "./obj_components.hpp"
|
||||||
#include "solanaceae/object_store/meta_components.hpp"
|
|
||||||
#include "solanaceae/util/span.hpp"
|
|
||||||
|
|
||||||
#include <sodium.h>
|
#include <sodium.h>
|
||||||
|
|
||||||
@ -81,12 +80,12 @@ ObjectHandle ToxTransferManager::toxFriendLookupReceiving(const uint32_t friend_
|
|||||||
|
|
||||||
ToxTransferManager::ToxTransferManager(
|
ToxTransferManager::ToxTransferManager(
|
||||||
RegistryMessageModelI& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
Contact3Registry& cr,
|
ContactStore4I& cs,
|
||||||
ToxContactModel2& tcm,
|
ToxContactModel2& tcm,
|
||||||
ToxI& t,
|
ToxI& t,
|
||||||
ToxEventProviderI& tep,
|
ToxEventProviderI& tep,
|
||||||
ObjectStore2& os
|
ObjectStore2& os
|
||||||
) : _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _cr(cr), _tcm(tcm), _t(t), _tep_sr(tep.newSubRef(this)), _os(os), _os_sr(_os.newSubRef(this)), _ftb(os) {
|
) : _rmm(rmm), _rmm_sr(_rmm.newSubRef(this)), _cs(cs), _tcm(tcm), _t(t), _tep_sr(tep.newSubRef(this)), _os(os), _os_sr(_os.newSubRef(this)), _ftb(os) {
|
||||||
_tep_sr
|
_tep_sr
|
||||||
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS)
|
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS)
|
||||||
.subscribe(Tox_Event_Type::TOX_EVENT_FILE_RECV)
|
.subscribe(Tox_Event_Type::TOX_EVENT_FILE_RECV)
|
||||||
@ -110,10 +109,11 @@ void ToxTransferManager::iterate(void) {
|
|||||||
// TODO: time out transfers
|
// TODO: time out transfers
|
||||||
}
|
}
|
||||||
|
|
||||||
Message3Handle ToxTransferManager::toxSendFilePath(const Contact3 c, uint32_t file_kind, std::string_view file_name, std::string_view file_path, std::vector<uint8_t> file_id) {
|
Message3Handle ToxTransferManager::toxSendFilePath(const Contact4 c, uint32_t file_kind, std::string_view file_name, std::string_view file_path, std::vector<uint8_t> file_id) {
|
||||||
|
const auto& cr = _cs.registry();
|
||||||
if (
|
if (
|
||||||
// TODO: add support of offline queuing
|
// TODO: add support of offline queuing
|
||||||
!_cr.all_of<Contact::Components::ToxFriendEphemeral>(c)
|
!cr.all_of<Contact::Components::ToxFriendEphemeral>(c)
|
||||||
) {
|
) {
|
||||||
std::cerr << "TTM error: unsupported contact type\n";
|
std::cerr << "TTM error: unsupported contact type\n";
|
||||||
return {};
|
return {};
|
||||||
@ -142,8 +142,8 @@ Message3Handle ToxTransferManager::toxSendFilePath(const Contact3 c, uint32_t fi
|
|||||||
}
|
}
|
||||||
assert(file_id.size() == 32);
|
assert(file_id.size() == 32);
|
||||||
|
|
||||||
const auto c_self = _cr.get<Contact::Components::Self>(c).self;
|
const auto c_self = cr.get<Contact::Components::Self>(c).self;
|
||||||
if (!_cr.valid(c_self)) {
|
if (!cr.valid(c_self)) {
|
||||||
std::cerr << "TTM error: failed to get self!\n";
|
std::cerr << "TTM error: failed to get self!\n";
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ Message3Handle ToxTransferManager::toxSendFilePath(const Contact3 c, uint32_t fi
|
|||||||
msg.emplace<Message::Components::ReceivedBy>().ts.try_emplace(c_self, ts);
|
msg.emplace<Message::Components::ReceivedBy>().ts.try_emplace(c_self, ts);
|
||||||
msg.emplace<Message::Components::MessageFileObject>(o);
|
msg.emplace<Message::Components::MessageFileObject>(o);
|
||||||
|
|
||||||
const auto friend_number = _cr.get<Contact::Components::ToxFriendEphemeral>(c).friend_number;
|
const auto friend_number = cr.get<Contact::Components::ToxFriendEphemeral>(c).friend_number;
|
||||||
const auto&& [transfer_id, err] = _t.toxFileSend(friend_number, file_kind, file_impl->_file_size, file_id, file_name);
|
const auto&& [transfer_id, err] = _t.toxFileSend(friend_number, file_kind, file_impl->_file_size, file_id, file_name);
|
||||||
if (err == TOX_ERR_FILE_SEND_OK) {
|
if (err == TOX_ERR_FILE_SEND_OK) {
|
||||||
assert(transfer_id.has_value());
|
assert(transfer_id.has_value());
|
||||||
@ -383,10 +383,11 @@ bool ToxTransferManager::accept(ObjectHandle transfer, std::string_view file_pat
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ToxTransferManager::sendFilePath(const Contact3 c, std::string_view file_name, std::string_view file_path) {
|
bool ToxTransferManager::sendFilePath(const Contact4 c, std::string_view file_name, std::string_view file_path) {
|
||||||
|
const auto& cr = _cs.registry();
|
||||||
if (
|
if (
|
||||||
// TODO: add support of offline queuing
|
// TODO: add support of offline queuing
|
||||||
!_cr.all_of<Contact::Components::ToxFriendEphemeral>(c)
|
!cr.all_of<Contact::Components::ToxFriendEphemeral>(c)
|
||||||
) {
|
) {
|
||||||
// TODO: add support for persistant friend filesends
|
// TODO: add support for persistant friend filesends
|
||||||
return false;
|
return false;
|
||||||
@ -504,7 +505,9 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv* e) {
|
|||||||
// get current time unix epoch utc
|
// get current time unix epoch utc
|
||||||
uint64_t ts = getTimeMS();
|
uint64_t ts = getTimeMS();
|
||||||
|
|
||||||
auto self_c = _cr.get<Contact::Components::Self>(c).self;
|
const auto& cr = _cs.registry();
|
||||||
|
|
||||||
|
auto self_c = cr.get<Contact::Components::Self>(c).self;
|
||||||
|
|
||||||
o = _ftb.newObject(ByteSpan{f_id_opt.value()}, false);
|
o = _ftb.newObject(ByteSpan{f_id_opt.value()}, false);
|
||||||
|
|
||||||
@ -628,7 +631,7 @@ bool ToxTransferManager::onToxEvent(const Tox_Event_File_Recv_Chunk* e) {
|
|||||||
|
|
||||||
auto c = _tcm.getContactFriend(friend_number);
|
auto c = _tcm.getContactFriend(friend_number);
|
||||||
if (static_cast<bool>(c)) {
|
if (static_cast<bool>(c)) {
|
||||||
auto self_c = _cr.get<Contact::Components::Self>(c).self;
|
auto self_c = c.get<Contact::Components::Self>().self;
|
||||||
auto& rb = msg.get_or_emplace<Message::Components::ReceivedBy>().ts;
|
auto& rb = msg.get_or_emplace<Message::Components::ReceivedBy>().ts;
|
||||||
rb.try_emplace(self_c, ts); // on completion
|
rb.try_emplace(self_c, ts); // on completion
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,9 @@
|
|||||||
|
|
||||||
#include "./backends/tox_ft_filesystem.hpp"
|
#include "./backends/tox_ft_filesystem.hpp"
|
||||||
|
|
||||||
// switch to fwd or remove
|
//#include <solanaceae/file/file2.hpp>
|
||||||
#include <solanaceae/file/file2.hpp>
|
// fwd
|
||||||
|
struct File2I;
|
||||||
|
|
||||||
#include <entt/container/dense_map.hpp>
|
#include <entt/container/dense_map.hpp>
|
||||||
|
|
||||||
@ -20,12 +21,12 @@ struct ToxI;
|
|||||||
|
|
||||||
class ToxTransferManager : public RegistryMessageModelEventI, public ObjectStoreEventI, public ToxEventI {
|
class ToxTransferManager : public RegistryMessageModelEventI, public ObjectStoreEventI, public ToxEventI {
|
||||||
public:
|
public:
|
||||||
static constexpr const char* version {"2"};
|
static constexpr const char* version {"3"};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
RegistryMessageModelI& _rmm;
|
RegistryMessageModelI& _rmm;
|
||||||
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
RegistryMessageModelI::SubscriptionReference _rmm_sr;
|
||||||
Contact3Registry& _cr;
|
ContactStore4I& _cs;
|
||||||
ToxContactModel2& _tcm;
|
ToxContactModel2& _tcm;
|
||||||
ToxI& _t;
|
ToxI& _t;
|
||||||
ToxEventProviderI::SubscriptionReference _tep_sr;
|
ToxEventProviderI::SubscriptionReference _tep_sr;
|
||||||
@ -48,7 +49,7 @@ class ToxTransferManager : public RegistryMessageModelEventI, public ObjectStore
|
|||||||
public:
|
public:
|
||||||
ToxTransferManager(
|
ToxTransferManager(
|
||||||
RegistryMessageModelI& rmm,
|
RegistryMessageModelI& rmm,
|
||||||
Contact3Registry& cr,
|
ContactStore4I& cs,
|
||||||
ToxContactModel2& tcm,
|
ToxContactModel2& tcm,
|
||||||
ToxI& t,
|
ToxI& t,
|
||||||
ToxEventProviderI& tep,
|
ToxEventProviderI& tep,
|
||||||
@ -59,7 +60,7 @@ class ToxTransferManager : public RegistryMessageModelEventI, public ObjectStore
|
|||||||
virtual void iterate(void);
|
virtual void iterate(void);
|
||||||
|
|
||||||
public: // TODO: private?
|
public: // TODO: private?
|
||||||
Message3Handle toxSendFilePath(const Contact3 c, uint32_t file_kind, std::string_view file_name, std::string_view file_path, std::vector<uint8_t> file_id = {});
|
Message3Handle toxSendFilePath(const Contact4 c, uint32_t file_kind, std::string_view file_name, std::string_view file_path, std::vector<uint8_t> file_id = {});
|
||||||
|
|
||||||
bool resume(ObjectHandle transfer);
|
bool resume(ObjectHandle transfer);
|
||||||
bool pause(ObjectHandle transfer);
|
bool pause(ObjectHandle transfer);
|
||||||
@ -72,7 +73,7 @@ class ToxTransferManager : public RegistryMessageModelEventI, public ObjectStore
|
|||||||
bool accept(ObjectHandle transfer, std::string_view file_path, bool path_is_file);
|
bool accept(ObjectHandle transfer, std::string_view file_path, bool path_is_file);
|
||||||
|
|
||||||
protected: // (r)mm
|
protected: // (r)mm
|
||||||
bool sendFilePath(const Contact3 c, std::string_view file_name, std::string_view file_path) override;
|
bool sendFilePath(const Contact4 c, std::string_view file_name, std::string_view file_path) override;
|
||||||
|
|
||||||
protected: // os
|
protected: // os
|
||||||
//bool onEvent(const ObjectStore::Events::ObjectConstruct&) override;
|
//bool onEvent(const ObjectStore::Events::ObjectConstruct&) override;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user