#121 Instead of explicit enable/disable IRCv3 features, just specify which ones we need.

master
Tomatix 4 years ago
parent 505231f9b2
commit 353b088dea
  1. 22
      IRCClient/IRCBase.cpp
  2. 9
      IRCClient/IRCBase.h

@ -427,30 +427,16 @@ const IRCMessage* IRCBase::getCurrentMessageRaw() const
return mp->currentMessage;
}
void IRCBase::enableIRCv3Features(const std::vector<std::string>& features)
void IRCBase::useIRCv3Features(const std::vector<std::string>& features)
{
auto isFeatureSupported = [](const std::string& feature) {
return std::find(V3Support.begin(), V3Support.end(), feature) == V3Support.end();
return std::find(V3Support.begin(), V3Support.end(), feature) != V3Support.end();
};
auto isFeatureEnabled = [this](const std::string& feature) {
return std::find(mp->ircv3enabled.begin(), mp->ircv3enabled.end(), feature) != mp->ircv3enabled.end();
};
mp->ircv3enabled.clear();
for (const auto& feature : features) {
if (!isFeatureSupported(feature) || isFeatureEnabled(feature))
continue;
else
if (isFeatureSupported(feature))
mp->ircv3enabled.emplace_back(feature);
}
}
void IRCBase::disableIRCv3Features(const std::vector<std::string>& features)
{
for (const auto& feature : features) {
auto it = std::find(mp->ircv3enabled.begin(), mp->ircv3enabled.end(), feature);
if (it != mp->ircv3enabled.end()) {
mp->ircv3enabled.erase(it);
}
}
}

@ -122,13 +122,12 @@ public:
[[nodiscard]] const IRCMessage* getCurrentMessageRaw() const;
/**
* Enables a set of IRCv3 features. The keys are strings as described by the standard (eg. account-notify, away-notify, etc.)
* Uses a set of IRCv3 features. The keys are strings as described by the standard (eg. account-notify, away-notify, etc.)
* If a feature given is not actually supported by the client, it's ignored. See 'V3Support' in IRCBasePriv.h.
* By default, if never called, all supported features are enabled. Persists between server-connections.
* To re-enable all features, pass clientV3Support() as an argument.
*/
void enableIRCv3Features(const std::vector<std::string>& features);
/// Disables a set of IRCv3 features. The keys are strings as described by the standard (eg. account-notify, away-notify, etc.)
void disableIRCv3Features(const std::vector<std::string>& features);
void useIRCv3Features(const std::vector<std::string>& features);
protected:
virtual void onConnected() {}

Loading…
Cancel
Save