2019-04-22 23:10:11 +00:00
|
|
|
// This file is required by the index.html file and will
|
|
|
|
// be executed in the renderer process for that window.
|
|
|
|
// All of the Node.js APIs are available in this process.
|
2019-04-25 00:35:36 +00:00
|
|
|
|
|
|
|
const keytar = require('keytar');
|
|
|
|
const angular = require('angular');
|
|
|
|
const settings = require('electron-settings');
|
|
|
|
|
2019-04-25 14:21:20 +00:00
|
|
|
|
|
|
|
var remote = require('electron').remote;
|
|
|
|
|
2019-04-25 00:35:36 +00:00
|
|
|
var angApp = angular.module('app', []);
|
|
|
|
|
|
|
|
angApp.controller('AppController', function ($scope) {
|
|
|
|
$scope.loginExist = false;
|
|
|
|
$scope.login = settings.get('login');
|
2019-04-25 14:21:20 +00:00
|
|
|
|
|
|
|
$scope.playAudio = function() {
|
|
|
|
var audio = new Audio('sounds/graceful.ogg');
|
|
|
|
audio.play();
|
|
|
|
};
|
|
|
|
|
2019-04-25 00:35:36 +00:00
|
|
|
if ($scope.login) {
|
2019-04-25 14:21:20 +00:00
|
|
|
var showEnvelope = remote.require('./main').showEnvelope;
|
2019-04-25 00:35:36 +00:00
|
|
|
$scope.loginExist = true;
|
|
|
|
$scope.boshService = settings.get('bosh');
|
|
|
|
var xmppService = $scope.login.split('@').pop();
|
|
|
|
var password = keytar.getPassword(xmppService, $scope.login);
|
|
|
|
password.then((result) => {
|
|
|
|
$scope.password = result;
|
2019-04-25 01:12:36 +00:00
|
|
|
converse.plugins.add('chimeVerse', {
|
|
|
|
initialize: function() {
|
|
|
|
var _converse = this._converse;
|
|
|
|
Promise.all([
|
|
|
|
_converse.api.waitUntil('rosterContactsFetched'),
|
|
|
|
_converse.api.waitUntil('chatBoxesFetched')
|
|
|
|
]).then(function() {
|
|
|
|
_converse.on('message', function (data) {
|
|
|
|
//_converse.api.archive.query({'with': 'admin2@localhost'});
|
2019-04-25 14:21:20 +00:00
|
|
|
$scope.playAudio();
|
|
|
|
showEnvelope();
|
2019-04-25 01:12:36 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-04-25 14:21:20 +00:00
|
|
|
var lang = navigator.language;
|
2019-04-25 00:35:36 +00:00
|
|
|
converse.initialize({
|
|
|
|
bosh_service_url: $scope.boshService,
|
|
|
|
view_mode: 'fullscreen',
|
|
|
|
jid: $scope.login,
|
|
|
|
password: $scope.password,
|
2019-04-25 01:12:36 +00:00
|
|
|
auto_login: true,
|
|
|
|
whitelisted_plugins: ['chimeVerse'],
|
2019-04-25 14:21:20 +00:00
|
|
|
i18n: lang
|
2019-04-25 00:35:36 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
angApp.controller('LoginController', function ($scope) {
|
|
|
|
$scope.addAccountAction = function() {
|
|
|
|
var xmppService = $scope.login.split('@').pop();
|
|
|
|
settings.set('bosh', $scope.boshService);
|
|
|
|
settings.set('login', $scope.login);
|
|
|
|
keytar.setPassword(xmppService, $scope.login, $scope.password);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|