]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Xmpp/lib/queued_xmpp.php
plugins onAutoload now only overloads if necessary (extlibs etc.)
[quix0rs-gnu-social.git] / plugins / Xmpp / lib / queued_xmpp.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * Queue-mediated proxy class for outgoing XMPP messages.
6  *
7  * PHP version 5
8  *
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.
13  *
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.
18  *
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/>.
21  *
22  * @category  Network
23  * @package   StatusNet
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/
28  */
29
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
31     exit(1);
32 }
33
34 class Queued_XMPP extends XMPPHP_XMPP
35 {
36     /**
37      * Reference to the XmppPlugin object we're hooked up to.
38      */
39     public $plugin;
40
41         /**
42          * Constructor
43          *
44      * @param XmppPlugin $plugin
45          * @param string  $host
46          * @param integer $port
47          * @param string  $user
48          * @param string  $password
49          * @param string  $resource
50          * @param string  $server
51          * @param boolean $printlog
52          * @param string  $loglevel
53          */
54         public function __construct($plugin, $host, $port, $user, $password, $resource, $server = null, $printlog = false, $loglevel = null)
55         {
56         $this->plugin = $plugin;
57
58         parent::__construct($host, $port, $user, $password, $resource, $server, $printlog, $loglevel);
59
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
63         // classes.
64         if (!$server) {
65             $server = $this->host;
66         }
67         $this->basejid = $this->user . '@' . $server;
68
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}";
72     }
73
74     /**
75      * Send a formatted message to the outgoing queue for later forwarding
76      * to a real XMPP connection.
77      *
78      * @param string $msg
79      */
80     public function send($msg, $timeout=NULL)
81     {
82         $this->plugin->enqueueOutgoingRaw($msg);
83     }
84
85     //@{
86     /**
87      * Stream i/o functions disabled; only do output
88      */
89     public function connect($timeout = 30, $persistent = false, $sendinit = true)
90     {
91         // No i18n needed. Test message.
92         throw new Exception('Cannot connect to server from fake XMPP.');
93     }
94
95     public function disconnect()
96     {
97         // No i18n needed. Test message.
98         throw new Exception('Cannot connect to server from fake XMPP.');
99     }
100
101     public function process()
102     {
103         // No i18n needed. Test message.
104         throw new Exception('Cannot read stream from fake XMPP.');
105     }
106
107     public function processUntil($event, $timeout=-1)
108     {
109         // No i18n needed. Test message.
110         throw new Exception('Cannot read stream from fake XMPP.');
111     }
112
113     public function read()
114     {
115         // No i18n needed. Test message.
116         throw new Exception('Cannot read stream from fake XMPP.');
117     }
118
119     public function readyToProcess()
120     {
121         // No i18n needed. Test message.
122         throw new Exception('Cannot read stream from fake XMPP.');
123     }
124     //@}
125 }