3 * StatusNet, the distributed open-source microblogging tool
5 * Queue-mediated proxy class for outgoing XMPP messages.
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Brion Vibber <brion@status.net>
25 * @copyright 2010 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
34 require_once dirname(__DIR__) . '/extlib/XMPPHP/XMPP.php';
38 class QueuedXMPP extends XMPP
41 * Reference to the XmppPlugin object we're hooked up to.
48 * @param XmppPlugin $plugin
50 * @param integer $port
52 * @param string $password
53 * @param string $resource
54 * @param string $server
55 * @param boolean $printlog
56 * @param string $loglevel
58 public function __construct($plugin, $host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null)
60 $this->plugin = $plugin;
62 parent::__construct($host, $port, $user, $password, $resource, $server, $printlog, $loglevel);
64 // We use $host to connect, but $server to build JIDs if specified.
65 // This seems to fix an upstream bug where $host was used to build
66 // $this->basejid, never seen since it isn't actually used in the base
69 $server = $this->host;
71 $this->basejid = $this->user . '@' . $server;
73 // Normally the fulljid is filled out by the server at resource binding
74 // time, but we need to do it since we're not talking to a real server.
75 $this->fulljid = "{$this->basejid}/{$this->resource}";
79 * Send a formatted message to the outgoing queue for later forwarding
80 * to a real XMPP connection.
83 * @param null $timeout
85 public function send($msg, $timeout = NULL)
87 @$this->plugin->enqueueOutgoingRaw($msg);
93 * Stream i/o functions disabled; only do output
95 * @param bool $persistent
96 * @param bool $sendinit
99 public function connect($timeout = 30, $persistent = false, $sendinit = true)
101 // No i18n needed. Test message.
102 throw new Exception('Cannot connect to server from fake XMPP.');
105 public function disconnect()
107 // No i18n needed. Test message.
108 throw new Exception('Cannot connect to server from fake XMPP.');
111 public function process()
113 // No i18n needed. Test message.
114 throw new Exception('Cannot read stream from fake XMPP.');
117 public function processUntil($event, $timeout = -1)
119 // No i18n needed. Test message.
120 throw new Exception('Cannot read stream from fake XMPP.');
123 public function read()
125 // No i18n needed. Test message.
126 throw new Exception('Cannot read stream from fake XMPP.');
129 public function readyToProcess()
131 // No i18n needed. Test message.
132 throw new Exception('Cannot read stream from fake XMPP.');