XMPP::getProtocols()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace OCA\Chat\XMPP;
4
5
use \OCA\Chat\IBackend;
6
use \OCA\Chat\App\Chat;
7
use \OCA\Chat\AbstractBackend;
8
use \OCA\Chat\Db\ConfigMapper;
9
use \OCP\IConfig;
10
11
class XMPP extends AbstractBackend implements IBackend {
12
13
	private $app;
14
15
	public function __construct(ConfigMapper $configMapper, IConfig $config, Chat $app){
16
		parent::__construct($configMapper, $config);
17
		$this->app = $app;
18
	}
19
20
	public function getId(){
21
		return 'xmpp';
22
	}
23
24
	public function getInitConvs(){
25
		$contacts = $this->app->getContacts();
26
		$contacts = $contacts['contacts'];
27
		$currentUser = $this->app->getCurrentUser();
28
		$currentUserId = $currentUser['id'];
29
		$initConvs = array();
30
		foreach($contacts as $contact) {
31
			foreach ($contact['backends'] as $backend) {
32
				if ($backend['id'] === 'xmpp') {
33
					$jid = $backend['value'];
34
					$initConvs[$jid] = array(
35
						"id" => $jid,
36
						"users" => array(
37
							$contact['id'],
38
							$currentUserId
39
						),
40
						"backend" => 'xmpp',
41
						"messages" => array(),
42
						"files" => array()
43
					);
44
				}
45
			}
46
		}
47
		return $initConvs;
48
	}
49
50
	public function getDisplayName(){
51
		return 'XMPP';
52
	}
53
54
	public function getProtocols(){
55
		return array(
56
			'xmpp'
57
		);
58
	}
59
60
	public function getDefaultConfig(){
61
		return array(
62
			'jid' => null,
63
			"password" => null,
64
			"bosh_url" => null
65
		);
66
	}
67
68
69
	public function getHelp(){
70
		return '';
71
	}
72
}