summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/iomaster.php2
-rw-r--r--lib/queuemanager.php24
-rw-r--r--lib/stompqueuemanager.php52
-rw-r--r--lib/xmppmanager.php6
4 files changed, 73 insertions, 11 deletions
diff --git a/lib/iomaster.php b/lib/iomaster.php
index 5d1071a39..ce77b53b2 100644
--- a/lib/iomaster.php
+++ b/lib/iomaster.php
@@ -70,7 +70,7 @@ class IoMaster
$classes = array();
if (Event::handle('StartIoManagerClasses', array(&$classes))) {
$classes[] = 'QueueManager';
- if (common_config('xmpp', 'enabled')) {
+ if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) {
$classes[] = 'XmppManager'; // handles pings/reconnects
$classes[] = 'XmppConfirmManager'; // polls for outgoing confirmations
}
diff --git a/lib/queuemanager.php b/lib/queuemanager.php
index a98c0efff..291174d3c 100644
--- a/lib/queuemanager.php
+++ b/lib/queuemanager.php
@@ -149,15 +149,17 @@ abstract class QueueManager extends IoManager
function initialize()
{
if (Event::handle('StartInitializeQueueManager', array($this))) {
- $this->connect('plugin', 'PluginQueueHandler');
- $this->connect('omb', 'OmbQueueHandler');
- $this->connect('ping', 'PingQueueHandler');
- if (common_config('sms', 'enabled')) {
- $this->connect('sms', 'SmsQueueHandler');
+ if (!defined('XMPP_ONLY_FLAG')) { // hack!
+ $this->connect('plugin', 'PluginQueueHandler');
+ $this->connect('omb', 'OmbQueueHandler');
+ $this->connect('ping', 'PingQueueHandler');
+ if (common_config('sms', 'enabled')) {
+ $this->connect('sms', 'SmsQueueHandler');
+ }
}
// XMPP output handlers...
- if (common_config('xmpp', 'enabled')) {
+ if (common_config('xmpp', 'enabled') && !defined('XMPP_EMERGENCY_FLAG')) {
$this->connect('jabber', 'JabberQueueHandler');
$this->connect('public', 'PublicQueueHandler');
@@ -165,10 +167,14 @@ abstract class QueueManager extends IoManager
$this->connect('confirm', 'XmppConfirmHandler');
}
- // For compat with old plugins not registering their own handlers.
- $this->connect('plugin', 'PluginQueueHandler');
+ if (!defined('XMPP_ONLY_FLAG')) { // hack!
+ // For compat with old plugins not registering their own handlers.
+ $this->connect('plugin', 'PluginQueueHandler');
+ }
+ }
+ if (!defined('XMPP_ONLY_FLAG')) { // hack!
+ Event::handle('EndInitializeQueueManager', array($this));
}
- Event::handle('EndInitializeQueueManager', array($this));
}
/**
diff --git a/lib/stompqueuemanager.php b/lib/stompqueuemanager.php
index 3090e0bfb..00590fdb6 100644
--- a/lib/stompqueuemanager.php
+++ b/lib/stompqueuemanager.php
@@ -66,10 +66,62 @@ class StompQueueManager extends QueueManager
*
* @fixme possibly actually do subscription here to save another
* loop over all sites later?
+ * @fixme possibly don't assume it's the current site
*/
public function addSite($server)
{
$this->sites[] = $server;
+ $this->initialize();
+ }
+
+
+ /**
+ * Instantiate the appropriate QueueHandler class for the given queue.
+ *
+ * @param string $queue
+ * @return mixed QueueHandler or null
+ */
+ function getHandler($queue)
+ {
+ $handlers = $this->handlers[common_config('site', 'server')];
+ if (isset($handlers[$queue])) {
+ $class = $handlers[$queue];
+ if (class_exists($class)) {
+ return new $class();
+ } else {
+ common_log(LOG_ERR, "Nonexistent handler class '$class' for queue '$queue'");
+ }
+ } else {
+ common_log(LOG_ERR, "Requested handler for unkown queue '$queue'");
+ }
+ return null;
+ }
+
+ /**
+ * Get a list of all registered queue transport names.
+ *
+ * @return array of strings
+ */
+ function getQueues()
+ {
+ $site = common_config('site', 'server');
+ if (empty($this->handlers[$site])) {
+ return array();
+ } else {
+ return array_keys($this->handlers[$site]);
+ }
+ }
+
+ /**
+ * Register a queue transport name and handler class for your plugin.
+ * Only registered transports will be reliably picked up!
+ *
+ * @param string $transport
+ * @param string $class
+ */
+ public function connect($transport, $class)
+ {
+ $this->handlers[common_config('site', 'server')][$transport] = $class;
}
/**
diff --git a/lib/xmppmanager.php b/lib/xmppmanager.php
index 0839cda57..dfff63a30 100644
--- a/lib/xmppmanager.php
+++ b/lib/xmppmanager.php
@@ -118,7 +118,11 @@ class XmppManager extends IoManager
*/
public function getSockets()
{
- return array($this->conn->getSocket());
+ if ($this->conn) {
+ return array($this->conn->getSocket());
+ } else {
+ return array();
+ }
}
/**