diff --git a/build.sh b/build.sh index 97ce9b0..f5b7003 100755 --- a/build.sh +++ b/build.sh @@ -32,7 +32,7 @@ if [ -d $universal ]; then else echo "$universal does not exist" echo "cloning universal" - git clone "$repoURL" "$universal" + git clone "$repoURL" -b pilot "$universal" cd $universal npm install cd $currentDir diff --git a/gpii.js b/gpii.js index 4280439..306770f 100644 --- a/gpii.js +++ b/gpii.js @@ -14,8 +14,9 @@ var fluid = require("universal"), gpii = fluid.registerNamespace("gpii"); fluid.require("gsettingsBridge", require); +fluid.require("orca", require); gpii.config.makeConfigLoader({ nodeEnv: gpii.config.getNodeEnv("fm.ps.sr.dr.mm.os.development"), configPath: gpii.config.getConfigPath() || "../node_modules/universal/gpii/configs" -}); \ No newline at end of file +}); diff --git a/node_modules/orca/index.js b/node_modules/orca/index.js new file mode 100644 index 0000000..d2dfff4 --- /dev/null +++ b/node_modules/orca/index.js @@ -0,0 +1,18 @@ +/*! + * GPII Orca Settings Handler + * + * Copyright 2013 Emergya + * Author Javier Hernández + * + * 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 + * */ + +var fluid = require("universal"); + +var loader = fluid.getLoader(__dirname); + +loader.require("./orcaSettingsHandler.js"); diff --git a/node_modules/orca/orcaSettingsHandler.js b/node_modules/orca/orcaSettingsHandler.js new file mode 100644 index 0000000..b1426b1 --- /dev/null +++ b/node_modules/orca/orcaSettingsHandler.js @@ -0,0 +1,136 @@ +/*! + * GPII Orca Settings Handler + * + * Copyright 2013 Emergya + * Author Javier Hernández + * + * 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 + * */ + +(function () { + "use strict"; + + var fluid = require("universal"); + var gpii = fluid.registerNamespace("gpii"); + var fs = require("fs"); + var spawn = require("child_process").spawn; + + // TODO: When FLUID-4852 is fixed, remove these definitions + var getParser = { + parser: { + parse: fluid.pathUtil.parseEL, + compose: fluid.pathUtil.composePath + }, + strategies: [fluid.model.defaultFetchStrategy] + }; + + var setParser = { + parser: { + parse: fluid.pathUtil.parseEL, + compose: fluid.pathUtil.composePath + }, + strategies: [fluid.model.defaultFetchStrategy, fluid.model.defaultCreatorStrategy] + }; + + var ORCA_ARGS = ["--disable", "speech", + "--disable", "braille", + "--disable", "braille-monitor", + "--disable", "main-window", + "--disable", "splash-window"]; + + var HOME = process.env.HOME; + var XDG_DATA_HOME = process.env.XDG_DATA_HOME || HOME + "/.local/share"; + var orcaSettingsFile = XDG_DATA_HOME + "/orca/user-settings.conf"; + + fluid.registerNamespace("gpii.launch"); + + gpii.orca = gpii.orca || {}; + + function wait(millis) { + var date = new Date(); + var curDate = null; + + do { curDate = new Date(); } + while(curDate-date < millis); + } + + function getJSONFromFile(file) { + return JSON.parse(fs.readFileSync(file, "utf8")); + } + + gpii.orca.set = function(settingsarray) { + var app = fluid.copy(settingsarray); + + var settings = app["org.gnome.orca"][0].settings; + var options = app["org.gnome.orca"][0].options; + var user = options.user; + var newSettingsResponse = {}; + + if (!fs.existsSync(orcaSettingsFile)) { + var orcaSpawn = spawn("orca", ORCA_ARGS); + + while(!fs.existsSync(orcaSettingsFile)) { + wait(500); + }; + + orcaSpawn.kill("SIGKILL"); + }; + + var userSettings = getJSONFromFile(orcaSettingsFile); + var defaultProfiles = fluid.copy(userSettings.profiles); + var defaultStartingProfile = fluid.copy(userSettings.general.startingProfile); + var customizedProfile = fluid.copy(userSettings.general); + + if ("profiles" in settings) { + // Then, we're running restoreSettings + // + userSettings.profiles = settings["profiles"]; + userSettings.general.startingProfile = settings["general.startingProfile"]; + } else { + // We're running setSettings + // + fluid.log("orcaSettingsHandler: User ", user, + " has requested these following settings: ", settings); + + // Apply settings + // + for (var k in settings) { + fluid.set(customizedProfile, k, settings[k], setParser); + } + + // Set profile id + // + customizedProfile.profile = customizedProfile.activeProfile = + customizedProfile.startingProfile = + [user, user]; + + userSettings.profiles[user] = customizedProfile; + userSettings.general.startingProfile = [user, user]; + }; + + // Write config file + // + fs.writeFileSync(orcaSettingsFile, + JSON.stringify(userSettings, null, 4)); + + newSettingsResponse = { + "profiles": { + "oldValue": defaultProfiles, + "newValue": userSettings.profiles + }, + "general.startingProfile": { + "oldValue": defaultStartingProfile, + "newValue": [user, user] + } + }; + + return { 'org.gnome.orca' : [{"options": options, + "settings": newSettingsResponse}] + }; + } + +})(); diff --git a/node_modules/orca/package.json b/node_modules/orca/package.json new file mode 100644 index 0000000..872bcc1 --- /dev/null +++ b/node_modules/orca/package.json @@ -0,0 +1,19 @@ +{ + "name": "orca", + "description": "GPII Orca Settings Handler", + "version": "0.1", + "author": "Javier Hernández", + "bugs": "http://wiki.gpii.net/index.php/Main_Page", + "homepage": "http://gpii.net/", + "dependencies": {}, + "licenses": [ + { + "type": "BSD-3-Clause", + "url": "http://www.opensource.org/licenses/BSD-3-Clause" + } + ], + "keywords": ["gpii", "accessibility", "settings", "fluid"], + "repository": "git://github.com:GPII/linux.git", + "main": "./index.js", + "engines": { "node" : ">=0.1.9" } +} diff --git a/start_RB.sh b/start_RB.sh new file mode 100755 index 0000000..5934f3a --- /dev/null +++ b/start_RB.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# GPII Linux Startup Script +# +# Copyright 2012 OCAD University +# +# 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 + +export NODE_ENV="rule.based.mm.production" + +fileName="gpii.js" + +# Start the Flow Manager +node "$fileName" $1 + +export NODE_ENV="" diff --git a/start_ST.sh b/start_ST.sh new file mode 100755 index 0000000..221170b --- /dev/null +++ b/start_ST.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# GPII Linux Startup Script +# +# Copyright 2012 OCAD University +# +# 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 + +export NODE_ENV="statistical.mm.production" + +fileName="gpii.js" + +# Start the Flow Manager +node "$fileName" $1 + +export NODE_ENV="" diff --git a/usbDriveListener/80-gpii.rules b/usbDriveListener/80-gpii.rules index 790cafd..d4d5289 100644 --- a/usbDriveListener/80-gpii.rules +++ b/usbDriveListener/80-gpii.rules @@ -1,2 +1,2 @@ -KERNEL=="sd[a-z][0-9]", SUBSYSTEM=="block", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/usr/local/gpii/bin/trigger.sh 1 /dev/%k" -KERNEL=="sd[a-z][0-9]", SUBSYSTEM=="block", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="/usr/local/gpii/bin/trigger.sh 0 /dev/%k" +KERNEL=="sd[a-z]", SUBSYSTEM=="block", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/usr/local/gpii/bin/trigger.sh 1 /dev/%k" +KERNEL=="sd[a-z]", SUBSYSTEM=="block", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="/usr/local/gpii/bin/trigger.sh 0 /dev/%k"