From 342dd2a71f1e04f7110def2bce1e8ed988a87f4d Mon Sep 17 00:00:00 2001
From: licui
Date: Tue, 29 Jan 2019 15:46:51 -0500
Subject: [PATCH] Add missing API functions in Application
---
types/openfin/index.d.ts | 26 ++++++++++++++++++++----
types/openfin/openfin-tests.ts | 36 ++++++++++++++++++++++++++++++----
2 files changed, 54 insertions(+), 8 deletions(-)
diff --git a/types/openfin/index.d.ts b/types/openfin/index.d.ts
index 54b5523130..559a6318b3 100644
--- a/types/openfin/index.d.ts
+++ b/types/openfin/index.d.ts
@@ -37,6 +37,7 @@ declare namespace fin {
// v2 shapes
type Identity = import('./_v2/identity').Identity;
+ type applicationLogInfo = import('./_v2/api/application/application').LogInfo;
type LaunchInfo = import('./_v2/api/application/application').ApplicationInfo;
type ShortCutConfig = import('./_v2/api/application/application').ShortCutConfig;
type TrayInfo = import('./_v2/api/application/application').TrayInfo;
@@ -144,6 +145,10 @@ declare namespace fin {
* Retrieves an array of active window groups for all of the application's windows. Each group is represented as an array of wrapped fin.desktop.Windows.
*/
getGroups(callback?: (groups: OpenFinWindow[][]) => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Retrieves information about the application.
+ */
+ getInfo(callback?: (info: LaunchInfo) => void, errorCallback?: (reason: string) => void): void;
/**
* Retrieves the JSON manifest that was used to create the application. Invokes the error callback if the application was not created from a manifest.
*/
@@ -156,14 +161,14 @@ declare namespace fin {
* Retrieves current configuration of application's shortcuts.
*/
getShortcuts(callback?: (config: ShortCutConfig) => void, errorCallback?: (reason: string) => void): void;
- /**
- * Retrieves information about the application.
- */
- getInfo(callback?: (info: LaunchInfo) => void, errorCallback?: (reason: string) => void): void;
/**
* Retrieves information about the system tray.
*/
getTrayIconInfo(callback?: (trayInfo: TrayInfo) => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Returns the current zoom level of the application.
+ */
+ getZoomLevel(callback?: (level: number) => void, errorCallback?: (reason: string) => void): void;
/**
* Determines if the application is currently running.
*/
@@ -202,6 +207,14 @@ declare namespace fin {
* Tells the rvm to relaunch the main application once upon a complete shutdown
*/
scheduleRestart(callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Sends a message to the RVM to upload the application's logs. On success, an object containing logId is returned.
+ */
+ sendApplicationLog(callback?: (logInfo: applicationLogInfo) => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Sets an associated username with that app for Application Log Management use
+ */
+ setAppLogUsername(username: string, callback?: () => void, errorCallback?: (reason: string) => void): void;
/**
* Sets new shortcut configuration for current application.
* Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest to
@@ -212,6 +225,11 @@ declare namespace fin {
* Adds a customizable icon in the system tray and notifies the application when clicked.
*/
setTrayIcon(iconUrl: string, listener: (clickInfo: TrayIconClickedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void;
+ /**
+ * Sets the zoom level of the application. The original size is 0 and each increment above or below represents zooming 20%
+ * larger or smaller to default limits of 300% and 50% of original size, respectively.
+ */
+ setZoomLevel(level: number, callback?: () => void, errorCallback?: (reason: string) => void): void;
/**
* Closes the application by terminating its process.
*/
diff --git a/types/openfin/openfin-tests.ts b/types/openfin/openfin-tests.ts
index 5367823dae..134139ce2e 100644
--- a/types/openfin/openfin-tests.ts
+++ b/types/openfin/openfin-tests.ts
@@ -56,6 +56,10 @@ function test_application() {
++groupCounter;
});
});
+ // getInfo
+ application.getInfo(info => {
+ console.log(`Launch mode: ${info.launchMode}`);
+ });
// getManifest
application.getManifest(manifest => {
console.log("Application manifest:");
@@ -72,15 +76,16 @@ function test_application() {
console.log("Start Menu shortcut is enabled: ", config.startMenu);
console.log("System Startup shortcut is enabled: ", config.systemStartup);
});
- // getInfo
- application.getInfo(info => {
- console.log(`Launch mode: ${info.launchMode}`);
- });
// getTrayIconInfo
application.getTrayIconInfo(info => {
console.log(info.x, info.y, info.bounds.left, info.bounds.top, info.bounds.height, info.bounds.width,
info.monitorInfo.reason);
});
+ // getZoomLevel
+ application.getZoomLevel(level => {
+ console.log("Application zoom level:");
+ console.log(level);
+ });
// isRunning
application.isRunning(running => {
console.log("the application is", running ? "running" : "not running");
@@ -107,12 +112,29 @@ function test_application() {
}, err => {
console.log("failure:", err);
});
+ // run
+ application.run(() => {
+ console.log("Application is running.");
+ }, err => {
+ console.log("failure:", err);
+ });
// schedule restart
application.scheduleRestart(() => {
console.log("You will not read this.");
}, err => {
console.log("failure:", err);
});
+ // sendApplicationLog
+ application.sendApplicationLog(info => {
+ console.log("Application logId:");
+ console.log(info.logId);
+ });
+ // setAppLogUsername
+ application.setAppLogUsername("username", () => {
+ console.log("Successfully set app log username");
+ }, error => {
+ console.log("Failed to set app log username. Error: ", error);
+ });
// setShortcuts
application.setShortcuts({
desktop: true,
@@ -127,6 +149,12 @@ function test_application() {
application.setTrayIcon("https://developer.openf.in/download/openfin.png", clickInfo => {
console.log(`The mouse has clicked at (${clickInfo.x}, ${clickInfo.y})`);
});
+ // setZoomLevel
+ application.setZoomLevel(2, () => {
+ console.log("Successfully set application zoom level");
+ }, error => {
+ console.log("Failed to set application zoom level. Error: ", error);
+ });
// terminate
application.terminate();
// wait