Skip to content

Commit

Permalink
SDA-4178 Add support for SMS protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenmoussati committed Jul 13, 2023
1 parent 028292b commit 3d5519a
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 120 deletions.
1 change: 1 addition & 0 deletions installer/win/WixSharpInstaller/Symphony.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ public static ActionResult CleanRegistryCurrentUser(Session session)
{
key.DeleteSubKeyTree("symphony", false);
key.DeleteSubKeyTree("Symphony.tel", false);
key.DeleteSubKeyTree("Symphony.sms", false);
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/app/child-window-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const verifyProtocolForNewUrl = (url: string): boolean => {
return false;
}

const allowedProtocols = ['http:', 'https:', 'mailto:', 'symphony:'];
const allowedProtocols = ['http:', 'https:', 'mailto:', 'symphony:', 'sms:'];
// url parse returns protocol with :
if (allowedProtocols.includes(parsedUrl.protocol)) {
logger.info(
Expand Down Expand Up @@ -207,7 +207,8 @@ export const handleChildWindow = (webContents: WebContents): void => {
webContents.on(
'did-create-window',
(browserWindow: BrowserWindow, details: DidCreateWindowDetails) => {
const newWinOptions = details.options as ICustomBrowserWindowConstructorOpts;
const newWinOptions =
details.options as ICustomBrowserWindowConstructorOpts;
const width = newWinOptions.width || DEFAULT_POP_OUT_WIDTH;
const height = newWinOptions.height || DEFAULT_POP_OUT_HEIGHT;
const newWinKey = getGuid();
Expand Down
9 changes: 7 additions & 2 deletions src/app/main-api-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,13 @@ ipcMain.on(
autoUpdate.checkUpdates();
}
break;
case apiCmds.registerVoiceServices:
voiceHandler.registerSymphonyAsDefaultCallApp();
case apiCmds.registerPhoneNumberServices:
voiceHandler.registerSymphonyAsDefaultApp(arg.protocols);
break;
case apiCmds.unregisterPhoneNumberServices:
voiceHandler.unregisterSymphonyAsDefaultApp(arg.protocols);
break;
default:
break;
}
},
Expand Down
18 changes: 13 additions & 5 deletions src/app/protocol-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { windowHandler } from './window-handler';
enum protocol {
SymphonyProtocol = 'symphony://',
TelProtocol = 'tel:',
SmsProtocol = 'sms:',
}

class ProtocolHandler {
Expand Down Expand Up @@ -87,11 +88,8 @@ class ProtocolHandler {
`protocol-handler: our protocol request is a valid url ${url}! sending request to SFE for further action!`,
);
this.preloadWebContents.send('protocol-action', url);
} else if (url?.includes('tel:')) {
this.preloadWebContents.send(
'phone-number-received',
url.split('tel:')[1],
);
} else if (url?.includes('tel:') || url?.includes('sms:')) {
this.preloadWebContents.send('phone-number-received', url);
}
}

Expand All @@ -112,6 +110,11 @@ class ProtocolHandler {
protocol.TelProtocol,
false,
);
const smsArgFromArgv = getCommandLineArgs(
argv || process.argv,
protocol.SmsProtocol,
false,
);
if (protocolUriFromArgv) {
logger.info(
`protocol-handler: we have a protocol request for the url ${protocolUriFromArgv}!`,
Expand All @@ -122,6 +125,11 @@ class ProtocolHandler {
`protocol-handler: we have a tel request for ${telArgFromArgv}!`,
);
this.sendProtocol(telArgFromArgv, isAppAlreadyOpen);
} else if (smsArgFromArgv) {
logger.info(
`protocol-handler: we have an sms request for ${smsArgFromArgv}!`,
);
this.sendProtocol(smsArgFromArgv, isAppAlreadyOpen);
}
}

Expand Down
Loading

0 comments on commit 3d5519a

Please sign in to comment.