]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
separate out presence from connection, send different presence types from queuehandlers
authorEvan Prodromou <evan@prodromou.name>
Tue, 2 Sep 2008 01:26:04 +0000 (21:26 -0400)
committerEvan Prodromou <evan@prodromou.name>
Tue, 2 Sep 2008 01:26:04 +0000 (21:26 -0400)
darcs-hash:20080902012604-84dde-073a583da9b09c80e5e9a47a5eddd144fad8e87a.gz

lib/jabber.php
scripts/publicqueuehandler.php
scripts/xmppconfirmhandler.php
scripts/xmppdaemon.php
scripts/xmppqueuehandler.php

index 22e2d11b3172c93992772603b1912beb1f4a8d7c..3e74cbbb82d8601541a9ef35d5f8712ea1cfb266 100644 (file)
@@ -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;
 }
 
index bbb95f1fcec9f145f559acfe48d974aca1c123a0..4ebe8187a233ad06202a3ee9a9674b7020756271 100755 (executable)
@@ -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);
        }
 
index ff166485d6c8244106328b60a388d78010970b9e..1a1c550013e5e393382d3398baae9735b12984b3 100755 (executable)
@@ -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);
        }
        
index 37d638b02cc9a7d69184bf4d7ecc1d3474cafa99..03cadee7cb50a58819a16f9f3950b6ee91d8b435 100755 (executable)
@@ -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();
        }
 
index 8e86fe9bb19b5aa80b77447d43efb61cb8ed700e..0b62670bc0ce941029d6389eaf5cc5123425c282 100755 (executable)
@@ -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);
        }