diff --git a/app/browser/notifications/activityManager.js b/app/browser/notifications/activityManager.js index e617d68a..60dc0ffc 100644 --- a/app/browser/notifications/activityManager.js +++ b/app/browser/notifications/activityManager.js @@ -77,8 +77,8 @@ function updateActivityCountHandler(self) { * @param {ActivityManager} self */ function incomingCallCreatedHandler(self) { - return async () => { - self.ipcRenderer.invoke('incoming-call-created'); + return async (data) => { + self.ipcRenderer.invoke('incoming-call-created', data); }; } diff --git a/app/browser/tools/activityHub.js b/app/browser/tools/activityHub.js index de6a9203..cc741916 100644 --- a/app/browser/tools/activityHub.js +++ b/app/browser/tools/activityHub.js @@ -223,7 +223,7 @@ function assignIncomingCallCreatedHandler(controller) { controller.constants.events.calling.callCreated, (e, data) => { if (data.signalingSession.isIncomingCall) { - onIncomingCallCreated(); + onIncomingCallCreated({ caller: data.signalingSession.remoteCaller.displayName }); } }); } @@ -286,10 +286,10 @@ async function onActivitiesCountUpdated(controller) { } } -async function onIncomingCallCreated() { +async function onIncomingCallCreated(data) { const handlers = getEventHandlers('incoming-call-created'); for (const handler of handlers) { - handler.handler({}); + handler.handler(data); } } diff --git a/app/config/index.js b/app/config/index.js index 93a2ed48..1cb8ed66 100644 --- a/app/config/index.js +++ b/app/config/index.js @@ -222,6 +222,10 @@ function argv(configPath) { incomingCallCommand: { default: null, describe: 'Command to execute on an incoming call.' + }, + incomingCallCommandArgs: { + default: [], + describe: 'Arguments for the incomming call command.' } }) .parse(process.argv.slice(1)); diff --git a/app/mainAppWindow/index.js b/app/mainAppWindow/index.js index 87b2a6c8..7dc2472b 100644 --- a/app/mainAppWindow/index.js +++ b/app/mainAppWindow/index.js @@ -16,8 +16,6 @@ const TrayIconChooser = require('../browser/tools/trayIconChooser'); const { AppConfiguration } = require('../appConfiguration'); const connMgr = require('../connectionManager'); -const commandSplitRegex = /"(\\"|[^"])*?"|(\\ |[^\s])*/gm; - /** * @type {TrayIconChooser} */ @@ -511,16 +509,17 @@ function assignSelectSourceHandler() { }; } -async function handleOnIncomingCallCreated() { - if (!incomingCallCommandProcess && config.incomingCallCommand) { - let commandParts = config.incomingCallCommand.match(commandSplitRegex); - incomingCallCommandProcess = spawn(commandParts.shift(), commandParts); +async function handleOnIncomingCallCreated(e, data) { + if (config.incomingCallCommand) { + incomingCallCommandTerminate(); + const commandArgs = [...config.incomingCallCommandArgs, data.caller]; + incomingCallCommandProcess = spawn(config.incomingCallCommand, commandArgs); } } -async function incomingCallCommandKill() { +async function incomingCallCommandTerminate() { if (incomingCallCommandProcess) { - incomingCallCommandProcess.kill('SIGKILL'); + incomingCallCommandProcess.kill('SIGTERM'); incomingCallCommandProcess = null; } } diff --git a/package.json b/package.json index 6ffc337b..d5c4a06b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "teams-for-linux", - "version": "1.3.26", + "version": "1.3.27", "main": "app/index.js", "description": "Unofficial client for Microsoft Teams for Linux", "homepage": "https://github.com/IsmaelMartinez/teams-for-linux",