Skip to content

Commit

Permalink
SDA-4770 Expose Openfin API - Adding setContext (#2308)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenmoussati authored Feb 21, 2025
1 parent 2ffd498 commit 8b9c469
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/Symphony.config
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"licenseKey": "",
"runtimeVersion": "",
"autoConnect": false,
"channelName": "",
"platformUuid": "",
"connectionTimeout": "10000"
}
}
4 changes: 2 additions & 2 deletions installer/mac/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ if [ "$EUID" -ne 0 ]; then
defaults write "$plistFilePath" uuid -string ""
defaults write "$plistFilePath" licenseKey -string ""
defaults write "$plistFilePath" runtimeVersion -string ""
defaults write "$plistFilePath" channelName -string ""
defaults write "$plistFilePath" platformUuid -string ""
defaults write "$plistFilePath" autoConnect -bool false
else
sudo -u "$userName" defaults write "$plistFilePath" url -string "$pod_url"
Expand Down Expand Up @@ -176,7 +176,7 @@ else
sudo -u "$userName" defaults write "$plistFilePath" uuid -string ""
sudo -u "$userName" defaults write "$plistFilePath" licenseKey -string ""
sudo -u "$userName" defaults write "$plistFilePath" runtimeVersion -string ""
sudo -u "$userName" defaults write "$plistFilePath" channelName -string ""
sudo -u "$userName" defaults write "$plistFilePath" platformUuid -string ""
sudo -u "$userName" defaults write "$plistFilePath" autoConnect -bool false
fi

Expand Down
2 changes: 1 addition & 1 deletion spec/mainApiHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jest.mock('../src/app/config-handler', () => {
uuid: 'some-uuid',
licenseKey: 'some-license-key',
runtimeVersion: 'some-runtime-version',
channelName: 'some-channel-name',
platformUuid: 'platform-uuid',
connectionTimeout: '1000',
},
};
Expand Down
6 changes: 3 additions & 3 deletions spec/openfinHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jest.mock('../src/app/config-handler', () => ({
uuid: 'mock-uuid',
licenseKey: 'mock-license',
runtimeVersion: 'mock-version',
channelName: 'mock-channel',
platformUuid: 'platform-uuid',
connectionTimeout: '10000',
},
})),
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Openfin', () => {
jest.useFakeTimers();
const connectSyncSpy = jest
.spyOn(connectMock.Interop, 'connectSync')
.mockImplementationOnce((_channelName) => {
.mockImplementationOnce((_platformUuid) => {
return new Promise<void>((resolve) => {
setTimeout(() => {
resolve();
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('Openfin', () => {
jest.useFakeTimers();
const connectSyncSpy = jest
.spyOn(connectMock.Interop, 'connectSync')
.mockImplementationOnce((_channelName) => {
.mockImplementationOnce((_platformUuid) => {
return new Promise<void>((resolve) => {
setTimeout(() => {
resolve();
Expand Down
2 changes: 1 addition & 1 deletion spec/plistHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('Plist Handler', () => {
autoConnect: undefined,
licenseKey: undefined,
runtimeVersion: undefined,
channelName: undefined,
platformUuid: undefined,
uuid: undefined,
connectionTimeout: undefined,
},
Expand Down
2 changes: 1 addition & 1 deletion src/app/config-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export interface IOpenfin {
uuid: string;
licenseKey: string;
runtimeVersion: string;
channelName: string;
platformUuid: string;
autoConnect: boolean;
connectionTimeout: string;
}
Expand Down
2 changes: 2 additions & 0 deletions src/app/main-api-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ ipcMain.handle(
return openfinHandler.fireIntentForContext(arg.context);
case apiCmds.openfinRemoveFromContextGroup:
return openfinHandler.removeFromContextGroup();
case apiCmds.openfinSetContext:
return openfinHandler.setContext(arg.context);
default:
break;
}
Expand Down
12 changes: 10 additions & 2 deletions src/app/openfin-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ export class OpenfinHandler {
'openfin-handler: connection established to openfin runtime',
);
logger.info(
`openfin-handler: starting connection to interop broker using channel ${openfin.channelName}...`,
`openfin-handler: starting connection to interop broker using channel ${openfin.platformUuid}...`,
);

this.interopClient = this.fin.Interop.connectSync(openfin.channelName);
this.interopClient = this.fin.Interop.connectSync(openfin.platformUuid);
this.isConnected = true;
this.interopClient?.onDisconnection(this.disconnectionHandler);

Expand Down Expand Up @@ -202,6 +202,14 @@ export class OpenfinHandler {
return this.interopClient?.fireIntentForContext(context);
}

/**
* Sets a context for the context group of the current entity.
* @param context
*/
public setContext(context: any) {
return this.interopClient?.setContext(context);
}

/**
* Leaves current context group
*/
Expand Down
2 changes: 1 addition & 1 deletion src/app/plist-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const OPENFIN = {
uuid: 'string',
licenseKey: 'string',
runtimeVersion: 'string',
channelName: 'string',
platformUuid: 'string',
autoConnect: 'boolean',
connectionTimeout: 'string',
};
Expand Down
1 change: 1 addition & 0 deletions src/common/api-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export enum apiCmds {
openfinFireIntentForContext = 'openfin-fire-intent-for-context',
openfinRemoveFromContextGroup = 'openfin-remove-from-context-group',
openfinGetClientInfo = 'openfin-get-client-info',
openfinSetContext = 'openfin-set-context',
}

export enum apiName {
Expand Down
2 changes: 1 addition & 1 deletion src/common/config-interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const ConfigFieldsDefaultValues: Partial<IConfig> = {
uuid: '',
licenseKey: '',
runtimeVersion: '',
channelName: '',
platformUuid: '',
autoConnect: false,
connectionTimeout: '10000',
},
Expand Down
1 change: 1 addition & 0 deletions src/renderer/preload-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ if (ssfWindow.ssf) {
fireIntentForContext: ssfWindow.ssf.openfinFireIntentForContext,
removeFromContextGroup: ssfWindow.ssf.openfinRemoveFromContextGroup,
getClientInfo: ssfWindow.ssf.openfinGetClientInfo,
setContext: ssfWindow.ssf.openfinSetContext,
});
}

Expand Down
12 changes: 12 additions & 0 deletions src/renderer/ssf-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,18 @@ export class SSFApi {
return clients;
}

/**
* Sets a context for the context group of the current entity.
* @param context
*/
public async openfinSetContext(context: any) {
const response = await local.ipcRenderer.invoke(apiName.symphonyApi, {
cmd: apiCmds.openfinSetContext,
context,
});
return response;
}

/**
* Allows JS to register SDA for phone numbers clicks
* @param {Function} phoneNumberCallback callback function invoked when receiving a phone number for calls/sms
Expand Down

0 comments on commit 8b9c469

Please sign in to comment.