Skip to content

Commit

Permalink
build v3.0.0-beta2
Browse files Browse the repository at this point in the history
  • Loading branch information
sualko committed Feb 11, 2016
1 parent ced8cab commit 74bff96
Show file tree
Hide file tree
Showing 47 changed files with 1,582 additions and 798 deletions.
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<id>ojsxc</id>
<name>JavaScript XMPP Chat</name>
<description>Facebook-like chat with end-to-end encrypted conversation, video calls, multi-user rooms, XMPP and internal server backend.</description>
<version>3.0.0-beta1b</version>
<version>3.0.0-beta2</version>
<licence>MIT</licence>
<author>Klaus Herberth, Tobia De Koninck</author>
<requiremin>8.0</requiremin>
Expand Down
2 changes: 1 addition & 1 deletion appinfo/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0-beta1b
3.0.0-beta2
67 changes: 67 additions & 0 deletions build/ajax/getSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

header('Content-Type: application/json; charset=utf-8');

function validateBoolean($val)
{
return $val === true || $val === 'true';
}

OCP\JSON::callCheck();

$username = $_POST ['username'];
$password = $_POST ['password'];

$ocUser = new OCP\User();

$auth = ($password !== null) ? $ocUser->checkPassword($username, $password) : OCP\User::isLoggedIn();

if (!$auth) {
echo json_encode(array(
'result' => 'noauth',
));
exit();
}

$config = \OC::$server->getConfig();

$data = array();
$data ['xmpp'] = array();
$data ['serverType'] = $config->getAppValue('ojsxc', 'serverType', 'external');
$data ['loginForm'] ['startMinimized'] = validateBoolean($config->getAppValue('ojsxc', 'xmppStartMinimized'));

if ($data ['serverType'] === 'internal') {
echo json_encode(array(
'result' => 'success',
'data' => $data,
));

exit;
}

$data ['xmpp'] ['url'] = $config->getAppValue('ojsxc', 'boshUrl');
$data ['xmpp'] ['domain'] = $config->getAppValue('ojsxc', 'xmppDomain');
$data ['xmpp'] ['resource'] = $config->getAppValue('ojsxc', 'xmppResource');
$data ['xmpp'] ['overwrite'] = validateBoolean($config->getAppValue('ojsxc', 'xmppOverwrite'));
$data ['xmpp'] ['onlogin'] = true;

$options = $config->getUserValue($username, 'ojsxc', 'options');

if ($options !== null) {
$options = json_decode($options, true);

foreach ($options as $prop => $value) {
if ($prop !== 'xmpp' || $data ['xmpp'] ['overwrite']) {
foreach ($value as $key => $v) {
if ($v !== '') {
$data [$prop] [$key] = ($v === 'false' || $v === 'true') ? validateBoolean($v) : $v;
}
}
}
}
}

echo json_encode(array(
'result' => 'success',
'data' => $data,
));
33 changes: 33 additions & 0 deletions build/ajax/getTurnCredentials.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

OCP\User::checkLoggedIn();
OCP\JSON::callCheck();

header('Content-Type: application/json; charset=utf-8');

$config = \OC::$server->getConfig();
$secret = $config->getAppValue('ojsxc', 'iceSecret');
$user = \OC::$server->getUserSession()->getUser()->getUID();

$ttl = $config->getAppValue('ojsxc', 'iceTtl', 3600 * 24); // one day (according to TURN-REST-API)
$url = $config->getAppValue('ojsxc', 'iceUrl');
$url = $url ? "turn:$url" : $url;

$username = $secret ? (time() + $ttl).':'.$user : $user;
$username = $config->getAppValue('ojsxc', 'iceUsername', $username);

$credential = ($secret) ? base64_encode(hash_hmac('sha1', $username, $secret, true)) : '';
$credential = $config->getAppValue('ojsxc', 'iceCredential', $credential);

$data = array(
'ttl' => $ttl,
'iceServers' => array(
array(
'urls' => array($url),
'credential' => $credential,
'username' => $username,
),
),
);

echo json_encode($data);
12 changes: 7 additions & 5 deletions build/ajax/getUsers.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
OCP\User::checkLoggedIn ();
OCP\JSON::callCheck ();

OCP\User::checkLoggedIn();
OCP\JSON::callCheck();

header('Content-Type: application/json; charset=utf-8');

$limit = 10;
$offset = 0;

$users = OCP\User::getDisplayNames((string)$_GET['search'], $limit, $offset);
$users = OCP\User::getDisplayNames((string) $_GET['search'], $limit, $offset);

OCP\JSON::encodedPrint ( $users );
?>
echo json_encode($users);
61 changes: 0 additions & 61 deletions build/ajax/getsettings.php

This file was deleted.

26 changes: 0 additions & 26 deletions build/ajax/getturncredentials.php

This file was deleted.

21 changes: 21 additions & 0 deletions build/ajax/setAdminSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

OCP\User::checkAdminUser();
OCP\JSON::callCheck();

$config = \OC::$server->getConfig();

$config->setAppValue('ojsxc', 'serverType', $_POST ['serverType']);
$config->setAppValue('ojsxc', 'boshUrl', $_POST ['boshUrl']);
$config->setAppValue('ojsxc', 'xmppDomain', $_POST ['xmppDomain']);
$config->setAppValue('ojsxc', 'xmppResource', $_POST ['xmppResource']);
$config->setAppValue('ojsxc', 'xmppOverwrite', (isset($_POST ['xmppOverwrite'])) ? $_POST ['xmppOverwrite'] : 'false');
$config->setAppValue('ojsxc', 'xmppStartMinimized', (isset($_POST ['xmppStartMinimized'])) ? $_POST ['xmppStartMinimized'] : 'false');

$config->setAppValue('ojsxc', 'iceUrl', $_POST ['iceUrl']);
$config->setAppValue('ojsxc', 'iceUsername', $_POST ['iceUsername']);
$config->setAppValue('ojsxc', 'iceCredential', $_POST ['iceCredential']);
$config->setAppValue('ojsxc', 'iceSecret', $_POST ['iceSecret']);
$config->setAppValue('ojsxc', 'iceTtl', $_POST ['iceTtl']);

echo 'true';
10 changes: 7 additions & 3 deletions build/ajax/setUserSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
OCP\User::checkLoggedIn ();
OCP\JSON::callCheck ();

$user = OCP\User::getUser ();
$options = OCP\Config::getUserValue($user, 'ojsxc', 'options');
$config = \OC::$server->getConfig();
$uid = \OC::$server->getUserSession()->getUser()->getUID();

$options = $config->getUserValue($uid, 'ojsxc', 'options');
$options = json_decode($options, true);

foreach($_POST as $key => $val) {
$options[$key] = $val;
}

echo OCP\Config::setUserValue($user, 'ojsxc', 'options', json_encode($options));
$config->setUserValue($uid, 'ojsxc', 'options', json_encode($options));

echo 'true';
24 changes: 0 additions & 24 deletions build/ajax/setsettings.php

This file was deleted.

32 changes: 29 additions & 3 deletions build/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,36 @@
// ############# CSS #############
OCP\Util::addStyle ( 'ojsxc', 'jsxc.oc' );

$version = OCP\Util::getVersion();
if(class_exists('\\OCP\\AppFramework\\Http\\EmptyContentSecurityPolicy')) {
$manager = \OC::$server->getContentSecurityPolicyManager();
$policy = new \OCP\AppFramework\Http\EmptyContentSecurityPolicy();

if($version[0] <= 6)
OCP\Util::addStyle ( 'ojsxc', 'jsxc.oc.lte6' );
$policy->addAllowedStyleDomain('\'self\'');
$policy->addAllowedStyleDomain('\'unsafe-inline\'');

$policy->addAllowedScriptDomain('\'self\'');

$policy->addAllowedImageDomain('\'self\'');
$policy->addAllowedImageDomain('data:');
$policy->addAllowedImageDomain('blob:');

$policy->addAllowedMediaDomain('\'self\'');
$policy->addAllowedMediaDomain('blob:');

$policy->addAllowedChildSrcDomain('\'self\'');

$policy->addAllowedConnectDomain('\'self\'');

$boshUrl = \OC::$server->getConfig()->getAppValue('ojsxc', 'boshUrl');

if(preg_match('#^(https?:)?//([a-z0-9][a-z0-9\-.]*[a-z0-9])/#i', $boshUrl, $matches)) {
$boshDomain = $matches[2];

$policy->addAllowedConnectDomain($boshDomain);
}

$manager->addDefaultPolicy($policy);
}

require_once __DIR__ ."/../vendor/autoload.php";

Expand Down
Loading

0 comments on commit 74bff96

Please sign in to comment.