summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/jabber.php10
-rwxr-xr-xscripts/publicqueuehandler.php7
-rwxr-xr-xscripts/xmppconfirmhandler.php7
-rwxr-xr-xscripts/xmppdaemon.php4
-rwxr-xr-xscripts/xmppqueuehandler.php7
5 files changed, 23 insertions, 12 deletions
diff --git a/lib/jabber.php b/lib/jabber.php
index 22e2d11b3..3e74cbbb8 100644
--- a/lib/jabber.php
+++ b/lib/jabber.php
@@ -40,7 +40,7 @@ function jabber_daemon_address() {
return common_config('xmpp', 'user') . '@' . common_config('xmpp', 'server');
}
-function jabber_connect($resource=NULL, $status=NULL, $priority=NULL) {
+function jabber_connect($resource=NULL) {
static $conn = NULL;
if (!$conn) {
$conn = new XMPPHP_XMPP(common_config('xmpp', 'host') ?
@@ -68,8 +68,6 @@ function jabber_connect($resource=NULL, $status=NULL, $priority=NULL) {
return false;
}
$conn->processUntil('session_start');
-# $conn->getRoster();
- $conn->presence($presence, 'available', NULL, 'available', $priority);
}
return $conn;
}
@@ -149,12 +147,14 @@ function jabber_send_message($to, $body, $type='chat', $subject=NULL) {
return true;
}
-function jabber_send_presence($status, $show='available', $to=Null) {
+function jabber_send_presence($status, $show='available', $to=NULL,
+ $type = 'available', $priority=NULL)
+{
$conn = jabber_connect();
if (!$conn) {
return false;
}
- $conn->presence($status, $show, $to);
+ $conn->presence($status, $show, $to, $type, $priority);
return true;
}
diff --git a/scripts/publicqueuehandler.php b/scripts/publicqueuehandler.php
index bbb95f1fc..4ebe8187a 100755
--- a/scripts/publicqueuehandler.php
+++ b/scripts/publicqueuehandler.php
@@ -42,8 +42,11 @@ class PublicQueueHandler extends QueueHandler {
function start() {
$this->log(LOG_INFO, "INITIALIZE");
# Low priority; we don't want to receive messages
- $this->conn = jabber_connect($this->_id, NULL, -1);
- $this->conn->addEventHandler('message', 'forward_message', $this);
+ $this->conn = jabber_connect($this->_id);
+ if ($this->conn) {
+ $this->conn->addEventHandler('message', 'forward_message', $this);
+ jabber_send_presence("Send me a message to post an notice", 'dnd', NULL, 'available', -1);
+ }
return !is_null($this->conn);
}
diff --git a/scripts/xmppconfirmhandler.php b/scripts/xmppconfirmhandler.php
index ff166485d..1a1c55001 100755
--- a/scripts/xmppconfirmhandler.php
+++ b/scripts/xmppconfirmhandler.php
@@ -48,8 +48,11 @@ class XmppConfirmHandler {
function start() {
# Low priority; we don't want to receive messages
$this->log(LOG_INFO, "INITIALIZE");
- $this->conn = jabber_connect($this->_id, NULL, -1);
- $this->conn->addEventHandler('message', 'forward_message', $this);
+ $this->conn = jabber_connect($this->_id);
+ if ($this->conn) {
+ $this->conn->addEventHandler('message', 'forward_message', $this);
+ jabber_send_presence("Send me a message to post an notice", 'dnd', NULL, 'available', -1);
+ }
return !is_null($this->conn);
}
diff --git a/scripts/xmppdaemon.php b/scripts/xmppdaemon.php
index 37d638b02..03cadee7c 100755
--- a/scripts/xmppdaemon.php
+++ b/scripts/xmppdaemon.php
@@ -61,12 +61,14 @@ class XMPPDaemon {
$this->log(LOG_INFO, "Connecting to $connect_to on port $this->port");
- $this->conn = jabber_connect($this->resource, "Send me a message to post a notice", 100);
+ $this->conn = jabber_connect($this->resource);
if (!$this->conn) {
return false;
}
+ jabber_send_presence("Send me a message to post a notice", 'available',
+ NULL, 'available', 100);
return !$this->conn->isDisconnected();
}
diff --git a/scripts/xmppqueuehandler.php b/scripts/xmppqueuehandler.php
index 8e86fe9bb..0b62670bc 100755
--- a/scripts/xmppqueuehandler.php
+++ b/scripts/xmppqueuehandler.php
@@ -44,8 +44,11 @@ class XmppQueueHandler extends QueueHandler {
function start() {
$this->log(LOG_INFO, "INITIALIZE");
# Low priority; we don't want to receive messages
- $this->conn = jabber_connect($this->_id, NULL, -1);
- $this->conn->addEventHandler('message', 'forward_message', $this);
+ $this->conn = jabber_connect($this->_id);
+ if ($this->conn) {
+ $this->conn->addEventHandler('message', 'forward_message', $this);
+ jabber_send_presence("Send me a message to post an notice", 'dnd', NULL, 'available', -1);
+ }
return !is_null($this->conn);
}