summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2013-12-29 19:57:43 +0100
committerFlorent Le Coz <louiz@louiz.org>2014-01-04 01:59:36 +0100
commitacf769d83a40e971ccc1346225688841465b36ee (patch)
tree8388af28b20e258d412cc34f79cb3c3cfcedbcb6 /src/xmpp
parenta075517824da7e82e1be7b67d615834851482861 (diff)
downloadbiboumi-acf769d83a40e971ccc1346225688841465b36ee.tar.gz
biboumi-acf769d83a40e971ccc1346225688841465b36ee.tar.bz2
biboumi-acf769d83a40e971ccc1346225688841465b36ee.tar.xz
biboumi-acf769d83a40e971ccc1346225688841465b36ee.zip
Use isupport informations to know the user modes when joining
Also remove the duplicate send_self_join methods, user only send_user_join
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/xmpp_component.cpp48
-rw-r--r--src/xmpp/xmpp_component.hpp9
2 files changed, 18 insertions, 39 deletions
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 1cc4c25..f0d1d3a 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -294,7 +294,10 @@ void XmppComponent::send_message(const std::string& from, Xmpp::body&& body, con
void XmppComponent::send_user_join(const std::string& from,
const std::string& nick,
const std::string& realjid,
- const std::string& to)
+ const std::string& affiliation,
+ const std::string& role,
+ const std::string& to,
+ const bool self)
{
XmlNode node("presence");
node["to"] = to;
@@ -305,8 +308,8 @@ void XmppComponent::send_user_join(const std::string& from,
// TODO: put real values here
XmlNode item("item");
- item["affiliation"] = "member";
- item["role"] = "participant";
+ item["affiliation"] = affiliation;
+ item["role"] = role;
if (!realjid.empty())
{
const std::string preped_jid = jidprep(realjid);
@@ -315,35 +318,15 @@ void XmppComponent::send_user_join(const std::string& from,
}
item.close();
x.add_child(std::move(item));
- x.close();
- node.add_child(std::move(x));
- node.close();
- this->send_stanza(node);
-}
-
-void XmppComponent::send_self_join(const std::string& from, const std::string& nick, const std::string& to)
-{
- XmlNode node("presence");
- node["to"] = to;
- node["from"] = from + "@" + this->served_hostname + "/" + nick;
-
- XmlNode x("x");
- x["xmlns"] = MUC_USER_NS;
-
- // TODO: put real values here
- XmlNode item("item");
- item["affiliation"] = "member";
- item["role"] = "participant";
- item.close();
- x.add_child(std::move(item));
-
- XmlNode status("status");
- status["code"] = "110";
- status.close();
- x.add_child(std::move(status));
+ if (self)
+ {
+ XmlNode status("status");
+ status["code"] = "110";
+ status.close();
+ x.add_child(std::move(status));
+ }
x.close();
-
node.add_child(std::move(x));
node.close();
this->send_stanza(node);
@@ -438,10 +421,7 @@ void XmppComponent::send_nick_change(const std::string& muc_name, const std::str
presence.close();
this->send_stanza(presence);
- if (self)
- this->send_self_join(muc_name, new_nick, jid_to);
- else
- this->send_user_join(muc_name, new_nick, "", jid_to);
+ this->send_user_join(muc_name, new_nick, "", "participant", "none", jid_to, self);
}
void XmppComponent::kick_user(const std::string& muc_name,
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index 63eb88f..c10f10a 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -78,11 +78,10 @@ public:
void send_user_join(const std::string& from,
const std::string& nick,
const std::string& realjid,
- const std::string& to);
- /**
- * Send the self join to the user
- */
- void send_self_join(const std::string& from, const std::string& nick, const std::string& to);
+ const std::string& affiliation,
+ const std::string& role,
+ const std::string& to,
+ const bool self);
/**
* Send the MUC topic to the user
*/