Browse Source

Contacts can now be disabled on server module level (server.conf).

pull/174/head
Simon Eisenmann 10 years ago
parent
commit
457eabf23f
  1. 1
      server.conf.in
  2. 13
      src/app/spreed-webrtc-server/channelling_api.go
  3. 64
      src/app/spreed-webrtc-server/config.go
  4. 38
      src/styles/global/_withs.scss
  5. 1
      src/styles/main.scss
  6. 2
      static/css/main.min.css
  7. 3
      static/js/directives/buddylist.js
  8. 9
      static/js/directives/menu.js
  9. 25
      static/js/services/contacts.js
  10. 38
      static/js/services/modules.js
  11. 9
      static/js/services/services.js
  12. 2
      static/partials/buddy.html
  13. 2
      static/partials/menu.html

1
server.conf.in

@ -124,6 +124,7 @@ serverRealm = local @@ -124,6 +124,7 @@ serverRealm = local
;screensharing = true
;youtube = true
;presentation = true
;contacts = true
[log]
;logfile = /var/log/spreed-webrtc-server.log

13
src/app/spreed-webrtc-server/channelling_api.go

@ -139,6 +139,9 @@ func (api *channellingAPI) OnIncoming(c ResponseSender, session *Session, msg *D @@ -139,6 +139,9 @@ func (api *channellingAPI) OnIncoming(c ResponseSender, session *Session, msg *D
}
} else {
if msg.Chat.Chat.Status != nil && msg.Chat.Chat.Status.ContactRequest != nil {
if !api.Config.WithModule("contacts") {
return
}
if err := api.contactrequestHandler(session, msg.Chat.To, msg.Chat.Chat.Status.ContactRequest); err != nil {
log.Println("Ignoring invalid contact request.", err)
return
@ -173,10 +176,14 @@ func (api *channellingAPI) OnIncoming(c ResponseSender, session *Session, msg *D @@ -173,10 +176,14 @@ func (api *channellingAPI) OnIncoming(c ResponseSender, session *Session, msg *D
var users []*DataSession
switch msg.Sessions.Sessions.Type {
case "contact":
if userID, err := api.getContactID(session, msg.Sessions.Sessions.Token); err == nil {
users = api.GetUserSessions(session, userID)
if api.Config.WithModule("contacts") {
if userID, err := api.getContactID(session, msg.Sessions.Sessions.Token); err == nil {
users = api.GetUserSessions(session, userID)
} else {
log.Printf(err.Error())
}
} else {
log.Printf(err.Error())
log.Printf("Incoming contacts session request with contacts disabled")
}
case "session":
id, err := session.attestation.Decode(msg.Sessions.Sessions.Token)

64
src/app/spreed-webrtc-server/config.go

@ -31,26 +31,27 @@ import ( @@ -31,26 +31,27 @@ import (
)
type Config struct {
Title string // Title
ver string // Version (not exported to Javascript)
S string // Static URL prefix with version
B string // Base URL
Token string // Server token
StunURIs []string // STUN server URIs
TurnURIs []string // TURN server URIs
Tokens bool // True when we got a tokens file
Version string // Server version number
UsersEnabled bool // Flag if users are enabled
UsersAllowRegistration bool // Flag if users can register
UsersMode string // Users mode string
DefaultRoomEnabled bool // Flag if default room ("") is enabled
Plugin string // Plugin to load
AuthorizeRoomCreation bool // Whether a user account is required to create rooms
AuthorizeRoomJoin bool // Whether a user account is required to join rooms
Modules []string // List of enabled modules
globalRoomID string // Id of the global room (not exported to Javascript)
contentSecurityPolicy string // HTML content security policy
contentSecurityPolicyReportOnly string // HTML content security policy in report only mode
Title string // Title
ver string // Version (not exported to Javascript)
S string // Static URL prefix with version
B string // Base URL
Token string // Server token
StunURIs []string // STUN server URIs
TurnURIs []string // TURN server URIs
Tokens bool // True when we got a tokens file
Version string // Server version number
UsersEnabled bool // Flag if users are enabled
UsersAllowRegistration bool // Flag if users can register
UsersMode string // Users mode string
DefaultRoomEnabled bool // Flag if default room ("") is enabled
Plugin string // Plugin to load
AuthorizeRoomCreation bool // Whether a user account is required to create rooms
AuthorizeRoomJoin bool // Whether a user account is required to join rooms
Modules []string // List of enabled modules
modulesTable map[string]bool // Map of enabled modules
globalRoomID string // Id of the global room (not exported to Javascript)
contentSecurityPolicy string // HTML content security policy
contentSecurityPolicyReportOnly string // HTML content security policy in report only mode
}
func NewConfig(container phoenix.Container, tokens bool) *Config {
@ -88,11 +89,18 @@ func NewConfig(container phoenix.Container, tokens bool) *Config { @@ -88,11 +89,18 @@ func NewConfig(container phoenix.Container, tokens bool) *Config {
trimAndRemoveDuplicates(&turnURIs)
// Get enabled modules.
allModules := []string{"screensharing", "youtube", "presentation"}
modules := allModules[:0]
for _, module := range allModules {
modulesTable := map[string]bool{
"screensharing": true,
"youtube": true,
"presentation": true,
"contacts": true,
}
modules := []string{}
for module, _ := range modulesTable {
if container.GetBoolDefault("modules", module, true) {
modules = append(modules, module)
} else {
modulesTable[module] = false
}
}
log.Println("Enabled modules:", modules)
@ -115,6 +123,7 @@ func NewConfig(container phoenix.Container, tokens bool) *Config { @@ -115,6 +123,7 @@ func NewConfig(container phoenix.Container, tokens bool) *Config {
AuthorizeRoomCreation: container.GetBoolDefault("app", "authorizeRoomCreation", false),
AuthorizeRoomJoin: container.GetBoolDefault("app", "authorizeRoomJoin", false),
Modules: modules,
modulesTable: modulesTable,
globalRoomID: container.GetStringDefault("app", "globalRoom", ""),
contentSecurityPolicy: container.GetStringDefault("app", "contentSecurityPolicy", ""),
contentSecurityPolicyReportOnly: container.GetStringDefault("app", "contentSecurityPolicyReportOnly", ""),
@ -125,6 +134,15 @@ func (config *Config) Get(request *http.Request) (int, interface{}, http.Header) @@ -125,6 +134,15 @@ func (config *Config) Get(request *http.Request) (int, interface{}, http.Header)
return 200, config, http.Header{"Content-Type": {"application/json; charset=utf-8"}}
}
func (config *Config) WithModule(m string) bool {
if val, ok := config.modulesTable[m]; ok && val {
return true
}
return false
}
// Helper function to clean up string arrays.
func trimAndRemoveDuplicates(data *[]string) {
found := make(map[string]bool)

38
src/styles/global/_withs.scss

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
/*
* Spreed WebRTC.
* Copyright (C) 2013-2014 struktur AG
*
* This file is part of Spreed WebRTC.
*
* 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/>.
*
*/
.visible-with-contacts, .visible-with-contacts-inline {
display: none;
}
.hidden-with-contacts {
}
.with-contacts {
.visible-with-contacts {
display: block;
}
.visible-with-contacts-inline {
display: inline-block;
}
.hidden-with-contacts {
display: none;
}
}

1
src/styles/main.scss

@ -33,6 +33,7 @@ @@ -33,6 +33,7 @@
@import "global/nicescroll";
@import "global/animations";
@import "global/overlaybar";
@import "global/withs";
@import "components/rightslide";
@import "components/bar";

2
static/css/main.min.css vendored

File diff suppressed because one or more lines are too long

3
static/js/directives/buddylist.js

@ -141,6 +141,9 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) { @@ -141,6 +141,9 @@ define(['underscore', 'text!partials/buddylist.html'], function(_, template) {
}
scope.$apply();
});
if (contacts.enabled) {
iElement.addClass("with-contacts");
}
};

9
static/js/directives/menu.js

@ -23,15 +23,10 @@ @@ -23,15 +23,10 @@
define(['text!partials/menu.html'], function(template) {
// menu
return ["mediaStream", function(mediaStream) {
return ["modules", function(modules) {
var link = function($scope, $element) {
$scope.modules = mediaStream.config.Modules || [];
$scope.withModule = function(m) {
return $scope.modules.indexOf(m) !== -1;
};
$scope.withModule = modules.withModule;
};
return {

25
static/js/services/contacts.js

@ -123,11 +123,15 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana @@ -123,11 +123,15 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
};
// contacts
return ["appData", "contactData", "mediaStream", "$templateCache", function(appData, contactData, mediaStream, $templateCache) {
return ["appData", "contactData", "mediaStream", "$templateCache", "modules", function(appData, contactData, mediaStream, $templateCache, modules) {
// Inject our templates.
$templateCache.put('/contactsmanager/main.html', templateContactsManager);
$templateCache.put('/contactsmanager/edit.html', templateContactsManagerEdit);
var withContacts = modules.withModule("contacts");
if (withContacts) {
// Inject our templates.
$templateCache.put('/contactsmanager/main.html', templateContactsManager);
$templateCache.put('/contactsmanager/edit.html', templateContactsManagerEdit);
}
var Contacts = function() {
@ -135,6 +139,7 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana @@ -135,6 +139,7 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
this.userid = null;
this.key = null;
this.database = null;
this.enabled = withContacts;
appData.e.on("authenticationChanged", _.bind(function(event, userid, suserid) {
// TODO(longsleep): Avoid creating empty databases. Create db on store only.
@ -160,14 +165,24 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana @@ -160,14 +165,24 @@ define(['underscore', 'jquery', 'modernizr', 'sjcl', 'text!partials/contactsmana
};
Contacts.prototype.put = function(contact) {
if (!this.database) {
console.warn("Unable to put contact as no database is loaded.");
return;
}
this.database.put("contacts", {
id: this.id(contact.Userid),
contact: this.encrypt(contact)
});
}
};
Contacts.prototype.open = function(userid, suserid) {
if (!this.enabled) {
return null;
}
if (this.database && (!userid || this.userid !== userid)) {
// Unload existing contacts.
this.unload();

38
static/js/services/modules.js

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
/*
* Spreed WebRTC.
* Copyright (C) 2013-2014 struktur AG
*
* This file is part of Spreed WebRTC.
*
* 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/>.
*
*/
"use strict";
define([], function() {
// modules
return ["mediaStream", function(mediaStream) {
var enabledModules = mediaStream.config.Modules || [];
// Public api.
return {
withModule: function(m) {
return enabledModules.indexOf(m) !== -1;
}
}
}];
});

9
static/js/services/services.js

@ -65,7 +65,8 @@ define([ @@ -65,7 +65,8 @@ define([
'services/rooms',
'services/resturl',
'services/roompin',
'services/constraints'], function(_,
'services/constraints',
'services/modules'], function(_,
desktopNotify,
playSound,
safeApply,
@ -108,7 +109,8 @@ localStatus, @@ -108,7 +109,8 @@ localStatus,
rooms,
restURL,
roompin,
constraints) {
constraints,
modules) {
var services = {
desktopNotify: desktopNotify,
@ -153,7 +155,8 @@ constraints) { @@ -153,7 +155,8 @@ constraints) {
rooms: rooms,
restURL: restURL,
roompin: roompin,
constraints: constraints
constraints: constraints,
modules: modules
};
var initialize = function(angModule) {

2
static/partials/buddy.html

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<div class="buddy" ng-class="{'contact': contact, 'withSubline': display.subline || session.Userid, 'isself': session.Userid === myuserid}">
<div class="buddyPicture"><i class="fa fa-user"/><img ng-show="display.buddyPicture" alt ng-src="{{display.buddyPicture}}"/></div>
<div class="buddy1">{{session.Id|displayName}}</div>
<div class="buddy2"><span ng-show="session.Userid"><i class="fa contact" data-action="contact"></i><span ng-show="session.count"> ({{session.count}})</span></span> <span title="{{display.sublineFull}}">{{display.subline}}</span></div>
<div class="buddy2"><span ng-show="session.Userid"><i class="fa contact visible-with-contacts-inline" data-action="contact"></i><span ng-show="session.count"> ({{session.count}})</span></span> <span title="{{display.sublineFull}}">{{display.subline}}</span></div>
</div>

2
static/partials/menu.html

@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
<button ng-if="withModule('presentation')" title="{{_('Share a file as presentation')}}" class="btn aenablebtn btn-presentation" ng-show="status=='connected' || status=='conference' || layout.presentation" ng-model="layout.presentation" btn-checkbox><i class="fa fa-folder-open-o"></i></button>
<button ng-if="withModule('screensharing')" title="{{_('Share your screen')}}" class="btn aenablebtn btn-screenshare" ng-disabled="!supported.screensharing" ng-show="status=='connected' || status=='conference' || layout.screenshare" ng-model="layout.screenshare" btn-checkbox><i class="fa fa-desktop"></i></button>
<button title="{{_('Chat')}}" class="btn btn-chat" ng-class="{messagesunseen: chatMessagesUnseen>0}" ng-model="layout.chat" btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false"><i class="fa fa-comments-o"></i><span class="badge" ng-show="chatMessagesUnseen" ng-bind="chatMessagesUnseen"></span></button>
<button ng-show="myid && myuserid" title="{{_('Contacts')}}" class="btn btn-contacts" ng-click="openContactsManager()"><i class="fa fa-sitemap"></i></button>
<button ng-if="withModule('contacts')" ng-show="myid && myuserid" title="{{_('Contacts')}}" class="btn btn-contacts" ng-click="openContactsManager()"><i class="fa fa-sitemap"></i></button>
<button title="{{_('Mute microphone')}}" class="btn btn-mutemicrophone amutebtn" ng-model="microphoneMute" btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false"><i class="fa"></i></button>
<button title="{{_('Turn camera off')}}" class="btn btn-mutecamera amutebtn" ng-model="cameraMute" btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false"><i class="fa"></i></button>
<button title="{{_('Settings')}}" class="btn btn-settings" ng-model="layout.settings" btn-checkbox btn-checkbox-true="true" btn-checkbox-false="false"><i class="fa fa-cog"></i></button>

Loading…
Cancel
Save