23 #include "chatnetworkscfg.h" 25 #include "ini/inisection.h" 26 #include "irc/chatlogs.h" 27 #include "irc/configuration/ircconfig.h" 28 #include "patternlist.h" 31 const QString ChatNetworksCfg::SECTIONS_NAMES_PREFIX =
"Network.";
34 QList<IRCNetworkEntity> ChatNetworksCfg::autoJoinNetworks()
const 36 QList<IRCNetworkEntity> result;
46 bool ChatNetworksCfg::isAnyNetworkOnAutoJoin()
const 59 QString networkName = ini().
section(
"LastUsedNetwork").
value(
"Description").toString();
77 QList<IRCNetworkEntity> ChatNetworksCfg::networks()
const 79 QList<IRCNetworkEntity> result;
80 for (
const IniSection §ion : allNetworksSections())
82 result << loadNetwork(section);
87 void ChatNetworksCfg::setNetworks(
const QList<IRCNetworkEntity> &networks)
91 clearNetworkSections();
95 saveNetwork(networkSection(
id), network);
112 QList<IRCNetworkEntity> networks = this->networks();
113 QMutableListIterator<IRCNetworkEntity> it(networks);
123 setNetworks(networks);
128 if (!
ChatLogs().renameNetwork(errorDisplayParentWidget, oldDescription, newNetwork.
description()))
130 QList<IRCNetworkEntity> networks = this->networks();
131 QMutableListIterator<IRCNetworkEntity> it(networks);
137 network = newNetwork;
141 setNetworks(networks);
145 void ChatNetworksCfg::clearNetworkSections()
147 for (
const IniSection §ion : allNetworksSections())
156 network.setAddress(section[
"Address"]);
157 network.setAutojoinNetwork(section[
"bAutojoinNetwork"]);
158 network.setAutojoinChannels(static_cast<QString>(section[
"AutojoinChannels"])
159 .split(
" ", QString::SkipEmptyParts));
160 network.setAutojoinCommands(section.
value(
"AutojoinCommands").toStringList());
161 network.setDescription(section[
"Description"]);
162 network.setIgnoredUsers(PatternList::deserializeQVariant(section.
value(
"IgnoredUsers")));
163 network.setNickservCommand(section[
"NickservCommand"]);
164 network.setNickservPassword(section[
"NickservPassword"]);
165 network.setPassword(section[
"Password"]);
166 network.setPort(section[
"Port"]);
172 section[
"Address"] = network.
address();
177 section.
setValue(
"IgnoredUsers", network.ignoredUsers().serializeQVariant());
178 section[
"NickservCommand"] = network.nickservCommand();
179 section[
"NickservPassword"] = network.nickservPassword();
180 section[
"Password"] = network.
password();
181 section[
"Port"] = network.
port();
184 QVector<IniSection> ChatNetworksCfg::allNetworksSections()
const 189 IniSection ChatNetworksCfg::networkSection(
int id)
191 return ini().
section(SECTIONS_NAMES_PREFIX +
id);
194 Ini &ChatNetworksCfg::ini()
const 196 return *gIRCConfig.ini();
unsigned short port() const
Port of the server or network to connect to.
const QStringList & autojoinChannels() const
List of channels to which a /join command will be issued automatically when a connection with this ne...
QVector< IniSection > sectionsArray(const QString ®exPattern)
const QString & description() const
A short, human-readable description for the network. (Preferably a single word).
bool isAutojoinNetwork() const
Join this network when Doomseeker starts up.
QVariant value(const QString &key) const
Retrieves a variable directly; omits the IniVariable system.
bool replaceNetwork(const QString &oldDescription, const IRCNetworkEntity &newNetwork, QWidget *errorDisplayParentWidget)
Replace network definition in config and move around log files.
void setValue(const QString &key, const QVariant &value)
Sets a variable directly. Omits the IniVariable system.
Data structure that describes and defines a connection to an IRC network or server.
INI section representation.
const QStringList & autojoinCommands() const
List of commands executed on network join.
void removeNetwork(const IRCNetworkEntity &network)
Remove network definition from config.
IniSection section(const QString &name)
Access configuration file section.
void deleteSection(const QString §ionname)
const QString & password() const
Password for the server or network. Ignored if empty.
const QString & address() const
Address of the server or network to connect to.