summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2015-09-01 04:42:12 +0200
committerFlorent Le Coz <louiz@louiz.org>2015-09-01 04:42:12 +0200
commite8f22efe34415db0e1e5cb94635b089b18efe055 (patch)
tree64088065cd97cb941b9d35016c0dcf3aaf355c5e /src
parentdf006a191603c4a9f0bb364affa3731c2944fef5 (diff)
downloadbiboumi-e8f22efe34415db0e1e5cb94635b089b18efe055.tar.gz
biboumi-e8f22efe34415db0e1e5cb94635b089b18efe055.tar.bz2
biboumi-e8f22efe34415db0e1e5cb94635b089b18efe055.tar.xz
biboumi-e8f22efe34415db0e1e5cb94635b089b18efe055.zip
XmlNodes are now always closed
Remove the close() method and closed attribute. Remove all the calls to close(). (Save one bool per XmlNode, yay, and save a few ifs and some useless function calls. At best it should be unnoticeably faster and lighter and save a few keystrokes in the future)
Diffstat (limited to 'src')
-rw-r--r--src/bridge/colors.cpp8
-rw-r--r--src/xmpp/biboumi_adhoc_commands.cpp12
-rw-r--r--src/xmpp/biboumi_component.cpp12
3 files changed, 1 insertions, 31 deletions
diff --git a/src/bridge/colors.cpp b/src/bridge/colors.cpp
index 3d40ac4..bdc34bf 100644
--- a/src/bridge/colors.cpp
+++ b/src/bridge/colors.cpp
@@ -80,7 +80,6 @@ Xmpp::body irc_format_to_xhtmlim(const std::string& s)
else if (s[pos_end] == IRC_FORMAT_NEWLINE_CHAR)
{
XmlNode* br_node = new XmlNode("br");
- br_node->close();
current_node->add_child(br_node);
cleaned += '\n';
}
@@ -126,7 +125,6 @@ Xmpp::body irc_format_to_xhtmlim(const std::string& s)
// close opened span, if any
if (current_node != result.get())
{
- current_node->close();
result->add_child(current_node);
current_node = result.get();
}
@@ -163,12 +161,8 @@ Xmpp::body irc_format_to_xhtmlim(const std::string& s)
current_node->add_to_inner(txt);
if (current_node != result.get())
- {
- current_node->close();
- result->add_child(current_node);
- }
+ result->add_child(current_node);
- result->close();
Xmpp::body body_res = std::make_tuple(cleaned, std::move(result));
return body_res;
}
diff --git a/src/xmpp/biboumi_adhoc_commands.cpp b/src/xmpp/biboumi_adhoc_commands.cpp
index 089eebf..0dcaf0c 100644
--- a/src/xmpp/biboumi_adhoc_commands.cpp
+++ b/src/xmpp/biboumi_adhoc_commands.cpp
@@ -10,18 +10,15 @@ void DisconnectUserStep1(XmppComponent* xmpp_component, AdhocSession&, XmlNode&
x["type"] = "form";
XmlNode title("title");
title.set_inner("Disconnect a user from the gateway");
- title.close();
x.add_child(std::move(title));
XmlNode instructions("instructions");
instructions.set_inner("Choose a user JID and a quit message");
- instructions.close();
x.add_child(std::move(instructions));
XmlNode jids_field("field");
jids_field["var"] = "jids";
jids_field["type"] = "list-multi";
jids_field["label"] = "The JIDs to disconnect";
XmlNode required("required");
- required.close();
jids_field.add_child(std::move(required));
for (Bridge* bridge: biboumi_component->get_bridges())
{
@@ -29,12 +26,9 @@ void DisconnectUserStep1(XmppComponent* xmpp_component, AdhocSession&, XmlNode&
option["label"] = bridge->get_jid();
XmlNode value("value");
value.set_inner(bridge->get_jid());
- value.close();
option.add_child(std::move(value));
- option.close();
jids_field.add_child(std::move(option));
}
- jids_field.close();
x.add_child(std::move(jids_field));
XmlNode message_field("field");
@@ -43,11 +37,8 @@ void DisconnectUserStep1(XmppComponent* xmpp_component, AdhocSession&, XmlNode&
message_field["label"] = "Quit message";
XmlNode message_value("value");
message_value.set_inner("Disconnected by admin");
- message_value.close();
message_field.add_child(std::move(message_value));
- message_field.close();
x.add_child(std::move(message_field));
- x.close();
command_node.add_child(std::move(x));
}
@@ -95,7 +86,6 @@ void DisconnectUserStep2(XmppComponent* xmpp_component, AdhocSession& session, X
note.set_inner("1 user has been disconnected.");
else
note.set_inner(std::to_string(num) + " users have been disconnected.");
- note.close();
command_node.add_child(std::move(note));
return;
}
@@ -103,9 +93,7 @@ void DisconnectUserStep2(XmppComponent* xmpp_component, AdhocSession& session, X
XmlNode error(ADHOC_NS":error");
error["type"] = "modify";
XmlNode condition(STANZA_NS":bad-request");
- condition.close();
error.add_child(std::move(condition));
- error.close();
command_node.add_child(std::move(error));
session.terminate();
}
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index c1fa339..f578c30 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -321,7 +321,6 @@ void BiboumiComponent::handle_iq(const Stanza& stanza)
else
response["type"] = "result";
response.add_child(std::move(inner_node));
- response.close();
this->send_stanza(response);
stanza_error.disable();
}
@@ -494,18 +493,14 @@ void BiboumiComponent::send_self_disco_info(const std::string& id, const std::st
identity["category"] = "conference";
identity["type"] = "irc";
identity["name"] = "Biboumi XMPP-IRC gateway";
- identity.close();
query.add_child(std::move(identity));
for (const std::string& ns: {DISCO_INFO_NS, MUC_NS, ADHOC_NS})
{
XmlNode feature("feature");
feature["var"] = ns;
- feature.close();
query.add_child(std::move(feature));
}
- query.close();
iq.add_child(std::move(query));
- iq.close();
this->send_stanza(iq);
}
@@ -519,9 +514,7 @@ void BiboumiComponent::send_iq_version_request(const std::string& from,
iq["to"] = jid_to;
XmlNode query("query");
query["xmlns"] = VERSION_NS;
- query.close();
iq.add_child(std::move(query));
- iq.close();
this->send_stanza(iq);
}
@@ -536,9 +529,7 @@ void BiboumiComponent::send_ping_request(const std::string& from,
iq["to"] = jid_to;
XmlNode ping("ping");
ping["xmlns"] = PING_NS;
- ping.close();
iq.add_child(std::move(ping));
- iq.close();
this->send_stanza(iq);
auto result_cb = [from, id](Bridge* bridge, const Stanza& stanza)
@@ -571,11 +562,8 @@ void BiboumiComponent::send_iq_room_list_result(const std::string& id,
{
XmlNode item("item");
item["jid"] = room.channel + "%" + from + "@" + this->served_hostname;
- item.close();
query.add_child(std::move(item));
}
- query.close();
iq.add_child(std::move(query));
- iq.close();
this->send_stanza(iq);
}