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" #include "./tox_client.hpp"
AutoDirty::AutoDirty(ToxClient& tc) : _tc(tc), _tep_sr(_tc.newSubRef(this)) {
// TODO: add more events // TODO: add more events
_tep_sr
void AutoDirty::subscribe(void) { .subscribe(Tox_Event_Type::TOX_EVENT_SELF_CONNECTION_STATUS)
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_SELF_CONNECTION_STATUS); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS)
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_CONNECTION_STATUS); .subscribe(Tox_Event_Type::TOX_EVENT_FRIEND_REQUEST)
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_FRIEND_REQUEST); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_INVITE)
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_INVITE); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_SELF_JOIN)
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_SELF_JOIN); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN)
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_JOIN); .subscribe(Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT)
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_GROUP_PEER_EXIT); .subscribe(Tox_Event_Type::TOX_EVENT_CONFERENCE_INVITE)
_tc.subscribe(this, Tox_Event_Type::TOX_EVENT_CONFERENCE_INVITE); ;
}
AutoDirty::AutoDirty(ToxClient& tc) : _tc(tc) {
subscribe();
} }
bool AutoDirty::onToxEvent(const Tox_Event_Self_Connection_Status*) { bool AutoDirty::onToxEvent(const Tox_Event_Self_Connection_Status*) {

View File

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

View File

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