summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2014-04-15 07:02:09 +0200
committerFlorent Le Coz <louiz@louiz.org>2014-04-15 07:02:09 +0200
commit9d8166f10d1f14acb936b58fd2907184b1eeadad (patch)
tree4c2fa8a0c843626d2e10f17886816217aa1c3276 /src
parent58a2c00d443db24e415582fcd267b848e8c7e313 (diff)
downloadbiboumi-9d8166f10d1f14acb936b58fd2907184b1eeadad.tar.gz
biboumi-9d8166f10d1f14acb936b58fd2907184b1eeadad.tar.bz2
biboumi-9d8166f10d1f14acb936b58fd2907184b1eeadad.tar.xz
biboumi-9d8166f10d1f14acb936b58fd2907184b1eeadad.zip
Add support for systemd-daemon
Diffstat (limited to 'src')
-rw-r--r--src/config.h.cmake1
-rw-r--r--src/xmpp/xmpp_component.cpp17
2 files changed, 18 insertions, 0 deletions
diff --git a/src/config.h.cmake b/src/config.h.cmake
index 8ee0fd3..62186cc 100644
--- a/src/config.h.cmake
+++ b/src/config.h.cmake
@@ -1,3 +1,4 @@
#cmakedefine ICONV_SECOND_ARGUMENT_IS_CONST
#cmakedefine LIBIDN_FOUND
+#cmakedefine SYSTEMDDAEMON_FOUND
#cmakedefine POLLER ${POLLER}
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index a5e9842..17afd63 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -12,6 +12,12 @@
#include <stdio.h>
+#include <config.h>
+
+#ifdef SYSTEMDDAEMON_FOUND
+# include <systemd/sd-daemon.h>
+#endif
+
#define STREAM_NS "http://etherx.jabber.org/streams"
#define COMPONENT_NS "jabber:component:accept"
#define MUC_NS "http://jabber.org/protocol/muc"
@@ -74,6 +80,9 @@ void XmppComponent::send_stanza(const Stanza& stanza)
void XmppComponent::on_connection_failed(const std::string& reason)
{
log_error("Failed to connect to the XMPP server: " << reason);
+#ifdef SYSTEMDDAEMON_FOUND
+ sd_notifyf(0, "STATUS=Failed to connect to the XMPP server: %s", reason.data());
+#endif
}
void XmppComponent::on_connected()
@@ -248,6 +257,9 @@ void XmppComponent::handle_handshake(const Stanza& stanza)
this->ever_auth = true;
this->last_auth = true;
log_info("Authenticated with the XMPP server");
+#ifdef SYSTEMDDAEMON_FOUND
+ sd_notify(0, "READY=1");
+#endif
}
void XmppComponent::handle_presence(const Stanza& stanza)
@@ -420,6 +432,11 @@ void XmppComponent::handle_error(const Stanza& stanza)
if (text)
error_message = text->get_inner();
log_error("Stream error received from the XMPP server: " << error_message);
+#ifdef SYSTEMDDAEMON_FOUND
+ if (!this->ever_auth)
+ sd_notifyf(0, "STATUS=Failed to authenticate to the XMPP server: %s", error_message.data());
+#endif
+
}
Bridge* XmppComponent::get_user_bridge(const std::string& user_jid)