2017-02-19 00:42:11 +00:00
|
|
|
/* global APP, loggingConfig */
|
2016-12-14 12:09:29 +00:00
|
|
|
|
2017-01-15 04:05:56 +00:00
|
|
|
import { isRoomValid } from '../base/conference';
|
2017-02-19 00:42:11 +00:00
|
|
|
import JitsiMeetJS from '../base/lib-jitsi-meet';
|
2017-01-29 01:56:35 +00:00
|
|
|
import { RouteRegistry } from '../base/react';
|
|
|
|
import { interceptComponent } from '../base/util';
|
2017-01-15 04:05:56 +00:00
|
|
|
import { Conference } from '../conference';
|
|
|
|
import { WelcomePage } from '../welcome';
|
|
|
|
|
2016-12-14 12:09:29 +00:00
|
|
|
import URLProcessor from '../../../modules/config/URLProcessor';
|
2017-01-10 21:55:31 +00:00
|
|
|
import KeyboardShortcut
|
|
|
|
from '../../../modules/keyboardshortcut/keyboardshortcut';
|
|
|
|
import settings from '../../../modules/settings/Settings';
|
|
|
|
import getTokenData from '../../../modules/tokendata/TokenData';
|
2016-12-14 12:09:29 +00:00
|
|
|
import JitsiMeetLogStorage from '../../../modules/util/JitsiMeetLogStorage';
|
|
|
|
|
|
|
|
const Logger = require('jitsi-meet-logger');
|
|
|
|
|
2017-02-01 04:25:09 +00:00
|
|
|
export { _parseURIString } from './functions.native';
|
2016-12-14 12:09:29 +00:00
|
|
|
|
2016-12-27 16:03:30 +00:00
|
|
|
/**
|
|
|
|
* Determines which route is to be rendered in order to depict a specific Redux
|
|
|
|
* store.
|
|
|
|
*
|
|
|
|
* @param {(Object|Function)} stateOrGetState - Redux state or Regux getState()
|
|
|
|
* method.
|
|
|
|
* @returns {Route}
|
|
|
|
*/
|
|
|
|
export function _getRouteToRender(stateOrGetState) {
|
|
|
|
const state
|
|
|
|
= typeof stateOrGetState === 'function'
|
|
|
|
? stateOrGetState()
|
|
|
|
: stateOrGetState;
|
|
|
|
|
2017-01-19 15:47:22 +00:00
|
|
|
// If mobile browser page was shown, there is no need to show it again.
|
2017-01-18 12:21:30 +00:00
|
|
|
const { room } = state['features/base/conference'];
|
|
|
|
const component = isRoomValid(room) ? Conference : WelcomePage;
|
2017-01-19 15:47:22 +00:00
|
|
|
const route = RouteRegistry.getRouteByComponent(component);
|
2016-12-27 16:03:30 +00:00
|
|
|
|
2017-01-20 14:20:20 +00:00
|
|
|
// Intercepts route components if any of component interceptor rules
|
|
|
|
// is satisfied.
|
|
|
|
route.component = interceptComponent(state, component);
|
2016-12-27 16:03:30 +00:00
|
|
|
|
2017-01-18 12:21:30 +00:00
|
|
|
return route;
|
|
|
|
}
|
|
|
|
|
2016-12-14 12:09:29 +00:00
|
|
|
/**
|
2017-01-10 21:55:31 +00:00
|
|
|
* Temporary solution. Later we'll get rid of global APP and set its properties
|
|
|
|
* in redux store.
|
2016-12-14 12:09:29 +00:00
|
|
|
*
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
export function init() {
|
2017-01-10 21:55:31 +00:00
|
|
|
URLProcessor.setConfigParametersFromUrl();
|
2016-12-14 12:09:29 +00:00
|
|
|
_initLogging();
|
|
|
|
|
|
|
|
APP.keyboardshortcut = KeyboardShortcut;
|
|
|
|
APP.tokenData = getTokenData();
|
2017-01-18 00:16:18 +00:00
|
|
|
|
|
|
|
// Force enable the API if jwt token is passed because most probably
|
|
|
|
// jitsi meet is displayed inside of wrapper that will need to communicate
|
|
|
|
// with jitsi meet.
|
|
|
|
APP.API.init(APP.tokenData.jwt ? { forceEnable: true } : undefined);
|
2016-12-14 12:09:29 +00:00
|
|
|
|
|
|
|
APP.translation.init(settings.getLanguage());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adjusts the logging levels.
|
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-01-10 21:55:31 +00:00
|
|
|
function _configureLoggingLevels() {
|
|
|
|
// NOTE The library Logger is separated from the app loggers, so the levels
|
2016-12-14 12:09:29 +00:00
|
|
|
// have to be set in two places
|
|
|
|
|
|
|
|
// Set default logging level
|
|
|
|
const defaultLogLevel
|
|
|
|
= loggingConfig.defaultLogLevel || JitsiMeetJS.logLevels.TRACE;
|
|
|
|
|
|
|
|
Logger.setLogLevel(defaultLogLevel);
|
|
|
|
JitsiMeetJS.setLogLevel(defaultLogLevel);
|
|
|
|
|
2017-01-10 21:55:31 +00:00
|
|
|
// NOTE console was used on purpose here to go around the logging and always
|
|
|
|
// print the default logging level to the console
|
2016-12-14 12:09:29 +00:00
|
|
|
console.info(`Default logging level set to: ${defaultLogLevel}`);
|
|
|
|
|
|
|
|
// Set log level for each logger
|
|
|
|
if (loggingConfig) {
|
|
|
|
Object.keys(loggingConfig).forEach(loggerName => {
|
|
|
|
if (loggerName !== 'defaultLogLevel') {
|
|
|
|
const level = loggingConfig[loggerName];
|
|
|
|
|
|
|
|
Logger.setLogLevelById(level, loggerName);
|
|
|
|
JitsiMeetJS.setLogLevelById(level, loggerName);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-01-10 21:55:31 +00:00
|
|
|
* Initializes logging in the app.
|
2016-12-14 12:09:29 +00:00
|
|
|
*
|
|
|
|
* @private
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
2017-01-10 21:55:31 +00:00
|
|
|
function _initLogging() {
|
|
|
|
// Adjust logging level
|
|
|
|
_configureLoggingLevels();
|
|
|
|
|
|
|
|
// Create the LogCollector and register it as the global log transport. It
|
|
|
|
// is done early to capture as much logs as possible. Captured logs will be
|
|
|
|
// cached, before the JitsiMeetLogStorage gets ready (statistics module is
|
|
|
|
// initialized).
|
|
|
|
if (!APP.logCollector && !loggingConfig.disableLogCollector) {
|
|
|
|
APP.logCollector = new Logger.LogCollector(new JitsiMeetLogStorage());
|
|
|
|
Logger.addGlobalTransport(APP.logCollector);
|
|
|
|
JitsiMeetJS.addGlobalLogTransport(APP.logCollector);
|
|
|
|
}
|
2016-12-14 12:09:29 +00:00
|
|
|
}
|