/*
* Registry Resolver
*
* Copyright 2012 OCAD University
*
* Licensed under the New BSD license. You may not use this file except in
* compliance with this License.
*
* The research leading to these results has received funding from the European Union's
* Seventh Framework Programme (FP7/2007-2013)
* under grant agreement no. 289016.
*
* You may obtain a copy of the License at
* https://github.com/GPII/universal/blob/master/LICENSE.txt
*/
"use strict";
var fluid = require("universal"),
gpii = fluid.registerNamespace("gpii");
fluid.logObjectRenderChars = 2048;
require("../../registrySettingsHandler/src/RegistrySettingsHandler.js");
/* Registry resolver reads registry key based on the path provided.
* Arguments:
* registryPath {string} - a path into the Windows Registry to be resolved.
*/
gpii.windows.registryResolver = function (registryPath) {
var args = gpii.windows.registryResolver.parseArguments(registryPath);
return gpii.windows.readRegistryKey.apply(null, args).value;
};
/* Parses the path into the registry into an array of arguments taken by gpii.windows.readRegistryKey.
* Arguments:
* value {string} - a path into the Windows Registry to be parsed.
*/
// TODO: support other than String values
gpii.windows.registryResolver.parseArguments = function (value) {
var splitString = value.split("\\");
var subKey = splitString.pop();
var baseKey = splitString.shift();
return [ baseKey, splitString.join("\\"), subKey, "REG_SZ" ];
};
/* Component function definition for looking up if a registry key exists
* in the windows registry. Example usages are in the solutions registry
* json definition where we can add a device reporter entry to check if
* a program is installed by looking to see if it's key(s) is there.
*/
fluid.defaults("gpii.deviceReporter.registryKeyExists", {
gradeNames: "fluid.function",
argumentMap: {
hKey: 0,
path: 1,
subPath: 2,
dataType: 3
}
});
gpii.deviceReporter.registryKeyExists = function (hKey, path, subPath, dataType) {
fluid.log("gpii.deviceReporter.registryKeyExists:" + hKey + " " + path +
" " + subPath + " " + dataType);
var results = gpii.windows.readRegistryKey(hKey, path, subPath, dataType);
return results.statusCode === 200;
};
|