23 #include "chatnetworkscfg.h"
25 #include "irc/chatlogs.h"
26 #include "irc/configuration/ircconfig.h"
27 #include "ini/inisection.h"
28 #include "patternlist.h"
31 const QString ChatNetworksCfg::SECTIONS_NAMES_PREFIX =
"Network.";
34 QList<IRCNetworkEntity> ChatNetworksCfg::autoJoinNetworks()
const
36 QList<IRCNetworkEntity> result;
48 bool ChatNetworksCfg::isAnyNetworkOnAutoJoin()
const
63 QString networkName = ini().
section(
"LastUsedNetwork").
value(
"Description").toString();
83 QList<IRCNetworkEntity> ChatNetworksCfg::networks()
const
85 QList<IRCNetworkEntity> result;
86 foreach (
const IniSection §ion, allNetworksSections())
88 result << loadNetwork(section);
93 void ChatNetworksCfg::setNetworks(
const QList<IRCNetworkEntity> &networks)
97 clearNetworkSections();
101 saveNetwork(networkSection(
id), network);
120 if (!
ChatLogs().renameNetwork(errorDisplayParentWidget, oldDescription, newNetwork.
description()))
124 QList<IRCNetworkEntity> networks = this->networks();
125 QMutableListIterator<IRCNetworkEntity> it(networks);
131 network = newNetwork;
135 setNetworks(networks);
139 void ChatNetworksCfg::clearNetworkSections()
141 foreach (
const IniSection& section, allNetworksSections())
150 network.setAddress(section[
"Address"]);
151 network.setAutojoinNetwork(section[
"bAutojoinNetwork"]);
152 network.setAutojoinChannels(static_cast<QString>(section[
"AutojoinChannels"])
153 .split(
" ", QString::SkipEmptyParts));
154 network.setAutojoinCommands(section.
value(
"AutojoinCommands").toStringList());
155 network.setDescription(section[
"Description"]);
156 network.setIgnoredUsers(PatternList::deserializeQVariant(section.
value(
"IgnoredUsers")));
157 network.setNickservCommand(section[
"NickservCommand"]);
158 network.setNickservPassword(section[
"NickservPassword"]);
159 network.setPassword(section[
"Password"]);
160 network.setPort(section[
"Port"]);
166 section[
"Address"] = network.
address();
171 section.
setValue(
"IgnoredUsers", network.ignoredUsers().serializeQVariant());
172 section[
"NickservCommand"] = network.nickservCommand();
173 section[
"NickservPassword"] = network.nickservPassword();
174 section[
"Password"] = network.
password();
175 section[
"Port"] = network.
port();
178 QVector<IniSection> ChatNetworksCfg::allNetworksSections()
const
183 IniSection ChatNetworksCfg::networkSection(
int id)
185 return ini().
section(SECTIONS_NAMES_PREFIX +
id);
188 Ini& ChatNetworksCfg::ini()
const
190 return *gIRCConfig.ini();
unsigned short port() const
Port of the server or network to connect to.
const QString & name() const
A name (or path) of this section with lettercase preserved.
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.
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.