From f84645460a9c05b5c5adff9c85994c69dd3fe5a9 Mon Sep 17 00:00:00 2001 From: kaspermarkus Date: Fri, 14 Feb 2014 20:34:11 +0100 Subject: [PATCH 01/47] GPII-228: First steps towards the snapshotter implementation --- .../flowManager/src/FlowManager.js | 7 ++ gpii/node_modules/flowManager/src/Snapshot.js | 88 +++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100755 gpii/node_modules/flowManager/src/Snapshot.js diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index 10e93aa79..d4a2de9d8 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -25,6 +25,7 @@ https://github.com/gpii/universal/LICENSE.txt fluid.require("./UserSave.js", require); fluid.require("./GetToken.js", require); fluid.require("./UserUpdate.js", require); + fluid.require("./Snapshot.js", require); fluid.require("lifecycleManager", require); @@ -89,6 +90,10 @@ https://github.com/gpii/universal/LICENSE.txt getToken: { route: "/token", type: "get" + }, + snapshot: { + route: "/snapshot", + type: "get" } } }); @@ -132,6 +137,8 @@ https://github.com/gpii/universal/LICENSE.txt userSave: { }, getToken: { + }, + snapshot: { } } }); diff --git a/gpii/node_modules/flowManager/src/Snapshot.js b/gpii/node_modules/flowManager/src/Snapshot.js new file mode 100755 index 000000000..693b8ba1a --- /dev/null +++ b/gpii/node_modules/flowManager/src/Snapshot.js @@ -0,0 +1,88 @@ +/** + * GPII snapshot Handler + * + * Copyright 2014 Raising the Floor - International + * + * Licensed under the New BSD license. You may not use this file except in + * compliance with this License. + * + * You may obtain a copy of the License at + * https://github.com/gpii/universal/LICENSE.txt + */ + + /*global require*/ + +(function () { + + "use strict"; + + var fluid = require("infusion") + var gpii = fluid.registerNamespace("gpii"); + fluid.registerNamespace("gpii.request.flowManager.snapshotter"); + + fluid.defaults("kettle.requests.request.handler.snapshot", { + gradeNames: ["fluid.littleComponent", "autoInit"], + invokers: { + handle: { + funcName: "gpii.request.flowManager.snapshotter.onSnapshotRequest", + args: ["{that}", "{requestProxy}.events" ] + }, + getDevice: { + funcName: "gpii.request.flowManager.getDevice", + args: ["{flowManager}.deviceReporterDataSource", "{that}.events.onDevice"] + }, + getSolutions: { + funcName: "gpii.request.flowManager.snapshotter.getSolutions", + args: ["{gpii.matchMaker}.solutionsReporter", "{that}.events.onSolutions", "{arguments}.0", "{gpii.matchMaker}"] + }, + executeSnapshot: { + funcName: "gpii.request.flowManager.snapshotter.executeSnapshot", + args: ["{requestProxy}", "{arguments}.0", "{arguments}.1"] + } + }, + events: { + onDevice: null, + onSolutions: null + }, + listeners: { + onDevice: "{that}.getSolutions", + onSolutions: "{that}.executeSnapshot" + } + }); + + /** + * Called when snapshot request has been made. Fires get's on device and solution registry + * datasources. + * + */ + gpii.request.flowManager.snapshotter.onSnapshotRequest = function (that, events) { + that.getDevice(); + // events.onSuccess.fire("PLING"); + // that.withSession(function (session, tokens) { + // var token = tokens.join(","); + // fluid.log("Reporting currently logged in user(s) as: " + token); + // events.onSuccess.fire(token); + // }, "No user currently logged into the system"); + }; + + gpii.request.flowManager.snapshotter.getSolutions = function (solutionsReporterDataSource, event, model, matchMaker) { + var hello = "world"; + var device = model, + os = fluid.get(device, "OS.id"), + version = fluid.get(device, "OS.version"); + solutionsReporterDataSource.get({ + os: os, + version: version + }, function (solutions) { + matchMaker.prefilterSolutions(solutions, os, version); + solutions = matchMaker.prefilterSolutions(solutions, device); + event.fire(solutions, model); + }); + }; + + gpii.request.flowManager.snapshotter.executeSnapshot = function (that, device, solutions) { + console.log("SO FAR SO GOD"); + that.events.onSuccess.fire(JSON.stringify(device)); + }; + +})(); From 000b33c52c1c338c48487328eb5ad792301f2be4 Mon Sep 17 00:00:00 2001 From: kaspermarkus Date: Wed, 19 Feb 2014 11:21:06 +0100 Subject: [PATCH 02/47] GPII-228: Temporary save while doing other work --- gpii/node_modules/flowManager/src/Snapshot.js | 44 +++--- .../lifecycleManager/src/LifecycleManager.js | 64 ++++++++- .../src/js/settingsHandlerUtilities.js | 25 +++- .../deviceReporter/installedSolutions.json | 133 ------------------ testData/solutions/win32.json | 2 +- 5 files changed, 107 insertions(+), 161 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Snapshot.js b/gpii/node_modules/flowManager/src/Snapshot.js index 693b8ba1a..f9593120f 100755 --- a/gpii/node_modules/flowManager/src/Snapshot.js +++ b/gpii/node_modules/flowManager/src/Snapshot.js @@ -12,6 +12,11 @@ /*global require*/ +//OVERALL TODOS: +// Describe flow of this in comment +// Factor anything that needs factoring +// Write tests for this function (incl. acceptance tests?) +// write tests for .get calls with null for each settingshandler? (function () { "use strict"; @@ -24,10 +29,6 @@ gradeNames: ["fluid.littleComponent", "autoInit"], invokers: { handle: { - funcName: "gpii.request.flowManager.snapshotter.onSnapshotRequest", - args: ["{that}", "{requestProxy}.events" ] - }, - getDevice: { funcName: "gpii.request.flowManager.getDevice", args: ["{flowManager}.deviceReporterDataSource", "{that}.events.onDevice"] }, @@ -37,7 +38,7 @@ }, executeSnapshot: { funcName: "gpii.request.flowManager.snapshotter.executeSnapshot", - args: ["{requestProxy}", "{arguments}.0", "{arguments}.1"] + args: ["{gpii.lifecycleManager}.snapshot", "{requestProxy}", "{arguments}.0", "{arguments}.1"] } }, events: { @@ -50,23 +51,9 @@ } }); - /** - * Called when snapshot request has been made. Fires get's on device and solution registry - * datasources. - * - */ - gpii.request.flowManager.snapshotter.onSnapshotRequest = function (that, events) { - that.getDevice(); - // events.onSuccess.fire("PLING"); - // that.withSession(function (session, tokens) { - // var token = tokens.join(","); - // fluid.log("Reporting currently logged in user(s) as: " + token); - // events.onSuccess.fire(token); - // }, "No user currently logged into the system"); - }; - + //TODO: Factor out along with snapshotters get solutions function + //TODO: Remove duplicate call to prefilterSolutions gpii.request.flowManager.snapshotter.getSolutions = function (solutionsReporterDataSource, event, model, matchMaker) { - var hello = "world"; var device = model, os = fluid.get(device, "OS.id"), version = fluid.get(device, "OS.version"); @@ -80,9 +67,18 @@ }); }; - gpii.request.flowManager.snapshotter.executeSnapshot = function (that, device, solutions) { - console.log("SO FAR SO GOD"); - that.events.onSuccess.fire(JSON.stringify(device)); + gpii.request.flowManager.snapshotter.executeSnapshot = function (snapshotter, that, solutions, device) { + snapshotter(that, solutions, device); + //TODO: + //filter out solutions based on installed solutions + //add snapshot function to the lifecycle manager + //in that function + //for each solution + //for each settingsHandler + //call get function with 'null' + //return result + // console.log("SO FAR SO GOD"); + // that.events.onSuccess.fire(JSON.stringify(device)); }; })(); diff --git a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js index 7b57f05b3..d3ed226e9 100644 --- a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js +++ b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js @@ -52,6 +52,10 @@ var gpii = fluid.registerNamespace("gpii"); funcName: "gpii.lifecycleManager.update", args: ["{that}.activeSessions", "{that}.variableResolver", "{arguments}.0", "{arguments}.1", "{arguments}.2"] + }, + snapshot: { + funcName: "gpii.lifecycleManager.snapshot", + args: ["{arguments}.0", "{arguments}.1", "{arguments}.2","{gpii.lifecycleManager}.variableResolver"] } } }); @@ -241,14 +245,14 @@ var gpii = fluid.registerNamespace("gpii"); } return togo; }; - + // Will return one of the token keys for an active session // TODO: We need to implement logic to ensure at most one of these is set, or // to manage logic for superposition of sessions if we permit several gpii.lifecycleManager.getActiveSessionTokens = function (activeSessions) { return fluid.keys(activeSessions); }; - + gpii.lifecycleManager.getSession = function (activeSessions, tokens) { if (tokens.length === 0) { fluid.fail("Attempt to get sessions without keys"); @@ -364,4 +368,60 @@ var gpii = fluid.registerNamespace("gpii"); callback(true); }; + gpii.lifecycleManager.snapshot = function (request, solutions, device, resolver, callback) { + //TODO: + + //in that function + //for each solution + //for each settingsHandler + //call get function with 'null' + //return result + var payload = {}; + fluid.each(solutions, function (solution) { + fluid.each(solution.settingsHandlers, function (handlerSpec) { + // first prepare the payload for the settingsHandler in question - + // a more efficient implementation might bulk together payloads + // destined for the same handler + handlerSpec.settings = null; + var settingsHandlerPayload = + gpii.lifecycleManager.specToSettingsHandler(solution.id, handlerSpec); + settingsHandlerPayload = resolver.resolve(settingsHandlerPayload, {}); //sessionState.localResolver(settingsHandlers); + + var type = handlerSpec.type; + type = type.substring(0, type.length-4)+".get"; + + //send the payload to the settingsHandler + var handlerResponse = fluid.invokeGlobalFunction(type, + [settingsHandlerPayload]); + payload[handlerSpec.type] = handlerResponse; + console.log(JSON.stringify(handlerResponse, null, 4)); + //build structure for returned values (for later reset) + // var togo = fluid.copy(solution); + // var expanded = resolver.resolve(settingsHandlers, {}); //sessionState.localResolver(settingsHandlers); + // togo = gpii.lifecycleManager.invokeSettingsHandlers(solutionId, expanded); + // gpii.lifecycleManager.applySolution(togo, solution, + // solution.lifecycleManager.start, sessionState); + }); + }); + console.log("SO FAR SO GOD"); + request.events.onSuccess.fire(JSON.stringify(payload, null, 4)); + }; }()); + +//handlerSpec.type: "gpii.settingsHandlers.INISettingsHandler.set" + +//{ +// "org.nvda-project": [ +// { +// "settings": { +// "speech.symbolLevel": "200", +// "virtualBuffers.autoSayAllOnPageLoad": false +// }, +// "options": { +// "path": "C:\\Users\\kasper\\AppData\\Roaming\\nvda\\nvda.ini", +// "allowNumberSignComments": true, +// "allowSubSections": true +// } +// } +// ] +// } \ No newline at end of file diff --git a/gpii/node_modules/settingsHandlers/src/js/settingsHandlerUtilities.js b/gpii/node_modules/settingsHandlers/src/js/settingsHandlerUtilities.js index ff18c0be0..12991965a 100644 --- a/gpii/node_modules/settingsHandlers/src/js/settingsHandlerUtilities.js +++ b/gpii/node_modules/settingsHandlers/src/js/settingsHandlerUtilities.js @@ -37,16 +37,39 @@ var fluid = fluid || require("infusion"), options.encoding || "utf-8"); }; +settingsHandlers.extractELPaths = function (obj) { + var extracted = {}; + + var extract = function (rt, relPath) { + fluid.each(rt, function (val, key) { + var currentPath = fluid.model.composePath(relPath, key); + if (fluid.isPrimitive(val)) { + extracted[currentPath] = val; + } else { + extract(val, currentPath); + } + }); + } + extract (obj, ""); + return extracted; +} + settingsHandlers.getSettings = function (solutionEntry, currentSettings) { var newSettingsResponse = {}; var userRequestedSettings = solutionEntry.settings; + //consider just returning currentSettings if solutionEntry.settings = null + if (userRequestedSettings === null) { + return { + settings: settingsHandlers.extractELPaths(currentSettings) + } + } + fluid.each(userRequestedSettings, function (settingVal, settingKey) { var value = fluid.get(currentSettings, settingKey, fluid.model.escapedGetConfig); newSettingsResponse[settingKey] = value; }); - return { settings: newSettingsResponse }; diff --git a/testData/deviceReporter/installedSolutions.json b/testData/deviceReporter/installedSolutions.json index f7554c68d..222e1c25b 100644 --- a/testData/deviceReporter/installedSolutions.json +++ b/testData/deviceReporter/installedSolutions.json @@ -1,141 +1,8 @@ [ - { - "id": "net.gpii.smarthouses" - }, - { - "id": "org.gnome.desktop.interface" - }, - - { - "id": "org.gnome.shell.overrides" - }, - - { - "id": "org.gnome.desktop.wm.preferences" - }, - - { - "id": "org.gnome.nautilus" - }, - - { - "id": "org.gnome.desktop.a11y.keyboard" - }, - - { - "id": "org.gnome.desktop.a11y.applications.onscreen-keyboard" - }, - - { - "id": "org.gnome.orca" - }, - - { - "id": "org.gnome.desktop.a11y.magnifier" - }, - { "id": "com.microsoft.windows.magnifier" }, - - { - "id": "com.microsoft.windows.onscreenKeyboard" - }, - { "id": "org.nvda-project" - }, - - { - "id": "org.gnome.desktop.interface" - }, - - { - "id": "org.gnome.nautilus" - }, - - { - "id": "trace.easyOne.communicator.windows" - }, - - { - "id": "trace.easyOne.communicator.linux" - }, - - { - "id": "trace.easyOne.sudan.windows" - }, - - { - "id": "trace.easyOne.sudan.linux" - }, - - { - "id": "webinsight.webAnywhere.windows" - }, - - { - "id": "webinsight.webAnywhere.linux" - }, - - { - "id": "com.texthelp.readWriteGold" - }, - - { - "id": "net.opendirective.maavis" - }, - - { - "id": "com.microsoft.windows.highContrast" - }, - - { - "id": "com.microsoft.windows.mouseTrailing" - }, - - { - "id": "com.microsoft.windows.cursors" - }, - - { - "id": "com.android.activitymanager" - }, - - { - "id": "com.android.talkback" - }, - - { - "id": "com.android.freespeech" - }, - - { - "id": "org.chrome.cloud4chrome" - }, - - { - "id": "com.android.settings.secure" - }, - - { - "id": "com.android.audioManager" - }, - - { - "id": "com.android.persistentConfiguration" - }, - - { - "id": "org.alsa-project" - }, - - { - "id": "org.freedesktop.xrandr" - }, - - { - "id": "com.android.settings.system" } - ] diff --git a/testData/solutions/win32.json b/testData/solutions/win32.json index 809583c67..6f3bcd634 100644 --- a/testData/solutions/win32.json +++ b/testData/solutions/win32.json @@ -265,7 +265,7 @@ "type": "gpii.settingsHandlers.INISettingsHandler.set", "options": { "path": "${{environment}.APPDATA}\\nvda\\nvda.ini", - "allowNumberSignComments": true, + "allowHashComments": true, "allowSubSections": true }, "capabilities": [ From e36f564b3a09a444edefa1e5d5fda20aa86f848d Mon Sep 17 00:00:00 2001 From: kaspermarkus Date: Fri, 21 Feb 2014 01:17:45 +0100 Subject: [PATCH 03/47] GPII-228: Things are working now. Requires cleanup and tests --- gpii/node_modules/flowManager/src/Snapshot.js | 46 +------ .../lifecycleManager/src/LifecycleManager.js | 70 ++++------ gpii/node_modules/matchMaker/src/MatchPost.js | 8 +- .../deviceReporter/installedSolutions.json | 82 +++++++++++- testData/solutions/win32.json | 122 +++++++++++++++++- 5 files changed, 231 insertions(+), 97 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Snapshot.js b/gpii/node_modules/flowManager/src/Snapshot.js index f9593120f..4898ee7cf 100755 --- a/gpii/node_modules/flowManager/src/Snapshot.js +++ b/gpii/node_modules/flowManager/src/Snapshot.js @@ -12,11 +12,6 @@ /*global require*/ -//OVERALL TODOS: -// Describe flow of this in comment -// Factor anything that needs factoring -// Write tests for this function (incl. acceptance tests?) -// write tests for .get calls with null for each settingshandler? (function () { "use strict"; @@ -33,12 +28,8 @@ args: ["{flowManager}.deviceReporterDataSource", "{that}.events.onDevice"] }, getSolutions: { - funcName: "gpii.request.flowManager.snapshotter.getSolutions", - args: ["{gpii.matchMaker}.solutionsReporter", "{that}.events.onSolutions", "{arguments}.0", "{gpii.matchMaker}"] - }, - executeSnapshot: { - funcName: "gpii.request.flowManager.snapshotter.executeSnapshot", - args: ["{gpii.lifecycleManager}.snapshot", "{requestProxy}", "{arguments}.0", "{arguments}.1"] + funcName: "gpii.request.matchMaker.getSolutions", + args: ["{gpii.matchMaker}", "{that}.events.onSolutions", "{arguments}.0"] } }, events: { @@ -47,38 +38,7 @@ }, listeners: { onDevice: "{that}.getSolutions", - onSolutions: "{that}.executeSnapshot" + onSolutions: "{gpii.lifecycleManager}.snapshot" } }); - - //TODO: Factor out along with snapshotters get solutions function - //TODO: Remove duplicate call to prefilterSolutions - gpii.request.flowManager.snapshotter.getSolutions = function (solutionsReporterDataSource, event, model, matchMaker) { - var device = model, - os = fluid.get(device, "OS.id"), - version = fluid.get(device, "OS.version"); - solutionsReporterDataSource.get({ - os: os, - version: version - }, function (solutions) { - matchMaker.prefilterSolutions(solutions, os, version); - solutions = matchMaker.prefilterSolutions(solutions, device); - event.fire(solutions, model); - }); - }; - - gpii.request.flowManager.snapshotter.executeSnapshot = function (snapshotter, that, solutions, device) { - snapshotter(that, solutions, device); - //TODO: - //filter out solutions based on installed solutions - //add snapshot function to the lifecycle manager - //in that function - //for each solution - //for each settingsHandler - //call get function with 'null' - //return result - // console.log("SO FAR SO GOD"); - // that.events.onSuccess.fire(JSON.stringify(device)); - }; - })(); diff --git a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js index d3ed226e9..464929b7e 100644 --- a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js +++ b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js @@ -55,7 +55,9 @@ var gpii = fluid.registerNamespace("gpii"); }, snapshot: { funcName: "gpii.lifecycleManager.snapshot", - args: ["{arguments}.0", "{arguments}.1", "{arguments}.2","{gpii.lifecycleManager}.variableResolver"] + args: ["{requestProxy}", "{gpii.lifecycleManager}.variableResolver", "{arguments}.0"] + + // args: ["{arguments}.0", "{arguments}.1", "{gpii.lifecycleManager}.variableResolver"] } } }); @@ -368,60 +370,34 @@ var gpii = fluid.registerNamespace("gpii"); callback(true); }; - gpii.lifecycleManager.snapshot = function (request, solutions, device, resolver, callback) { - //TODO: - - //in that function - //for each solution - //for each settingsHandler - //call get function with 'null' - //return result + gpii.lifecycleManager.snapshot = function (request, resolver, solutions) { var payload = {}; fluid.each(solutions, function (solution) { fluid.each(solution.settingsHandlers, function (handlerSpec) { - // first prepare the payload for the settingsHandler in question - - // a more efficient implementation might bulk together payloads - // destined for the same handler - handlerSpec.settings = null; + //if applicationSettings is unspecified, dont attempt to get settings + if (!handlerSpec.applicationSettings) + return; + + //Transform the array of settings to an object with null values + handlerSpec.settings = handlerSpec.applicationSettings; + handlerSpec = resolver.resolve(handlerSpec, {}); + var settingsHandlerPayload = gpii.lifecycleManager.specToSettingsHandler(solution.id, handlerSpec); - settingsHandlerPayload = resolver.resolve(settingsHandlerPayload, {}); //sessionState.localResolver(settingsHandlers); - var type = handlerSpec.type; - type = type.substring(0, type.length-4)+".get"; + var type = handlerSpec.type; + type = type.substring(0, type.length-4)+".get"; //send the payload to the settingsHandler - var handlerResponse = fluid.invokeGlobalFunction(type, - [settingsHandlerPayload]); - payload[handlerSpec.type] = handlerResponse; - console.log(JSON.stringify(handlerResponse, null, 4)); - //build structure for returned values (for later reset) - // var togo = fluid.copy(solution); - // var expanded = resolver.resolve(settingsHandlers, {}); //sessionState.localResolver(settingsHandlers); - // togo = gpii.lifecycleManager.invokeSettingsHandlers(solutionId, expanded); - // gpii.lifecycleManager.applySolution(togo, solution, - // solution.lifecycleManager.start, sessionState); + var handlerResponse = fluid.invokeGlobalFunction(type, [settingsHandlerPayload]); + fluid.each(handlerResponse, function (settingsEntries, solutionId) { + payload["http://registry.gpii.org/applications/"+solutionId] = [{ + "value": settingsEntries[0].settings + }]; + }); }); }); - console.log("SO FAR SO GOD"); - request.events.onSuccess.fire(JSON.stringify(payload, null, 4)); + fluid.log("Snapshotted the settings: "+JSON.stringify(payload, null, 4)); + request.events.onSuccess.fire(payload); }; -}()); - -//handlerSpec.type: "gpii.settingsHandlers.INISettingsHandler.set" - -//{ -// "org.nvda-project": [ -// { -// "settings": { -// "speech.symbolLevel": "200", -// "virtualBuffers.autoSayAllOnPageLoad": false -// }, -// "options": { -// "path": "C:\\Users\\kasper\\AppData\\Roaming\\nvda\\nvda.ini", -// "allowNumberSignComments": true, -// "allowSubSections": true -// } -// } -// ] -// } \ No newline at end of file +}()); \ No newline at end of file diff --git a/gpii/node_modules/matchMaker/src/MatchPost.js b/gpii/node_modules/matchMaker/src/MatchPost.js index a374e95f7..d2e05e421 100644 --- a/gpii/node_modules/matchMaker/src/MatchPost.js +++ b/gpii/node_modules/matchMaker/src/MatchPost.js @@ -30,15 +30,13 @@ https://github.com/gpii/universal/LICENSE.txt }); }; - request.getSolutions = function (matchMaker, event, model) { - var device = model.device, - os = fluid.get(device, "OS.id"), + request.getSolutions = function (matchMaker, event, device) { + var os = fluid.get(device, "OS.id"), version = fluid.get(device, "OS.version"); matchMaker.solutionsReporter.get({ os: os, version: version }, function (solutions) { - matchMaker.prefilterSolutions(solutions, os, version); solutions = matchMaker.prefilterSolutions(solutions, device); event.fire(solutions); }); @@ -73,7 +71,7 @@ https://github.com/gpii/universal/LICENSE.txt }, getSolutions: { funcName: "gpii.request.matchMaker.getSolutions", - args: ["{gpii.matchMaker}", "{that}.events.onSolutionsReporter", "{arguments}.0"] + args: ["{gpii.matchMaker}", "{that}.events.onSolutionsReporter", "{arguments}.0.device"] }, transformPreferences: { funcName: "gpii.request.matchMaker.transformPreferences", diff --git a/testData/deviceReporter/installedSolutions.json b/testData/deviceReporter/installedSolutions.json index 222e1c25b..457ca4bbb 100644 --- a/testData/deviceReporter/installedSolutions.json +++ b/testData/deviceReporter/installedSolutions.json @@ -1,8 +1,88 @@ [ + { + "id": "org.gnome.desktop.interface" + }, + + { + "id": "org.gnome.nautilus" + }, + + { + "id": "org.gnome.desktop.a11y.keyboard" + }, + + { + "id": "org.gnome.orca" + }, + + { + "id": "org.gnome.desktop.a11y.magnifier" + }, + { "id": "com.microsoft.windows.magnifier" }, + + { + "id": "com.microsoft.windows.onscreenKeyboard" + }, + { "id": "org.nvda-project" - } + }, + + { + "id": "org.gnome.desktop.interface" + }, + + { + "id": "org.gnome.nautilus" + }, + + { + "id": "trace.easyOne.communicator.windows" + }, + + { + "id": "trace.easyOne.communicator.linux" + }, + + { + "id": "trace.easyOne.sudan.windows" + }, + + { + "id": "trace.easyOne.sudan.linux" + }, + + { + "id": "webinsight.webAnywhere.windows" + }, + + { + "id": "webinsight.webAnywhere.linux" + }, + + { + "id": "com.texthelp.readWriteGold" + }, + + { + "id": "net.opendirective.maavis" + }, + + { + "id": "com.microsoft.windows.highContrast" + }, + + { + "id": "com.microsoft.windows.mouseTracking" + }, + + { + "id": "com.microsoft.windows.cursors" + }, + + { "id": "com.microsoft.windows.mouseTrailing" +} ] diff --git a/testData/solutions/win32.json b/testData/solutions/win32.json index 6f3bcd634..4f93bf0fb 100644 --- a/testData/solutions/win32.json +++ b/testData/solutions/win32.json @@ -112,6 +112,32 @@ "hKey": "HKEY_CURRENT_USER", "path": "Software\\Microsoft\\ScreenMagnifier" }, + "applicationSettings": { + "Magnification": { + "dataType": "REG_DWORD", + "value": null + }, + "Invert": { + "value": null, + "dataType": "REG_DWORD" + }, + "FollowFocus": { + "value": null, + "dataType": "REG_DWORD" + }, + "FollowCaret": { + "value": null, + "dataType": "REG_DWORD" + }, + "FollowMouse": { + "value": null, + "dataType": "REG_DWORD" + }, + "MagnificationMode": { + "value": null, + "dataType": "REG_DWORD" + } + }, "capabilities": [ "applications.com\\.microsoft\\.windows\\.magnifier.id", "display.screenEnhancement.screenMagnification.applications.com\\.microsoft\\.windows\\.magnifier.name" @@ -268,6 +294,24 @@ "allowHashComments": true, "allowSubSections": true }, + "applicationSettings": { + "speech.espeak.pitch": null, + "speech.espeak.volume": null, + "presentation.reportHelpBalloons": null, + "keyboard.speakTypedCharacters": null, + "keyboard.speakTypedWords": null, + "speech.espeak.sayCapForCapitals": null, + "virtualBuffers.autoSayAllOnPageLoad": null, + "reviewCursor.followFocus": null, + "reviewCursor.followCaret": null, + "reviewCursor.followMouse": null, + "speech.synth": null, + "speech.outputDevice": null, + "speech.espeak.rate": null, + "speech.espeak.rateBoost": null, + "speech.symbolLevel": null, + "speech.espeak.voice": null + }, "capabilities": [ "applications.org\\.nvda-project.id", "display.screenReader.applications.org\\.nvda-project.name" @@ -797,6 +841,12 @@ "name": "HIGHCONTRAST" } }, + "applicationSettings": { + "HighContrastOn": { + "value": null, + "path": "pvParam.dwFlags.HCF_HIGHCONTRASTON" + } + }, "capabilities": [ "display.screenEnhancement.-provisional-highContrastEnabled", "applications.com\\.microsoft\\.windows\\.highContrast.id" @@ -850,6 +900,15 @@ "type": "BOOL" } }, + "applicationSettings": { + "HighContrastOn": { + "value": null, + "path": { + "get": "pvParam", + "set": "uiParam" + } + } + }, "capabilities": [ "display.screenEnhancement.mouseTrailing", "applications.com\\.microsoft\\.windows\\.mouseTrailing.id" @@ -902,6 +961,60 @@ "hKey": "HKEY_CURRENT_USER", "path": "Control Panel\\Cursors" }, + "applicationSettings": { + "Arrow": { + "value": null, + "dataType": "REG_SZ" + }, + "Hand": { + "value": null, + "dataType": "REG_SZ" + }, + "Help": { + "value": null, + "dataType": "REG_SZ" + }, + "AppStarting": { + "value": null, + "dataType": "REG_SZ" + }, + "No": { + "value": null, + "dataType": "REG_SZ" + }, + "NWPen": { + "value": null, + "dataType": "REG_SZ" + }, + "SizeAll": { + "value": null, + "dataType": "REG_SZ" + }, + "SizeNESW": { + "value": null, + "dataType": "REG_SZ" + }, + "SizeNS": { + "value": null, + "dataType": "REG_SZ" + }, + "SizeNWSE": { + "value": null, + "dataType": "REG_SZ" + }, + "SizeWE": { + "value": null, + "dataType": "REG_SZ" + }, + "UpArrow": { + "value": null, + "dataType": "REG_SZ" + }, + "Wait": { + "value": null, + "dataType": "REG_SZ" + } + }, "capabilities": [ "display.screenEnhancement.cursorSize", "applications.com\\.microsoft\\.windows\\.cursors.id" @@ -1350,7 +1463,14 @@ "filename": "C:\\Sociable\\Configuration.xml", "encoding": "utf-8", "xml-tag": "" - + }, + "applicationSettings": { + "user.$t": null, + "expert.$t": null, + "careCenter.$t": null, + "screenReaderTTSEnabled": null, + "highContrastEnabled": null, + "fontSize": null }, "capabilities": [ "applications.eu\\.singularlogic\\.pixelsense\\.sociable.id" From 179e705a67db76138fc489eb5f2952ff04d9e96b Mon Sep 17 00:00:00 2001 From: kaspermarkus Date: Fri, 21 Feb 2014 01:29:27 +0100 Subject: [PATCH 04/47] GPII-228: Cleaned up branch --- .../src/js/settingsHandlerUtilities.js | 25 +------- .../deviceReporter/installedSolutions.json | 59 ++++++++++++++++++- 2 files changed, 57 insertions(+), 27 deletions(-) diff --git a/gpii/node_modules/settingsHandlers/src/js/settingsHandlerUtilities.js b/gpii/node_modules/settingsHandlers/src/js/settingsHandlerUtilities.js index 12991965a..ff18c0be0 100644 --- a/gpii/node_modules/settingsHandlers/src/js/settingsHandlerUtilities.js +++ b/gpii/node_modules/settingsHandlers/src/js/settingsHandlerUtilities.js @@ -37,39 +37,16 @@ var fluid = fluid || require("infusion"), options.encoding || "utf-8"); }; -settingsHandlers.extractELPaths = function (obj) { - var extracted = {}; - - var extract = function (rt, relPath) { - fluid.each(rt, function (val, key) { - var currentPath = fluid.model.composePath(relPath, key); - if (fluid.isPrimitive(val)) { - extracted[currentPath] = val; - } else { - extract(val, currentPath); - } - }); - } - extract (obj, ""); - return extracted; -} - settingsHandlers.getSettings = function (solutionEntry, currentSettings) { var newSettingsResponse = {}; var userRequestedSettings = solutionEntry.settings; - //consider just returning currentSettings if solutionEntry.settings = null - if (userRequestedSettings === null) { - return { - settings: settingsHandlers.extractELPaths(currentSettings) - } - } - fluid.each(userRequestedSettings, function (settingVal, settingKey) { var value = fluid.get(currentSettings, settingKey, fluid.model.escapedGetConfig); newSettingsResponse[settingKey] = value; }); + return { settings: newSettingsResponse }; diff --git a/testData/deviceReporter/installedSolutions.json b/testData/deviceReporter/installedSolutions.json index 457ca4bbb..f7554c68d 100644 --- a/testData/deviceReporter/installedSolutions.json +++ b/testData/deviceReporter/installedSolutions.json @@ -1,8 +1,19 @@ [ + { + "id": "net.gpii.smarthouses" + }, { "id": "org.gnome.desktop.interface" }, + { + "id": "org.gnome.shell.overrides" + }, + + { + "id": "org.gnome.desktop.wm.preferences" + }, + { "id": "org.gnome.nautilus" }, @@ -11,6 +22,10 @@ "id": "org.gnome.desktop.a11y.keyboard" }, + { + "id": "org.gnome.desktop.a11y.applications.onscreen-keyboard" + }, + { "id": "org.gnome.orca" }, @@ -76,13 +91,51 @@ }, { - "id": "com.microsoft.windows.mouseTracking" + "id": "com.microsoft.windows.mouseTrailing" }, { "id": "com.microsoft.windows.cursors" }, - { "id": "com.microsoft.windows.mouseTrailing" -} + { + "id": "com.android.activitymanager" + }, + + { + "id": "com.android.talkback" + }, + + { + "id": "com.android.freespeech" + }, + + { + "id": "org.chrome.cloud4chrome" + }, + + { + "id": "com.android.settings.secure" + }, + + { + "id": "com.android.audioManager" + }, + + { + "id": "com.android.persistentConfiguration" + }, + + { + "id": "org.alsa-project" + }, + + { + "id": "org.freedesktop.xrandr" + }, + + { + "id": "com.android.settings.system" + } + ] From eb78e331b6a2883494fc030044f8addf11066418 Mon Sep 17 00:00:00 2001 From: kaspermarkus Date: Fri, 21 Feb 2014 01:34:10 +0100 Subject: [PATCH 05/47] GPII-228: Fixed a few more errors --- gpii/node_modules/flowManager/src/Snapshot.js | 3 +-- gpii/node_modules/lifecycleManager/src/LifecycleManager.js | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Snapshot.js b/gpii/node_modules/flowManager/src/Snapshot.js index 4898ee7cf..45409f33d 100755 --- a/gpii/node_modules/flowManager/src/Snapshot.js +++ b/gpii/node_modules/flowManager/src/Snapshot.js @@ -16,8 +16,7 @@ "use strict"; - var fluid = require("infusion") - var gpii = fluid.registerNamespace("gpii"); + var fluid = require("infusion"); fluid.registerNamespace("gpii.request.flowManager.snapshotter"); fluid.defaults("kettle.requests.request.handler.snapshot", { diff --git a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js index 464929b7e..62c51393b 100644 --- a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js +++ b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js @@ -56,8 +56,7 @@ var gpii = fluid.registerNamespace("gpii"); snapshot: { funcName: "gpii.lifecycleManager.snapshot", args: ["{requestProxy}", "{gpii.lifecycleManager}.variableResolver", "{arguments}.0"] - - // args: ["{arguments}.0", "{arguments}.1", "{gpii.lifecycleManager}.variableResolver"] + //solutions } } }); @@ -378,7 +377,6 @@ var gpii = fluid.registerNamespace("gpii"); if (!handlerSpec.applicationSettings) return; - //Transform the array of settings to an object with null values handlerSpec.settings = handlerSpec.applicationSettings; handlerSpec = resolver.resolve(handlerSpec, {}); From 04f4e0a1a1ee7741fb8099ec1b57ddf6c7faba10 Mon Sep 17 00:00:00 2001 From: kaspermarkus Date: Mon, 24 Feb 2014 10:56:14 +0100 Subject: [PATCH 06/47] GPII-228: Added linux entries for snapshotting --- testData/solutions/linux.json | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/testData/solutions/linux.json b/testData/solutions/linux.json index 59228f5ef..df07df170 100644 --- a/testData/solutions/linux.json +++ b/testData/solutions/linux.json @@ -64,6 +64,12 @@ "options": { "schema": "org.gnome.desktop.a11y.magnifier" }, + "applicationSettings": { + "mag-factor": null, + "show-cross-hairs": null, + "mouse-tracking": null, + "screen-position": null + }, "capabilities": [ "applications.org\\.gnome\\.desktop\\.a11y\\.magnifier.id", "display.screenEnhancement.screenMagnification.applications.org\\.gnome\\.desktop\\.a11y\\.magnifier.name" @@ -147,6 +153,12 @@ "settingsHandlers": [ { "type": "gpii.gsettings.set", + "applicationSettings": { + "text-scaling-factor": null, + "cursor-size": null, + "gtk-theme": null, + "icon-theme": null + }, "capabilities": [ "display.screenEnhancement.applications.org\\.gnome\\.desktop\\.interface.name", "applications.org\\.gnome\\.desktop\\.interface.id" @@ -250,6 +262,9 @@ "settingsHandlers": [ { "type": "gpii.gsettings.set", + "applicationSettings": { + "font": null + }, "capabilities": [ "applications.org\\.gnome\\.nautilus.id", "display.screenEnhancement.applications.org\\.gnome\\.nautilus.name" @@ -315,6 +330,17 @@ }, "settingsHandlers": [ { "type": "gpii.gsettings.set", + "applicationSettings": { + "stickykeys-enable": null, + "slowkeys-enable": null, + "slowkeys-delay": null, + "bouncekeys-enable": null, + "bouncekeys-delay": null, + "mousekeys-enable": null, + "mousekeys-init-delay": null, + "mousekeys-max-speed": null, + "mousekeys-accel-time": null + }, "capabilities": [ "applications.org\\.gnome\\.desktop\\.a11y\\.keyboard.id", "control.onscreenKeyboard.applications.org\\.gnome\\.desktop\\.a11y\\.keyboard.name", @@ -1257,6 +1283,9 @@ "settingsHandlers": [ { "type": "gpii.alsa.set", + "applicationSettings": { + "masterVolume": null + }, "capabilities": [ "applications.org\\.alsa-project.id" ], From fa8a2fbf307bafcdec82543f552d67f33bdb284e Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Fri, 1 Jun 2018 11:38:48 -0700 Subject: [PATCH 07/47] GPII-228 Continuing cleanup and refactoring. --- .../flowManager/src/FlowManager.js | 112 +++++++++++++++++- gpii/node_modules/flowManager/src/Snapshot.js | 67 ++++------- .../lifecycleManager/src/LifecycleManager.js | 34 ------ 3 files changed, 133 insertions(+), 80 deletions(-) diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index e27d59b43..aa1f7f816 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -110,6 +110,9 @@ fluid.defaults("gpii.flowManager.local", { options: { gradeNames: ["gpii.userListeners"] } + }, + capture: { + type: "gpii.flowManager.capture" } }, requestHandlers: { @@ -135,10 +138,10 @@ fluid.defaults("gpii.flowManager.local", { method: "get", type: "gpii.flowManager.getGpiiKey.handler" }, - snapshot: { - route: "/snapshot", + capture: { + route: "/capture", method: "get", - type: "???" + type: "gpii.flowManager.capture.handler" } }, listeners: { @@ -147,6 +150,109 @@ fluid.defaults("gpii.flowManager.local", { } }); +fluid.defaults("gpii.flowManager.capture", { + gradeNames: ["fluid.component"], + events: { + onPrepareCapture: null, + onPrepareSolutions: null, + onSolutions: null, + onReadyToCapture: { + events: { + prepareCapture: "onPrepareCapture", + prepareSolutions: "onPrepareSolutions", + solutions: "onSolutions" + }, + args: [ + "{arguments}.solutions.0", + "{arguments}.prepareCapture.0" + ] + }, + onError: null + }, + listeners: { + "onPrepareCapture.deviceContext": { + funcName: "gpii.flowManager.getDeviceContext", + args: ["{flowManager}.deviceReporterDataSource", "{that}.events.onPrepareSolutions"] + }, + onPrepareSolutions: { + func: "{that}.getSolutions", + args: ["{arguments}.0"] + }, + onReadyToCapture: { + func: "{that}.captureSystemSettings", + args: ["{arguments}.0", "{arguments}.1"] + }, + onError: { + funcName: "console.log", + args: ["{arguments}.0"] + } + }, + invokers: { + getSolutions: { + funcName: "gpii.flowManager.getSolutions", + args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0", "{that}.events.onSolutions", "{that}.events.onError"] //"{request}.events.onError"] + }, + captureSystemSettings: { + funcName: "gpii.flowManager.captureSystemSettings", + args: ["{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] + } + } +}); + +/** + * Runs through all the solutions currently available on the system, pulls the current + * setting for each supportedSetting and returns them in an object. Primary use case + * is for backing Capture tools that would allow a user to set up their GPII profile + * starting with the current settings for their applications on the local machine. + * + * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications + * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. + * @param {event} event - Event to call with the payload as an argument after processing. + * @return Returns nothing. Results are fired as an argument to the `event` argument. + */ +gpii.flowManager.captureSystemSettings = function (resolver, solutions, event) { + var payload = {}; + fluid.each(solutions, function (solution, solutionID) { + fluid.each(solution.settingsHandlers, function (handlerSpec) { + //if applicationSettings is unspecified, dont attempt to get settings + if (!handlerSpec.supportedSettings) { + return; + } + + handlerSpec.settings = handlerSpec.supportedSettings; + handlerSpec = resolver.resolve(handlerSpec, {}); + + var settingsHandlerPayload = + gpii.lifecycleManager.specToSettingsHandler(solutionID, handlerSpec); + + var type = handlerSpec.type + "get"; + + //send the payload to the settingsHandler + var handlerResponse; + try { + // At the time of writing that only setting handler on windows that seemed to + // be missing their get function was `gpii.settingsHandlers.noSettings` + if (!fluid.getGlobalValue(type)) { + fluid.warn("Could not find get handler during snapshotting for: ", type); + return; + } + handlerResponse = fluid.invokeGlobalFunction(type, [settingsHandlerPayload]); + } catch (e) { + // TODO Some of the windows setting handlers seem to be throwing errors + fluid.error("Problem capturing setting: " + type); + return; + } + fluid.each(handlerResponse.value, function (settingsEntries, solutionId) { + payload["http://registry.gpii.org/applications/" + solutionId] = [{ + "value": settingsEntries[0].settings + }]; + }); + }); + }); + fluid.log("Snapshotted the settings: " + JSON.stringify(payload, null, 4)); + event.fire(payload); +}; + fluid.defaults("gpii.flowManager.save", { requestHandlers: { userSavePost: { diff --git a/gpii/node_modules/flowManager/src/Snapshot.js b/gpii/node_modules/flowManager/src/Snapshot.js index 45409f33d..5404193e5 100755 --- a/gpii/node_modules/flowManager/src/Snapshot.js +++ b/gpii/node_modules/flowManager/src/Snapshot.js @@ -1,43 +1,24 @@ -/** - * GPII snapshot Handler - * - * Copyright 2014 Raising the Floor - International - * - * Licensed under the New BSD license. You may not use this file except in - * compliance with this License. - * - * You may obtain a copy of the License at - * https://github.com/gpii/universal/LICENSE.txt - */ - - /*global require*/ - -(function () { - - "use strict"; - - var fluid = require("infusion"); - fluid.registerNamespace("gpii.request.flowManager.snapshotter"); - - fluid.defaults("kettle.requests.request.handler.snapshot", { - gradeNames: ["fluid.littleComponent", "autoInit"], - invokers: { - handle: { - funcName: "gpii.request.flowManager.getDevice", - args: ["{flowManager}.deviceReporterDataSource", "{that}.events.onDevice"] - }, - getSolutions: { - funcName: "gpii.request.matchMaker.getSolutions", - args: ["{gpii.matchMaker}", "{that}.events.onSolutions", "{arguments}.0"] - } - }, - events: { - onDevice: null, - onSolutions: null - }, - listeners: { - onDevice: "{that}.getSolutions", - onSolutions: "{gpii.lifecycleManager}.snapshot" - } - }); -})(); +/** + * GPII snapshot Handler + * + * Copyright 2014 Raising the Floor - International + * + * Licensed under the New BSD license. You may not use this file except in + * compliance with this License. + * + * You may obtain a copy of the License at + * https://github.com/gpii/universal/LICENSE.txt + */ +"use strict"; + +var fluid = require("infusion"); + +fluid.defaults("gpii.flowManager.capture.handler", { + gradeNames: ["kettle.request.http"], //, "gpii.flowManager.sessionAware"], + invokers: { + handleRequest: { + func: "{flowManager}.capture.events.onPrepareCapture.fire", + args: ["{request}.events.onSuccess", "{request}.events.onError"] + } + } +}); diff --git a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js index d0c9eb013..9fef5e28b 100644 --- a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js +++ b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js @@ -152,10 +152,6 @@ var gpii = fluid.registerNamespace("gpii"); funcName: "gpii.lifecycleManager.getSolutionRunningState", args: ["{that}", "{arguments}.0", "{arguments}.1", "{arguments}.2"] // solutionId, solution, session - snapshot: { - funcName: "gpii.lifecycleManager.snapshot", - args: ["{requestProxy}", "{gpii.lifecycleManager}.variableResolver", "{arguments}.0"] - //solutions } } }); @@ -875,34 +871,4 @@ var gpii = fluid.registerNamespace("gpii"); // via the settings handlers) return fluid.promise.sequence(tasks);; }; - - gpii.lifecycleManager.snapshot = function (request, resolver, solutions) { - var payload = {}; - fluid.each(solutions, function (solution) { - fluid.each(solution.settingsHandlers, function (handlerSpec) { - //if applicationSettings is unspecified, dont attempt to get settings - if (!handlerSpec.applicationSettings) - return; - - handlerSpec.settings = handlerSpec.applicationSettings; - handlerSpec = resolver.resolve(handlerSpec, {}); - - var settingsHandlerPayload = - gpii.lifecycleManager.specToSettingsHandler(solution.id, handlerSpec); - - var type = handlerSpec.type; - type = type.substring(0, type.length-4)+".get"; - - //send the payload to the settingsHandler - var handlerResponse = fluid.invokeGlobalFunction(type, [settingsHandlerPayload]); - fluid.each(handlerResponse, function (settingsEntries, solutionId) { - payload["http://registry.gpii.org/applications/"+solutionId] = [{ - "value": settingsEntries[0].settings - }]; - }); - }); - }); - fluid.log("Snapshotted the settings: "+JSON.stringify(payload, null, 4)); - request.events.onSuccess.fire(payload); - }; })(); From 526d545c673dd581db66fb9b8f37c0f28a0094bf Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Fri, 1 Jun 2018 11:41:11 -0700 Subject: [PATCH 08/47] GPII-228 Renaming snapshot to capture. --- gpii/node_modules/flowManager/src/{Snapshot.js => Capture.js} | 0 gpii/node_modules/flowManager/src/FlowManager.js | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename gpii/node_modules/flowManager/src/{Snapshot.js => Capture.js} (100%) diff --git a/gpii/node_modules/flowManager/src/Snapshot.js b/gpii/node_modules/flowManager/src/Capture.js similarity index 100% rename from gpii/node_modules/flowManager/src/Snapshot.js rename to gpii/node_modules/flowManager/src/Capture.js diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index aa1f7f816..27dff4e4b 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -31,7 +31,7 @@ require("./UntrustedSettingsGetHandler.js"); require("./UntrustedSettingsPutHandler.js"); require("./UntrustedSettingsDataSource.js"); require("./UntrustedFlowManager.js"); -require("./Snapshot.js"); +require("./Capture.js"); require("preferencesServer"); require("lifecycleManager"); From 4516c892e21d05e166c93c3600fb96b0b59ab7be Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Mon, 4 Jun 2018 14:01:23 -0700 Subject: [PATCH 09/47] GPII-228 Finished with first iteration of snapshotter revival - Next step will be to fix issues with the SPI Settings Handlers, and then finish revising the payload that will need to be returned. --- .../flowManager/src/FlowManager.js | 49 +++++++------------ .../settingsHandlers/src/NoSettingsHandler.js | 1 + 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index 27dff4e4b..8462e1b28 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -194,11 +194,12 @@ fluid.defaults("gpii.flowManager.capture", { }, captureSystemSettings: { funcName: "gpii.flowManager.captureSystemSettings", - args: ["{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] + args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] } } }); + /** * Runs through all the solutions currently available on the system, pulls the current * setting for each supportedSetting and returns them in an object. Primary use case @@ -210,10 +211,11 @@ fluid.defaults("gpii.flowManager.capture", { * @param {event} event - Event to call with the payload as an argument after processing. * @return Returns nothing. Results are fired as an argument to the `event` argument. */ -gpii.flowManager.captureSystemSettings = function (resolver, solutions, event) { - var payload = {}; +gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, event) { + var handlerGetPromises = []; fluid.each(solutions, function (solution, solutionID) { - fluid.each(solution.settingsHandlers, function (handlerSpec) { + var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); + fluid.each(newSolution.settingsHandlers, function (handlerSpec) { //if applicationSettings is unspecified, dont attempt to get settings if (!handlerSpec.supportedSettings) { return; @@ -221,36 +223,19 @@ gpii.flowManager.captureSystemSettings = function (resolver, solutions, event) { handlerSpec.settings = handlerSpec.supportedSettings; handlerSpec = resolver.resolve(handlerSpec, {}); - - var settingsHandlerPayload = - gpii.lifecycleManager.specToSettingsHandler(solutionID, handlerSpec); - - var type = handlerSpec.type + "get"; - - //send the payload to the settingsHandler - var handlerResponse; - try { - // At the time of writing that only setting handler on windows that seemed to - // be missing their get function was `gpii.settingsHandlers.noSettings` - if (!fluid.getGlobalValue(type)) { - fluid.warn("Could not find get handler during snapshotting for: ", type); - return; - } - handlerResponse = fluid.invokeGlobalFunction(type, [settingsHandlerPayload]); - } catch (e) { - // TODO Some of the windows setting handlers seem to be throwing errors - fluid.error("Problem capturing setting: " + type); - return; - } - fluid.each(handlerResponse.value, function (settingsEntries, solutionId) { - payload["http://registry.gpii.org/applications/" + solutionId] = [{ - "value": settingsEntries[0].settings - }]; - }); + handlerGetPromises.push(invokeSettingsHandlerGet(solutionID, handlerSpec)); }); }); - fluid.log("Snapshotted the settings: " + JSON.stringify(payload, null, 4)); - event.fire(payload); + var promisesSequence = fluid.promise.sequence(handlerGetPromises); + promisesSequence.then(function (responses) { + console.log("Sequence Ok"); + // TODO Assemble a better looking payload to send back once we finish + // working through the Windows SPI Settings Handler Issues + event.fire(responses); + }, function (responses) { + console.log("Sequence Not Great"); + event.fire(responses); + }); }; fluid.defaults("gpii.flowManager.save", { diff --git a/gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js b/gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js index f4b6f279c..feda0b2a4 100644 --- a/gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js +++ b/gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js @@ -21,4 +21,5 @@ var fluid = require("infusion"), settingsHandlers.noSettings = fluid.identity; settingsHandlers.noSettings.set = fluid.identity; +settingsHandlers.noSettings.get = fluid.identity; From 1764ef9f9aef5686645b0ee1dffbb838a5f0751c Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Mon, 4 Jun 2018 14:21:06 -0700 Subject: [PATCH 10/47] GPII-228 Removign some spaces that got removed. --- gpii/node_modules/lifecycleManager/src/LifecycleManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js index 9fef5e28b..e3261f3bd 100644 --- a/gpii/node_modules/lifecycleManager/src/LifecycleManager.js +++ b/gpii/node_modules/lifecycleManager/src/LifecycleManager.js @@ -871,4 +871,5 @@ var gpii = fluid.registerNamespace("gpii"); // via the settings handlers) return fluid.promise.sequence(tasks);; }; + })(); From 1c05b525f36dc460eea6a410b7ebb72be2f966f5 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Mon, 31 Dec 2018 15:16:35 -0800 Subject: [PATCH 11/47] GPII-228 Updating location of getDeviceContext --- gpii/node_modules/flowManager/src/FlowManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index 1d99f7cd6..3f3b2e1be 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -350,7 +350,7 @@ fluid.defaults("gpii.flowManager.capture", { }, listeners: { "onPrepareCapture.deviceContext": { - funcName: "gpii.flowManager.getDeviceContext", + funcName: "gpii.lifecycleManager.getDeviceContext", args: ["{flowManager}.deviceReporterDataSource", "{that}.events.onPrepareSolutions"] }, onPrepareSolutions: { From 29a27083b2e4999d396d03e1d75552e1a5b0565c Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Tue, 15 Jan 2019 14:29:07 -0800 Subject: [PATCH 12/47] GPII-228 Another round of Capture/Snapshotting prototyping --- gpii/node_modules/flowManager/src/Capture.js | 184 +++++++++++++++++- .../flowManager/src/FlowManager.js | 87 --------- .../flowManager/src/MatchMaking.js | 15 ++ .../src/UserLogonStateChange.js | 23 +++ 4 files changed, 221 insertions(+), 88 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 5404193e5..299837ba2 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -11,7 +11,8 @@ */ "use strict"; -var fluid = require("infusion"); +var fluid = require("infusion"), + gpii = fluid.registerNamespace("gpii"); fluid.defaults("gpii.flowManager.capture.handler", { gradeNames: ["kettle.request.http"], //, "gpii.flowManager.sessionAware"], @@ -19,6 +20,187 @@ fluid.defaults("gpii.flowManager.capture.handler", { handleRequest: { func: "{flowManager}.capture.events.onPrepareCapture.fire", args: ["{request}.events.onSuccess", "{request}.events.onError"] + + // funcName: "gpii.flowManager.captureHandler", + // args: ["{flowManager}", "{request}.events.onSuccess", "{request}.events.onError"] } } }); + +gpii.flowManager.captureHandler = function (flowManager, onSuccess, onError) { + flowManager.capture.getInstalledSolutions().then(onSuccess.fire, onError.fire); +}; + +fluid.defaults("gpii.flowManager.capture", { + gradeNames: ["fluid.component"], + events: { + onPrepareCapture: null, + onPrepareSolutions: null, + onSolutions: null, + onReadyToCapture: { + events: { + prepareCapture: "onPrepareCapture", + prepareSolutions: "onPrepareSolutions", + solutions: "onSolutions" + }, + args: [ + "{arguments}.solutions.0", + "{arguments}.prepareCapture.0" + ] + }, + onError: null, + + // Newer versions below using fireTransformEvent + onSolutionsForCurrentDevice: null, + onCaptureSettingsForCurrentDevice: null + }, + listeners: { + onSolutionsForCurrentDevice: [ + { + funcName: "gpii.lifecycleManager.getDeviceContextPromise", + args: ["{flowManager}.deviceReporterDataSource"] + }, + { + funcName: "gpii.flowManager.getSolutionsPromise", + args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"] + } + ], + onCaptureSettingsForCurrentDevice: [ + { + funcName: "gpii.lifecycleManager.getDeviceContextPromise", + args: ["{flowManager}.deviceReporterDataSource"] + }, + { + funcName: "gpii.flowManager.getSolutionsPromise", + args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"] + }, + { + func: "{that}.captureSystemSettingsPromise", + args: ["{arguments}.0", "{arguments}.1"] + } + ], + + + "onPrepareCapture.deviceContext": { + funcName: "gpii.lifecycleManager.getDeviceContext", + args: ["{flowManager}.deviceReporterDataSource", "{that}.events.onPrepareSolutions"] + }, + onPrepareSolutions: { + func: "{that}.getSolutions", + args: ["{arguments}.0"] + }, + onReadyToCapture: { + func: "{that}.captureSystemSettings", + args: ["{arguments}.0", "{arguments}.1"] + }, + onError: { + funcName: "console.log", + args: ["{arguments}.0"] + } + }, + invokers: { + getSolutions: { + funcName: "gpii.flowManager.getSolutions", + args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0", "{that}.events.onSolutions", "{that}.events.onError"] //"{request}.events.onError"] + }, + captureSystemSettings: { + funcName: "gpii.flowManager.captureSystemSettings", + args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] + }, + + getInstalledSolutions: { + funcName: "gpii.flowManager.getInstalledSolutions", + args: ["{that}"] + }, + getSystemSettingsCapture: { + funcName: "gpii.flowManager.getSystemSettingsCapture", + args: ["{that}", "{arguments}.0"] // Options + }, + captureSystemSettingsPromise: { + funcName: "gpii.flowManager.captureSystemSettings", + args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", + "{arguments}.0", "{arguments}.1"] + } + } +}); + + +gpii.flowManager.getInstalledSolutions = function (that) { + return fluid.promise.fireTransformEvent(that.events.onSolutionsForCurrentDevice); +}; + +/** + * Options: solutionsList - Optional list of solutions to filter by + */ +gpii.flowManager.getSystemSettingsCapture = function (that, options) { + return fluid.promise.fireTransformEvent(that.events.onCaptureSettingsForCurrentDevice, + {}, options); +}; + +/** + * Runs through all the solutions currently available on the system, pulls the current + * setting for each supportedSetting and returns them in an object. Primary use case + * is for backing Capture tools that would allow a user to set up their GPII profile + * starting with the current settings for their applications on the local machine. + * + * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications + * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. + * @param {event} event - Event to call with the payload as an argument after processing. + * @return Returns nothing. Results are fired as an argument to the `event` argument. + */ +gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, options) { + var promiseTogo = fluid.promise(); + + var handlerGetPromises = []; + + var safeHandlerGet = function (invokeSettingsHandlerGet, solutionID, handlerSpec) { + var promiseTogo = fluid.promise(); + try { + invokeSettingsHandlerGet(solutionID, handlerSpec).then(function (data) { + promiseTogo.resolve(data); + }, function (err) { + console.log("Error issuging invokeSettingsHandlerGET: ", err); + promiseTogo.resolve({}); + }); + } + catch(error) { + console.log("Very bad error: ", error); + promiseTogo.resolve({}); + } + return promiseTogo; + }; + + var solutionsToFetch = solutions; + if (options.solutionsList) { + solutionsToFetch = {}; + fluid.each(solutions, function (solution, solutionID) { + if (options.solutionsList.indexOf(solutionID) >= 0) { + solutionsToFetch[solutionID] = solution; + } + }); + } + fluid.each(solutionsToFetch, function (solution, solutionID) { + var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); + fluid.each(newSolution.settingsHandlers, function (handlerSpec) { + //if applicationSettings is unspecified, dont attempt to get settings + if (!handlerSpec.supportedSettings) { + return; + } + + handlerSpec.settings = handlerSpec.supportedSettings; + handlerSpec = resolver.resolve(handlerSpec, {}); + // handlerGetPromises.push(invokeSettingsHandlerGet(solutionID, handlerSpec)); + handlerGetPromises.push(safeHandlerGet(invokeSettingsHandlerGet, solutionID, handlerSpec)); + }); + }); + var promisesSequence = fluid.promise.sequence(handlerGetPromises); + promisesSequence.then(function (responses) { + // TODO Assemble a better looking payload to send back once we finish + // working through the Windows SPI Settings Handler Issues + promiseTogo.resolve(responses); + }, function (responses) { + promiseTogo.resolve(responses); + }); + + return promiseTogo; +}; \ No newline at end of file diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index 3f3b2e1be..4c9f8288c 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -328,90 +328,3 @@ gpii.flowManager.local.savePreferences = function (that, gpiiKey, preferences) { that.events.preferencesSavedSuccess.fire(); } }; - -fluid.defaults("gpii.flowManager.capture", { - gradeNames: ["fluid.component"], - events: { - onPrepareCapture: null, - onPrepareSolutions: null, - onSolutions: null, - onReadyToCapture: { - events: { - prepareCapture: "onPrepareCapture", - prepareSolutions: "onPrepareSolutions", - solutions: "onSolutions" - }, - args: [ - "{arguments}.solutions.0", - "{arguments}.prepareCapture.0" - ] - }, - onError: null - }, - listeners: { - "onPrepareCapture.deviceContext": { - funcName: "gpii.lifecycleManager.getDeviceContext", - args: ["{flowManager}.deviceReporterDataSource", "{that}.events.onPrepareSolutions"] - }, - onPrepareSolutions: { - func: "{that}.getSolutions", - args: ["{arguments}.0"] - }, - onReadyToCapture: { - func: "{that}.captureSystemSettings", - args: ["{arguments}.0", "{arguments}.1"] - }, - onError: { - funcName: "console.log", - args: ["{arguments}.0"] - } - }, - invokers: { - getSolutions: { - funcName: "gpii.flowManager.getSolutions", - args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0", "{that}.events.onSolutions", "{that}.events.onError"] //"{request}.events.onError"] - }, - captureSystemSettings: { - funcName: "gpii.flowManager.captureSystemSettings", - args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] - } - } -}); - -/** - * Runs through all the solutions currently available on the system, pulls the current - * setting for each supportedSetting and returns them in an object. Primary use case - * is for backing Capture tools that would allow a user to set up their GPII profile - * starting with the current settings for their applications on the local machine. - * - * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications - * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. - * @param {event} event - Event to call with the payload as an argument after processing. - * @return Returns nothing. Results are fired as an argument to the `event` argument. - */ -gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, event) { - var handlerGetPromises = []; - fluid.each(solutions, function (solution, solutionID) { - var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); - fluid.each(newSolution.settingsHandlers, function (handlerSpec) { - //if applicationSettings is unspecified, dont attempt to get settings - if (!handlerSpec.supportedSettings) { - return; - } - - handlerSpec.settings = handlerSpec.supportedSettings; - handlerSpec = resolver.resolve(handlerSpec, {}); - handlerGetPromises.push(invokeSettingsHandlerGet(solutionID, handlerSpec)); - }); - }); - var promisesSequence = fluid.promise.sequence(handlerGetPromises); - promisesSequence.then(function (responses) { - console.log("Sequence Ok"); - // TODO Assemble a better looking payload to send back once we finish - // working through the Windows SPI Settings Handler Issues - event.fire(responses); - }, function (responses) { - console.log("Sequence Not Great"); - event.fire(responses); - }); -}; \ No newline at end of file diff --git a/gpii/node_modules/flowManager/src/MatchMaking.js b/gpii/node_modules/flowManager/src/MatchMaking.js index 641e9d847..cb0ec762f 100644 --- a/gpii/node_modules/flowManager/src/MatchMaking.js +++ b/gpii/node_modules/flowManager/src/MatchMaking.js @@ -96,6 +96,21 @@ }, onError.fire); }; + gpii.flowManager.getSolutionsPromise = function (solutionsRegistryDataSource, deviceContext) { + var promiseTogo = fluid.promise(); + + var os = fluid.get(deviceContext, "OS.id"); + var promise = solutionsRegistryDataSource.get({}); + promise.then(function (solutions) { + var solutionsRegistryEntries = gpii.matchMakerFramework.filterSolutions(solutions[os], deviceContext); + fluid.log("Fetched filtered solutions registry entries: ", gpii.renderMegapayload({solutionsRegistryEntries: solutionsRegistryEntries})); + // event.fire(solutionsRegistryEntries, solutions); + promiseTogo.resolve(solutionsRegistryEntries); + }, promiseTogo.reject); + + return promiseTogo; + }; + // initialPayload contains fields // gpiiKey, preferences, deviceContext, solutionsRegistryEntry // resulting from the initial fetch process diff --git a/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js b/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js index 77f58136b..e14b01d8e 100644 --- a/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js +++ b/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js @@ -169,6 +169,29 @@ gpii.lifecycleManager.getDeviceContext = function (deviceReporterDataSource, eve }); }; +gpii.lifecycleManager.getDeviceContextPromise = function (deviceReporterDataSource) { + var promiseTogo = fluid.promise(); + + var promise = deviceReporterDataSource.get(); + promise.then(function (deviceData) { + gpii.logFully("getDeviceContext got deviceData ", deviceData); + if (!deviceData) { + promiseTogo.reject({message: "Device reporter returned `undefined`." }); + } else if (deviceData.isError) { + promiseTogo.reject({message: "Error in device reporter data: " + deviceData.message}); + } else { + promiseTogo.resolve(deviceData); + } + }, function (err) { + var error = fluid.extend(err, { + message: "Rejected deviceReporter promise: " + err.message + }); + promiseTogo.reject(error); + }); + + return promiseTogo; +}; + // A mixin grade for a matchMakingRequest request handler, supporting local user logon fluid.defaults("gpii.lifecycleManager.userLogonHandling.stateChangeHandler", { invokers: { From eba8606477989f9295cd54a0e72123e43b59116f Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Fri, 19 Apr 2019 11:29:08 -0700 Subject: [PATCH 13/47] GPII-228 Reverting to current version of NoSettingsHandler --- gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js b/gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js index 05431fe6c..b396dd31b 100644 --- a/gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js +++ b/gpii/node_modules/settingsHandlers/src/NoSettingsHandler.js @@ -21,11 +21,6 @@ var fluid = require("infusion"), fluid.registerNamespace("gpii.settingsHandlers.noSettings"); -// sgithens These identity's I believe are no longer necessary with the new work in master. -// settingsHandlers.noSettings = fluid.identity; -// settingsHandlers.noSettings.set = fluid.identity; -// settingsHandlers.noSettings.get = fluid.identity; - // Get/Set settings handlers for "gpii.settingsHandlers.noSettings" gpii.settingsHandlers.noSettingsGet = function () { return function (payload) { From 179c7e1dcf459c12ba2ad44fea03bc402661d98b Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Fri, 19 Apr 2019 11:47:31 -0700 Subject: [PATCH 14/47] GPII-228 Removing http handler endpoints for capturing. --- gpii/node_modules/flowManager/src/Capture.js | 23 +++---------------- .../flowManager/src/FlowManager.js | 5 ---- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 299837ba2..a56b122d5 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -14,23 +14,6 @@ var fluid = require("infusion"), gpii = fluid.registerNamespace("gpii"); -fluid.defaults("gpii.flowManager.capture.handler", { - gradeNames: ["kettle.request.http"], //, "gpii.flowManager.sessionAware"], - invokers: { - handleRequest: { - func: "{flowManager}.capture.events.onPrepareCapture.fire", - args: ["{request}.events.onSuccess", "{request}.events.onError"] - - // funcName: "gpii.flowManager.captureHandler", - // args: ["{flowManager}", "{request}.events.onSuccess", "{request}.events.onError"] - } - } -}); - -gpii.flowManager.captureHandler = function (flowManager, onSuccess, onError) { - flowManager.capture.getInstalledSolutions().then(onSuccess.fire, onError.fire); -}; - fluid.defaults("gpii.flowManager.capture", { gradeNames: ["fluid.component"], events: { @@ -118,7 +101,7 @@ fluid.defaults("gpii.flowManager.capture", { }, captureSystemSettingsPromise: { funcName: "gpii.flowManager.captureSystemSettings", - args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", + args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] } } @@ -163,7 +146,7 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res promiseTogo.resolve({}); }); } - catch(error) { + catch (error) { console.log("Very bad error: ", error); promiseTogo.resolve({}); } @@ -203,4 +186,4 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res }); return promiseTogo; -}; \ No newline at end of file +}; diff --git a/gpii/node_modules/flowManager/src/FlowManager.js b/gpii/node_modules/flowManager/src/FlowManager.js index b78529ea6..69a832b64 100644 --- a/gpii/node_modules/flowManager/src/FlowManager.js +++ b/gpii/node_modules/flowManager/src/FlowManager.js @@ -193,11 +193,6 @@ fluid.defaults("gpii.flowManager.local", { } }, requestHandlers: { - capture: { - route: "/capture", - method: "get", - type: "gpii.flowManager.capture.handler" - }, browserChannel: { route: "/browserChannel", type: "gpii.flowManager.browserChannel.handler" From b94f13753f62547c7acb2ead1067523ed5685e83 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Tue, 7 May 2019 14:51:31 -0700 Subject: [PATCH 15/47] GPII-228 Minor refactorings and initial tests. --- .../flowManager/test/CaptureTests.js | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 gpii/node_modules/flowManager/test/CaptureTests.js diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js new file mode 100644 index 000000000..41eed4126 --- /dev/null +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -0,0 +1,49 @@ +/** + * GPII Untrusted Settings Data Source Tests + * + * Copyright 2019 Raising the Floor - International + * + * Licensed under the New BSD license. You may not use this file except in + * compliance with this License. + * + * You may obtain a copy of the License at + * https://github.com/GPII/universal/blob/master/LICENSE.txt + */ + +"use strict"; + +var fluid = require("infusion"), + gpii = fluid.registerNamespace("gpii"); + +var jqUnit = require("node-jqunit"); + +fluid.require("%gpii-universal"); +gpii.loadTestingSupport(); + +fluid.registerNamespace("gpii.tests.flowManager.capture"); + +gpii.tests.flowManager.capture.testDefs = [{ + name: "My first capture test", + config: { + configName: "gpii.config.development.local", + configPath: "%gpii-universal/gpii/configs/shared" + }, + sequence: [{ + task: "gpii.tests.flowManager.capture.systemSettingsPromise", + args: ["{gpii.flowManager.capture}"], + resolve: "jqUnit.assertDeepEq", + // TODO Create a few tests with configs that include existing settings, for mock + // installed solutions to test this more realistically. + resolveArgs: ["The current capture on these configs is empty", [], "{arguments}.0"] + }] +}]; + +gpii.tests.flowManager.capture.systemSettingsPromise = function(capture) { + // TODO: figure out the proper way to inject the capture component in to these tests. + // The injected copy is undefined, I *think* because it's being wired up between test runs, + // and the tree is torn down and up between each test... + capture = fluid.queryIoCSelector(fluid.rootComponent, "gpii.flowManager.capture")[0]; + return capture.getSystemSettingsCapture(); +}; + +gpii.test.runCouchTestDefs(gpii.tests.flowManager.capture.testDefs); From c727f64c7eebd13016f0190be82477b64d5d7fbb Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Tue, 7 May 2019 14:55:29 -0700 Subject: [PATCH 16/47] GPII-228 Refactoring event->promise based methods needed for capture --- .../flowManager/src/MatchMaking.js | 12 ++++------- .../src/UserLogonStateChange.js | 20 ++++--------------- tests/all-tests.js | 1 + 3 files changed, 9 insertions(+), 24 deletions(-) diff --git a/gpii/node_modules/flowManager/src/MatchMaking.js b/gpii/node_modules/flowManager/src/MatchMaking.js index 46936f5ff..d84f993af 100644 --- a/gpii/node_modules/flowManager/src/MatchMaking.js +++ b/gpii/node_modules/flowManager/src/MatchMaking.js @@ -92,13 +92,10 @@ * is fired with the modified mmpayload. */ gpii.flowManager.getSolutions = function (solutionsRegistryDataSource, deviceContext, event, onError) { - var os = fluid.get(deviceContext, "OS.id"); - var promise = solutionsRegistryDataSource.get({}); - promise.then(function (solutions) { - var solutionsRegistryEntries = gpii.matchMakerFramework.filterSolutions(solutions[os], deviceContext); - fluid.log("Fetched filtered solutions registry entries: ", gpii.renderMegapayload({solutionsRegistryEntries: solutionsRegistryEntries})); - event.fire(solutionsRegistryEntries, solutions); - }, onError.fire); + gpii.flowManager.getSolutionsPromise(solutionsRegistryDataSource, deviceContext).then( + event.fire, + onError.fire + ); }; gpii.flowManager.getSolutionsPromise = function (solutionsRegistryDataSource, deviceContext) { @@ -109,7 +106,6 @@ promise.then(function (solutions) { var solutionsRegistryEntries = gpii.matchMakerFramework.filterSolutions(solutions[os], deviceContext); fluid.log("Fetched filtered solutions registry entries: ", gpii.renderMegapayload({solutionsRegistryEntries: solutionsRegistryEntries})); - // event.fire(solutionsRegistryEntries, solutions); promiseTogo.resolve(solutionsRegistryEntries); }, promiseTogo.reject); diff --git a/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js b/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js index b0d28cd30..2c20df841 100644 --- a/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js +++ b/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js @@ -150,22 +150,10 @@ gpii.lifecycleManager.userLogonHandling.loginUser = function (that, lifecycleMan }; gpii.lifecycleManager.getDeviceContext = function (deviceReporterDataSource, event, errorEvent) { - var promise = deviceReporterDataSource.get(); - promise.then(function (deviceData) { - gpii.logFully("getDeviceContext got deviceData ", deviceData); - if (!deviceData) { - errorEvent.fire({message: "Device reporter returned `undefined`." }); - } else if (deviceData.isError) { - errorEvent.fire({message: "Error in device reporter data: " + deviceData.message}); - } else { - event.fire(deviceData); - } - }, function (err) { - var error = fluid.extend(err, { - message: "Rejected deviceReporter promise: " + err.message - }); - errorEvent.fire(error); - }); + gpii.lifecycleManager.getDeviceContextPromise(deviceReporterDataSource).then( + event.fire, + errorEvent.fire + ); }; gpii.lifecycleManager.getDeviceContextPromise = function (deviceReporterDataSource) { diff --git a/tests/all-tests.js b/tests/all-tests.js index 8a6d9a4c4..89288bae6 100644 --- a/tests/all-tests.js +++ b/tests/all-tests.js @@ -62,6 +62,7 @@ var testIncludes = [ "../gpii/node_modules/eventLog/test/all-tests.js", "../gpii/node_modules/flatMatchMaker/test/FlatMatchMakerTests.js", "../gpii/node_modules/flowManager/test/BrowserChannelTests.js", + "../gpii/node_modules/flowManager/test/CaptureTests.js", "../gpii/node_modules/flowManager/test/DefaultSettingsLoaderTests.js", "../gpii/node_modules/flowManager/test/PrefsServerDataSourceTests.js", "../gpii/node_modules/flowManager/test/PSPChannelTests.js", From db831bb3cf03692f538a9b5bf53714b7fa65992c Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Wed, 26 Jun 2019 11:22:00 -0700 Subject: [PATCH 17/47] GPII-228 Minor change to promise/event signature to match previous args --- gpii/node_modules/flowManager/src/MatchMaking.js | 9 +++++++-- tests/all-tests.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gpii/node_modules/flowManager/src/MatchMaking.js b/gpii/node_modules/flowManager/src/MatchMaking.js index d84f993af..23e2fcb3c 100644 --- a/gpii/node_modules/flowManager/src/MatchMaking.js +++ b/gpii/node_modules/flowManager/src/MatchMaking.js @@ -93,7 +93,9 @@ */ gpii.flowManager.getSolutions = function (solutionsRegistryDataSource, deviceContext, event, onError) { gpii.flowManager.getSolutionsPromise(solutionsRegistryDataSource, deviceContext).then( - event.fire, + function (data) { + event.fire(data.solutionsRegistryEntries, data.solutions); + }, onError.fire ); }; @@ -106,7 +108,10 @@ promise.then(function (solutions) { var solutionsRegistryEntries = gpii.matchMakerFramework.filterSolutions(solutions[os], deviceContext); fluid.log("Fetched filtered solutions registry entries: ", gpii.renderMegapayload({solutionsRegistryEntries: solutionsRegistryEntries})); - promiseTogo.resolve(solutionsRegistryEntries); + promiseTogo.resolve({ + solutionsRegistryEntries: solutionsRegistryEntries, + solutions: solutions + }); }, promiseTogo.reject); return promiseTogo; diff --git a/tests/all-tests.js b/tests/all-tests.js index b75f941bb..754d0d446 100644 --- a/tests/all-tests.js +++ b/tests/all-tests.js @@ -63,7 +63,7 @@ var testIncludes = [ "../gpii/node_modules/eventLog/test/all-tests.js", "../gpii/node_modules/flatMatchMaker/test/FlatMatchMakerTests.js", "../gpii/node_modules/flowManager/test/BrowserChannelTests.js", - "../gpii/node_modules/flowManager/test/CaptureTests.js", + // "../gpii/node_modules/flowManager/test/CaptureTests.js", "../gpii/node_modules/flowManager/test/DefaultSettingsLoaderTests.js", "../gpii/node_modules/flowManager/test/PrefsServerDataSourceTests.js", "../gpii/node_modules/flowManager/test/PSPChannelTests.js", From f484faf27be2026843b8d14611f2c40ee682e5e9 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Tue, 9 Jul 2019 18:03:49 -0700 Subject: [PATCH 18/47] GPII-228 Initial unit tests, some cleanup --- gpii/node_modules/flowManager/src/Capture.js | 17 ++-- .../flowManager/test/CaptureTests.js | 83 +++++++++++++------ ...pii.flowManager.tests.capture.config.json5 | 4 + ...anager.tests.capture.fakeData.config.json5 | 18 ++++ .../test/data/capture_fakemag2_settings.json | 4 + testData/solutions/darwin.json5 | 51 ++++++++++++ 6 files changed, 146 insertions(+), 31 deletions(-) create mode 100644 gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.config.json5 create mode 100644 gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 create mode 100644 gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 43304e51b..c27cbaca2 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -41,29 +41,35 @@ fluid.defaults("gpii.flowManager.capture", { onSolutionsForCurrentDevice: [ { funcName: "gpii.lifecycleManager.getDeviceContextPromise", - args: ["{flowManager}.deviceReporterDataSource"] + args: ["{flowManager}.deviceReporter"] }, { funcName: "gpii.flowManager.getSolutionsPromise", args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"] + }, + { + funcName: "fluid.toPromise", + args: ["{arguments}.0.solutionsRegistryEntries"] } ], onCaptureSettingsForCurrentDevice: [ { funcName: "gpii.lifecycleManager.getDeviceContextPromise", - args: ["{flowManager}.deviceReporterDataSource"] + args: ["{flowManager}.deviceReporter"] }, { funcName: "gpii.flowManager.getSolutionsPromise", args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"] }, + { + funcName: "fluid.toPromise", + args: ["{arguments}.0.solutionsRegistryEntries"] + }, { func: "{that}.captureSystemSettingsPromise", args: ["{arguments}.0", "{arguments}.1"] } ], - - "onPrepareCapture.deviceContext": { funcName: "gpii.lifecycleManager.getDeviceContext", args: ["{flowManager}.deviceReporter", "{that}.events.onPrepareSolutions"] @@ -142,12 +148,10 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res invokeSettingsHandlerGet(solutionID, handlerSpec).then(function (data) { promiseTogo.resolve(data); }, function (err) { - console.log("Error issuging invokeSettingsHandlerGET: ", err); promiseTogo.resolve({}); }); } catch (error) { - console.log("Very bad error: ", error); promiseTogo.resolve({}); } return promiseTogo; @@ -169,7 +173,6 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res if (!handlerSpec.supportedSettings) { return; } - handlerSpec.settings = handlerSpec.supportedSettings; handlerSpec = resolver.resolve(handlerSpec, {}); // handlerGetPromises.push(invokeSettingsHandlerGet(solutionID, handlerSpec)); diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index 41eed4126..b2e9d8533 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -13,7 +13,8 @@ "use strict"; var fluid = require("infusion"), - gpii = fluid.registerNamespace("gpii"); + gpii = fluid.registerNamespace("gpii"), + kettle = require("kettle"); var jqUnit = require("node-jqunit"); @@ -22,28 +23,62 @@ gpii.loadTestingSupport(); fluid.registerNamespace("gpii.tests.flowManager.capture"); -gpii.tests.flowManager.capture.testDefs = [{ - name: "My first capture test", - config: { - configName: "gpii.config.development.local", - configPath: "%gpii-universal/gpii/configs/shared" - }, - sequence: [{ - task: "gpii.tests.flowManager.capture.systemSettingsPromise", - args: ["{gpii.flowManager.capture}"], - resolve: "jqUnit.assertDeepEq", - // TODO Create a few tests with configs that include existing settings, for mock - // installed solutions to test this more realistically. - resolveArgs: ["The current capture on these configs is empty", [], "{arguments}.0"] - }] -}]; - -gpii.tests.flowManager.capture.systemSettingsPromise = function(capture) { - // TODO: figure out the proper way to inject the capture component in to these tests. - // The injected copy is undefined, I *think* because it's being wired up between test runs, - // and the tree is torn down and up between each test... - capture = fluid.queryIoCSelector(fluid.rootComponent, "gpii.flowManager.capture")[0]; - return capture.getSystemSettingsCapture(); +kettle.config.createDefaults({ + configName: "gpii.flowManager.tests.capture.fakeData.config", + configPath: "%gpii-universal/gpii/node_modules/flowManager/test/configs" +}); + +fluid.defaults("gpii.tests.flowManager.capture.tests", { + gradeNames: ["fluid.test.testEnvironment", "fluid.test.testCaseHolder"], + modules: [ + { + name: "Simple system capture", + tests: [{ + name: "Check for existing FakeMag2 Settings", + expect: 1, + sequence: [{ + funcName: "gpii.tests.flowManager.capture.adjustSolutions", + args: ["{config}.server.flowManager.solutionsRegistryDataSource"] + }, { + task: "{config}.server.flowManager.capture.getSystemSettingsCapture", + args: [], + resolve: "gpii.tests.flowManager.capture.checkForFakeMag2", + resolveArgs: ["{arguments}.0"] + }] + }] + } + ], + components: { + "config": { + type: "gpii.flowManager.tests.capture.fakeData.config" + } + } +}); + +gpii.tests.flowManager.capture.checkForFakeMag2 = function (payload) { + // TODO add tests for solutions with multiple capabilities blocks. At the moment I believe they are all + // going to end up in separate blocks. + fluid.each(payload, function (item) { + if (item.fakemag2) { + jqUnit.assertDeepEq("FakeMag2", { + "fakemag2": [ + { + "settings": { + "magnification": 2, + "invert": true + } + } + ] + }, item); + } + }); +}; + +gpii.tests.flowManager.capture.adjustSolutions = function (solutionsRegistryDataSource) { + var testDataFile = __dirname + "/data/capture_fakemag2_settings.json"; + solutionsRegistryDataSource.fullSolutionsRegistry.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile; }; -gpii.test.runCouchTestDefs(gpii.tests.flowManager.capture.testDefs); +fluid.test.runTests([ + "gpii.tests.flowManager.capture.tests" +]); diff --git a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.config.json5 b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.config.json5 new file mode 100644 index 000000000..a7f97811e --- /dev/null +++ b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.config.json5 @@ -0,0 +1,4 @@ +{ + "type": "gpii.flowManager.tests.capture.config", + "mergeConfigs": "%gpii-universal/gpii/configs/shared/gpii.config.untrusted.development.json5" +} diff --git a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 new file mode 100644 index 000000000..c0fb3cea7 --- /dev/null +++ b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 @@ -0,0 +1,18 @@ +{ + "type": "gpii.flowManager.tests.capture.fakeData.config", + // "options": { + // "distributeOptions": { + // "multiSH.deviceReporter": { + // "record": "%gpii-universal/tests/data/multiSHDeviceReporter.json", + // "target": "{that deviceReporter installedSolutionsDataSource}.options.path", + // "priority": "after:development.installedSolutionsPath" + // }, + // "multiSH.solutionsRegistry": { + // "record": "%gpii-universal/tests/data/multiSHsolutionsRegistry.json", + // "target": "{that flowManager solutionsRegistryDataSource}.options.path", + // "priority": "after:flowManager.solutions" + // } + // } + // }, + "mergeConfigs": "%gpii-universal/gpii/configs/shared/gpii.config.untrusted.development.json5" +} diff --git a/gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json b/gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json new file mode 100644 index 000000000..5b2a4985b --- /dev/null +++ b/gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json @@ -0,0 +1,4 @@ +{ + "invert": true, + "magnification": 2.0 +} diff --git a/testData/solutions/darwin.json5 b/testData/solutions/darwin.json5 index 97aa912c4..3e124df1b 100644 --- a/testData/solutions/darwin.json5 +++ b/testData/solutions/darwin.json5 @@ -20,6 +20,16 @@ }, "capabilitiesTransformations": { "magnification": "http://registry\\.gpii\\.net/common/magnification" + }, + "supportedSettings": { + "magnification": { + schema: { + title: "Magnification Level", + description: "How many times to magnify content when magnification is enabled.", + type: "number", + default: 1.10 + } + } } } }, @@ -60,6 +70,23 @@ "capabilitiesTransformations": { "magnification": "http://registry\\.gpii\\.net/common/magnification", "invert": "http://registry\\.gpii\\.net/common/invertColours" + }, + "supportedSettings": { + "magnification": { + "schema": { + "title": "Magnification Level", + "description": "How many times to magnify content when magnification is enabled.", + "type": "number", + "default": 1.10 + } + }, + "invert": { + "schema": { + "title": "Invert Colours", + "description": "Enable colour inversion for Magnifier", + "type": "boolean" + } + } } } }, @@ -101,6 +128,30 @@ "pitch": "http://registry\\.gpii\\.net/common/pitch", "volumeTTS": "http://registry\\.gpii\\.net/common/volumeTTS", "rate": "http://registry\\.gpii\\.net/common/speechRate" + }, + "supportedSettings": { + "pitch": { + "schema": { + "title": "Speech Pitch", + "description": "The pitch at which text is announced.", + "minimum": 0, + "maximum": 20 + } + }, + "volumeTTS": { + "schema": { + "title": "Volume TTS", + "description": "Volume TTS", + "type": "integer" + } + }, + "rate": { + "schema": { + "title": "Rate", + "description": "Speech rate for all announcements (scale varies by voice).", + "type": "integer" + } + } } } }, From b79d476651921ae11832d696b9eba027529add07 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Tue, 9 Jul 2019 18:06:38 -0700 Subject: [PATCH 19/47] GPII-228 Adding Capture Tests back in --- tests/all-tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/all-tests.js b/tests/all-tests.js index 754d0d446..b75f941bb 100644 --- a/tests/all-tests.js +++ b/tests/all-tests.js @@ -63,7 +63,7 @@ var testIncludes = [ "../gpii/node_modules/eventLog/test/all-tests.js", "../gpii/node_modules/flatMatchMaker/test/FlatMatchMakerTests.js", "../gpii/node_modules/flowManager/test/BrowserChannelTests.js", - // "../gpii/node_modules/flowManager/test/CaptureTests.js", + "../gpii/node_modules/flowManager/test/CaptureTests.js", "../gpii/node_modules/flowManager/test/DefaultSettingsLoaderTests.js", "../gpii/node_modules/flowManager/test/PrefsServerDataSourceTests.js", "../gpii/node_modules/flowManager/test/PSPChannelTests.js", From 38bea00a202cfd1b86b6db23b172962ed2dc6d20 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Sun, 14 Jul 2019 08:45:03 -0700 Subject: [PATCH 20/47] GPII-228 Continuing impl work --- gpii/node_modules/flowManager/src/Capture.js | 58 ++++++++++++++++---- 1 file changed, 48 insertions(+), 10 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index c27cbaca2..80a45ba53 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -96,14 +96,13 @@ fluid.defaults("gpii.flowManager.capture", { funcName: "gpii.flowManager.captureSystemSettings", args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] }, - getInstalledSolutions: { funcName: "gpii.flowManager.getInstalledSolutions", args: ["{that}"] }, getSystemSettingsCapture: { funcName: "gpii.flowManager.getSystemSettingsCapture", - args: ["{that}", "{arguments}.0"] // Options + args: ["{that}.events.onCaptureSettingsForCurrentDevice", "{arguments}.0"] // Options }, captureSystemSettingsPromise: { funcName: "gpii.flowManager.captureSystemSettings", @@ -119,23 +118,34 @@ gpii.flowManager.getInstalledSolutions = function (that) { }; /** - * Options: solutionsList - Optional list of solutions to filter by + * This main API entry point for capturing settings from a system or computer. This captures + * the actual settings on the device, so it assumed to be running in a local untrusted flow + * manager. + * + * @param {Event} onCaptureSettingsForCurrentDevice - The transforming promise chain + * @param {Object} options - Options for this chain. + * @param {Array} options.solutionsList - An array of solution IDs to filter by when + * retreiving settings. If this option is not included, all available settings will be + * returned. ex: `["com.microsoft.windows.mouseSettings", "com.freedomscientific.jaws"]`. + * @return {Promise} A promise resolved with the payload of captured system settings. */ -gpii.flowManager.getSystemSettingsCapture = function (that, options) { - return fluid.promise.fireTransformEvent(that.events.onCaptureSettingsForCurrentDevice, +gpii.flowManager.getSystemSettingsCapture = function (onCaptureSettingsForCurrentDevice, options) { + return fluid.promise.fireTransformEvent(onCaptureSettingsForCurrentDevice, {}, options); }; -/** +/* * Runs through all the solutions currently available on the system, pulls the current * setting for each supportedSetting and returns them in an object. Primary use case * is for backing Capture tools that would allow a user to set up their GPII profile * starting with the current settings for their applications on the local machine. * + * TODO update jsdoc with super detailed param info + * * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. * @param {event} event - Event to call with the payload as an argument after processing. - * @return Returns nothing. Results are fired as an argument to the `event` argument. + * @return {undefined} Returns nothing. Results are fired as an argument to the `event` argument. */ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, options) { var promiseTogo = fluid.promise(); @@ -148,11 +158,23 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res invokeSettingsHandlerGet(solutionID, handlerSpec).then(function (data) { promiseTogo.resolve(data); }, function (err) { - promiseTogo.resolve({}); + promiseTogo.resolve({ + solutionId: solutionID, + handlerSpec: handlerSpec, + isError: true, + message: "inner promise error", + err: err + }); }); } - catch (error) { - promiseTogo.resolve({}); + catch (err) { + promiseTogo.resolve({ + solutionId: solutionID, + handlerSpec: handlerSpec, + isError: true, + message: "outer try error", + err: err + }); } return promiseTogo; }; @@ -174,6 +196,22 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res return; } handlerSpec.settings = handlerSpec.supportedSettings; + // TODO GPII-228 This is temporary debugging code while we work through + // the processing that is missing from this chain that transforms the paths + // in capabilitiesTransforms to the schema information needed for the settings + // handler + if (handlerSpec.type === "gpii.windows.spiSettingsHandler") { + fluid.each(handlerSpec.settings, function (handler, handlerKey) { + if (handlerSpec.capabilitiesTransformations[handlerKey].path.transform) { + handlerSpec.settings[handlerKey].path = + handlerSpec.capabilitiesTransformations[handlerKey].path.transform.input; + }; + if (handlerSpec.capabilitiesTransformations[handlerKey].path.literalValue) { + handlerSpec.settings[handlerKey].path = + handlerSpec.capabilitiesTransformations[handlerKey].path.literalValue; + }; + }); + } handlerSpec = resolver.resolve(handlerSpec, {}); // handlerGetPromises.push(invokeSettingsHandlerGet(solutionID, handlerSpec)); handlerGetPromises.push(safeHandlerGet(invokeSettingsHandlerGet, solutionID, handlerSpec)); From eb54bb82355258594197f558f760c94f2d128929 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Thu, 15 Aug 2019 10:24:56 -0700 Subject: [PATCH 21/47] GPII-228 Tests/impl for solutions with multiple settings handlers --- gpii/node_modules/flowManager/src/Capture.js | 61 ++++++++- .../flowManager/test/CaptureTests.js | 40 +++--- ...anager.tests.capture.fakeData.config.json5 | 28 ++-- .../test/data/capture_deviceReporter.json | 8 ++ ...ngs.json => capture_fakemag_settings.json} | 0 .../test/data/capture_solutionsRegistry.json | 129 ++++++++++++++++++ 6 files changed, 227 insertions(+), 39 deletions(-) create mode 100644 gpii/node_modules/flowManager/test/data/capture_deviceReporter.json rename gpii/node_modules/flowManager/test/data/{capture_fakemag2_settings.json => capture_fakemag_settings.json} (100%) create mode 100644 gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 80a45ba53..a20406075 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -188,6 +188,7 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res } }); } + fluid.each(solutionsToFetch, function (solution, solutionID) { var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); fluid.each(newSolution.settingsHandlers, function (handlerSpec) { @@ -213,15 +214,67 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res }); } handlerSpec = resolver.resolve(handlerSpec, {}); - // handlerGetPromises.push(invokeSettingsHandlerGet(solutionID, handlerSpec)); handlerGetPromises.push(safeHandlerGet(invokeSettingsHandlerGet, solutionID, handlerSpec)); }); }); var promisesSequence = fluid.promise.sequence(handlerGetPromises); promisesSequence.then(function (responses) { - // TODO Assemble a better looking payload to send back once we finish - // working through the Windows SPI Settings Handler Issues - promiseTogo.resolve(responses); + // The return payload from the promise sequence looks like: + // [ + // { + // "fakemag1": [ + // { + // "settings": { + // "magnification": 2 + // } + // } + // ] + // }, + // { + // "fakemag1": [ + // { + // "settings": { + // "invert": true + // } + // } + // ] + // }, + // { + // "fakemag2": [ + // { + // "settings": { + // "magnification": 2, + // "invert": true + // } + // } + // ] + // } + // ] + // + // and we want: + // + // { + // "fakemag1": { + // "magnification": 2, + // "invert": true + // }, + // "fakemag2": { + // "magnification": 2, + // "invert": true + // } + // } + var finalPayload = {}; + fluid.each(responses, function (sequenceItem) { + fluid.each(sequenceItem, function (item, key) { + if (!finalPayload[key]) { + finalPayload[key] = {}; + } + fluid.each(item[0].settings, function (value, settingId) { + finalPayload[key][settingId] = value; + }); + }); + }); + promiseTogo.resolve(finalPayload); }, function (responses) { promiseTogo.resolve(responses); }); diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index b2e9d8533..22f85b611 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -1,5 +1,5 @@ /** - * GPII Untrusted Settings Data Source Tests + * GPII Capture Tests * * Copyright 2019 Raising the Floor - International * @@ -34,15 +34,15 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { { name: "Simple system capture", tests: [{ - name: "Check for existing FakeMag2 Settings", - expect: 1, + name: "Check for existing FakeMag Settings", + expect: 2, sequence: [{ funcName: "gpii.tests.flowManager.capture.adjustSolutions", args: ["{config}.server.flowManager.solutionsRegistryDataSource"] }, { task: "{config}.server.flowManager.capture.getSystemSettingsCapture", args: [], - resolve: "gpii.tests.flowManager.capture.checkForFakeMag2", + resolve: "gpii.tests.flowManager.capture.checkForFakeMags", resolveArgs: ["{arguments}.0"] }] }] @@ -55,28 +55,26 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { } }); -gpii.tests.flowManager.capture.checkForFakeMag2 = function (payload) { - // TODO add tests for solutions with multiple capabilities blocks. At the moment I believe they are all - // going to end up in separate blocks. - fluid.each(payload, function (item) { - if (item.fakemag2) { - jqUnit.assertDeepEq("FakeMag2", { - "fakemag2": [ - { - "settings": { - "magnification": 2, - "invert": true - } - } - ] - }, item); - } +gpii.tests.flowManager.capture.checkForFakeMags = function (payload) { + + jqUnit.assertDeepEq("FakeMag1 with multiple settings handlers", payload.fakemag1, { + "magnification": 2, + "invert": true + }); + + jqUnit.assertDeepEq("FakeMag2 with single settings handler", payload.fakemag2, { + "magnification": 2, + "invert": true }); + }; gpii.tests.flowManager.capture.adjustSolutions = function (solutionsRegistryDataSource) { - var testDataFile = __dirname + "/data/capture_fakemag2_settings.json"; + var testDataFile = __dirname + "/data/capture_fakemag_settings.json"; + solutionsRegistryDataSource.fullSolutionsRegistry.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile; + solutionsRegistryDataSource.fullSolutionsRegistry.darwin.fakemag1.settingsHandlers.configuration.options.filename = testDataFile; + solutionsRegistryDataSource.fullSolutionsRegistry.darwin.fakemag1.settingsHandlers.configuration1.options.filename = testDataFile; }; fluid.test.runTests([ diff --git a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 index c0fb3cea7..f77878c0a 100644 --- a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 +++ b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 @@ -1,18 +1,18 @@ { "type": "gpii.flowManager.tests.capture.fakeData.config", - // "options": { - // "distributeOptions": { - // "multiSH.deviceReporter": { - // "record": "%gpii-universal/tests/data/multiSHDeviceReporter.json", - // "target": "{that deviceReporter installedSolutionsDataSource}.options.path", - // "priority": "after:development.installedSolutionsPath" - // }, - // "multiSH.solutionsRegistry": { - // "record": "%gpii-universal/tests/data/multiSHsolutionsRegistry.json", - // "target": "{that flowManager solutionsRegistryDataSource}.options.path", - // "priority": "after:flowManager.solutions" - // } - // } - // }, + "options": { + "distributeOptions": { + "capture.deviceReporter": { + "record": "%gpii-universal/gpii/node_modules/flowManager/test/data/capture_deviceReporter.json", + "target": "{that deviceReporter installedSolutionsDataSource}.options.path", + "priority": "after:development.installedSolutionsPath" + }, + "capture.solutionsRegistry": { + "record": "%gpii-universal/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json", + "target": "{that flowManager solutionsRegistryDataSource}.options.path", + "priority": "after:flowManager.solutions" + } + } + }, "mergeConfigs": "%gpii-universal/gpii/configs/shared/gpii.config.untrusted.development.json5" } diff --git a/gpii/node_modules/flowManager/test/data/capture_deviceReporter.json b/gpii/node_modules/flowManager/test/data/capture_deviceReporter.json new file mode 100644 index 000000000..eb53914cb --- /dev/null +++ b/gpii/node_modules/flowManager/test/data/capture_deviceReporter.json @@ -0,0 +1,8 @@ +[ + { + "id": "fakemag1" + }, + { + "id": "fakemag2" + } +] diff --git a/gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json b/gpii/node_modules/flowManager/test/data/capture_fakemag_settings.json similarity index 100% rename from gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json rename to gpii/node_modules/flowManager/test/data/capture_fakemag_settings.json diff --git a/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json b/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json new file mode 100644 index 000000000..6e2db46da --- /dev/null +++ b/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json @@ -0,0 +1,129 @@ +{ + "darwin": { + "fakemag1": { + "name": "Fake Magnifier 1", + "contexts": { + "OS": [ + { + "id": "darwin" + } + ] + }, + "capabilities": [ + "http://registry\\.gpii\\.net/common/magnification/enabled" + ], + "settingsHandlers": { + "configuration": { + "type": "gpii.settingsHandlers.JSONSettingsHandler", + "liveness": "live", + "options": { + "filename": "/tmp/fakemag2.settings.json" + }, + "capabilitiesTransformations": { + "magnification": "http://registry\\.gpii\\.net/common/magnification" + }, + "supportedSettings": { + "magnification": { + "schema": { + "title": "Magnification Level", + "description": "How many times to magnify content when magnification is enabled.", + "type": "number", + "default": 1.10 + } + } + } + }, + "configuration1": { + "type": "gpii.settingsHandlers.JSONSettingsHandler", + "liveness": "live", + "options": { + "filename": "/tmp/fakemag2.settings.json" + }, + "capabilitiesTransformations": { + "invert": "http://registry\\.gpii\\.net/common/invertColours" + }, + "supportedSettings": { + "invert": { + "schema": { + "title": "Invert Colours", + "description": "Enable colour inversion for Magnifier", + "type": "boolean" + } + } + } + } + }, + "configure": [ + "settings.configuration", + "settings.configuration1" + ], + "restore": [ + "settings.configuration", + "settings.configuration1" + ], + "start": [], + "stop": [], + "isInstalled": [ + { + "type": "gpii.deviceReporter.alwaysInstalled" + } + ] + }, + "fakemag2": { + "name": "Fake Magnifier 2 - fully featured", + "contexts": { + "OS": [ + { + "id": "darwin" + } + ] + }, + "capabilities": [ + "http://registry\\.gpii\\.net/common/magnification/enabled" + ], + "settingsHandlers": { + "configuration": { + "type": "gpii.settingsHandlers.JSONSettingsHandler", + "liveness": "live", + "options": { + "filename": "/tmp/fakemag2.settings.json" + }, + "capabilitiesTransformations": { + "magnification": "http://registry\\.gpii\\.net/common/magnification", + "invert": "http://registry\\.gpii\\.net/common/invertColours" + }, + "supportedSettings": { + "magnification": { + "schema": { + "title": "Magnification Level", + "description": "How many times to magnify content when magnification is enabled.", + "type": "number", + "default": 1.10 + } + }, + "invert": { + "schema": { + "title": "Invert Colours", + "description": "Enable colour inversion for Magnifier", + "type": "boolean" + } + } + } + } + }, + "configure": [ + "settings.configuration" + ], + "restore": [ + "settings.configuration" + ], + "start": [ ], + "stop": [ ], + "isInstalled": [ + { + "type": "gpii.deviceReporter.alwaysInstalled" + } + ] + } + } +} From f562fe8e5355fe05b9be39a54f68f06ee20b2e89 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Wed, 25 Sep 2019 19:31:34 -0700 Subject: [PATCH 22/47] GPII-228 Removing duplicate sequences from installed solutions events. --- gpii/node_modules/flowManager/src/Capture.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index a20406075..a37445f6a 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -54,16 +54,7 @@ fluid.defaults("gpii.flowManager.capture", { ], onCaptureSettingsForCurrentDevice: [ { - funcName: "gpii.lifecycleManager.getDeviceContextPromise", - args: ["{flowManager}.deviceReporter"] - }, - { - funcName: "gpii.flowManager.getSolutionsPromise", - args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"] - }, - { - funcName: "fluid.toPromise", - args: ["{arguments}.0.solutionsRegistryEntries"] + func: "{that}.getInstalledSolutions" }, { func: "{that}.captureSystemSettingsPromise", From 17ce607907f7896a3751f91a0b5569056d5dedc3 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Wed, 25 Sep 2019 19:59:13 -0700 Subject: [PATCH 23/47] GPII-228 Added test for capture.getInstalledSolutions --- .../flowManager/test/CaptureTests.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index 22f85b611..ea37e6160 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -46,6 +46,22 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { resolveArgs: ["{arguments}.0"] }] }] + }, + { + name: "Simple installed solutions fetch", + tests: [{ + name: "Testing get installed solutions", + expect: 3, + sequence: [{ + funcName: "gpii.tests.flowManager.capture.adjustSolutions", + args: ["{config}.server.flowManager.solutionsRegistryDataSource"] + }, { + task: "{config}.server.flowManager.capture.getInstalledSolutions", + args: [], + resolve: "gpii.tests.flowManager.capture.checkForInstalledMags", + resolveArgs: ["{arguments}.0"] + }] + }] } ], components: { @@ -69,6 +85,12 @@ gpii.tests.flowManager.capture.checkForFakeMags = function (payload) { }; +gpii.tests.flowManager.capture.checkForInstalledMags = function (payload) { + jqUnit.assertEquals("There should be 2 solutions installed", Object.keys(payload).length, 2); + jqUnit.assertEquals("Check for Fake Mag 1", payload.fakemag1.name, "Fake Magnifier 1"); + jqUnit.assertEquals("Check for Fake Mag 2", payload.fakemag2.name, "Fake Magnifier 2 - fully featured"); +}; + gpii.tests.flowManager.capture.adjustSolutions = function (solutionsRegistryDataSource) { var testDataFile = __dirname + "/data/capture_fakemag_settings.json"; From ec7cb2facfd3f8068a3fc92a4698eb1d903f752f Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Wed, 25 Sep 2019 20:09:43 -0700 Subject: [PATCH 24/47] GPII-228 Removing event based capture in favor of promise based API --- gpii/node_modules/flowManager/src/Capture.js | 43 +------------------- 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index a37445f6a..863da3933 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -17,23 +17,6 @@ var fluid = require("infusion"), fluid.defaults("gpii.flowManager.capture", { gradeNames: ["fluid.component"], events: { - onPrepareCapture: null, - onPrepareSolutions: null, - onSolutions: null, - onReadyToCapture: { - events: { - prepareCapture: "onPrepareCapture", - prepareSolutions: "onPrepareSolutions", - solutions: "onSolutions" - }, - args: [ - "{arguments}.solutions.0", - "{arguments}.prepareCapture.0" - ] - }, - onError: null, - - // Newer versions below using fireTransformEvent onSolutionsForCurrentDevice: null, onCaptureSettingsForCurrentDevice: null }, @@ -60,33 +43,9 @@ fluid.defaults("gpii.flowManager.capture", { func: "{that}.captureSystemSettingsPromise", args: ["{arguments}.0", "{arguments}.1"] } - ], - "onPrepareCapture.deviceContext": { - funcName: "gpii.lifecycleManager.getDeviceContext", - args: ["{flowManager}.deviceReporter", "{that}.events.onPrepareSolutions"] - }, - onPrepareSolutions: { - func: "{that}.getSolutions", - args: ["{arguments}.0"] - }, - onReadyToCapture: { - func: "{that}.captureSystemSettings", - args: ["{arguments}.0", "{arguments}.1"] - }, - onError: { - funcName: "console.log", - args: ["{arguments}.0"] - } + ] }, invokers: { - getSolutions: { - funcName: "gpii.flowManager.getSolutions", - args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0", "{that}.events.onSolutions", "{that}.events.onError"] //"{request}.events.onError"] - }, - captureSystemSettings: { - funcName: "gpii.flowManager.captureSystemSettings", - args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] - }, getInstalledSolutions: { funcName: "gpii.flowManager.getInstalledSolutions", args: ["{that}"] From f32a13dff9b1e5d1bece8caf11a764580a03d165 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Thu, 26 Sep 2019 14:05:02 -0700 Subject: [PATCH 25/47] GPII-228 Fixing up jsdoc on captureSystemSettings --- gpii/node_modules/flowManager/src/Capture.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 863da3933..2dc23d945 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -90,12 +90,18 @@ gpii.flowManager.getSystemSettingsCapture = function (onCaptureSettingsForCurren * is for backing Capture tools that would allow a user to set up their GPII profile * starting with the current settings for their applications on the local machine. * - * TODO update jsdoc with super detailed param info - * + * @param {lifecycleManager.invokeSettingsHandlerGet} invokeSettingsHandlerGet - Invoker from the `lifecycleManager` + * necessary for extracting settings from a solution and it's spec. * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. - * @param {event} event - Event to call with the payload as an argument after processing. - * @return {undefined} Returns nothing. Results are fired as an argument to the `event` argument. + * @param {Object} options - Extra options for processing. + * @param {Array} options.solutionsList - If provided, only solutions in this list of `solutionsID`s will + * be captures. Example: + * + * '''json + * ["com.microsoft.windows.cursors", "com.freedomscientific.jaws"] + * ''' + * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. */ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, options) { var promiseTogo = fluid.promise(); From e15f44d4eb0f2da0f9e1410852317557d83b1c28 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Thu, 26 Sep 2019 14:13:36 -0700 Subject: [PATCH 26/47] GPII-228 Simplifying invoker name. --- gpii/node_modules/flowManager/src/Capture.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 2dc23d945..fa9be4af3 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -40,7 +40,7 @@ fluid.defaults("gpii.flowManager.capture", { func: "{that}.getInstalledSolutions" }, { - func: "{that}.captureSystemSettingsPromise", + func: "{that}.captureSystemSettings", args: ["{arguments}.0", "{arguments}.1"] } ] @@ -54,7 +54,7 @@ fluid.defaults("gpii.flowManager.capture", { funcName: "gpii.flowManager.getSystemSettingsCapture", args: ["{that}.events.onCaptureSettingsForCurrentDevice", "{arguments}.0"] // Options }, - captureSystemSettingsPromise: { + captureSystemSettings: { funcName: "gpii.flowManager.captureSystemSettings", args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", "{arguments}.0", "{arguments}.1"] From 1b636f76877274a3c9d6aaf303821640e31494b7 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Wed, 2 Oct 2019 14:05:01 -0700 Subject: [PATCH 27/47] GPII-4146 GPII-228 Adding adjustments for capturing from JAWS default voice profiles. --- gpii/node_modules/flowManager/src/Capture.js | 71 +++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index fa9be4af3..f005dae35 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -11,7 +11,8 @@ */ "use strict"; -var fluid = require("infusion"), +var fs = require("fs"), + fluid = require("infusion"), gpii = fluid.registerNamespace("gpii"); fluid.defaults("gpii.flowManager.capture", { @@ -57,7 +58,7 @@ fluid.defaults("gpii.flowManager.capture", { captureSystemSettings: { funcName: "gpii.flowManager.captureSystemSettings", args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", - "{arguments}.0", "{arguments}.1"] + "{lifecycleManager}.userSession.localResolver", "{arguments}.0", "{arguments}.1"] } } }); @@ -93,6 +94,8 @@ gpii.flowManager.getSystemSettingsCapture = function (onCaptureSettingsForCurren * @param {lifecycleManager.invokeSettingsHandlerGet} invokeSettingsHandlerGet - Invoker from the `lifecycleManager` * necessary for extracting settings from a solution and it's spec. * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications + * @param {lifecycleManager.userSession.localResolver} localResolver - Resolver for expanding configuration file paths + * from the solutions registry. * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. * @param {Object} options - Extra options for processing. * @param {Array} options.solutionsList - If provided, only solutions in this list of `solutionsID`s will @@ -103,7 +106,7 @@ gpii.flowManager.getSystemSettingsCapture = function (onCaptureSettingsForCurren * ''' * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. */ -gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, options) { +gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, localResolver, solutions, options) { var promiseTogo = fluid.promise(); var handlerGetPromises = []; @@ -147,6 +150,11 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res fluid.each(solutionsToFetch, function (solution, solutionID) { var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); + + if (solutionID === "com.freedomscientific.jaws") { + newSolution = gpii.flowManager.jawsVoiceProfileAdjustment(newSolution, localResolver); + } + fluid.each(newSolution.settingsHandlers, function (handlerSpec) { //if applicationSettings is unspecified, dont attempt to get settings if (!handlerSpec.supportedSettings) { @@ -237,3 +245,60 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res return promiseTogo; }; + +/** + * JAWS Voice Profile Adjustment GPII-4146 + * + * When applying settings to a machine we create our own Voice Profile to use, which is + * hardcoded in the solutions registry as `GPII`. However, when capturing JAWS settings + * we want to use whatever the default voice profile is, if there is one. More so, if there + * is not a default voice profile, or a factory default is in use, we want to ignore the + * voice profile configuration. + * + * Note: While the JAWS solution entry is fairly stable, if there are changes to the settings + * configuration names, this will need to be updated. + * + * @param {Object} handlerSpec - The solutions registry entry for JAWS + * @param {Function} localResolver - The localResolver, usually from the `userSession` on the + * `lifecycleManager` to resolve the INI configuration paths where JAWS stores it's settings. + * @return {Object} Returns a new handlerSpec with the configurations adjusted depending on the + * current default voice profile on the system. This is a deep copy of `handlerSpec` the original + * is not modified. + */ +gpii.flowManager.jawsVoiceProfileAdjustment = function (handlerSpec, localResolver) { + var togo = fluid.copy(handlerSpec); + + // Configuration1 contains the path to the default settings stored in INI format + var defaultJCFpath = localResolver(handlerSpec.settingsHandlers.configuration1.options.filename); + var defaultJAWsSettings = gpii.iniFile.readFile(defaultJCFpath, {}); + + // It's possible to not have a current voice profile set in DEFAULT.JCF + // In the DEFAULT.JCF file it is stored here: + // ```ini + // [Voice Profiles] + // ActiveVoiceProfileName=GPII + // ``` + var currentVoiceProfile = false; + if (defaultJAWsSettings["Voice Profiles"] && defaultJAWsSettings["Voice Profiles"].ActiveVoiceProfileName) { + currentVoiceProfile = defaultJAWsSettings["Voice Profiles"].ActiveVoiceProfileName; + } + + // Again this will need to be updated in sync with JAWS support. As of now, we don't store this path by itself in the + // solution entry. + var voiceProfilesDir = localResolver("${{environment}.APPDATA}\\Freedom Scientific\\JAWS\\2019\\Settings\\VoiceProfiles\\"); + var voiceProfilesPath = voiceProfilesDir + currentVoiceProfile + ".VPF"; + var voiceProfileExists = fs.existsSync(voiceProfilesPath); + + if (!voiceProfileExists) { + // If the voice profile does not exist delete the second configuration from the + // handlerSpec. The INI settings handler will fail for both configurations if the + // file is missing. + delete togo.settingsHandlers.configuration2; + } + else { + // Otherwise update the .VPC ini configuration with the voice profile path + togo.settingsHandlers.configuration2.options.filename = voiceProfilesPath; + } + + return togo; +}; From edd516040abf1f6bba9f1d21794c03457d8e095e Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Wed, 9 Oct 2019 13:00:00 -0700 Subject: [PATCH 28/47] GPII-228 Adding checks and unit tests for error payload that may be in capture return sequence. --- gpii/node_modules/flowManager/src/Capture.js | 129 ++++++++++-------- .../flowManager/test/CaptureTests.js | 100 ++++++++++++++ 2 files changed, 174 insertions(+), 55 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index f005dae35..8c59d32dc 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -183,61 +183,8 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res }); var promisesSequence = fluid.promise.sequence(handlerGetPromises); promisesSequence.then(function (responses) { - // The return payload from the promise sequence looks like: - // [ - // { - // "fakemag1": [ - // { - // "settings": { - // "magnification": 2 - // } - // } - // ] - // }, - // { - // "fakemag1": [ - // { - // "settings": { - // "invert": true - // } - // } - // ] - // }, - // { - // "fakemag2": [ - // { - // "settings": { - // "magnification": 2, - // "invert": true - // } - // } - // ] - // } - // ] - // - // and we want: - // - // { - // "fakemag1": { - // "magnification": 2, - // "invert": true - // }, - // "fakemag2": { - // "magnification": 2, - // "invert": true - // } - // } - var finalPayload = {}; - fluid.each(responses, function (sequenceItem) { - fluid.each(sequenceItem, function (item, key) { - if (!finalPayload[key]) { - finalPayload[key] = {}; - } - fluid.each(item[0].settings, function (value, settingId) { - finalPayload[key][settingId] = value; - }); - }); - }); + + var finalPayload = gpii.flowManager.formatRawCapturedSettings(responses); promiseTogo.resolve(finalPayload); }, function (responses) { promiseTogo.resolve(responses); @@ -246,6 +193,78 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res return promiseTogo; }; +/** + * The raw return payload from the capture promise sequence looks like: + * '''json + * [ + * { + * "fakemag1": [ + * { + * "settings": { + * "magnification": 2 + * } + * } + * ] + * }, + * { + * "fakemag1": [ + * { + * "settings": { + * "invert": true + * } + * } + * ] + * }, + * { + * "fakemag2": [ + * { + * "settings": { + * "magnification": 2, + * "invert": true + * } + * } + * ] + * } + * ] + * ''' + * + * and we want: + * '''json + * { + * "fakemag1": { + * "magnification": 2, + * "invert": true + * }, + * "fakemag2": { + * "magnification": 2, + * "invert": true + * } + * } + * ''' + * + * @param {Object} data - The raw captured data. + * @return {Object} Returns a new payload with collapsed data, and multiple settings handler + * results for the same solution merged together. + */ +gpii.flowManager.formatRawCapturedSettings = function (data) { + var togo = {}; + fluid.each(data, function (sequenceItem) { + if (sequenceItem.isError) { + fluid.log("Error capturing settings for: ", sequenceItem); + return; + } + fluid.each(sequenceItem, function (item, key) { + if (!togo[key]) { + togo[key] = {}; + } + fluid.each(item[0].settings, function (value, settingId) { + togo[key][settingId] = value; + }); + }); + }); + return togo; +}; + /** * JAWS Voice Profile Adjustment GPII-4146 * diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index ea37e6160..7a83b5e52 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -62,6 +62,16 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { resolveArgs: ["{arguments}.0"] }] }] + }, + { + name: "Test Raw Settings Formatting", + tests: [{ + name: "All correct settings", + expect: 2, + sequence: [{ + funcName: "gpii.tests.flowManager.capture.testFormatRawCapturedSettings" + }] + }] } ], components: { @@ -71,6 +81,96 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { } }); +gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () { + var allCorrectSettings = gpii.flowManager.formatRawCapturedSettings([ + { + "fakemag1": [ + { + "settings": { + "magnification": 2 + } + } + ] + }, + { + "fakemag1": [ + { + "settings": { + "invert": true + } + } + ] + }, + { + "fakemag2": [ + { + "settings": { + "magnification": 2, + "invert": true + } + } + ] + } + ]); + jqUnit.assertDeepEq("There should be 2 solutions each with 2 settings from the all correct payload", + allCorrectSettings, { + "fakemag1": { + "magnification": 2, + "invert": true + }, + "fakemag2": { + "magnification": 2, + "invert": true + } + }); + + var someErrorsSettings = gpii.flowManager.formatRawCapturedSettings([ + { + "fakemag1": [ + { + "settings": { + "magnification": 2 + } + } + ] + }, + { + "fakemag1": [ + { + "settings": { + "invert": true + } + } + ] + }, + { + isError: true, + msg: "This didn't work properly during capture" + }, + { + "fakemag2": [ + { + "settings": { + "magnification": 2, + "invert": true + } + } + ] + } + ]); + jqUnit.assertDeepEq("There should still be 2 solutions each with 2 settings from the all payload that contained an error in addition to correct entries.", + someErrorsSettings, { + "fakemag1": { + "magnification": 2, + "invert": true + }, + "fakemag2": { + "magnification": 2, + "invert": true + } + }); +}; + gpii.tests.flowManager.capture.checkForFakeMags = function (payload) { jqUnit.assertDeepEq("FakeMag1 with multiple settings handlers", payload.fakemag1, { From 6b0416d769e1ed24df96aa2f33842dbe4bea9ab2 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Tue, 5 Nov 2019 13:41:06 -0800 Subject: [PATCH 29/47] GPII-228 Temporary workaround for SPI and native windows payloads --- gpii/node_modules/flowManager/src/Capture.js | 62 ++++++++- .../flowManager/test/CaptureTests.js | 124 ++++++++++++++++++ 2 files changed, 185 insertions(+), 1 deletion(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 8c59d32dc..a90651c37 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -115,7 +115,9 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res var promiseTogo = fluid.promise(); try { invokeSettingsHandlerGet(solutionID, handlerSpec).then(function (data) { - promiseTogo.resolve(data); + // Fix up the nativeWindows and SPI Settings Handlers + var filteredData = gpii.flowManager.filterInvokeSettingsHandlersReturn(data, handlerSpec); + promiseTogo.resolve(filteredData); }, function (err) { promiseTogo.resolve({ solutionId: solutionID, @@ -321,3 +323,61 @@ gpii.flowManager.jawsVoiceProfileAdjustment = function (handlerSpec, localResolv return togo; }; + +/** + * This makes adjustments (hacks really) for the return payload of certain settings handlers, + * which when invoked return the value of the setting in a separate sub-structure, rather than + * as the direct proper of the settings block. This should be temporary, and we should resolve + * why the SPI and Native Settings Handler snapshots come back as (technically) generic capability + * versions, rather than the transformed app specific settings like the rest of the settings + * handlers. + * + * "com.microsoft.windows.magnifier": [ + * { + * "settings": { + * "Magnification": 200 + * } + * } + * ] + * + * "com.microsoft.windows.mouseSettings": [ + * { + * "settings": { + * "DoubleClickWidthConfig": { + * "value": 4 + * } + * } + * } + * ] + * + * "com.microsoft.windows.mouseSettings": [ + * { + * "settings": { + * "ScrollWheelModeConfig": { + * "value": 3, + * "path": { + * "get": "pvParam", + * "set": "uiParam" + * } + * } + * } + * } + * ] + */ +gpii.flowManager.filterInvokeSettingsHandlersReturn = function (data, handlerSpec) { + if (handlerSpec.type === "gpii.windows.spiSettingsHandler" || + handlerSpec.type === "gpii.windows.nativeSettingsHandler") { + var togo = fluid.copy(data); + fluid.each(togo, function (appSettingHandlerArray, appId) { + fluid.each(appSettingHandlerArray, function (settingsBlock) { + fluid.each(settingsBlock.settings, function (settingsData, settingsKey) { + settingsBlock.settings[settingsKey] = settingsData.value; + }); + }) + }); + return togo; + } + else { + return data; + } +}; diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index 7a83b5e52..0e2231c68 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -72,6 +72,15 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { funcName: "gpii.tests.flowManager.capture.testFormatRawCapturedSettings" }] }] + }, + { + name: "Test filterInvokeSettingsHandlersReturn", + tests: [{ + name: "Test filter results", + sequence: [{ + funcName: "gpii.tests.flowManager.capture.testfilterInvokeSettingsHandlersReturn" + }] + }] } ], components: { @@ -81,6 +90,121 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { } }); +gpii.tests.flowManager.capture.testfilterInvokeSettingsHandlersReturn = function () { + // 1. Test a regular setting + var regularResult = gpii.flowManager.filterInvokeSettingsHandlersReturn({ + "com.microsoft.windows.magnifier": [ + { + "settings": { + "Magnification": 200 + } + } + ] + }, { + type: "org.gnome.settingsHandler" + }); + + jqUnit.assertDeepEq("Regular setting with no modifications:", { + "com.microsoft.windows.magnifier": [ + { + "settings": { + "Magnification": 200 + } + } + ] + }, regularResult); + + // 2. Test a windows nativeSettingsHandler + var nativeResult = gpii.flowManager.filterInvokeSettingsHandlersReturn({ + "com.microsoft.windows.mouseSettings": [ + { + "settings": { + "DoubleClickWidthConfig": { + "value": 4 + } + } + } + ] + }, { + type: "gpii.windows.nativeSettingsHandler" + }); + + jqUnit.assertDeepEq("Native Settings Handler", { + "com.microsoft.windows.mouseSettings": [ + { + "settings": { + "DoubleClickWidthConfig": 4 + } + } + ] + }, nativeResult); + + // 3. Test an SPI Setting + var spiResult = gpii.flowManager.filterInvokeSettingsHandlersReturn({ + "com.microsoft.windows.mouseSettings": [ + { + "settings": { + "ScrollWheelModeConfig": { + "value": 3, + "path": { + "get": "pvParam", + "set": "uiParam" + } + } + } + } + ] + }, { + type: "gpii.windows.spiSettingsHandler" + }); + + jqUnit.assertDeepEq("SPI Settings Handler", { + "com.microsoft.windows.mouseSettings": [ + { + "settings": { + "ScrollWheelModeConfig": 3 + } + } + ] + }, spiResult); + + // 4. SPI Case with multiple settings + var complexSPIResult = gpii.flowManager.filterInvokeSettingsHandlersReturn({ + "com.microsoft.windows.mouseKeys": [ + { + "settings": { + "MouseKeysOn": { + "value": true, + "path": "pvParam.dwFlags.MKF_MOUSEKEYSON" + }, + "MaxSpeed": { + "value": 80, + "path": "pvParam.iMaxSpeed" + }, + "Acceleration": { + "value": 3000, + "path": "pvParam.iTimeToMaxSpeed" + } + } + } + ] + }, { + type: "gpii.windows.spiSettingsHandler" + }); + + jqUnit.assertDeepEq("Complex SPI Settings Handler", { + "com.microsoft.windows.mouseKeys": [ + { + "settings": { + "MouseKeysOn": true, + "MaxSpeed": 80, + "Acceleration": 3000 + } + } + ] + }, complexSPIResult); +} + gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () { var allCorrectSettings = gpii.flowManager.formatRawCapturedSettings([ { From adcf3383ac538843423f73526ada9483e005c398 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Wed, 27 Nov 2019 16:52:49 -0800 Subject: [PATCH 30/47] GPII-228 Refactoring and cleanup - Removing some windows specific code that is being refactored to gpii-windows - Splitting out some code in to reusable methods --- gpii/node_modules/flowManager/src/Capture.js | 262 +++++------------- .../flowManager/test/CaptureTests.js | 124 --------- 2 files changed, 72 insertions(+), 314 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index a90651c37..f13fadd5a 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -11,8 +11,7 @@ */ "use strict"; -var fs = require("fs"), - fluid = require("infusion"), +var fluid = require("infusion"), gpii = fluid.registerNamespace("gpii"); fluid.defaults("gpii.flowManager.capture", { @@ -43,6 +42,10 @@ fluid.defaults("gpii.flowManager.capture", { { func: "{that}.captureSystemSettings", args: ["{arguments}.0", "{arguments}.1"] + }, + { + func: "gpii.flowManager.formatRawCapturedSettings", + args: ["{arguments}.0"] } ] }, @@ -63,7 +66,6 @@ fluid.defaults("gpii.flowManager.capture", { } }); - gpii.flowManager.getInstalledSolutions = function (that) { return fluid.promise.fireTransformEvent(that.events.onSolutionsForCurrentDevice); }; @@ -85,7 +87,70 @@ gpii.flowManager.getSystemSettingsCapture = function (onCaptureSettingsForCurren {}, options); }; -/* +/** + * This function invokers a settings handler to fetch settings, but wraps the processing and reports + * back any failures in an `isError: true` json block. + * + * @param {Function} invokeSettingsHandlerGet - The get function from the appropriate settings handler. + * @param {String} solutionID - The dotted solution id, ex `com.freedomscientific.jaws` + * @param {Object} handlerSpec - TODO, exactly how much of the solutions entry block is this? + * @return {Object} The returned settings, or an error block with debugging information. + */ +gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, solutionID, handlerSpec) { + var promiseTogo = fluid.promise(); + try { + invokeSettingsHandlerGet(solutionID, handlerSpec).then(function (data) { + // TODO In progress refactoring back to gpii-windows + // Fix up the nativeWindows and SPI Settings Handlers + // var filteredData = gpii.flowManager.filterInvokeSettingsHandlersReturn(data, handlerSpec); + promiseTogo.resolve(data); + }, function (err) { + promiseTogo.resolve({ + solutionId: solutionID, + handlerSpec: handlerSpec, + isError: true, + message: "inner promise error", + err: err + }); + }); + } + catch (err) { + promiseTogo.resolve({ + solutionId: solutionID, + handlerSpec: handlerSpec, + isError: true, + message: "outer try error", + err: err + }); + } + return promiseTogo; +}; + +gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsHandlerGet, solution, solutionID, resolver) { + var settingsPromisesTogo = []; + + var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); + + // TODO In progress refactoring back to gpii-windows + // if (solutionID === "com.freedomscientific.jaws") { + // newSolution = gpii.flowManager.jawsVoiceProfileAdjustment(newSolution, localResolver); + // } + + fluid.each(newSolution.settingsHandlers, function (handlerSpec) { + //if applicationSettings is unspecified, dont attempt to get settings + if (!handlerSpec.supportedSettings) { + return; + } + handlerSpec.settings = handlerSpec.supportedSettings; + // TODO There is some in progress refactoring that happened here to update spiSettingsHandler. + // No longer here, but this is a reminder to resolve it when there are acceptance tests for the SPI settings capture. + handlerSpec = resolver.resolve(handlerSpec, {}); + settingsPromisesTogo.push(gpii.flowManager.capture.safeHandlerGet(invokeSettingsHandlerGet, solutionID, handlerSpec)); + }); + return settingsPromisesTogo; +}; + +/** * Runs through all the solutions currently available on the system, pulls the current * setting for each supportedSetting and returns them in an object. Primary use case * is for backing Capture tools that would allow a user to set up their GPII profile @@ -107,39 +172,8 @@ gpii.flowManager.getSystemSettingsCapture = function (onCaptureSettingsForCurren * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. */ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, localResolver, solutions, options) { - var promiseTogo = fluid.promise(); - var handlerGetPromises = []; - var safeHandlerGet = function (invokeSettingsHandlerGet, solutionID, handlerSpec) { - var promiseTogo = fluid.promise(); - try { - invokeSettingsHandlerGet(solutionID, handlerSpec).then(function (data) { - // Fix up the nativeWindows and SPI Settings Handlers - var filteredData = gpii.flowManager.filterInvokeSettingsHandlersReturn(data, handlerSpec); - promiseTogo.resolve(filteredData); - }, function (err) { - promiseTogo.resolve({ - solutionId: solutionID, - handlerSpec: handlerSpec, - isError: true, - message: "inner promise error", - err: err - }); - }); - } - catch (err) { - promiseTogo.resolve({ - solutionId: solutionID, - handlerSpec: handlerSpec, - isError: true, - message: "outer try error", - err: err - }); - } - return promiseTogo; - }; - var solutionsToFetch = solutions; if (options.solutionsList) { solutionsToFetch = {}; @@ -151,48 +185,11 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res } fluid.each(solutionsToFetch, function (solution, solutionID) { - var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); - - if (solutionID === "com.freedomscientific.jaws") { - newSolution = gpii.flowManager.jawsVoiceProfileAdjustment(newSolution, localResolver); - } - - fluid.each(newSolution.settingsHandlers, function (handlerSpec) { - //if applicationSettings is unspecified, dont attempt to get settings - if (!handlerSpec.supportedSettings) { - return; - } - handlerSpec.settings = handlerSpec.supportedSettings; - // TODO GPII-228 This is temporary debugging code while we work through - // the processing that is missing from this chain that transforms the paths - // in capabilitiesTransforms to the schema information needed for the settings - // handler - if (handlerSpec.type === "gpii.windows.spiSettingsHandler") { - fluid.each(handlerSpec.settings, function (handler, handlerKey) { - if (handlerSpec.capabilitiesTransformations[handlerKey].path.transform) { - handlerSpec.settings[handlerKey].path = - handlerSpec.capabilitiesTransformations[handlerKey].path.transform.input; - }; - if (handlerSpec.capabilitiesTransformations[handlerKey].path.literalValue) { - handlerSpec.settings[handlerKey].path = - handlerSpec.capabilitiesTransformations[handlerKey].path.literalValue; - }; - }); - } - handlerSpec = resolver.resolve(handlerSpec, {}); - handlerGetPromises.push(safeHandlerGet(invokeSettingsHandlerGet, solutionID, handlerSpec)); - }); - }); - var promisesSequence = fluid.promise.sequence(handlerGetPromises); - promisesSequence.then(function (responses) { - - var finalPayload = gpii.flowManager.formatRawCapturedSettings(responses); - promiseTogo.resolve(finalPayload); - }, function (responses) { - promiseTogo.resolve(responses); + var nextPromises = gpii.flowManager.capture.fetchAllSettingsForSolution(invokeSettingsHandlerGet, solution, solutionID, resolver); + handlerGetPromises = handlerGetPromises.concat(nextPromises); }); - return promiseTogo; + return fluid.promise.sequence(handlerGetPromises); }; /** @@ -266,118 +263,3 @@ gpii.flowManager.formatRawCapturedSettings = function (data) { }); return togo; }; - -/** - * JAWS Voice Profile Adjustment GPII-4146 - * - * When applying settings to a machine we create our own Voice Profile to use, which is - * hardcoded in the solutions registry as `GPII`. However, when capturing JAWS settings - * we want to use whatever the default voice profile is, if there is one. More so, if there - * is not a default voice profile, or a factory default is in use, we want to ignore the - * voice profile configuration. - * - * Note: While the JAWS solution entry is fairly stable, if there are changes to the settings - * configuration names, this will need to be updated. - * - * @param {Object} handlerSpec - The solutions registry entry for JAWS - * @param {Function} localResolver - The localResolver, usually from the `userSession` on the - * `lifecycleManager` to resolve the INI configuration paths where JAWS stores it's settings. - * @return {Object} Returns a new handlerSpec with the configurations adjusted depending on the - * current default voice profile on the system. This is a deep copy of `handlerSpec` the original - * is not modified. - */ -gpii.flowManager.jawsVoiceProfileAdjustment = function (handlerSpec, localResolver) { - var togo = fluid.copy(handlerSpec); - - // Configuration1 contains the path to the default settings stored in INI format - var defaultJCFpath = localResolver(handlerSpec.settingsHandlers.configuration1.options.filename); - var defaultJAWsSettings = gpii.iniFile.readFile(defaultJCFpath, {}); - - // It's possible to not have a current voice profile set in DEFAULT.JCF - // In the DEFAULT.JCF file it is stored here: - // ```ini - // [Voice Profiles] - // ActiveVoiceProfileName=GPII - // ``` - var currentVoiceProfile = false; - if (defaultJAWsSettings["Voice Profiles"] && defaultJAWsSettings["Voice Profiles"].ActiveVoiceProfileName) { - currentVoiceProfile = defaultJAWsSettings["Voice Profiles"].ActiveVoiceProfileName; - } - - // Again this will need to be updated in sync with JAWS support. As of now, we don't store this path by itself in the - // solution entry. - var voiceProfilesDir = localResolver("${{environment}.APPDATA}\\Freedom Scientific\\JAWS\\2019\\Settings\\VoiceProfiles\\"); - var voiceProfilesPath = voiceProfilesDir + currentVoiceProfile + ".VPF"; - var voiceProfileExists = fs.existsSync(voiceProfilesPath); - - if (!voiceProfileExists) { - // If the voice profile does not exist delete the second configuration from the - // handlerSpec. The INI settings handler will fail for both configurations if the - // file is missing. - delete togo.settingsHandlers.configuration2; - } - else { - // Otherwise update the .VPC ini configuration with the voice profile path - togo.settingsHandlers.configuration2.options.filename = voiceProfilesPath; - } - - return togo; -}; - -/** - * This makes adjustments (hacks really) for the return payload of certain settings handlers, - * which when invoked return the value of the setting in a separate sub-structure, rather than - * as the direct proper of the settings block. This should be temporary, and we should resolve - * why the SPI and Native Settings Handler snapshots come back as (technically) generic capability - * versions, rather than the transformed app specific settings like the rest of the settings - * handlers. - * - * "com.microsoft.windows.magnifier": [ - * { - * "settings": { - * "Magnification": 200 - * } - * } - * ] - * - * "com.microsoft.windows.mouseSettings": [ - * { - * "settings": { - * "DoubleClickWidthConfig": { - * "value": 4 - * } - * } - * } - * ] - * - * "com.microsoft.windows.mouseSettings": [ - * { - * "settings": { - * "ScrollWheelModeConfig": { - * "value": 3, - * "path": { - * "get": "pvParam", - * "set": "uiParam" - * } - * } - * } - * } - * ] - */ -gpii.flowManager.filterInvokeSettingsHandlersReturn = function (data, handlerSpec) { - if (handlerSpec.type === "gpii.windows.spiSettingsHandler" || - handlerSpec.type === "gpii.windows.nativeSettingsHandler") { - var togo = fluid.copy(data); - fluid.each(togo, function (appSettingHandlerArray, appId) { - fluid.each(appSettingHandlerArray, function (settingsBlock) { - fluid.each(settingsBlock.settings, function (settingsData, settingsKey) { - settingsBlock.settings[settingsKey] = settingsData.value; - }); - }) - }); - return togo; - } - else { - return data; - } -}; diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index 0e2231c68..7a83b5e52 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -72,15 +72,6 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { funcName: "gpii.tests.flowManager.capture.testFormatRawCapturedSettings" }] }] - }, - { - name: "Test filterInvokeSettingsHandlersReturn", - tests: [{ - name: "Test filter results", - sequence: [{ - funcName: "gpii.tests.flowManager.capture.testfilterInvokeSettingsHandlersReturn" - }] - }] } ], components: { @@ -90,121 +81,6 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { } }); -gpii.tests.flowManager.capture.testfilterInvokeSettingsHandlersReturn = function () { - // 1. Test a regular setting - var regularResult = gpii.flowManager.filterInvokeSettingsHandlersReturn({ - "com.microsoft.windows.magnifier": [ - { - "settings": { - "Magnification": 200 - } - } - ] - }, { - type: "org.gnome.settingsHandler" - }); - - jqUnit.assertDeepEq("Regular setting with no modifications:", { - "com.microsoft.windows.magnifier": [ - { - "settings": { - "Magnification": 200 - } - } - ] - }, regularResult); - - // 2. Test a windows nativeSettingsHandler - var nativeResult = gpii.flowManager.filterInvokeSettingsHandlersReturn({ - "com.microsoft.windows.mouseSettings": [ - { - "settings": { - "DoubleClickWidthConfig": { - "value": 4 - } - } - } - ] - }, { - type: "gpii.windows.nativeSettingsHandler" - }); - - jqUnit.assertDeepEq("Native Settings Handler", { - "com.microsoft.windows.mouseSettings": [ - { - "settings": { - "DoubleClickWidthConfig": 4 - } - } - ] - }, nativeResult); - - // 3. Test an SPI Setting - var spiResult = gpii.flowManager.filterInvokeSettingsHandlersReturn({ - "com.microsoft.windows.mouseSettings": [ - { - "settings": { - "ScrollWheelModeConfig": { - "value": 3, - "path": { - "get": "pvParam", - "set": "uiParam" - } - } - } - } - ] - }, { - type: "gpii.windows.spiSettingsHandler" - }); - - jqUnit.assertDeepEq("SPI Settings Handler", { - "com.microsoft.windows.mouseSettings": [ - { - "settings": { - "ScrollWheelModeConfig": 3 - } - } - ] - }, spiResult); - - // 4. SPI Case with multiple settings - var complexSPIResult = gpii.flowManager.filterInvokeSettingsHandlersReturn({ - "com.microsoft.windows.mouseKeys": [ - { - "settings": { - "MouseKeysOn": { - "value": true, - "path": "pvParam.dwFlags.MKF_MOUSEKEYSON" - }, - "MaxSpeed": { - "value": 80, - "path": "pvParam.iMaxSpeed" - }, - "Acceleration": { - "value": 3000, - "path": "pvParam.iTimeToMaxSpeed" - } - } - } - ] - }, { - type: "gpii.windows.spiSettingsHandler" - }); - - jqUnit.assertDeepEq("Complex SPI Settings Handler", { - "com.microsoft.windows.mouseKeys": [ - { - "settings": { - "MouseKeysOn": true, - "MaxSpeed": 80, - "Acceleration": 3000 - } - } - ] - }, complexSPIResult); -} - gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () { var allCorrectSettings = gpii.flowManager.formatRawCapturedSettings([ { From 49e4a38a84d5cb78b7299dae910c9b66352a7a0c Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Mon, 9 Dec 2019 13:16:50 -0800 Subject: [PATCH 31/47] GPII-228 Updating test data adjustments --- gpii/node_modules/flowManager/test/CaptureTests.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index 7a83b5e52..3ab0b54df 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -194,9 +194,13 @@ gpii.tests.flowManager.capture.checkForInstalledMags = function (payload) { gpii.tests.flowManager.capture.adjustSolutions = function (solutionsRegistryDataSource) { var testDataFile = __dirname + "/data/capture_fakemag_settings.json"; - solutionsRegistryDataSource.fullSolutionsRegistry.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile; - solutionsRegistryDataSource.fullSolutionsRegistry.darwin.fakemag1.settingsHandlers.configuration.options.filename = testDataFile; - solutionsRegistryDataSource.fullSolutionsRegistry.darwin.fakemag1.settingsHandlers.configuration1.options.filename = testDataFile; + // The solutions block is a read only data structure + var adjustedSolutions = fluid.copy(solutionsRegistryDataSource.fullSolutionsRegistry); + adjustedSolutions.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile; + adjustedSolutions.darwin.fakemag1.settingsHandlers.configuration.options.filename = testDataFile; + adjustedSolutions.darwin.fakemag1.settingsHandlers.configuration1.options.filename = testDataFile; + solutionsRegistryDataSource.fullSolutionsRegistry = adjustedSolutions; + }; fluid.test.runTests([ From 3e70229fe4c44e78bb46df8b8a389cdcd6b776b4 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Fri, 24 Jan 2020 14:20:55 -0800 Subject: [PATCH 32/47] GPII-228 Removed unused test configuration --- .../test/configs/gpii.flowManager.tests.capture.config.json5 | 4 ---- .../gpii.flowManager.tests.capture.fakeData.config.json5 | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-) delete mode 100644 gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.config.json5 diff --git a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.config.json5 b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.config.json5 deleted file mode 100644 index a7f97811e..000000000 --- a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.config.json5 +++ /dev/null @@ -1,4 +0,0 @@ -{ - "type": "gpii.flowManager.tests.capture.config", - "mergeConfigs": "%gpii-universal/gpii/configs/shared/gpii.config.untrusted.development.json5" -} diff --git a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 index f77878c0a..8e61377c1 100644 --- a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 +++ b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 @@ -1,3 +1,7 @@ +// +// This configuration is used for testing the snappingshotting Capture API. Capturing setting will only +// ever happen on a users local machine, so there is only an untrusted test configuration. +// { "type": "gpii.flowManager.tests.capture.fakeData.config", "options": { From 2017627d236eb657d46140600f7c58fb1fdaa6f5 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Sat, 25 Jan 2020 14:03:12 -0800 Subject: [PATCH 33/47] GPII-228 Rearranging test runs so simple functions are just called with jqUnit.test --- .../flowManager/test/CaptureTests.js | 82 +++++++++---------- 1 file changed, 37 insertions(+), 45 deletions(-) diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index 3ab0b54df..fc7d05170 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -28,6 +28,35 @@ kettle.config.createDefaults({ configPath: "%gpii-universal/gpii/node_modules/flowManager/test/configs" }); +gpii.tests.flowManager.capture.checkForFakeMags = function (payload) { + jqUnit.assertDeepEq("FakeMag1 with multiple settings handlers", payload.fakemag1, { + "magnification": 2, + "invert": true + }); + + jqUnit.assertDeepEq("FakeMag2 with single settings handler", payload.fakemag2, { + "magnification": 2, + "invert": true + }); +}; + +gpii.tests.flowManager.capture.checkForInstalledMags = function (payload) { + jqUnit.assertEquals("There should be 2 solutions installed", Object.keys(payload).length, 2); + jqUnit.assertEquals("Check for Fake Mag 1", payload.fakemag1.name, "Fake Magnifier 1"); + jqUnit.assertEquals("Check for Fake Mag 2", payload.fakemag2.name, "Fake Magnifier 2 - fully featured"); +}; + +gpii.tests.flowManager.capture.adjustSolutions = function (solutionsRegistryDataSource) { + var testDataFile = __dirname + "/data/capture_fakemag_settings.json"; + + // The solutions block is a read only data structure + var adjustedSolutions = fluid.copy(solutionsRegistryDataSource.fullSolutionsRegistry); + adjustedSolutions.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile; + adjustedSolutions.darwin.fakemag1.settingsHandlers.configuration.options.filename = testDataFile; + adjustedSolutions.darwin.fakemag1.settingsHandlers.configuration1.options.filename = testDataFile; + solutionsRegistryDataSource.fullSolutionsRegistry = adjustedSolutions; +}; + fluid.defaults("gpii.tests.flowManager.capture.tests", { gradeNames: ["fluid.test.testEnvironment", "fluid.test.testCaseHolder"], modules: [ @@ -62,16 +91,6 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { resolveArgs: ["{arguments}.0"] }] }] - }, - { - name: "Test Raw Settings Formatting", - tests: [{ - name: "All correct settings", - expect: 2, - sequence: [{ - funcName: "gpii.tests.flowManager.capture.testFormatRawCapturedSettings" - }] - }] } ], components: { @@ -81,6 +100,13 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { } }); +fluid.test.runTests([ + "gpii.tests.flowManager.capture.tests" +]); + +/* + * Tests for formatting raw captures. + */ gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () { var allCorrectSettings = gpii.flowManager.formatRawCapturedSettings([ { @@ -171,38 +197,4 @@ gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () { }); }; -gpii.tests.flowManager.capture.checkForFakeMags = function (payload) { - - jqUnit.assertDeepEq("FakeMag1 with multiple settings handlers", payload.fakemag1, { - "magnification": 2, - "invert": true - }); - - jqUnit.assertDeepEq("FakeMag2 with single settings handler", payload.fakemag2, { - "magnification": 2, - "invert": true - }); - -}; - -gpii.tests.flowManager.capture.checkForInstalledMags = function (payload) { - jqUnit.assertEquals("There should be 2 solutions installed", Object.keys(payload).length, 2); - jqUnit.assertEquals("Check for Fake Mag 1", payload.fakemag1.name, "Fake Magnifier 1"); - jqUnit.assertEquals("Check for Fake Mag 2", payload.fakemag2.name, "Fake Magnifier 2 - fully featured"); -}; - -gpii.tests.flowManager.capture.adjustSolutions = function (solutionsRegistryDataSource) { - var testDataFile = __dirname + "/data/capture_fakemag_settings.json"; - - // The solutions block is a read only data structure - var adjustedSolutions = fluid.copy(solutionsRegistryDataSource.fullSolutionsRegistry); - adjustedSolutions.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile; - adjustedSolutions.darwin.fakemag1.settingsHandlers.configuration.options.filename = testDataFile; - adjustedSolutions.darwin.fakemag1.settingsHandlers.configuration1.options.filename = testDataFile; - solutionsRegistryDataSource.fullSolutionsRegistry = adjustedSolutions; - -}; - -fluid.test.runTests([ - "gpii.tests.flowManager.capture.tests" -]); +jqUnit.test("Test Raw Settings Formatting", gpii.tests.flowManager.capture.testFormatRawCapturedSettings); From 98e56d4fe4705ebdac8dadf04cdaf4a25e86adcc Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Sat, 25 Jan 2020 14:16:55 -0800 Subject: [PATCH 34/47] GPII-288 More meaningful messages on errors in operating settings handlers. --- gpii/node_modules/flowManager/src/Capture.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index f13fadd5a..45e2a3ec4 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -109,7 +109,7 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so solutionId: solutionID, handlerSpec: handlerSpec, isError: true, - message: "inner promise error", + message: "Settings Handler Promise Rejection", err: err }); }); @@ -119,7 +119,7 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so solutionId: solutionID, handlerSpec: handlerSpec, isError: true, - message: "outer try error", + message: "Unexpected Error in operating settings handler.", err: err }); } From 2b3f8e98cf7a249e068befd35d26245cd842cca7 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Sat, 25 Jan 2020 14:24:46 -0800 Subject: [PATCH 35/47] GPII-228 Cleaning up TODO comments --- gpii/node_modules/flowManager/src/Capture.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 45e2a3ec4..3520f466c 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -100,9 +100,6 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so var promiseTogo = fluid.promise(); try { invokeSettingsHandlerGet(solutionID, handlerSpec).then(function (data) { - // TODO In progress refactoring back to gpii-windows - // Fix up the nativeWindows and SPI Settings Handlers - // var filteredData = gpii.flowManager.filterInvokeSettingsHandlersReturn(data, handlerSpec); promiseTogo.resolve(data); }, function (err) { promiseTogo.resolve({ @@ -131,7 +128,8 @@ gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsH var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); - // TODO In progress refactoring back to gpii-windows + // TODO GPII-4146 In progress refactoring back to gpii-windows + // https://issues.gpii.net/browse/GPII-4146 // if (solutionID === "com.freedomscientific.jaws") { // newSolution = gpii.flowManager.jawsVoiceProfileAdjustment(newSolution, localResolver); // } From caa65083c990e0926bcc1d764e314463cb426f95 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Sat, 25 Jan 2020 15:17:21 -0800 Subject: [PATCH 36/47] GPII-228 Refactoring fetch all solutions loop --- gpii/node_modules/flowManager/src/Capture.js | 26 +++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 3520f466c..c07e4b95e 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -61,7 +61,7 @@ fluid.defaults("gpii.flowManager.capture", { captureSystemSettings: { funcName: "gpii.flowManager.captureSystemSettings", args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", - "{lifecycleManager}.userSession.localResolver", "{arguments}.0", "{arguments}.1"] + "{arguments}.0", "{arguments}.1"] } } }); @@ -148,6 +148,17 @@ gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsH return settingsPromisesTogo; }; +gpii.flowManager.capture.fetchAllSettingsForSolutionsList = function (solutionsToFetch, invokeSettingsHandlerGet, resolver) { + var handlerGetPromises = []; + + fluid.each(solutionsToFetch, function (solution, solutionID) { + var nextPromises = gpii.flowManager.capture.fetchAllSettingsForSolution(invokeSettingsHandlerGet, solution, solutionID, resolver); + handlerGetPromises = handlerGetPromises.concat(nextPromises); + }); + + return fluid.promise.sequence(handlerGetPromises); +}; + /** * Runs through all the solutions currently available on the system, pulls the current * setting for each supportedSetting and returns them in an object. Primary use case @@ -157,8 +168,6 @@ gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsH * @param {lifecycleManager.invokeSettingsHandlerGet} invokeSettingsHandlerGet - Invoker from the `lifecycleManager` * necessary for extracting settings from a solution and it's spec. * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications - * @param {lifecycleManager.userSession.localResolver} localResolver - Resolver for expanding configuration file paths - * from the solutions registry. * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. * @param {Object} options - Extra options for processing. * @param {Array} options.solutionsList - If provided, only solutions in this list of `solutionsID`s will @@ -169,9 +178,7 @@ gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsH * ''' * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. */ -gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, localResolver, solutions, options) { - var handlerGetPromises = []; - +gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, options) { var solutionsToFetch = solutions; if (options.solutionsList) { solutionsToFetch = {}; @@ -182,12 +189,7 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res }); } - fluid.each(solutionsToFetch, function (solution, solutionID) { - var nextPromises = gpii.flowManager.capture.fetchAllSettingsForSolution(invokeSettingsHandlerGet, solution, solutionID, resolver); - handlerGetPromises = handlerGetPromises.concat(nextPromises); - }); - - return fluid.promise.sequence(handlerGetPromises); + return gpii.flowManager.capture.fetchAllSettingsForSolutionsList(solutionsToFetch, invokeSettingsHandlerGet, resolver); }; /** From 4b167f85e7d74169f295d4dd80626d16e700c6c4 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Sun, 26 Jan 2020 13:18:57 -0800 Subject: [PATCH 37/47] GPII-228 Adding missing jsdocs --- gpii/node_modules/flowManager/src/Capture.js | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index c07e4b95e..14f76ac0a 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -123,6 +123,16 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so return promiseTogo; }; +/** + * Fetches all settings for a particular solution, going through all of the solutions settings handlers. + * + * @param {lifecycleManager.invokeSettingsHandlerGet} invokeSettingsHandlerGet - Invoker from the `lifecycleManager` + * necessary for extracting settings from a solution and it's spec. + * @param {Object} solution - The solution registry entry body for this solution. + * @param {String} solutionID - The dotted solution id, example `com.microsoft.windows.cursors`. + * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications + * @return {Array} An array of promises resolving to the results from each settings handler the solution uses. + */ gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsHandlerGet, solution, solutionID, resolver) { var settingsPromisesTogo = []; @@ -148,6 +158,17 @@ gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsH return settingsPromisesTogo; }; +/** + * Fetches all the settings for an entire list of solutions. + * + * @param {Object} solutionsToFetch - A keyed object of solutions using the same format as the solutions registry. Keys + * are solutionsIDs, like `com.freedomscientific.jaws` and the entries are the full solution registry entries. + * @param {lifecycleManager.invokeSettingsHandlerGet} invokeSettingsHandlerGet - Invoker from the `lifecycleManager` + * necessary for extracting settings from a solution and it's spec. + * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications + * @return {Array} Returns a list of promises that resolve to captured settings for each particular settings handler in + * every solution. + */ gpii.flowManager.capture.fetchAllSettingsForSolutionsList = function (solutionsToFetch, invokeSettingsHandlerGet, resolver) { var handlerGetPromises = []; From 146119b7260a3e7726d22f895b5d98d36ca18288 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Mon, 27 Jan 2020 15:28:04 -0800 Subject: [PATCH 38/47] GPII-228 cleanup - Added namespaces for promise chains - Added Comments - More useful error strings - Removed stub comments --- gpii/node_modules/flowManager/src/Capture.js | 68 ++++++++++---------- 1 file changed, 33 insertions(+), 35 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 14f76ac0a..0f131d2ef 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -17,37 +17,41 @@ var fluid = require("infusion"), fluid.defaults("gpii.flowManager.capture", { gradeNames: ["fluid.component"], events: { + // Pseudoevents for transforming promise chains to fetch the solutions on the current device + // and capture the settings for the device. onSolutionsForCurrentDevice: null, onCaptureSettingsForCurrentDevice: null }, listeners: { - onSolutionsForCurrentDevice: [ - { - funcName: "gpii.lifecycleManager.getDeviceContextPromise", - args: ["{flowManager}.deviceReporter"] - }, - { - funcName: "gpii.flowManager.getSolutionsPromise", - args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"] - }, - { - funcName: "fluid.toPromise", - args: ["{arguments}.0.solutionsRegistryEntries"] - } - ], - onCaptureSettingsForCurrentDevice: [ - { - func: "{that}.getInstalledSolutions" - }, - { - func: "{that}.captureSystemSettings", - args: ["{arguments}.0", "{arguments}.1"] - }, - { - func: "gpii.flowManager.formatRawCapturedSettings", - args: ["{arguments}.0"] - } - ] + // Begin declaration of Promise Chain for onSolutionsForCurrentDevice + "onSolutionsForCurrentDevice.getDeviceContextPromise": { + funcName: "gpii.lifecycleManager.getDeviceContextPromise", + args: ["{flowManager}.deviceReporter"] + }, + "onSolutionsForCurrentDevice.getSolutionsPromise": { + funcName: "gpii.flowManager.getSolutionsPromise", + args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"], + priority: "after:getDeviceContextPromise" + }, + "onSolutionsForCurrentDevice.solutionsRegistryEntriesToPromise": { + funcName: "fluid.toPromise", + args: ["{arguments}.0.solutionsRegistryEntries"], + priority: "after:getSolutionsPromise" + }, + // Begin declaration of Promise Chain for onCaptureSettingsForCurrentDevice + "onCaptureSettingsForCurrentDevice.getInstalledSolutions": { + func: "{that}.getInstalledSolutions" + }, + "onCaptureSettingsForCurrentDevice.captureSystemSettings": { + func: "{that}.captureSystemSettings", + args: ["{arguments}.0", "{arguments}.1"], + priority: "after:getInstalledSolutions" + }, + "onCaptureSettingsForCurrentDevice.formatRawCapturedSettings": { + func: "gpii.flowManager.formatRawCapturedSettings", + args: ["{arguments}.0"], + priority: "after:captureSystemSettings" + } }, invokers: { getInstalledSolutions: { @@ -106,7 +110,7 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so solutionId: solutionID, handlerSpec: handlerSpec, isError: true, - message: "Settings Handler Promise Rejection", + message: "Capture Workflow Error: Settings Handler Promise Rejection", err: err }); }); @@ -116,7 +120,7 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so solutionId: solutionID, handlerSpec: handlerSpec, isError: true, - message: "Unexpected Error in operating settings handler.", + message: "Capture Workflow Error: Unexpected Error in operating settings handler.", err: err }); } @@ -138,12 +142,6 @@ gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsH var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); - // TODO GPII-4146 In progress refactoring back to gpii-windows - // https://issues.gpii.net/browse/GPII-4146 - // if (solutionID === "com.freedomscientific.jaws") { - // newSolution = gpii.flowManager.jawsVoiceProfileAdjustment(newSolution, localResolver); - // } - fluid.each(newSolution.settingsHandlers, function (handlerSpec) { //if applicationSettings is unspecified, dont attempt to get settings if (!handlerSpec.supportedSettings) { From 2eb479f3160476e77ceb3dc834ed06fe50be3b98 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Mon, 27 Jan 2020 16:29:27 -0800 Subject: [PATCH 39/47] GPII-228 Cleanup - Namespaced/prioritized promise chain listeners - Added comments - Updated invoker names to match purpose - Updated some things to use idiomatic fluid conventions fluid.transform, fluid.remove_if... --- gpii/node_modules/flowManager/src/Capture.js | 36 ++++++++----------- .../flowManager/test/CaptureTests.js | 2 +- .../src/UserLogonStateChange.js | 6 ++++ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 0f131d2ef..d4ed06ff9 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -39,13 +39,13 @@ fluid.defaults("gpii.flowManager.capture", { priority: "after:getSolutionsPromise" }, // Begin declaration of Promise Chain for onCaptureSettingsForCurrentDevice - "onCaptureSettingsForCurrentDevice.getInstalledSolutions": { - func: "{that}.getInstalledSolutions" + "onCaptureSettingsForCurrentDevice.getInstalledSolutionsForCurrentDevice": { + func: "{that}.getInstalledSolutionsForCurrentDevice" }, "onCaptureSettingsForCurrentDevice.captureSystemSettings": { func: "{that}.captureSystemSettings", args: ["{arguments}.0", "{arguments}.1"], - priority: "after:getInstalledSolutions" + priority: "after:getInstalledSolutionsForCurrentDevice" }, "onCaptureSettingsForCurrentDevice.formatRawCapturedSettings": { func: "gpii.flowManager.formatRawCapturedSettings", @@ -54,23 +54,23 @@ fluid.defaults("gpii.flowManager.capture", { } }, invokers: { - getInstalledSolutions: { - funcName: "gpii.flowManager.getInstalledSolutions", + getInstalledSolutionsForCurrentDevice: { + funcName: "gpii.flowManager.getInstalledSolutionsForCurrentDevice", args: ["{that}"] }, getSystemSettingsCapture: { funcName: "gpii.flowManager.getSystemSettingsCapture", - args: ["{that}.events.onCaptureSettingsForCurrentDevice", "{arguments}.0"] // Options + args: ["{that}.events.onCaptureSettingsForCurrentDevice", "{arguments}.0"] // options }, captureSystemSettings: { funcName: "gpii.flowManager.captureSystemSettings", args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", - "{arguments}.0", "{arguments}.1"] + "{arguments}.0", "{arguments}.1"] // solutionsRegistryEntries, options } } }); -gpii.flowManager.getInstalledSolutions = function (that) { +gpii.flowManager.getInstalledSolutionsForCurrentDevice = function (that) { return fluid.promise.fireTransformEvent(that.events.onSolutionsForCurrentDevice); }; @@ -168,14 +168,11 @@ gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsH * every solution. */ gpii.flowManager.capture.fetchAllSettingsForSolutionsList = function (solutionsToFetch, invokeSettingsHandlerGet, resolver) { - var handlerGetPromises = []; - - fluid.each(solutionsToFetch, function (solution, solutionID) { - var nextPromises = gpii.flowManager.capture.fetchAllSettingsForSolution(invokeSettingsHandlerGet, solution, solutionID, resolver); - handlerGetPromises = handlerGetPromises.concat(nextPromises); + var handlerGetPromises = fluid.transform(solutionsToFetch, function (solution, solutionID) { + return gpii.flowManager.capture.fetchAllSettingsForSolution(invokeSettingsHandlerGet, solution, solutionID, resolver); }); - return fluid.promise.sequence(handlerGetPromises); + return fluid.promise.sequence(fluid.flatten(handlerGetPromises)); }; /** @@ -190,7 +187,7 @@ gpii.flowManager.capture.fetchAllSettingsForSolutionsList = function (solutionsT * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. * @param {Object} options - Extra options for processing. * @param {Array} options.solutionsList - If provided, only solutions in this list of `solutionsID`s will - * be captures. Example: + * be captured. Example: * * '''json * ["com.microsoft.windows.cursors", "com.freedomscientific.jaws"] @@ -198,13 +195,10 @@ gpii.flowManager.capture.fetchAllSettingsForSolutionsList = function (solutionsT * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. */ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, options) { - var solutionsToFetch = solutions; + var solutionsToFetch = fluid.copy(solutions); if (options.solutionsList) { - solutionsToFetch = {}; - fluid.each(solutions, function (solution, solutionID) { - if (options.solutionsList.indexOf(solutionID) >= 0) { - solutionsToFetch[solutionID] = solution; - } + fluid.remove_if(solutionsToFetch, function (solution, solutionID) { + return !options.solutionsList.includes(solutionID); }); } diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index fc7d05170..de72bddd3 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -85,7 +85,7 @@ fluid.defaults("gpii.tests.flowManager.capture.tests", { funcName: "gpii.tests.flowManager.capture.adjustSolutions", args: ["{config}.server.flowManager.solutionsRegistryDataSource"] }, { - task: "{config}.server.flowManager.capture.getInstalledSolutions", + task: "{config}.server.flowManager.capture.getInstalledSolutionsForCurrentDevice", args: [], resolve: "gpii.tests.flowManager.capture.checkForInstalledMags", resolveArgs: ["{arguments}.0"] diff --git a/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js b/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js index de0868e5b..3070cca77 100644 --- a/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js +++ b/gpii/node_modules/lifecycleManager/src/UserLogonStateChange.js @@ -160,6 +160,12 @@ gpii.lifecycleManager.getDeviceContext = function (deviceReporter, event, errorE }; gpii.lifecycleManager.getDeviceContextPromise = function (deviceReporter) { + // GPII-4324 TODO: We have a factoring problem here since properly the LifecycleManager has no business + // reaching out into the environment to interact with the DeviceReporter, as shown by the + // awkward-looking reference {flowManager}.deviceReporter which is out of place with the others. + // However, this ended up being a natural place for the implementation since it is scoped to the + // matchmaking workflow which is tied to lifecycleManager's userLogonRequest via containment. + // When we improve this factoring we will better deliver on our goal of "containment without dependency" var promiseTogo = fluid.promise(); var promise = deviceReporter.get(); promise.then(function (deviceData) { From e7100780b229961f63665db0a8ef3155a435f5bc Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Tue, 28 Jan 2020 12:19:56 -0800 Subject: [PATCH 40/47] GPII-228 Using lifecycle managers now identicle settings read functionality. --- gpii/node_modules/flowManager/src/Capture.js | 59 ++------------------ 1 file changed, 4 insertions(+), 55 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index d4ed06ff9..3052a9330 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -64,8 +64,7 @@ fluid.defaults("gpii.flowManager.capture", { }, captureSystemSettings: { funcName: "gpii.flowManager.captureSystemSettings", - args: ["{lifecycleManager}.invokeSettingsHandlerGet", "{lifecycleManager}.variableResolver", - "{arguments}.0", "{arguments}.1"] // solutionsRegistryEntries, options + args: ["{lifecycleManager}", "{arguments}.0", "{arguments}.1"] // solutionsRegistryEntries, options } } }); @@ -127,63 +126,13 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so return promiseTogo; }; -/** - * Fetches all settings for a particular solution, going through all of the solutions settings handlers. - * - * @param {lifecycleManager.invokeSettingsHandlerGet} invokeSettingsHandlerGet - Invoker from the `lifecycleManager` - * necessary for extracting settings from a solution and it's spec. - * @param {Object} solution - The solution registry entry body for this solution. - * @param {String} solutionID - The dotted solution id, example `com.microsoft.windows.cursors`. - * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications - * @return {Array} An array of promises resolving to the results from each settings handler the solution uses. - */ -gpii.flowManager.capture.fetchAllSettingsForSolution = function (invokeSettingsHandlerGet, solution, solutionID, resolver) { - var settingsPromisesTogo = []; - - var newSolution = gpii.lifecycleManager.transformSolutionSettings(solution, gpii.settingsHandlers.changesToSettings); - - fluid.each(newSolution.settingsHandlers, function (handlerSpec) { - //if applicationSettings is unspecified, dont attempt to get settings - if (!handlerSpec.supportedSettings) { - return; - } - handlerSpec.settings = handlerSpec.supportedSettings; - // TODO There is some in progress refactoring that happened here to update spiSettingsHandler. - // No longer here, but this is a reminder to resolve it when there are acceptance tests for the SPI settings capture. - handlerSpec = resolver.resolve(handlerSpec, {}); - settingsPromisesTogo.push(gpii.flowManager.capture.safeHandlerGet(invokeSettingsHandlerGet, solutionID, handlerSpec)); - }); - return settingsPromisesTogo; -}; - -/** - * Fetches all the settings for an entire list of solutions. - * - * @param {Object} solutionsToFetch - A keyed object of solutions using the same format as the solutions registry. Keys - * are solutionsIDs, like `com.freedomscientific.jaws` and the entries are the full solution registry entries. - * @param {lifecycleManager.invokeSettingsHandlerGet} invokeSettingsHandlerGet - Invoker from the `lifecycleManager` - * necessary for extracting settings from a solution and it's spec. - * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications - * @return {Array} Returns a list of promises that resolve to captured settings for each particular settings handler in - * every solution. - */ -gpii.flowManager.capture.fetchAllSettingsForSolutionsList = function (solutionsToFetch, invokeSettingsHandlerGet, resolver) { - var handlerGetPromises = fluid.transform(solutionsToFetch, function (solution, solutionID) { - return gpii.flowManager.capture.fetchAllSettingsForSolution(invokeSettingsHandlerGet, solution, solutionID, resolver); - }); - - return fluid.promise.sequence(fluid.flatten(handlerGetPromises)); -}; - /** * Runs through all the solutions currently available on the system, pulls the current * setting for each supportedSetting and returns them in an object. Primary use case * is for backing Capture tools that would allow a user to set up their GPII profile * starting with the current settings for their applications on the local machine. * - * @param {lifecycleManager.invokeSettingsHandlerGet} invokeSettingsHandlerGet - Invoker from the `lifecycleManager` - * necessary for extracting settings from a solution and it's spec. - * @param {lifecycleManager.variableResolver} resolver - Resolver for looking up handler specifications + * @param {gpii.lifecycleManager} lifecycleManager - Instance of the local machine lifecycle manager. * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. * @param {Object} options - Extra options for processing. * @param {Array} options.solutionsList - If provided, only solutions in this list of `solutionsID`s will @@ -194,7 +143,7 @@ gpii.flowManager.capture.fetchAllSettingsForSolutionsList = function (solutionsT * ''' * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. */ -gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, resolver, solutions, options) { +gpii.flowManager.captureSystemSettings = function (lifecycleManager, solutions, options) { var solutionsToFetch = fluid.copy(solutions); if (options.solutionsList) { fluid.remove_if(solutionsToFetch, function (solution, solutionID) { @@ -202,7 +151,7 @@ gpii.flowManager.captureSystemSettings = function (invokeSettingsHandlerGet, res }); } - return gpii.flowManager.capture.fetchAllSettingsForSolutionsList(solutionsToFetch, invokeSettingsHandlerGet, resolver); + return lifecycleManager.processRead(solutionsToFetch); }; /** From 382c51fac204270a2f69e0143ad0549e1cb571c5 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Tue, 28 Jan 2020 13:01:43 -0800 Subject: [PATCH 41/47] GPII-228 Scoping argument to lifecycleManager.read invoker --- gpii/node_modules/flowManager/src/Capture.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 3052a9330..2cf31db6c 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -64,7 +64,7 @@ fluid.defaults("gpii.flowManager.capture", { }, captureSystemSettings: { funcName: "gpii.flowManager.captureSystemSettings", - args: ["{lifecycleManager}", "{arguments}.0", "{arguments}.1"] // solutionsRegistryEntries, options + args: ["{lifecycleManager}.read", "{arguments}.0", "{arguments}.1"] // solutionsRegistryEntries, options } } }); @@ -132,7 +132,9 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so * is for backing Capture tools that would allow a user to set up their GPII profile * starting with the current settings for their applications on the local machine. * - * @param {gpii.lifecycleManager} lifecycleManager - Instance of the local machine lifecycle manager. + * @param {Function|gpii.lifecycleManager.read} readSettingsFunc - lifecycleManager.read (or suitable implementation), + * that takes solution registry entries, reads their current values on the device, and returns a promise resolved to + * them. * @param {Object} solutions - Solutions registry entries for solutions available on the current machine. * @param {Object} options - Extra options for processing. * @param {Array} options.solutionsList - If provided, only solutions in this list of `solutionsID`s will @@ -143,7 +145,7 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so * ''' * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. */ -gpii.flowManager.captureSystemSettings = function (lifecycleManager, solutions, options) { +gpii.flowManager.captureSystemSettings = function (readSettingsFunc, solutions, options) { var solutionsToFetch = fluid.copy(solutions); if (options.solutionsList) { fluid.remove_if(solutionsToFetch, function (solution, solutionID) { @@ -151,7 +153,7 @@ gpii.flowManager.captureSystemSettings = function (lifecycleManager, solutions, }); } - return lifecycleManager.processRead(solutionsToFetch); + return readSettingsFunc(solutionsToFetch); }; /** From 41b100d71beef681afae6a7d79014b23424735a1 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Wed, 29 Jan 2020 15:08:31 -0800 Subject: [PATCH 42/47] GPII-228 Fixing tests (OS reported) for CI Pipeline (and running on linux/windows) --- .../node_modules/flowManager/test/CaptureTests.js | 8 +++++++- ...lowManager.tests.capture.fakeData.config.json5 | 15 +++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index de72bddd3..c7c57ed0e 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -40,8 +40,14 @@ gpii.tests.flowManager.capture.checkForFakeMags = function (payload) { }); }; +gpii.tests.flowManager.capture.platformReporter = function () { + return { + id: "darwin" + }; +}; + gpii.tests.flowManager.capture.checkForInstalledMags = function (payload) { - jqUnit.assertEquals("There should be 2 solutions installed", Object.keys(payload).length, 2); + jqUnit.assertEquals("There should be 2 solutions installed", 2, Object.keys(payload).length); jqUnit.assertEquals("Check for Fake Mag 1", payload.fakemag1.name, "Fake Magnifier 1"); jqUnit.assertEquals("Check for Fake Mag 2", payload.fakemag2.name, "Fake Magnifier 2 - fully featured"); }; diff --git a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 index 8e61377c1..cc6b605a5 100644 --- a/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 +++ b/gpii/node_modules/flowManager/test/configs/gpii.flowManager.tests.capture.fakeData.config.json5 @@ -6,15 +6,22 @@ "type": "gpii.flowManager.tests.capture.fakeData.config", "options": { "distributeOptions": { + "capture.solutionsRegistry": { + "record": "%gpii-universal/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json", + "target": "{that flowManager solutionsRegistryDataSource}.options.path", + "priority": "after:flowManager.solutions" + }, "capture.deviceReporter": { "record": "%gpii-universal/gpii/node_modules/flowManager/test/data/capture_deviceReporter.json", "target": "{that deviceReporter installedSolutionsDataSource}.options.path", "priority": "after:development.installedSolutionsPath" }, - "capture.solutionsRegistry": { - "record": "%gpii-universal/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json", - "target": "{that flowManager solutionsRegistryDataSource}.options.path", - "priority": "after:flowManager.solutions" + "capture.deviceReporterOS": { + "record": { + "funcName": "gpii.tests.flowManager.capture.platformReporter" + }, + "target": "{that deviceReporter platformReporter}.options.invokers.reportPlatform", + "priority": "after:development.installedSolutionsPath" } } }, From 53ae90877b3f2f92f611d4149782d7f035305841 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Thu, 6 Feb 2020 05:04:27 -0800 Subject: [PATCH 43/47] GPII-228 Updates from review - Updated method name packages - Updated license header - Removed unused code - Converted single line methods to invoker definitions - Used fluid.get for property access --- gpii/node_modules/flowManager/src/Capture.js | 77 +++++-------------- .../flowManager/test/CaptureTests.js | 4 +- 2 files changed, 22 insertions(+), 59 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 2cf31db6c..8d0cc50f3 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -1,7 +1,7 @@ /** - * GPII snapshot Handler + * GPII Capture Component * - * Copyright 2014 Raising the Floor - International + * Copyright 2020 Raising the Floor - International * * Licensed under the New BSD license. You may not use this file except in * compliance with this License. @@ -26,7 +26,8 @@ fluid.defaults("gpii.flowManager.capture", { // Begin declaration of Promise Chain for onSolutionsForCurrentDevice "onSolutionsForCurrentDevice.getDeviceContextPromise": { funcName: "gpii.lifecycleManager.getDeviceContextPromise", - args: ["{flowManager}.deviceReporter"] + args: ["{flowManager}.deviceReporter"], + priority: "first" }, "onSolutionsForCurrentDevice.getSolutionsPromise": { funcName: "gpii.flowManager.getSolutionsPromise", @@ -40,7 +41,8 @@ fluid.defaults("gpii.flowManager.capture", { }, // Begin declaration of Promise Chain for onCaptureSettingsForCurrentDevice "onCaptureSettingsForCurrentDevice.getInstalledSolutionsForCurrentDevice": { - func: "{that}.getInstalledSolutionsForCurrentDevice" + func: "{that}.getInstalledSolutionsForCurrentDevice", + priority: "first" }, "onCaptureSettingsForCurrentDevice.captureSystemSettings": { func: "{that}.captureSystemSettings", @@ -48,32 +50,33 @@ fluid.defaults("gpii.flowManager.capture", { priority: "after:getInstalledSolutionsForCurrentDevice" }, "onCaptureSettingsForCurrentDevice.formatRawCapturedSettings": { - func: "gpii.flowManager.formatRawCapturedSettings", + func: "gpii.flowManager.capture.formatRawCapturedSettings", args: ["{arguments}.0"], priority: "after:captureSystemSettings" } }, invokers: { getInstalledSolutionsForCurrentDevice: { - funcName: "gpii.flowManager.getInstalledSolutionsForCurrentDevice", - args: ["{that}"] + funcName: "fluid.promise.fireTransformEvent", + args: ["{that}.events.onSolutionsForCurrentDevice"] }, getSystemSettingsCapture: { - funcName: "gpii.flowManager.getSystemSettingsCapture", - args: ["{that}.events.onCaptureSettingsForCurrentDevice", "{arguments}.0"] // options + funcName: "fluid.promise.fireTransformEvent", + args: ["{that}.events.onCaptureSettingsForCurrentDevice", {}, "{arguments}.0"] // options }, captureSystemSettings: { - funcName: "gpii.flowManager.captureSystemSettings", + funcName: "gpii.flowManager.capture.captureSystemSettings", args: ["{lifecycleManager}.read", "{arguments}.0", "{arguments}.1"] // solutionsRegistryEntries, options } } }); -gpii.flowManager.getInstalledSolutionsForCurrentDevice = function (that) { - return fluid.promise.fireTransformEvent(that.events.onSolutionsForCurrentDevice); -}; - /** + * Invoker `{gpii.flowManager.capture}.getSystemSettingsCapture` + * + * @function + * @name {gpii.flowManager.capture}.getSystemSettingsCapture + * * This main API entry point for capturing settings from a system or computer. This captures * the actual settings on the device, so it assumed to be running in a local untrusted flow * manager. @@ -85,46 +88,6 @@ gpii.flowManager.getInstalledSolutionsForCurrentDevice = function (that) { * returned. ex: `["com.microsoft.windows.mouseSettings", "com.freedomscientific.jaws"]`. * @return {Promise} A promise resolved with the payload of captured system settings. */ -gpii.flowManager.getSystemSettingsCapture = function (onCaptureSettingsForCurrentDevice, options) { - return fluid.promise.fireTransformEvent(onCaptureSettingsForCurrentDevice, - {}, options); -}; - -/** - * This function invokers a settings handler to fetch settings, but wraps the processing and reports - * back any failures in an `isError: true` json block. - * - * @param {Function} invokeSettingsHandlerGet - The get function from the appropriate settings handler. - * @param {String} solutionID - The dotted solution id, ex `com.freedomscientific.jaws` - * @param {Object} handlerSpec - TODO, exactly how much of the solutions entry block is this? - * @return {Object} The returned settings, or an error block with debugging information. - */ -gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, solutionID, handlerSpec) { - var promiseTogo = fluid.promise(); - try { - invokeSettingsHandlerGet(solutionID, handlerSpec).then(function (data) { - promiseTogo.resolve(data); - }, function (err) { - promiseTogo.resolve({ - solutionId: solutionID, - handlerSpec: handlerSpec, - isError: true, - message: "Capture Workflow Error: Settings Handler Promise Rejection", - err: err - }); - }); - } - catch (err) { - promiseTogo.resolve({ - solutionId: solutionID, - handlerSpec: handlerSpec, - isError: true, - message: "Capture Workflow Error: Unexpected Error in operating settings handler.", - err: err - }); - } - return promiseTogo; -}; /** * Runs through all the solutions currently available on the system, pulls the current @@ -145,7 +108,7 @@ gpii.flowManager.capture.safeHandlerGet = function (invokeSettingsHandlerGet, so * ''' * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. */ -gpii.flowManager.captureSystemSettings = function (readSettingsFunc, solutions, options) { +gpii.flowManager.capture.captureSystemSettings = function (readSettingsFunc, solutions, options) { var solutionsToFetch = fluid.copy(solutions); if (options.solutionsList) { fluid.remove_if(solutionsToFetch, function (solution, solutionID) { @@ -209,7 +172,7 @@ gpii.flowManager.captureSystemSettings = function (readSettingsFunc, solutions, * @return {Object} Returns a new payload with collapsed data, and multiple settings handler * results for the same solution merged together. */ -gpii.flowManager.formatRawCapturedSettings = function (data) { +gpii.flowManager.capture.formatRawCapturedSettings = function (data) { var togo = {}; fluid.each(data, function (sequenceItem) { if (sequenceItem.isError) { @@ -220,7 +183,7 @@ gpii.flowManager.formatRawCapturedSettings = function (data) { if (!togo[key]) { togo[key] = {}; } - fluid.each(item[0].settings, function (value, settingId) { + fluid.each(fluid.get(item, "0.settings"), function (value, settingId) { togo[key][settingId] = value; }); }); diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index c7c57ed0e..d2c21e9c9 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -114,7 +114,7 @@ fluid.test.runTests([ * Tests for formatting raw captures. */ gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () { - var allCorrectSettings = gpii.flowManager.formatRawCapturedSettings([ + var allCorrectSettings = gpii.flowManager.capture.formatRawCapturedSettings([ { "fakemag1": [ { @@ -156,7 +156,7 @@ gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () { } }); - var someErrorsSettings = gpii.flowManager.formatRawCapturedSettings([ + var someErrorsSettings = gpii.flowManager.capture.formatRawCapturedSettings([ { "fakemag1": [ { From b71918f2094f2f383866a70482fc38ef020705a7 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Thu, 6 Feb 2020 05:22:05 -0800 Subject: [PATCH 44/47] GPII-228 Combined gpii.flowManager getSolutions and getSolutionsPromise --- gpii/node_modules/flowManager/src/Capture.js | 6 ++-- .../flowManager/src/MatchMaking.js | 32 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index 8d0cc50f3..fd5b63c73 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -29,15 +29,15 @@ fluid.defaults("gpii.flowManager.capture", { args: ["{flowManager}.deviceReporter"], priority: "first" }, - "onSolutionsForCurrentDevice.getSolutionsPromise": { - funcName: "gpii.flowManager.getSolutionsPromise", + "onSolutionsForCurrentDevice.getSolutions": { + funcName: "gpii.flowManager.getSolutions", args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"], priority: "after:getDeviceContextPromise" }, "onSolutionsForCurrentDevice.solutionsRegistryEntriesToPromise": { funcName: "fluid.toPromise", args: ["{arguments}.0.solutionsRegistryEntries"], - priority: "after:getSolutionsPromise" + priority: "after:getSolutions" }, // Begin declaration of Promise Chain for onCaptureSettingsForCurrentDevice "onCaptureSettingsForCurrentDevice.getInstalledSolutionsForCurrentDevice": { diff --git a/gpii/node_modules/flowManager/src/MatchMaking.js b/gpii/node_modules/flowManager/src/MatchMaking.js index 23e2fcb3c..90bcebf1b 100644 --- a/gpii/node_modules/flowManager/src/MatchMaking.js +++ b/gpii/node_modules/flowManager/src/MatchMaking.js @@ -78,29 +78,23 @@ }; /* - * Asynchronous function which makes a get call to the solutions registry (1st parameter) to + * Asynchronous/Promise returning function which makes a get call to the solutions registry (1st parameter) to * retrieve the solutions registry matching what is passed in the `device` parameter. * This is appended to the matchmaker payload (mmpayload) parameter, which in turn is passed * as parameter in the event fired. * + * This function can be used with either (or both) asyncronously with an `event` and `onError` handlers + * passed in, or with the returned `fluid.promise`. + * * @solutionsRegistryDataSource (Object) - a solutions registry data source * @deviceContext (Object) - output from a device reporter. Used to filter solutions registry entries - * @event (Object) - Event to be fired when the solutionsRegistry entry has been retrieved - * @onError (Object) - Event to be fired when an error occurs + * @event (Object) - Optional: Event to be fired when the solutionsRegistry entry has been retrieved + * @onError (Object) - Optional: Event to be fired when an error occurs * - * @return (undefined) - function is asynchronous and doesn't return anything. Instead the event - * is fired with the modified mmpayload. + * @return (fluid.promise) - Returns a promise resolving with the mmpayload . Optionally if provided, the events + * are also fired with the modified mmpayload. */ gpii.flowManager.getSolutions = function (solutionsRegistryDataSource, deviceContext, event, onError) { - gpii.flowManager.getSolutionsPromise(solutionsRegistryDataSource, deviceContext).then( - function (data) { - event.fire(data.solutionsRegistryEntries, data.solutions); - }, - onError.fire - ); - }; - - gpii.flowManager.getSolutionsPromise = function (solutionsRegistryDataSource, deviceContext) { var promiseTogo = fluid.promise(); var os = fluid.get(deviceContext, "OS.id"); @@ -112,7 +106,15 @@ solutionsRegistryEntries: solutionsRegistryEntries, solutions: solutions }); - }, promiseTogo.reject); + if (event) { + event.fire(solutionsRegistryEntries, solutions); + } + }, function (error) { + promiseTogo.reject(error); + if (onError) { + onError.fire(error); + } + }); return promiseTogo; }; From 97b5f8219bf2392f5bfd27acba6af58d0fbefbb8 Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Thu, 6 Feb 2020 13:12:52 -0800 Subject: [PATCH 45/47] GPII-228 Updates from Review - Updated jsdoc formatting - Updated event names - Restructured tests and added more --- .../flowManager/src/MatchMaking.js | 23 +-- .../flowManager/test/CaptureTests.js | 191 ++++++++++-------- 2 files changed, 120 insertions(+), 94 deletions(-) diff --git a/gpii/node_modules/flowManager/src/MatchMaking.js b/gpii/node_modules/flowManager/src/MatchMaking.js index 90bcebf1b..f805484db 100644 --- a/gpii/node_modules/flowManager/src/MatchMaking.js +++ b/gpii/node_modules/flowManager/src/MatchMaking.js @@ -77,7 +77,7 @@ }); }; - /* + /** * Asynchronous/Promise returning function which makes a get call to the solutions registry (1st parameter) to * retrieve the solutions registry matching what is passed in the `device` parameter. * This is appended to the matchmaker payload (mmpayload) parameter, which in turn is passed @@ -86,15 +86,14 @@ * This function can be used with either (or both) asyncronously with an `event` and `onError` handlers * passed in, or with the returned `fluid.promise`. * - * @solutionsRegistryDataSource (Object) - a solutions registry data source - * @deviceContext (Object) - output from a device reporter. Used to filter solutions registry entries - * @event (Object) - Optional: Event to be fired when the solutionsRegistry entry has been retrieved - * @onError (Object) - Optional: Event to be fired when an error occurs - * - * @return (fluid.promise) - Returns a promise resolving with the mmpayload . Optionally if provided, the events + * @param {Object} solutionsRegistryDataSource - a solutions registry data source + * @param {Object} deviceContext - output from a device reporter. Used to filter solutions registry entries + * @param {Object} onSuccessEvent - Optional: Event to be fired when the solutionsRegistry entry has been retrieved + * @param {Object} onErrorEvent - Optional: Event to be fired when an error occurs + * @return {fluid.promise} - Returns a promise resolving with the mmpayload. Optionally if provided, the events * are also fired with the modified mmpayload. */ - gpii.flowManager.getSolutions = function (solutionsRegistryDataSource, deviceContext, event, onError) { + gpii.flowManager.getSolutions = function (solutionsRegistryDataSource, deviceContext, onSuccessEvent, onErrorEvent) { var promiseTogo = fluid.promise(); var os = fluid.get(deviceContext, "OS.id"); @@ -106,13 +105,13 @@ solutionsRegistryEntries: solutionsRegistryEntries, solutions: solutions }); - if (event) { - event.fire(solutionsRegistryEntries, solutions); + if (onSuccessEvent) { + onSuccessEvent.fire(solutionsRegistryEntries, solutions); } }, function (error) { promiseTogo.reject(error); - if (onError) { - onError.fire(error); + if (onErrorEvent) { + onErrorEvent.fire(error); } }); diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index d2c21e9c9..8d61e761b 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -29,15 +29,15 @@ kettle.config.createDefaults({ }); gpii.tests.flowManager.capture.checkForFakeMags = function (payload) { - jqUnit.assertDeepEq("FakeMag1 with multiple settings handlers", payload.fakemag1, { + jqUnit.assertDeepEq("FakeMag1 with multiple settings handlers", { "magnification": 2, "invert": true - }); + }, payload.fakemag1); - jqUnit.assertDeepEq("FakeMag2 with single settings handler", payload.fakemag2, { + jqUnit.assertDeepEq("FakeMag2 with single settings handler", { "magnification": 2, "invert": true - }); + }, payload.fakemag2); }; gpii.tests.flowManager.capture.platformReporter = function () { @@ -48,8 +48,8 @@ gpii.tests.flowManager.capture.platformReporter = function () { gpii.tests.flowManager.capture.checkForInstalledMags = function (payload) { jqUnit.assertEquals("There should be 2 solutions installed", 2, Object.keys(payload).length); - jqUnit.assertEquals("Check for Fake Mag 1", payload.fakemag1.name, "Fake Magnifier 1"); - jqUnit.assertEquals("Check for Fake Mag 2", payload.fakemag2.name, "Fake Magnifier 2 - fully featured"); + jqUnit.assertEquals("Check for Fake Mag 1", "Fake Magnifier 1", payload.fakemag1.name); + jqUnit.assertEquals("Check for Fake Mag 2", "Fake Magnifier 2 - fully featured", payload.fakemag2.name); }; gpii.tests.flowManager.capture.adjustSolutions = function (solutionsRegistryDataSource) { @@ -113,94 +113,121 @@ fluid.test.runTests([ /* * Tests for formatting raw captures. */ -gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () { - var allCorrectSettings = gpii.flowManager.capture.formatRawCapturedSettings([ - { - "fakemag1": [ - { - "settings": { - "magnification": 2 +gpii.tests.flowManager.capture.formatRawCapturedSettingsTestCases = { + emptyInput: { + message: "Empy Input should produce an empty object", + input: [], + expected: {} + }, + allCorrectSettings: { + message: "There should be 2 solutions each with 2 settings from the all correct payload", + input: [ + { + "fakemag1": [ + { + "settings": { + "magnification": 3 + } } - } - ] - }, - { - "fakemag1": [ - { - "settings": { - "invert": true + ] + }, + { + "fakemag1": [ + { + "settings": { + "invert": false + } } - } - ] - }, - { - "fakemag2": [ - { - "settings": { - "magnification": 2, - "invert": true + ] + }, + { + "fakemag2": [ + { + "settings": { + "magnification": 2, + "invert": true + } } - } - ] - } - ]); - jqUnit.assertDeepEq("There should be 2 solutions each with 2 settings from the all correct payload", - allCorrectSettings, { + ] + } + ], + expected: { "fakemag1": { - "magnification": 2, - "invert": true + "magnification": 3, + "invert": false }, "fakemag2": { "magnification": 2, "invert": true } - }); - - var someErrorsSettings = gpii.flowManager.capture.formatRawCapturedSettings([ - { - "fakemag1": [ - { - "settings": { - "magnification": 2 + } + }, + someErrorsSettings: { + message: "There should still be 2 solutions each with 2 settings from the all payload that contained an error in addition to correct entries.", + input: [ + { + "fakemag1": [ + { + "settings": { + "bouncedelay": 2 + } } - } - ] - }, - { - "fakemag1": [ - { - "settings": { - "invert": true + ] + }, + { + "fakemag1": [ + { + "settings": { + "invert": true + } } - } - ] - }, - { - isError: true, - msg: "This didn't work properly during capture" - }, - { - "fakemag2": [ - { - "settings": { - "magnification": 2, - "invert": true + ] + }, + { + isError: true, + msg: "This didn't work properly during capture" + }, + { + "fakemag2": [ + { + "settings": { + "magnification": 5, + "invert": false + } } - } - ] - } - ]); - jqUnit.assertDeepEq("There should still be 2 solutions each with 2 settings from the all payload that contained an error in addition to correct entries.", - someErrorsSettings, { - "fakemag1": { - "magnification": 2, - "invert": true - }, - "fakemag2": { - "magnification": 2, - "invert": true + ] + } + ], + expected: { + "fakemag1": { + "bouncedelay": 2, + "invert": true + }, + "fakemag2": { + "magnification": 5, + "invert": false + } } - }); + }, + allErrorsSettings: { + message: "Settings with just errors should yield an empty object", + input: [ + { + isError: true, + msg: "This didn't work properly during capture" + }, + { + isError: true, + msg: "This is another error apparently" + } + ], + expected: {} + } }; -jqUnit.test("Test Raw Settings Formatting", gpii.tests.flowManager.capture.testFormatRawCapturedSettings); +jqUnit.test("Test Raw Settings Formatting", function () { + fluid.each(gpii.tests.flowManager.capture.formatRawCapturedSettingsTestCases, function (nextTest) { + var result = gpii.flowManager.capture.formatRawCapturedSettings(nextTest.input); + jqUnit.assertDeepEq(nextTest.message, nextTest.expected, result); + }); +}); From 5c985d047d85dafdb5de366ece9db41372d7e32b Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Thu, 6 Feb 2020 13:40:05 -0800 Subject: [PATCH 46/47] GPII-228 Diversifying test data --- gpii/node_modules/flowManager/test/CaptureTests.js | 8 +++++--- .../test/data/capture_fakemag2_settings.json | 5 +++++ .../test/data/capture_solutionsRegistry.json | 13 +++++++++++-- 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json diff --git a/gpii/node_modules/flowManager/test/CaptureTests.js b/gpii/node_modules/flowManager/test/CaptureTests.js index 8d61e761b..9d5147617 100644 --- a/gpii/node_modules/flowManager/test/CaptureTests.js +++ b/gpii/node_modules/flowManager/test/CaptureTests.js @@ -35,8 +35,9 @@ gpii.tests.flowManager.capture.checkForFakeMags = function (payload) { }, payload.fakemag1); jqUnit.assertDeepEq("FakeMag2 with single settings handler", { - "magnification": 2, - "invert": true + "invert": 1, + "magnification": 4.5, + "location": "topRight" }, payload.fakemag2); }; @@ -54,10 +55,11 @@ gpii.tests.flowManager.capture.checkForInstalledMags = function (payload) { gpii.tests.flowManager.capture.adjustSolutions = function (solutionsRegistryDataSource) { var testDataFile = __dirname + "/data/capture_fakemag_settings.json"; + var testDataFile2 = __dirname + "/data/capture_fakemag2_settings.json"; // The solutions block is a read only data structure var adjustedSolutions = fluid.copy(solutionsRegistryDataSource.fullSolutionsRegistry); - adjustedSolutions.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile; + adjustedSolutions.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile2; adjustedSolutions.darwin.fakemag1.settingsHandlers.configuration.options.filename = testDataFile; adjustedSolutions.darwin.fakemag1.settingsHandlers.configuration1.options.filename = testDataFile; solutionsRegistryDataSource.fullSolutionsRegistry = adjustedSolutions; diff --git a/gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json b/gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json new file mode 100644 index 000000000..a3c3735d9 --- /dev/null +++ b/gpii/node_modules/flowManager/test/data/capture_fakemag2_settings.json @@ -0,0 +1,5 @@ +{ + "invert": 1, + "magnification": 4.5, + "location": "topRight" +} diff --git a/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json b/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json index 6e2db46da..ad190cd29 100644 --- a/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json +++ b/gpii/node_modules/flowManager/test/data/capture_solutionsRegistry.json @@ -90,7 +90,8 @@ }, "capabilitiesTransformations": { "magnification": "http://registry\\.gpii\\.net/common/magnification", - "invert": "http://registry\\.gpii\\.net/common/invertColours" + "invert": "http://registry\\.gpii\\.net/common/invertColours", + "location": "http://registry\\.gpii\\.net/common/magnifierLocation" }, "supportedSettings": { "magnification": { @@ -105,7 +106,15 @@ "schema": { "title": "Invert Colours", "description": "Enable colour inversion for Magnifier", - "type": "boolean" + "type": "integer", + "default": 0 + } + }, + "location": { + "schema": { + "title": "Magnifier Location", + "description": "Magnifier location on screen", + "type": "string" } } } From 38340827d0569f528d282f06da96a0723a3cc12b Mon Sep 17 00:00:00 2001 From: Steven Githens Date: Fri, 7 Feb 2020 10:47:37 -0800 Subject: [PATCH 47/47] GPII-228 Minor refactoring of promise chains, documenting invokers --- gpii/node_modules/flowManager/src/Capture.js | 28 +++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/gpii/node_modules/flowManager/src/Capture.js b/gpii/node_modules/flowManager/src/Capture.js index fd5b63c73..8332f724c 100755 --- a/gpii/node_modules/flowManager/src/Capture.js +++ b/gpii/node_modules/flowManager/src/Capture.js @@ -45,8 +45,8 @@ fluid.defaults("gpii.flowManager.capture", { priority: "first" }, "onCaptureSettingsForCurrentDevice.captureSystemSettings": { - func: "{that}.captureSystemSettings", - args: ["{arguments}.0", "{arguments}.1"], + funcName: "gpii.flowManager.capture.captureSystemSettings", + args: ["{lifecycleManager}.read", "{arguments}.0", "{arguments}.1"], // solutionsRegistryEntries, options priority: "after:getInstalledSolutionsForCurrentDevice" }, "onCaptureSettingsForCurrentDevice.formatRawCapturedSettings": { @@ -62,26 +62,34 @@ fluid.defaults("gpii.flowManager.capture", { }, getSystemSettingsCapture: { funcName: "fluid.promise.fireTransformEvent", - args: ["{that}.events.onCaptureSettingsForCurrentDevice", {}, "{arguments}.0"] // options - }, - captureSystemSettings: { - funcName: "gpii.flowManager.capture.captureSystemSettings", - args: ["{lifecycleManager}.read", "{arguments}.0", "{arguments}.1"] // solutionsRegistryEntries, options + args: ["{that}.events.onCaptureSettingsForCurrentDevice", null, "{arguments}.0"] // options } } }); +/** + * Invoker `{gpii.flowManager.capture}.getInstalledSolutionsForCurrentDevice` + * + * @method + * @name {gpii.flowManager.capture}.getInstalledSolutionsForCurrentDevice + * + * This invoker method will return the solution registry entries, in their usual json format, + * that are available on the current device. + * + * @return {Promise} A promise resolved with an object of solutions registry entries available on the + * current device. As with the solutions registry itself, these are keyed by the solution ID. + */ + /** * Invoker `{gpii.flowManager.capture}.getSystemSettingsCapture` * - * @function + * @method * @name {gpii.flowManager.capture}.getSystemSettingsCapture * * This main API entry point for capturing settings from a system or computer. This captures * the actual settings on the device, so it assumed to be running in a local untrusted flow * manager. * - * @param {Event} onCaptureSettingsForCurrentDevice - The transforming promise chain * @param {Object} options - Options for this chain. * @param {Array} options.solutionsList - An array of solution IDs to filter by when * retreiving settings. If this option is not included, all available settings will be @@ -183,7 +191,7 @@ gpii.flowManager.capture.formatRawCapturedSettings = function (data) { if (!togo[key]) { togo[key] = {}; } - fluid.each(fluid.get(item, "0.settings"), function (value, settingId) { + fluid.each(fluid.get(item, [0, "settings"]), function (value, settingId) { togo[key][settingId] = value; }); });