Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(click2call): added new event to handle physical phones #41

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,6 @@
"presentation": {
"hidden": false
}
},
{
"name": "Debug Renderer Process",
"port": 9222,
"request": "attach",
"type": "chrome",
"webRoot": "${workspaceFolder}/src/renderer",
"timeout": 15000,
"presentation": {
"hidden": true
}
}
],
"compounds": [
{
"name": "Debug main and renderer processes",
"configurations": [
"Debug Main Process",
"Debug Renderer Process"
],
"presentation": {
"order": 1
}
}
]
}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,13 @@ $ npm run publish:patch
> `INSTANCE=<numer_of_the_instance>`\
> enables multiple instances of the process. Use this function with extreme caution, it can cause many problems - for testing purposes only. When this variable is set, a new `user_data_<instance_number>.json` is created and the instance only changes its related file.
### User data folders

- Windows: `%APPDATA%/nethlink/`
- Linux: `~/.config/nethlink/`
- macOS: `~/Library/Application Support/nethlink/`


We then have two files: user_data.json and available_users.json the first file contains the data of the currently logged in user, the other contains the data of all available users in that device who have logged in at least once

83 changes: 76 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"@headlessui/react": "^1.7.18",
"@hookform/resolvers": "^3.3.4",
"@nethesis/phone-island": "^0.8.28",
"@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.8.31",
"@tailwindcss/forms": "^0.5.7",
"@types/lodash": "^4.14.202",
"@types/node": "^18.19.9",
Expand Down Expand Up @@ -76,6 +79,7 @@
"i18next-http-backend": "^2.1.1",
"lodash": "^4.17.21",
"moment": "^2.30.1",
"motion": "^11.13.1",
"path-browserify": "^1.0.1",
"postcss": "^8.4.35",
"prettier": "^3.2.4",
Expand Down
38 changes: 22 additions & 16 deletions public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"application_update_body": "Click here to open the page where you can download the new release",
"lost_call_title": "Missed call from {{user}}",
"lost_call_body": "You received a call from {{number}} at {{datetime}}",
"physical_phone_error": "the phone {{phone}} is not reachable. Make sure it is connected",
"call_transferred_title": "Call tranferred",
"call_transferred_body": "The call was succesfully tranferred"
},
Expand Down Expand Up @@ -322,7 +323,9 @@
"For the following states": "For the following states",
"Callforward": "Forward",
"Do not disturb": "Do not disturb",
"Available presence": "Available presence"
"Available presence": "Available presence",
"IP Phone": "IP Phone",
"Only nethlink": "Only Nethlink"
},
"TopBar": {
"Signed in as": "Signed in as",
Expand All @@ -344,7 +347,9 @@
"Mobile": "Mobile",
"Cellphone": "Cellphone",
"Activate voicemail": "Activate voicemail",
"Go to NethVoice CTI": "Go to NethVoice CTI"
"Go to NethVoice CTI": "Go to NethVoice CTI",
"Pair device": "Pair device",
"Theme": "Theme"
},
"OperatorDrawer": {
"Book": "Book",
Expand Down Expand Up @@ -893,19 +898,20 @@
"download": "Download the update"
},
"Errors": {
"browser_permissions": "Errore di autorizzazione",
"user_permissions": "Errore di autorizzazione",
"unknown_media_permissions": "Errore di autorizzazione",
"webrtc_down": "WebRTC non disponibile",
"socket_down": "Socket non disponibile",
"busy_camera": "Camera occupata",
"call_transfered": "Chiamata trasferita con successo",
"The browser doesn't have permission to access camera or microphone.": "Il browser non ha il permesso di accedere alla fotocamera o al microfono.",
"You must accept audio and video permissions.": "Devi accettare i permessi audio e video.",
"Web Phone can't access audio or camera on this device.": "Il Web Phone non può accedere all'audio o alla fotocamera su questo dispositivo.",
"Web Phone connection is down.": "La connessione del Web Phone è interrotta.",
"Server connection is down.": "La connessione al server è interrotta.",
"Camera is used by another application.": "La fotocamera è utilizzata da un'altra applicazione.",
"Call transferred successfully.": "Chiamata trasferita con successo."
"browser_permissions": "Browser Permissions Error",
"user_permissions": "User Permissions Error",
"unknown_media_permissions": "Unknown Media Permissions Error",
"webrtc_down": "WebRTC Down",
"socket_down": "Socket Down",
"busy_camera": "Busy Camera",
"call_transfered": "Call Transferred Successfully",
"The browser doesn't have permission to access camera or microphone.": "The browser doesn't have permission to access camera or microphone.",
"You must accept audio and video permissions.": "You must accept audio and video permissions.",
"Web Phone can't access audio or camera on this device.": "Web Phone can't access audio or camera on this device.",
"Web Phone connection is down.": "Web Phone connection is down.",
"NethLink connection is down.": "NethLink connection is down",
"Server connection is down.": "Server connection is down.",
"Camera is used by another application.": "Camera is used by another application.",
"Call transferred successfully.": "Call transferred successfully."
}
}
38 changes: 22 additions & 16 deletions public/locales/it/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@
"application_update_body": "Clicca quì per aprire la pagina dove potrai scaricare la nuova release",
"lost_call_title": "Chiamata persa da {{user}}",
"lost_call_body": "Hai ricevuto una chiamata da {{number}} alle {{datetime}}",
"physical_phone_error": "Il telefono {{phone}} non è raggiungibile. Assicurarsi che sia collegato",
"call_transferred_title": "Traferimento di chiamata",
"call_transferred_body": "La chiamata è stata trasferita con successo"
},
Expand Down Expand Up @@ -322,7 +323,9 @@
"For the following states": "Per i seguenti stati",
"Callforward": "Inoltro",
"Do not disturb": "Non disturbare",
"Available presence": "Presence disponibili"
"Available presence": "Presence disponibili",
"IP Phone": "Telefono IP",
"Only nethlink": "Solo Nethlink"
},
"TopBar": {
"Signed in as": "Accesso effettuato come",
Expand All @@ -344,7 +347,9 @@
"Mobile": "Cellulare",
"Cellphone": "Cellulare",
"Activate voicemail": "Attiva voicemail",
"Go to NethVoice CTI": "Vai a NethVoice CTI"
"Go to NethVoice CTI": "Vai a NethVoice CTI",
"Pair device": "Abbina dispositivo",
"Theme": "Tema"
},
"OperatorDrawer": {
"Book": "Prenota",
Expand Down Expand Up @@ -893,19 +898,20 @@
"download": "Scarica l'aggiornamento"
},
"Errors": {
"browser_permissions": "Browser Permissions Error",
"user_permissions": "User Permissions Error",
"unknown_media_permissions": "Unknown Media Permissions Error",
"webrtc_down": "WebRTC Down",
"socket_down": "Socket Down",
"busy_camera": "Busy Camera",
"call_transfered": "Call Transferred Successfully",
"The browser doesn't have permission to access camera or microphone.": "The browser doesn't have permission to access camera or microphone.",
"You must accept audio and video permissions.": "You must accept audio and video permissions.",
"Web Phone can't access audio or camera on this device.": "Web Phone can't access audio or camera on this device.",
"Web Phone connection is down.": "Web Phone connection is down.",
"Server connection is down.": "Server connection is down.",
"Camera is used by another application.": "Camera is used by another application.",
"Call transferred successfully.": "Call transferred successfully."
"browser_permissions": "Errore di autorizzazione",
"user_permissions": "Errore di autorizzazione",
"unknown_media_permissions": "Errore di autorizzazione",
"webrtc_down": "WebRTC non disponibile",
"socket_down": "Socket non disponibile",
"busy_camera": "Camera occupata",
"call_transfered": "Chiamata trasferita con successo",
"The browser doesn't have permission to access camera or microphone.": "Il browser non ha il permesso di accedere alla fotocamera o al microfono.",
"You must accept audio and video permissions.": "Devi accettare i permessi audio e video.",
"Web Phone can't access audio or camera on this device.": "Il Web Phone non può accedere all'audio o alla fotocamera su questo dispositivo.",
"Web Phone connection is down.": "La connessione del Web Phone è interrotta.",
"NethLink connection is down.": "Connessione NethLink non disponibile",
"Server connection is down.": "La connessione al server è interrotta.",
"Camera is used by another application.": "La fotocamera è utilizzata da un'altra applicazione.",
"Call transferred successfully.": "Chiamata trasferita con successo."
}
}
9 changes: 8 additions & 1 deletion src/main/classes/controllers/AccountController.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Account, AuthAppData, ConfigFile } from '@shared/types'
import { Account, AuthAppData, AvailableDevices, ConfigFile } from '@shared/types'
import { Log } from '@shared/utils/logger'
import { safeStorage } from 'electron'
import { store } from '@/lib/mainStore'
Expand Down Expand Up @@ -77,6 +77,7 @@ export class AccountController {
let loggedAccount: Account = {
...lastLoggedAccount,
...tempLoggedAccount,
theme: lastLoggedAccount.theme || tempLoggedAccount.theme
}

const { parseConfig } = useLogin()
Expand Down Expand Up @@ -111,6 +112,10 @@ export class AccountController {
lastUser: accountUID,
lastUserCryptPsw: cryptString
},
device: account.data?.default_device ? {
type: account.data.default_device.type as AvailableDevices,
id: account.data.default_device.id,
} : undefined,
connection: store.store.connection || false
}, 'saveLoggedAccount')
store.saveToDisk()
Expand All @@ -137,6 +142,7 @@ export class AccountController {
auth!.availableAccounts[getAccountUID(account)] = account
store.set('auth', auth)
}
store.saveToDisk()
}
}

Expand Down Expand Up @@ -170,6 +176,7 @@ export class AccountController {

setAccountNethLinkBounds(nethlinkBounds: Electron.Rectangle | undefined): void {
const account = store.store.account
Log.info('MAIN PRESENCE BACK', account?.data?.mainPresence)
const auth = store.store.auth
if (account) {
account!.nethlinkBounds = nethlinkBounds
Expand Down
14 changes: 13 additions & 1 deletion src/main/classes/controllers/PhoneIslandController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { once } from '@/lib/ipcEvents'
import { useNethVoiceAPI } from '@shared/useNethVoiceAPI'
import { store } from '@/lib/mainStore'
import { screen } from 'electron'
import { Size } from '@shared/types'
import { Extension, Size } from '@shared/types'

export class PhoneIslandController {
static instance: PhoneIslandController
Expand Down Expand Up @@ -120,6 +120,18 @@ export class PhoneIslandController {
this.window.emit(IPC_EVENTS.TRANSFER_CALL, to)
}

updateDefaultDevice(ext: Extension, force: boolean) {
try {

//const { NethVoiceAPI } = useNethVoiceAPI(store.store.account)
//NethVoiceAPI.User.me().then((me) => {
this.window.emit(IPC_EVENTS.CHANGE_DEFAULT_DEVICE, ext, force)
//})
} catch (e) {
Log.warning('error during emitting updateDefaultDevice event to the PhoneIslandWindow:', e)
}
}

reconnect() {
try {
Log.info('PHONE ISLAND RECONNECT')
Expand Down
Loading
Loading