diff --git a/package-lock.json b/package-lock.json index 5320e924..3e1c6bf8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,7 +30,7 @@ "@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands", "@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light", "@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid", - "@nethesis/phone-island": "^0.18.1", + "@nethesis/phone-island": "^0.18.2", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", @@ -5641,9 +5641,9 @@ } }, "node_modules/@nethesis/phone-island": { - "version": "0.18.1", - "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.18.1.tgz", - "integrity": "sha512-kqV7BnPvireD0078MDqqqWwUAc0Qqci7YfW78wu4Am9uDoSabM+mc+TGiIBlS+9dAj5Md53aBH99SUsPTpWAuA==", + "version": "0.18.2", + "resolved": "https://registry.npmjs.org/@nethesis/phone-island/-/phone-island-0.18.2.tgz", + "integrity": "sha512-tvRQfc3LE48lVJu2McTw8ifDH6unTHc3/GqUjlgwGX05gAEPjCFicKoLh3b5YnfjOUxcKmltIE1yLqZCAmTUOw==", "dev": true, "license": "GPL-3.0-or-later", "dependencies": { diff --git a/package.json b/package.json index 85ec9265..f590770a 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "@nethesis/nethesis-brands-svg-icons": "github:nethesis/Font-Awesome#ns-brands", "@nethesis/nethesis-light-svg-icons": "github:nethesis/Font-Awesome#ns-light", "@nethesis/nethesis-solid-svg-icons": "github:nethesis/Font-Awesome#ns-solid", - "@nethesis/phone-island": "^0.18.1", + "@nethesis/phone-island": "^0.18.2", "@tailwindcss/forms": "^0.5.7", "@types/lodash": "^4.14.202", "@types/node": "^18.19.9", diff --git a/src/main/classes/controllers/PhoneIslandController.ts b/src/main/classes/controllers/PhoneIslandController.ts index 1a731a9d..a1ca938f 100644 --- a/src/main/classes/controllers/PhoneIslandController.ts +++ b/src/main/classes/controllers/PhoneIslandController.ts @@ -121,9 +121,20 @@ export class PhoneIslandController { } callTransfer(to: string) { + Log.info("Tranfer to", to) this.window.emit(IPC_EVENTS.TRANSFER_CALL, to) } + intrudeCall(to: string) { + Log.info("Intrude to", to) + this.window.emit(IPC_EVENTS.INTRUDE_CALL, to) + } + + listenCall(to: string) { + Log.info("Listen to", to) + this.window.emit(IPC_EVENTS.LISTEN_CALL, to) + } + updateDefaultDevice(ext: Extension, force: boolean) { try { diff --git a/src/main/main.ts b/src/main/main.ts index 3ff5df93..d265b527 100644 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -543,16 +543,40 @@ async function attachProtocolListeners() { function handleNethLinkProtocol(url: string): Promise { //we have to define the purpose of the nethlink custom protocol Log.info('HandleProtocol Nethlink:', url) - const data = new URL("nethlink://" + url) - const action = data.host + const cleanUrl = url.replace(/^nethlink:\/?\/?/, '') + const [actionPart, queryString] = cleanUrl.split('?') + const action = actionPart.toLowerCase().trim() + const params = new URLSearchParams(queryString || '') + const to = params.get('to') + + Log.info(`[NethLink Protocol] Action: '${action}', To: '${to}'`) + try { switch (action) { - case 'transfer': - const to = data.searchParams.get('to') - if (to) + case 'transfer': { + if (to) { + Log.info('Transfer call to:', to) PhoneIslandController.instance.callTransfer(to) + } + break; + } + case 'listen': { + if (to) { + Log.info('Listen call to:', to) + PhoneIslandController.instance.listenCall(to) + } break; + } + case 'intrude': { + if (to) { + Log.info('Intrude call to:', to) + PhoneIslandController.instance.intrudeCall(to) + } + break; + } + default: + Log.warning('Unknown nethlink action:', action) } NethLinkController.instance.show() } catch (e) { diff --git a/src/renderer/src/pages/PhoneIslandPage.tsx b/src/renderer/src/pages/PhoneIslandPage.tsx index fe0012d3..510c9248 100644 --- a/src/renderer/src/pages/PhoneIslandPage.tsx +++ b/src/renderer/src/pages/PhoneIslandPage.tsx @@ -183,11 +183,26 @@ export function PhoneIslandPage() { }) window.electron.receive(IPC_EVENTS.TRANSFER_CALL, (to: string) => { + Log.info("Receive event and send Transfer to", to) eventDispatch(PHONE_ISLAND_EVENTS['phone-island-call-transfer'], { to }) }) + window.electron.receive(IPC_EVENTS.INTRUDE_CALL, (to: string) => { + Log.info("Receive event and send Intrude to", to) + eventDispatch(PHONE_ISLAND_EVENTS['phone-island-call-intrude'], { + to + }) + }) + + window.electron.receive(IPC_EVENTS.LISTEN_CALL, (to: string) => { + Log.info("Receive event and send Listen to", to) + eventDispatch(PHONE_ISLAND_EVENTS['phone-island-call-listen'], { + to + }) + }) + window.electron.receive(IPC_EVENTS.RECONNECT_PHONE_ISLAND, () => { logout() }) diff --git a/src/shared/constants.ts b/src/shared/constants.ts index 5af4baf4..78c0e621 100644 --- a/src/shared/constants.ts +++ b/src/shared/constants.ts @@ -105,6 +105,8 @@ export enum IPC_EVENTS { SHOW_COMMAND_BAR = "SHOW_COMMAND_BAR", HIDE_COMMAND_BAR = "HIDE_COMMAND_BAR", CHANGE_COMMAND_BAR_SHORTCUT = "CHANGE_COMMAND_BAR_SHORTCUT", + INTRUDE_CALL = "INTRUDE_CALL", + LISTEN_CALL = "LISTEN_CALL", } //PHONE ISLAND EVENTS