Commit 43b5b696 authored by louiz’'s avatar louiz’

Add some scopes around various XmlSubNode

parent 9f7782bb
...@@ -122,45 +122,48 @@ void ConfigureGlobalStep1(XmppComponent&, AdhocSession& session, XmlNode& comman ...@@ -122,45 +122,48 @@ void ConfigureGlobalStep1(XmppComponent&, AdhocSession& session, XmlNode& comman
XmlSubNode instructions(x, "instructions"); XmlSubNode instructions(x, "instructions");
instructions.set_inner("Edit the form, to configure your global settings for the component."); instructions.set_inner("Edit the form, to configure your global settings for the component.");
XmlSubNode max_histo_length(x, "field");
max_histo_length["var"] = "max_history_length";
max_histo_length["type"] = "text-single";
max_histo_length["label"] = "Max history length";
max_histo_length["desc"] = "The maximum number of lines in the history that the server sends when joining a channel";
{ {
XmlSubNode value(max_histo_length, "value"); XmlSubNode max_histo_length(x, "field");
value.set_inner(std::to_string(options.col<Database::MaxHistoryLength>())); max_histo_length["var"] = "max_history_length";
max_histo_length["type"] = "text-single";
max_histo_length["label"] = "Max history length";
max_histo_length["desc"] = "The maximum number of lines in the history that the server sends when joining a channel";
{
XmlSubNode value(max_histo_length, "value");
value.set_inner(std::to_string(options.col<Database::MaxHistoryLength>()));
}
} }
XmlSubNode record_history(x, "field");
record_history["var"] = "record_history";
record_history["type"] = "boolean";
record_history["label"] = "Record history";
record_history["desc"] = "Whether to save the messages into the database, or not";
{ {
XmlSubNode value(record_history, "value"); XmlSubNode record_history(x, "field");
value.set_name("value"); record_history["var"] = "record_history";
if (options.col<Database::RecordHistory>()) record_history["type"] = "boolean";
value.set_inner("true"); record_history["label"] = "Record history";
else record_history["desc"] = "Whether to save the messages into the database, or not";
value.set_inner("false"); {
XmlSubNode value(record_history, "value");
value.set_name("value");
if (options.col<Database::RecordHistory>())
value.set_inner("true");
else
value.set_inner("false");
}
} }
XmlSubNode persistent(x, "field");
persistent["var"] = "persistent";
persistent["type"] = "boolean";
persistent["label"] = "Make all channels persistent";
persistent["desc"] = "If true, all channels will be persistent";
{ {
XmlSubNode value(persistent, "value"); XmlSubNode persistent(x, "field");
value.set_name("value"); persistent["var"] = "persistent";
if (options.col<Database::Persistent>()) persistent["type"] = "boolean";
value.set_inner("true"); persistent["label"] = "Make all channels persistent";
else persistent["desc"] = "If true, all channels will be persistent";
value.set_inner("false"); {
XmlSubNode value(persistent, "value");
value.set_name("value");
if (options.col<Database::Persistent>())
value.set_inner("true");
else
value.set_inner("false");
}
} }
} }
...@@ -224,96 +227,112 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com ...@@ -224,96 +227,112 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com
XmlSubNode instructions(x, "instructions"); XmlSubNode instructions(x, "instructions");
instructions.set_inner("Edit the form, to configure the settings of the IRC server "s + server_domain); instructions.set_inner("Edit the form, to configure the settings of the IRC server "s + server_domain);
XmlSubNode ports(x, "field"); {
ports["var"] = "ports"; XmlSubNode ports(x, "field");
ports["type"] = "text-multi"; ports["var"] = "ports";
ports["label"] = "Ports"; ports["type"] = "text-multi";
ports["desc"] = "List of ports to try, without TLS. Defaults: 6667."; ports["label"] = "Ports";
for (const auto& val: utils::split(options.col<Database::Ports>(), ';', false)) ports["desc"] = "List of ports to try, without TLS. Defaults: 6667.";
{ for (const auto& val: utils::split(options.col<Database::Ports>(), ';', false))
XmlSubNode ports_value(ports, "value"); {
ports_value.set_inner(val); XmlSubNode ports_value(ports, "value");
} ports_value.set_inner(val);
}
}
#ifdef BOTAN_FOUND #ifdef BOTAN_FOUND
XmlSubNode tls_ports(x, "field"); {
tls_ports["var"] = "tls_ports"; XmlSubNode tls_ports(x, "field");
tls_ports["type"] = "text-multi"; tls_ports["var"] = "tls_ports";
tls_ports["label"] = "TLS ports"; tls_ports["type"] = "text-multi";
tls_ports["desc"] = "List of ports to try, with TLS. Defaults: 6697, 6670."; tls_ports["label"] = "TLS ports";
for (const auto& val: utils::split(options.col<Database::TlsPorts>(), ';', false)) tls_ports["desc"] = "List of ports to try, with TLS. Defaults: 6697, 6670.";
{ for (const auto& val: utils::split(options.col<Database::TlsPorts>(), ';', false))
XmlSubNode tls_ports_value(tls_ports, "value"); {
tls_ports_value.set_inner(val); XmlSubNode tls_ports_value(tls_ports, "value");
} tls_ports_value.set_inner(val);
}
}
XmlSubNode verify_cert(x, "field"); {
verify_cert["var"] = "verify_cert"; XmlSubNode verify_cert(x, "field");
verify_cert["type"] = "boolean"; verify_cert["var"] = "verify_cert";
verify_cert["label"] = "Verify certificate"; verify_cert["type"] = "boolean";
verify_cert["desc"] = "Whether or not to abort the connection if the server’s TLS certificate is invalid"; verify_cert["label"] = "Verify certificate";
XmlSubNode verify_cert_value(verify_cert, "value"); verify_cert["desc"] = "Whether or not to abort the connection if the server’s TLS certificate is invalid";
if (options.col<Database::VerifyCert>()) XmlSubNode verify_cert_value(verify_cert, "value");
verify_cert_value.set_inner("true"); if (options.col<Database::VerifyCert>())
else verify_cert_value.set_inner("true");
verify_cert_value.set_inner("false"); else
verify_cert_value.set_inner("false");
}
XmlSubNode fingerprint(x, "field"); {
fingerprint["var"] = "fingerprint"; XmlSubNode fingerprint(x, "field");
fingerprint["type"] = "text-single"; fingerprint["var"] = "fingerprint";
fingerprint["label"] = "SHA-1 fingerprint of the TLS certificate to trust."; fingerprint["type"] = "text-single";
if (!options.col<Database::TrustedFingerprint>().empty()) fingerprint["label"] = "SHA-1 fingerprint of the TLS certificate to trust.";
{ if (!options.col<Database::TrustedFingerprint>().empty())
XmlSubNode fingerprint_value(fingerprint, "value"); {
fingerprint_value.set_inner(options.col<Database::TrustedFingerprint>()); XmlSubNode fingerprint_value(fingerprint, "value");
} fingerprint_value.set_inner(options.col<Database::TrustedFingerprint>());
}
}
#endif #endif
{
XmlSubNode pass(x, "field");
pass["var"] = "pass";
pass["type"] = "text-private";
pass["label"] = "Server password";
pass["desc"] = "Will be used in a PASS command when connecting";
if (!options.col<Database::Pass>().empty())
{
XmlSubNode pass_value(pass, "value");
pass_value.set_inner(options.col<Database::Pass>());
}
}
XmlSubNode pass(x, "field"); {
pass["var"] = "pass"; XmlSubNode after_cnt_cmd(x, "field");
pass["type"] = "text-private"; after_cnt_cmd["var"] = "after_connect_command";
pass["label"] = "Server password"; after_cnt_cmd["type"] = "text-single";
pass["desc"] = "Will be used in a PASS command when connecting"; after_cnt_cmd["desc"] = "Custom IRC command sent after the connection is established with the server.";
if (!options.col<Database::Pass>().empty()) after_cnt_cmd["label"] = "After-connection IRC command";
{ if (!options.col<Database::AfterConnectionCommand>().empty())
XmlSubNode pass_value(pass, "value"); {
pass_value.set_inner(options.col<Database::Pass>()); XmlSubNode after_cnt_cmd_value(after_cnt_cmd, "value");
} after_cnt_cmd_value.set_inner(options.col<Database::AfterConnectionCommand>());
}
XmlSubNode after_cnt_cmd(x, "field"); }
after_cnt_cmd["var"] = "after_connect_command";
after_cnt_cmd["type"] = "text-single";
after_cnt_cmd["desc"] = "Custom IRC command sent after the connection is established with the server.";
after_cnt_cmd["label"] = "After-connection IRC command";
if (!options.col<Database::AfterConnectionCommand>().empty())
{
XmlSubNode after_cnt_cmd_value(after_cnt_cmd, "value");
after_cnt_cmd_value.set_inner(options.col<Database::AfterConnectionCommand>());
}
if (Config::get("realname_customization", "true") == "true") if (Config::get("realname_customization", "true") == "true")
{ {
XmlSubNode username(x, "field"); {
username["var"] = "username"; XmlSubNode username(x, "field");
username["type"] = "text-single"; username["var"] = "username";
username["label"] = "Username"; username["type"] = "text-single";
if (!options.col<Database::Username>().empty()) username["label"] = "Username";
{ if (!options.col<Database::Username>().empty())
XmlSubNode username_value(username, "value"); {
username_value.set_inner(options.col<Database::Username>()); XmlSubNode username_value(username, "value");
} username_value.set_inner(options.col<Database::Username>());
}
XmlSubNode realname(x, "field"); }
realname["var"] = "realname";
realname["type"] = "text-single"; {
realname["label"] = "Realname"; XmlSubNode realname(x, "field");
if (!options.col<Database::Realname>().empty()) realname["var"] = "realname";
{ realname["type"] = "text-single";
XmlSubNode realname_value(realname, "value"); realname["label"] = "Realname";
realname_value.set_inner(options.col<Database::Realname>()); if (!options.col<Database::Realname>().empty())
} {
XmlSubNode realname_value(realname, "value");
realname_value.set_inner(options.col<Database::Realname>());
}
}
} }
{
XmlSubNode encoding_out(x, "field"); XmlSubNode encoding_out(x, "field");
encoding_out["var"] = "encoding_out"; encoding_out["var"] = "encoding_out";
encoding_out["type"] = "text-single"; encoding_out["type"] = "text-single";
...@@ -324,17 +343,20 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com ...@@ -324,17 +343,20 @@ void ConfigureIrcServerStep1(XmppComponent&, AdhocSession& session, XmlNode& com
XmlSubNode encoding_out_value(encoding_out, "value"); XmlSubNode encoding_out_value(encoding_out, "value");
encoding_out_value.set_inner(options.col<Database::EncodingOut>()); encoding_out_value.set_inner(options.col<Database::EncodingOut>());
} }
}
XmlSubNode encoding_in(x, "field"); {
encoding_in["var"] = "encoding_in"; XmlSubNode encoding_in(x, "field");
encoding_in["type"] = "text-single"; encoding_in["var"] = "encoding_in";
encoding_in["desc"] = "The encoding used to decode message received from the IRC server."; encoding_in["type"] = "text-single";
encoding_in["label"] = "In encoding"; encoding_in["desc"] = "The encoding used to decode message received from the IRC server.";
if (!options.col<Database::EncodingIn>().empty()) encoding_in["label"] = "In encoding";
{ if (!options.col<Database::EncodingIn>().empty())
XmlSubNode encoding_in_value(encoding_in, "value"); {
encoding_in_value.set_inner(options.col<Database::EncodingIn>()); XmlSubNode encoding_in_value(encoding_in, "value");
} encoding_in_value.set_inner(options.col<Database::EncodingIn>());
}
}
} }
void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node) void ConfigureIrcServerStep2(XmppComponent&, AdhocSession& session, XmlNode& command_node)
...@@ -444,7 +466,6 @@ void insert_irc_channel_configuration_form(XmlNode& node, const Jid& requester, ...@@ -444,7 +466,6 @@ void insert_irc_channel_configuration_form(XmlNode& node, const Jid& requester,
auto options = Database::get_irc_channel_options_with_server_default(requester.local + "@" + requester.domain, auto options = Database::get_irc_channel_options_with_server_default(requester.local + "@" + requester.domain,
iid.get_server(), iid.get_local()); iid.get_server(), iid.get_local());
XmlSubNode x(node, "jabber:x:data:x"); XmlSubNode x(node, "jabber:x:data:x");
x["type"] = "form"; x["type"] = "form";
XmlSubNode title(x, "title"); XmlSubNode title(x, "title");
...@@ -452,60 +473,67 @@ void insert_irc_channel_configuration_form(XmlNode& node, const Jid& requester, ...@@ -452,60 +473,67 @@ void insert_irc_channel_configuration_form(XmlNode& node, const Jid& requester,
XmlSubNode instructions(x, "instructions"); XmlSubNode instructions(x, "instructions");
instructions.set_inner("Edit the form, to configure the settings of the IRC channel "s + iid.get_local()); instructions.set_inner("Edit the form, to configure the settings of the IRC channel "s + iid.get_local());
XmlSubNode record_history(x, "field");
record_history["var"] = "record_history";
record_history["type"] = "list-single";
record_history["label"] = "Record history for this channel";
record_history["desc"] = "If unset, the value is the one configured globally";
{ {
// Value selected by default XmlSubNode record_history(x, "field");
XmlSubNode value(record_history, "value"); record_history["var"] = "record_history";
value.set_inner(options.col<Database::RecordHistoryOptional>().to_string()); record_history["type"] = "list-single";
record_history["label"] = "Record history for this channel";
record_history["desc"] = "If unset, the value is the one configured globally";
{
// Value selected by default
XmlSubNode value(record_history, "value");
value.set_inner(options.col<Database::RecordHistoryOptional>().to_string());
}
// All three possible values
for (const auto& val: {"unset", "true", "false"})
{
XmlSubNode option(record_history, "option");
option["label"] = val;
XmlSubNode value(option, "value");
value.set_inner(val);
}
} }
// All three possible values
for (const auto& val: {"unset", "true", "false"})
{ {
XmlSubNode option(record_history, "option"); XmlSubNode encoding_out(x, "field");
option["label"] = val; encoding_out["var"] = "encoding_out";
XmlSubNode value(option, "value"); encoding_out["type"] = "text-single";
value.set_inner(val); encoding_out["desc"] = "The encoding used when sending messages to the IRC server. Defaults to the server's “out encoding” if unset for the channel";
encoding_out["label"] = "Out encoding";
if (!options.col<Database::EncodingOut>().empty())
{
XmlSubNode encoding_out_value(encoding_out, "value");
encoding_out_value.set_inner(options.col<Database::EncodingOut>());
}
} }
XmlSubNode encoding_out(x, "field"); {
encoding_out["var"] = "encoding_out"; XmlSubNode encoding_in(x, "field");
encoding_out["type"] = "text-single"; encoding_in["var"] = "encoding_in";
encoding_out["desc"] = "The encoding used when sending messages to the IRC server. Defaults to the server's “out encoding” if unset for the channel"; encoding_in["type"] = "text-single";
encoding_out["label"] = "Out encoding"; encoding_in["desc"] = "The encoding used to decode message received from the IRC server. Defaults to the server's “in encoding” if unset for the channel";
if (!options.col<Database::EncodingOut>().empty()) encoding_in["label"] = "In encoding";
{ if (!options.col<Database::EncodingIn>().empty())
XmlSubNode encoding_out_value(encoding_out, "value"); {
encoding_out_value.set_inner(options.col<Database::EncodingOut>()); XmlSubNode encoding_in_value(encoding_in, "value");
} encoding_in_value.set_inner(options.col<Database::EncodingIn>());
}
}
XmlSubNode encoding_in(x, "field"); {
encoding_in["var"] = "encoding_in"; XmlSubNode persistent(x, "field");
encoding_in["type"] = "text-single"; persistent["var"] = "persistent";
encoding_in["desc"] = "The encoding used to decode message received from the IRC server. Defaults to the server's “in encoding” if unset for the channel"; persistent["type"] = "boolean";
encoding_in["label"] = "In encoding"; persistent["desc"] = "If set to true, when all XMPP clients have left this channel, biboumi will stay idle in it, without sending a PART command.";
if (!options.col<Database::EncodingIn>().empty()) persistent["label"] = "Persistent";
{ {
XmlSubNode encoding_in_value(encoding_in, "value"); XmlSubNode value(persistent, "value");
encoding_in_value.set_inner(options.col<Database::EncodingIn>()); value.set_name("value");
if (options.col<Database::Persistent>())
value.set_inner("true");
else
value.set_inner("false");
} }
XmlSubNode persistent(x, "field");
persistent["var"] = "persistent";
persistent["type"] = "boolean";
persistent["desc"] = "If set to true, when all XMPP clients have left this channel, biboumi will stay idle in it, without sending a PART command.";
persistent["label"] = "Persistent";
{
XmlSubNode value(persistent, "value");
value.set_name("value");
if (options.col<Database::Persistent>())
value.set_inner("true");
else
value.set_inner("false");
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment