summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-07-04 20:42:40 +0200
committerlouiz’ <louiz@louiz.org>2017-07-16 00:16:43 +0200
commitf9a6f973966430b108642ac57d54db5fd0d5535e (patch)
treed34574f81b9b55b7ce49ba5d10ef543c7db9f3bc /src/xmpp
parent368bb82818d4b68e4984698ea4454091ecb049a2 (diff)
downloadbiboumi-f9a6f973966430b108642ac57d54db5fd0d5535e.tar.gz
biboumi-f9a6f973966430b108642ac57d54db5fd0d5535e.tar.bz2
biboumi-f9a6f973966430b108642ac57d54db5fd0d5535e.tar.xz
biboumi-f9a6f973966430b108642ac57d54db5fd0d5535e.zip
Implement the roster presences from IRC servers
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/biboumi_component.cpp18
-rw-r--r--src/xmpp/biboumi_component.hpp3
2 files changed, 17 insertions, 4 deletions
diff --git a/src/xmpp/biboumi_component.cpp b/src/xmpp/biboumi_component.cpp
index 91e92aa..71a5f3d 100644
--- a/src/xmpp/biboumi_component.cpp
+++ b/src/xmpp/biboumi_component.cpp
@@ -84,8 +84,7 @@ void BiboumiComponent::shutdown()
for (auto& pair: this->bridges)
pair.second->shutdown("Gateway shutdown");
#ifdef USE_DATABASE
- const auto full_roster = Database::get_full_roster();
- for (const Database::RosterItem& roster_item: full_roster)
+ for (const Database::RosterItem& roster_item: Database::get_full_roster())
{
this->send_presence_to_contact(roster_item.col<Database::LocalJid>(),
roster_item.col<Database::RemoteJid>(),
@@ -170,7 +169,7 @@ void BiboumiComponent::handle_presence(const Stanza& stanza)
if (type == "subscribe")
{ // Auto-accept any subscription request for an IRC server
this->send_presence_to_contact(to_str, from.bare(), "subscribed", id);
- if (iid.type == Iid::Type::None)
+ if (iid.type == Iid::Type::None || bridge->find_irc_client(iid.get_server()))
this->send_presence_to_contact(to_str, from.bare(), "");
this->send_presence_to_contact(to_str, from.bare(), "subscribe");
#ifdef USE_DATABASE
@@ -192,7 +191,8 @@ void BiboumiComponent::handle_presence(const Stanza& stanza)
else if (type.empty())
{ // We just receive a presence from someone (as the result of a probe,
// or a directed presence, or a normal presence change)
- this->send_presence_to_contact(to_str, from.bare(), "");
+ if (iid.type == Iid::Type::None)
+ this->send_presence_to_contact(to_str, from.bare(), "");
}
}
else
@@ -1023,6 +1023,16 @@ void BiboumiComponent::send_presence_to_contact(const std::string& from, const s
this->send_stanza(presence);
}
+void BiboumiComponent::on_irc_client_connected(const std::string& irc_hostname, const std::string& jid)
+{
+ this->send_presence_to_contact(irc_hostname + "@" + this->served_hostname, jid, "");
+}
+
+void BiboumiComponent::on_irc_client_disconnected(const std::string& irc_hostname, const std::string& jid)
+{
+ this->send_presence_to_contact(irc_hostname + "@" + this->served_hostname, jid, "unavailable");
+}
+
void BiboumiComponent::after_handshake()
{
XmppComponent::after_handshake();
diff --git a/src/xmpp/biboumi_component.hpp b/src/xmpp/biboumi_component.hpp
index 2d67f8b..e5547f9 100644
--- a/src/xmpp/biboumi_component.hpp
+++ b/src/xmpp/biboumi_component.hpp
@@ -90,6 +90,9 @@ public:
void accept_subscription(const std::string& from, const std::string& to);
void ask_subscription(const std::string& from, const std::string& to);
void send_presence_to_contact(const std::string& from, const std::string& to, const std::string& type, const std::string& id="");
+ void on_irc_client_connected(const std::string& irc_hostname, const std::string& jid);
+ void on_irc_client_disconnected(const std::string& irc_hostname, const std::string& jid);
+
/**
* Handle the various stanza types
*/