Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/js/admin/*
/js/collections.js
/js/collectionsintegration.js
/js/tests/*
/js/vendor/*
/js/simplewebrtc/*
Expand Down
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
/js/admin/*.js binary
/js/admin/*.js.map binary
/js/collections.js binary
/js/collections.js.map binary
/js/collectionsintegration.js binary
/js/collectionsintegration.js.map binary
4 changes: 4 additions & 0 deletions .l10nignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
js/admin/
js/vendor/
js/tests/
js/collections.js
js/collections.js.map
js/collectionsintegration.js
js/collectionsintegration.js.map
build/
28 changes: 14 additions & 14 deletions js/admin/allowed-groups.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/admin/allowed-groups.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions js/admin/commands.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/admin/commands.js.map

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions js/admin/signaling-server.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/admin/signaling-server.js.map

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions js/admin/stun-server.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/admin/stun-server.js.map

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions js/admin/turn-server.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/admin/turn-server.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@
_participants: null,
/** @property {OCA.SpreedMe.Views.ParticipantView} _participantsView */
_participantsView: null,
/** @property {OCA.SpreedMe.Views.CollectionsView} _collectionsView */
_collectionsView: null,
fullscreenDisabled: true,
_searchTerm: '',
guestNick: null,
Expand Down Expand Up @@ -288,6 +290,17 @@
});

this._sidebarView.addTab('participants', { label: t('spreed', 'Participants'), icon: 'icon-contacts-dark' }, this._participantsView);

this._collectionsView = new OCA.SpreedMe.Views.CollectionsView({
room: this.activeRoom,
id: 'collectionsTabView'
});
this._collectionsView.listenTo(this._rooms, 'change:active', function(model, active) {
if (active) {
this.setRoom(model);
}
});
this._sidebarView.addTab('collections', { label: t('spreed', 'Collections'), icon: 'icon-category-integration' }, this._collectionsView);
},
_hideParticipantList: function() {
this._sidebarView.removeTab('participants');
Expand Down
272 changes: 272 additions & 0 deletions js/collections.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/collections.js.map

Large diffs are not rendered by default.

325 changes: 325 additions & 0 deletions js/collectionsintegration.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/collectionsintegration.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions js/merged.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"vendor/Caret.js/dist/jquery.caret.min.js",
"vendor/At.js/dist/js/jquery.atwho.min.js",
"simplewebrtc/bundled.js",
"collectionsintegration.js",
"models/chatmessage.js",
"models/chatmessagecollection.js",
"models/room.js",
Expand All @@ -16,6 +17,7 @@
"views/callbutton.js",
"views/callinfoview.js",
"views/chatview.js",
"views/collectionsview.js",
"views/editabletextlabel.js",
"views/emptycontentview.js",
"views/localvideoview.js",
Expand Down
53 changes: 53 additions & 0 deletions js/views/collectionsview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* global Marionette */

/**
*
* @copyright Copyright (c) 2017, Daniel Calviño Sánchez ([email protected])
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

(function(OC, OCA, Marionette) {
'use strict';

OCA.SpreedMe = OCA.SpreedMe || {};
OCA.SpreedMe.Views = OCA.SpreedMe.Views || {};

OCA.SpreedMe.Views.CollectionsView = Marionette.View.extend({

template: '<div id="collectionsView"></div>',

initialize: function(options) {
this.room = options.room;
this.render();
},

/**
* @param {OCA.SpreedMe.Models.Room} room
*/
setRoom: function(room) {
this.room = room;
OCA.Talk.CollectionsTabView.setRoomModel(this.room);
},

onAttach: function () {
OCA.Talk.CollectionsTabView.init(this.el, this.room);
}

});

})(OC, OCA, Marionette);
14 changes: 14 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use OCA\Spreed\Chat\Command\Listener as CommandListener;
use OCA\Spreed\Chat\Parser\Listener as ParserListener;
use OCA\Spreed\Chat\SystemMessage\Listener as SystemMessageListener;
use OCA\Spreed\Collaboration\Resources\ConversationProvider;
use OCA\Spreed\Collaboration\Resources\Listener as ResourceListener;
use OCA\Spreed\Config;
use OCA\Spreed\Files\Listener as FilesListener;
use OCA\Spreed\Files\TemplateLoader as FilesTemplateLoader;
Expand All @@ -48,6 +50,7 @@
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Utility\IControllerMethodReflector;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Collaboration\Resources\IManager as IResourceManager;
use OCP\IServerContainer;
use OCP\IUser;
use OCP\Settings\IManager;
Expand Down Expand Up @@ -93,6 +96,7 @@ public function register(): void {

$this->extendDefaultContentSecurityPolicy();
$this->registerNotifier($server);
$this->registerCollaborationResourceProvider($server);
$this->getContainer()->registerCapability(Capabilities::class);

$dispatcher = $server->getEventDispatcher();
Expand All @@ -108,6 +112,7 @@ public function register(): void {
RoomShareProvider::register($dispatcher);
SignalingListener::register($dispatcher);
CommandListener::register($dispatcher);
ResourceListener::register($dispatcher);

$this->registerNavigationLink($server);
$this->registerRoomActivityHooks($dispatcher);
Expand All @@ -129,6 +134,15 @@ protected function registerNotifier(IServerContainer $server): void {
});
}

protected function registerCollaborationResourceProvider(IServerContainer $server): void {
/** @var IResourceManager $resourceManager */
$resourceManager = $server->query(IResourceManager::class);
$resourceManager->registerResourceProvider(ConversationProvider::class);
\OC::$server->getEventDispatcher()->addListener('\OCP\Collaboration\Resources::loadAdditionalScripts', function () {
\OCP\Util::addScript('spreed', 'collections');
});
}

protected function registerClientLinks(IServerContainer $server): void {
if ($server->getAppManager()->isEnabledForUser('firstrunwizard')) {
/** @var IManager $settingManager */
Expand Down
111 changes: 111 additions & 0 deletions lib/Collaboration/Resources/ConversationProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php
declare(strict_types=1);
/**
* @copyright Copyright (c) 2018 Joas Schilling <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

namespace OCA\Spreed\Collaboration\Resources;

use OCA\Spreed\Exceptions\RoomNotFoundException;
use OCA\Spreed\Manager;
use OCA\Spreed\Room;
use OCP\Collaboration\Resources\IProvider;
use OCP\Collaboration\Resources\IResource;
use OCP\Collaboration\Resources\ResourceException;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;

class ConversationProvider implements IProvider {

/** @var Manager */
protected $manager;
/** @var IUserSession */
protected $userSession;
/** @var IURLGenerator */
protected $urlGenerator;

public function __construct(Manager $manager,
IUserSession $userSession,
IURLGenerator $urlGenerator) {
$this->manager = $manager;
$this->userSession = $userSession;
$this->urlGenerator = $urlGenerator;
}

public function getResourceRichObject(IResource $resource): array {
try {
$room = $this->manager->getRoomByToken($resource->getId());
$user = $this->userSession->getUser();

$iconURL = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('spreed', 'app-dark.svg'));
/**
* Disabled for now, because it would show a square avatar
if ($room->getType() === Room::ONE_TO_ONE_CALL) {
$iconURL = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => 'admin', 'size' => 32]);
}
*/

return [
'type' => 'room',
'id' => $resource->getId(),
'name' => $room->getDisplayName($user instanceof IUser ? $user->getUID() : ''),
'call-type' => $this->getRoomType($room),
'iconUrl' => $iconURL,
'link' => $this->urlGenerator->linkToRouteAbsolute('spreed.pagecontroller.showCall', ['token' => $room->getToken()])
];
} catch (RoomNotFoundException $e) {
throw new ResourceException('Conversation not found');
}
}

public function canAccessResource(IResource $resource, IUser $user = null): bool {
try {
$room = $this->manager->getRoomForParticipantByToken(
$resource->getId(),
$user instanceof IUser ? $user->getUID() : null
);
return $user instanceof IUser || $room->getType() === Room::PUBLIC_CALL;
} catch (RoomNotFoundException $e) {
throw new ResourceException('Conversation not found');
}
}

public function getType(): string {
return 'room';
}

/**
* @param Room $room
* @return string
* @throws \InvalidArgumentException
*/
protected function getRoomType(Room $room): string {
switch ($room->getType()) {
case Room::ONE_TO_ONE_CALL:
return 'one2one';
case Room::GROUP_CALL:
return 'group';
case Room::PUBLIC_CALL:
return 'public';
default:
throw new \InvalidArgumentException('Unknown room type');
}
}
}
Loading