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 class QueuedXMPP extends XMPPHP_XMPP
37 * Reference to the XmppPlugin object we're hooked up to.
44 * @param XmppPlugin $plugin
46 * @param integer $port
48 * @param string $password
49 * @param string $resource
50 * @param string $server
51 * @param boolean $printlog
52 * @param string $loglevel
54 public function __construct($plugin, $host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null)
56 $this->plugin = $plugin;
58 parent::__construct($host, $port, $user, $password, $resource, $server, $printlog, $loglevel);
60 // We use $host to connect, but $server to build JIDs if specified.
61 // This seems to fix an upstream bug where $host was used to build
62 // $this->basejid, never seen since it isn't actually used in the base
65 $server = $this->host;
67 $this->basejid = $this->user . '@' . $server;
69 // Normally the fulljid is filled out by the server at resource binding
70 // time, but we need to do it since we're not talking to a real server.
71 $this->fulljid = "{$this->basejid}/{$this->resource}";
75 * Send a formatted message to the outgoing queue for later forwarding
76 * to a real XMPP connection.
80 public function send($msg, $timeout=NULL)
82 $this->plugin->enqueueOutgoingRaw($msg);
87 * Stream i/o functions disabled; only do output
89 public function connect($timeout = 30, $persistent = false, $sendinit = true)
91 // No i18n needed. Test message.
92 throw new Exception('Cannot connect to server from fake XMPP.');
95 public function disconnect()
97 // No i18n needed. Test message.
98 throw new Exception('Cannot connect to server from fake XMPP.');
101 public function process()
103 // No i18n needed. Test message.
104 throw new Exception('Cannot read stream from fake XMPP.');
107 public function processUntil($event, $timeout=-1)
109 // No i18n needed. Test message.
110 throw new Exception('Cannot read stream from fake XMPP.');
113 public function read()
115 // No i18n needed. Test message.
116 throw new Exception('Cannot read stream from fake XMPP.');
119 public function readyToProcess()
121 // No i18n needed. Test message.
122 throw new Exception('Cannot read stream from fake XMPP.');