diff --git a/source/shared_lib/include/platform/posix/ircclient.h b/source/shared_lib/include/platform/posix/ircclient.h index 29c96f953..8d6cc7569 100644 --- a/source/shared_lib/include/platform/posix/ircclient.h +++ b/source/shared_lib/include/platform/posix/ircclient.h @@ -74,6 +74,8 @@ protected: Mutex mutexIRCCB; IRCCallbackInterface *callbackObj; + bool wantToLeaveChannel; + public: IRCThread(const std::vector &argv,IRCCallbackInterface *callbackObj); @@ -81,6 +83,8 @@ public: virtual void signalQuit(); virtual bool shutdownAndWait(); + bool getWantToLeaveChannel() const { return wantToLeaveChannel; } + void SendIRCCmdMessage(string target, string msg); std::vector getNickList(); bool isConnected(); diff --git a/source/shared_lib/sources/platform/posix/ircclient.cpp b/source/shared_lib/sources/platform/posix/ircclient.cpp index cc4747f50..7f3918ccb 100644 --- a/source/shared_lib/sources/platform/posix/ircclient.cpp +++ b/source/shared_lib/sources/platform/posix/ircclient.cpp @@ -159,6 +159,10 @@ void event_join(irc_session_t * session, const char * event, const char * origin nickList.push_back(realNick); } } + + if(ctx->getWantToLeaveChannel() == true) { + ctx->leaveChannel(); + } } } @@ -456,6 +460,7 @@ IRCThread::IRCThread(const std::vector &argv, IRCCallbackInterface *call eventDataDone = false; hasJoinedChannel = false; lastNickListUpdate = time(NULL); + wantToLeaveChannel = false; } void IRCThread::signalQuit() { @@ -727,6 +732,7 @@ void IRCThread::connectToHost() { } void IRCThread::joinChannel() { + wantToLeaveChannel = false; connectToHost(); if(ircSession != NULL) { IRCThread *ctx = (IRCThread *)irc_get_ctx(ircSession); @@ -742,6 +748,7 @@ void IRCThread::joinChannel() { } void IRCThread::leaveChannel() { + wantToLeaveChannel = true; if(ircSession != NULL) { IRCThread *ctx = (IRCThread *)irc_get_ctx(ircSession); if(ctx != NULL) {