channels now PART when they are destroyed
This commit is contained in:
@@ -95,12 +95,12 @@ void AbstractIrcServer::writeConnectionMessageReceived(Communi::IrcMessage *mess
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<Channel> AbstractIrcServer::addChannel(const QString &dirtyChannelName)
|
||||
std::shared_ptr<Channel> AbstractIrcServer::getOrAddChannel(const QString &dirtyChannelName)
|
||||
{
|
||||
auto channelName = this->CleanChannelName(dirtyChannelName);
|
||||
auto channelName = this->cleanChannelName(dirtyChannelName);
|
||||
|
||||
// try get channel
|
||||
ChannelPtr chan = this->getChannel(channelName);
|
||||
ChannelPtr chan = this->getChannelOrEmpty(channelName);
|
||||
if (chan != Channel::getEmpty()) {
|
||||
return chan;
|
||||
}
|
||||
@@ -121,6 +121,14 @@ std::shared_ptr<Channel> AbstractIrcServer::addChannel(const QString &dirtyChann
|
||||
|
||||
debug::Log("[AbstractIrcServer::addChannel] {} was destroyed", clojuresInCppAreShit);
|
||||
this->channels.remove(clojuresInCppAreShit);
|
||||
|
||||
if (this->readConnection) {
|
||||
this->readConnection->sendRaw("PART #" + clojuresInCppAreShit);
|
||||
}
|
||||
|
||||
if (this->writeConnection) {
|
||||
this->writeConnection->sendRaw("PART #" + clojuresInCppAreShit);
|
||||
}
|
||||
});
|
||||
|
||||
// join irc channel
|
||||
@@ -139,9 +147,9 @@ std::shared_ptr<Channel> AbstractIrcServer::addChannel(const QString &dirtyChann
|
||||
return chan;
|
||||
}
|
||||
|
||||
std::shared_ptr<Channel> AbstractIrcServer::getChannel(const QString &dirtyChannelName)
|
||||
std::shared_ptr<Channel> AbstractIrcServer::getChannelOrEmpty(const QString &dirtyChannelName)
|
||||
{
|
||||
auto channelName = this->CleanChannelName(dirtyChannelName);
|
||||
auto channelName = this->cleanChannelName(dirtyChannelName);
|
||||
|
||||
std::lock_guard<std::mutex> lock(this->channelMutex);
|
||||
|
||||
@@ -214,7 +222,7 @@ std::shared_ptr<Channel> AbstractIrcServer::getCustomChannel(const QString &chan
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString AbstractIrcServer::CleanChannelName(const QString &dirtyChannelName)
|
||||
QString AbstractIrcServer::cleanChannelName(const QString &dirtyChannelName)
|
||||
{
|
||||
return dirtyChannelName;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ public:
|
||||
void sendMessage(const QString &channelName, const QString &message);
|
||||
|
||||
// channels
|
||||
std::shared_ptr<Channel> addChannel(const QString &dirtyChannelName);
|
||||
std::shared_ptr<Channel> getChannel(const QString &dirtyChannelName);
|
||||
std::shared_ptr<Channel> getOrAddChannel(const QString &dirtyChannelName);
|
||||
std::shared_ptr<Channel> getChannelOrEmpty(const QString &dirtyChannelName);
|
||||
|
||||
// signals
|
||||
pajlada::Signals::NoArgSignal connected;
|
||||
@@ -56,7 +56,7 @@ protected:
|
||||
|
||||
virtual std::shared_ptr<Channel> getCustomChannel(const QString &channelName);
|
||||
|
||||
virtual QString CleanChannelName(const QString &dirtyChannelName);
|
||||
virtual QString cleanChannelName(const QString &dirtyChannelName);
|
||||
|
||||
QMap<QString, std::weak_ptr<Channel>> channels;
|
||||
std::mutex channelMutex;
|
||||
|
||||
Reference in New Issue
Block a user