Index: trunk/extensions/XMLRC/XMLRC_XMPP.class.php |
— | — | @@ -1,68 +0,0 @@ |
2 | | -<?php |
3 | | -if (!defined('MEDIAWIKI')) { |
4 | | - echo "XMLRC extension"; |
5 | | - exit(1); |
6 | | -} |
7 | | - |
8 | | -class XMLRC_XMPP extends XMLRC_Transport { |
9 | | - function __construct( $config ) { |
10 | | - |
11 | | - if (!isset($config['library_path'])) { |
12 | | - include( "XMPP.php" ); |
13 | | - } else { |
14 | | - include("{$config['library_path']}/XMPP.php"); |
15 | | - } |
16 | | - |
17 | | - |
18 | | - if (!isset($config['server']) || is_null($config['server'])) { |
19 | | - $config['server'] = $config['host']; |
20 | | - } |
21 | | - |
22 | | - if (!isset($config['nickname']) || is_null($config['nickname'])) { |
23 | | - $config['nickname'] = $config['user']; |
24 | | - } |
25 | | - |
26 | | - $this->conn = null; |
27 | | - |
28 | | - $this->channel = $config['channel']; |
29 | | - $this->nickname = $config['nickname']; |
30 | | - $this->resource = $config['resource']; |
31 | | - |
32 | | - $this->host = $config['host']; |
33 | | - $this->port = $config['port']; |
34 | | - $this->user = $config['user']; |
35 | | - $this->password = $config['password']; |
36 | | - $this->server = $config['server']; |
37 | | - |
38 | | - $this->loglevel = -1; |
39 | | - } |
40 | | - |
41 | | - public function connect() { |
42 | | - if ( $this->conn ) return; |
43 | | - |
44 | | - $this->conn = new XMPP( $this->host, $this->port, $this->user, $this->password, |
45 | | - $this->resource, $this->server, |
46 | | - $this->loglevel <= LEVEL_VERBOSE && $this->loglevel >= 0, $this->loglevel ); |
47 | | - |
48 | | - $this->conn->connect(); |
49 | | - $this->conn->processUntil( 'session_start' ); |
50 | | - |
51 | | - $conn->presence(null, "available", $this->channel . '/' . $this->nickname, "available" ); |
52 | | - } |
53 | | - |
54 | | - public function disconnect() { |
55 | | - if ( !$this->conn ) return; |
56 | | - |
57 | | - $conn->presence(null, "unavailable", $this->channel . '/' . $this->nickname, "unavailable" ); |
58 | | - |
59 | | - $this->conn->disconnect(); |
60 | | - $this->conn = null; |
61 | | - } |
62 | | - |
63 | | - public function send( $xml ) { |
64 | | - $do_disconnect = !$this->conn; |
65 | | - $this->connect(); |
66 | | - $conn->message( $this->channel, $xml, 'groupchat' ); //TODO: use send to send XML content directly |
67 | | - if ( $do_disconnect ) $this->disconnect(); |
68 | | - } |
69 | | -} |