-
Notifications
You must be signed in to change notification settings - Fork 62
GPII-228 Capture Settings Backend (Snapshotter 2018) #616
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
f846454
GPII-228: First steps towards the snapshotter implementation
000b33c
GPII-228: Temporary save while doing other work
e36f564
GPII-228: Things are working now. Requires cleanup and tests
179e705
GPII-228: Cleaned up branch
eb78e33
GPII-228: Fixed a few more errors
04f4e0a
GPII-228: Added linux entries for snapshotting
b45079c
GPII-228 First attempt at merging Kapsers work from 2014
sgithens fa8a2fb
GPII-228 Continuing cleanup and refactoring.
sgithens 526d545
GPII-228 Renaming snapshot to capture.
sgithens 25ac4d4
Merge remote-tracking branch 'gpii/master' into gpii-228-2018
sgithens 4516c89
GPII-228 Finished with first iteration of snapshotter revival
sgithens 1764ef9
GPII-228 Removign some spaces that got removed.
sgithens 2ef4b41
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens 1c05b52
GPII-228 Updating location of getDeviceContext
sgithens 3c55217
Merge remote-tracking branch 'GPII' into gpii-228-2018
sgithens 29a2708
GPII-228 Another round of Capture/Snapshotting prototyping
sgithens f30a253
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens cd8127b
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens eba8606
GPII-228 Reverting to current version of NoSettingsHandler
sgithens 179c7e1
GPII-228 Removing http handler endpoints for capturing.
sgithens b94f137
GPII-228 Minor refactorings and initial tests.
sgithens c727f64
GPII-228 Refactoring event->promise based methods needed for capture
sgithens 4aba301
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens db831bb
GPII-228 Minor change to promise/event signature to match previous args
sgithens f484faf
GPII-228 Initial unit tests, some cleanup
sgithens b79d476
GPII-228 Adding Capture Tests back in
sgithens b26a588
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens 38bea00
GPII-228 Continuing impl work
sgithens 8dec2c5
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens eb54bb8
GPII-228 Tests/impl for solutions with multiple settings handlers
sgithens d594966
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens 0131b23
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens f562fe8
GPII-228 Removing duplicate sequences from installed solutions events.
sgithens 17ce607
GPII-228 Added test for capture.getInstalledSolutions
sgithens ec7cb2f
GPII-228 Removing event based capture in favor of promise based API
sgithens f32a13d
GPII-228 Fixing up jsdoc on captureSystemSettings
sgithens e15f44d
GPII-228 Simplifying invoker name.
sgithens 1b636f7
GPII-4146 GPII-228 Adding adjustments for capturing from JAWS default…
sgithens edd5160
GPII-228 Adding checks and unit tests for error payload that may be i…
sgithens 6b0416d
GPII-228 Temporary workaround for SPI and native windows payloads
sgithens 511e08b
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens adcf338
GPII-228 Refactoring and cleanup
sgithens 0fd86ac
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens 49e4a38
GPII-228 Updating test data adjustments
sgithens dd53284
Merge remote-tracking branch 'GPII/master' into gpii-228-2018
sgithens 3e70229
GPII-228 Removed unused test configuration
sgithens 2017627
GPII-228 Rearranging test runs so simple functions are just called wi…
sgithens 98e56d4
GPII-288 More meaningful messages on errors in operating settings han…
sgithens 2b3f8e9
GPII-228 Cleaning up TODO comments
sgithens caa6508
GPII-228 Refactoring fetch all solutions loop
sgithens 4b167f8
GPII-228 Adding missing jsdocs
sgithens 146119b
GPII-228 cleanup
sgithens 2eb479f
GPII-228 Cleanup
sgithens e710078
GPII-228 Using lifecycle managers now identicle settings read functio…
sgithens 382c51f
GPII-228 Scoping argument to lifecycleManager.read invoker
sgithens 41b100d
GPII-228 Fixing tests (OS reported) for CI Pipeline (and running on l…
sgithens 53ae908
GPII-228 Updates from review
sgithens b71918f
GPII-228 Combined gpii.flowManager getSolutions and getSolutionsPromise
sgithens 97b5f82
GPII-228 Updates from Review
sgithens 5c985d0
GPII-228 Diversifying test data
sgithens 3834082
GPII-228 Minor refactoring of promise chains, documenting invokers
sgithens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,200 @@ | ||
| /** | ||
| * GPII Capture Component | ||
| * | ||
| * Copyright 2020 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"), | ||
| gpii = fluid.registerNamespace("gpii"); | ||
|
|
||
| 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: { | ||
| // Begin declaration of Promise Chain for onSolutionsForCurrentDevice | ||
| "onSolutionsForCurrentDevice.getDeviceContextPromise": { | ||
sgithens marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| funcName: "gpii.lifecycleManager.getDeviceContextPromise", | ||
| args: ["{flowManager}.deviceReporter"], | ||
| priority: "first" | ||
| }, | ||
| "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:getSolutions" | ||
| }, | ||
| // Begin declaration of Promise Chain for onCaptureSettingsForCurrentDevice | ||
| "onCaptureSettingsForCurrentDevice.getInstalledSolutionsForCurrentDevice": { | ||
| func: "{that}.getInstalledSolutionsForCurrentDevice", | ||
| priority: "first" | ||
| }, | ||
| "onCaptureSettingsForCurrentDevice.captureSystemSettings": { | ||
| funcName: "gpii.flowManager.capture.captureSystemSettings", | ||
| args: ["{lifecycleManager}.read", "{arguments}.0", "{arguments}.1"], // solutionsRegistryEntries, options | ||
| priority: "after:getInstalledSolutionsForCurrentDevice" | ||
| }, | ||
| "onCaptureSettingsForCurrentDevice.formatRawCapturedSettings": { | ||
| func: "gpii.flowManager.capture.formatRawCapturedSettings", | ||
| args: ["{arguments}.0"], | ||
| priority: "after:captureSystemSettings" | ||
| } | ||
| }, | ||
| invokers: { | ||
| getInstalledSolutionsForCurrentDevice: { | ||
| funcName: "fluid.promise.fireTransformEvent", | ||
| args: ["{that}.events.onSolutionsForCurrentDevice"] | ||
| }, | ||
| getSystemSettingsCapture: { | ||
| funcName: "fluid.promise.fireTransformEvent", | ||
| 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` | ||
| * | ||
| * @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 {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. | ||
| */ | ||
|
|
||
| /** | ||
| * 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 {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 | ||
| * be captured. Example: | ||
| * | ||
| * '''json | ||
| * ["com.microsoft.windows.cursors", "com.freedomscientific.jaws"] | ||
| * ''' | ||
| * @return {fluid.promise} Returns a promise resolving with the entire system settings capture. | ||
| */ | ||
| gpii.flowManager.capture.captureSystemSettings = function (readSettingsFunc, solutions, options) { | ||
| var solutionsToFetch = fluid.copy(solutions); | ||
| if (options.solutionsList) { | ||
sgithens marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fluid.remove_if(solutionsToFetch, function (solution, solutionID) { | ||
| return !options.solutionsList.includes(solutionID); | ||
| }); | ||
| } | ||
|
|
||
| return readSettingsFunc(solutionsToFetch); | ||
| }; | ||
|
|
||
| /** | ||
| * 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.capture.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(fluid.get(item, [0, "settings"]), function (value, settingId) { | ||
| togo[key][settingId] = value; | ||
| }); | ||
| }); | ||
| }); | ||
| return togo; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.