This commit is contained in:
Green Sky 2024-10-25 13:04:12 +02:00
parent 1a032ce260
commit 754310ef00
No known key found for this signature in database
3 changed files with 15 additions and 19 deletions

View File

@ -2,21 +2,18 @@
#include "./tox_client.hpp"
AutoDirty::AutoDirty(ToxClient& tc) : _tc(tc), _tep_sr(_tc.newSubRef(this)) {
// TODO: add more events
void AutoDirty::subscribe(void) {
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_SELF_CONNECTION_STATUS);
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS);
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_REQUEST);
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_INVITE);
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_SELF_JOIN);
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN);
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT);
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_CONFERENCE_INVITE);
}
AutoDirty::AutoDirty(ToxClient& tc) : _tc(tc) {
subscribe();
_tep_sr
.subscribe(Tox_Event_Type::TOX_EVENT_SELF_CONNECTION_STATUS)
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS)
.subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_REQUEST)
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_INVITE)
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_SELF_JOIN)
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN)
.subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT)
.subscribe(Tox_Event_Type::TOX_EVENT_CONFERENCE_INVITE)
;
}
bool AutoDirty::onToxEvent(const Tox_Event_Self_Connection_Status*) {

View File

@ -8,8 +8,7 @@ class ToxClient;
// sets ToxClient dirty on some events
class AutoDirty : public ToxEventI {
ToxClient& _tc;
void subscribe(void); // private
ToxEventProviderI::SubscriptionReference _tep_sr;
public:
AutoDirty(ToxClient& tc);

View File

@ -205,11 +205,11 @@ int main(int argc, char** argv) {
}
ToxEventLogger tel{std::cout}; // TODO: config
// TODO: password?
ToxClient tc{conf, conf.get_string("tox", "save_file_path").value(), ""};
tel.subscribeAll(tc);
ToxEventLogger tel{tc, std::cout}; // TODO: config
tel.subscribeAll();
{ // name stuff
auto name = tc.toxSelfGetName();
if (name.empty()) {