Difference between revisions of "Settings Handler Payload Examples"

From wiki.gpii
Jump to: navigation, search
(Clarify some settingsHandler semantics - rename "newValue" to "value", rename "PUT" to "SET")
 
Line 4: Line 4:
  
 
The Settings Handler payload is a dictionary keyed by application ID, containing an array of “settings specifications.” Inside each of these, there are two supported keys: <code>settings</code> and <code>options</code>. The settings object contains a set of key/value pairs, which are implementation-specific and represent the settings to be set. The options payload is also implementation-specific, providing a place to specify configuration for the settings handler.
 
The Settings Handler payload is a dictionary keyed by application ID, containing an array of “settings specifications.” Inside each of these, there are two supported keys: <code>settings</code> and <code>options</code>. The settings object contains a set of key/value pairs, which are implementation-specific and represent the settings to be set. The options payload is also implementation-specific, providing a place to specify configuration for the settings handler.
 +
There is a general expectation that the keys hold "."-separated paths into a hierarchical structure, but there is no requirement that this be the case. A settings handler may operate a flat address space for its keys. A settings handler must guarantee to restore the settings that it manages to their original condition, when a payload provided by a previous GET operation (or the "oldValue" set of a SET operation) is provided back to a SET operation.
  
 
Also keep in mind that if you’re doing any of the standard lifecycle actions&mdash;<code>start</code>, <code>stop</code>, <code>setSettings</code>, etc.&mdash;you should be delegating to the Lifecycle Manager to do so for you, rather than directly invoking Settings Handlers.
 
Also keep in mind that if you’re doing any of the standard lifecycle actions&mdash;<code>start</code>, <code>stop</code>, <code>setSettings</code>, etc.&mdash;you should be delegating to the Lifecycle Manager to do so for you, rather than directly invoking Settings Handlers.
Line 104: Line 105:
 
</pre>
 
</pre>
  
==PUT Request==
+
==SET Request==
 
<pre>
 
<pre>
 
     {
 
     {
Line 131: Line 132:
 
</pre>
 
</pre>
  
==PUT Response==
+
==SET Response==
 
<pre>
 
<pre>
 
     {
 
     {
Line 137: Line 138:
 
                 {
 
                 {
 
                 settings: {
 
                 settings: {
"cross-hairs-clip": { "oldValue":  false, "newValue": true },
+
"cross-hairs-clip": { "oldValue":  false, "value": true },
"cross-hairs-color": { "oldValue":  "red", "newValue": "red", statusCode: 500, statusMessage: "Internal Error"},
+
"cross-hairs-color": { "oldValue":  "red", "value": "red", statusCode: 500, statusMessage: "Internal Error"},
"cross-hairs-length": { "oldValue":  20, "newValue": 4096 },
+
"cross-hairs-length": { "oldValue":  20, "value": 4096 },
"cross-hairs-opacity": { "oldValue":  "0.1", "newValue": "0.2" },
+
"cross-hairs-opacity": { "oldValue":  "0.1", "value": "0.2" },
"cross-hairs-thickness": { "oldValue":  "3", "newValue": "10" },
+
"cross-hairs-thickness": { "oldValue":  "3", "value": "10" },
"lens-mode": { "oldValue":  false, "newValue": true },
+
"lens-mode": { "oldValue":  false, "value": true },
"mag-factor": { "oldValue":  "0.4", "newValue": "12.2" },
+
"mag-factor": { "oldValue":  "0.4", "value": "12.2" },
"mouse-tracking": { "oldValue":  "centered", "newValue": "push" },
+
"mouse-tracking": { "oldValue":  "centered", "value": "push" },
"screen-position": { "oldValue":  "none", "newValue": "top-half" },
+
"screen-position": { "oldValue":  "none", "value": "top-half" },
"scroll-at-edges": { "oldValue":  false, "newValue": true },
+
"scroll-at-edges": { "oldValue":  false, "value": true },
"show-cross-hairs": { "oldValue":  true, "newValue": true, statusCode: 400 }
+
"show-cross-hairs": { "oldValue":  true, "value": true, statusCode: 400 }
 
                         }
 
                         }
 
}
 
}
Line 155: Line 156:
  
  
More examples of PUT payloads are available in the tests for settings handlers, e.g.:
+
More examples of SET payloads are available in the tests for settings handlers, e.g.:
 
* [https://github.com/GPII/universal/blob/master/gpii/node_modules/settingsHandlers/test/JSONSettingsHandlerTests.js JSON Settings Handler Tests]
 
* [https://github.com/GPII/universal/blob/master/gpii/node_modules/settingsHandlers/test/JSONSettingsHandlerTests.js JSON Settings Handler Tests]
 
* [https://github.com/GPII/windows/blob/master/gpii/node_modules/registrySettingsHandler/test/testRegistrySettingsHandler.js RegistrySettingsHandler test].  
 
* [https://github.com/GPII/windows/blob/master/gpii/node_modules/registrySettingsHandler/test/testRegistrySettingsHandler.js RegistrySettingsHandler test].  

Latest revision as of 18:41, 29 October 2014

See Example Payloads.

GET Request

The Settings Handler payload is a dictionary keyed by application ID, containing an array of “settings specifications.” Inside each of these, there are two supported keys: settings and options. The settings object contains a set of key/value pairs, which are implementation-specific and represent the settings to be set. The options payload is also implementation-specific, providing a place to specify configuration for the settings handler. There is a general expectation that the keys hold "."-separated paths into a hierarchical structure, but there is no requirement that this be the case. A settings handler may operate a flat address space for its keys. A settings handler must guarantee to restore the settings that it manages to their original condition, when a payload provided by a previous GET operation (or the "oldValue" set of a SET operation) is provided back to a SET operation.

Also keep in mind that if you’re doing any of the standard lifecycle actions—start, stop, setSettings, etc.—you should be delegating to the Lifecycle Manager to do so for you, rather than directly invoking Settings Handlers.

[
    {
	"org.gnome.desktop.a11y.magnifier": [
            {
                options: {
                    schema: "org.gnome.desktop.a11y.magnifier"
                },

                settings: {
		    "cross-hairs-clip": null,
		    "cross-hairs-color": null,
		    "cross-hairs-length": null,
		    "cross-hairs-opacity": null,
		    "cross-hairs-thickness": null,
		    "lens-mode": null,
		    "mag-factor": null,
		    "mouse-tracking": null,
		    "screen-position": null,
		    "scroll-at-edges": null,
		    "show-cross-hairs": null
	        }
            }
     }, 

     {
	"org.gnome.desktop.contrast": [
            {
                options: {
                    schema: "org.gnome.desktop.interface"
                },
                settings: {
                    "gtk-theme": null,
                    "icon-theme": null
                }
            },
            {
                options: {
                    schema: "org.gnome.desktop.background"
                },
                settings: {
                    "primary-color": null,
                    "secondary-color": null
                }
            }
        }  
    }
]

GET Response

[
    {
	"org.gnome.desktop.a11y.magnifier": {
            settings:
            {
		"cross-hairs-clip": "false",
		"cross-hairs-color": "red",
		"cross-hairs-length": "20",
		"cross-hairs-opacity": "0.1",
		"cross-hairs-thickness": "10",
		"lens-mode": "true",
		"mag-factor": "12.2",
		"mouse-tracking": "push",
		"screen-position": "top-half",
		"scroll-at-edges": "true",
		"show-cross-hairs": "400"
            }
	}
    },

    {
	"org.gnome.desktop.contrast": [
            {
                options: {
                    schema: "org.gnome.desktop.interface"
                },
                settings: {
                    "gtk-theme": "HighContrast",
                    "icon-theme": "HighContrast
                }
            },
            {
                options: {
                    schema: "org.gnome.desktop.background"
                },
                settings: {
                    "primary-color": "#FFFFFFFFFFFF",
                    "secondary-color": "#4a2c59f36e75"
                }
            }
        }  
    }
]

SET Request

    {
	"org.gnome.desktop.a11y.magnifier": [
            {
                settings: {
			"cross-hairs-clip": true,
			"cross-hairs-color": "rubbish",
			"cross-hairs-length": 4096,
			"cross-hairs-opacity": 0.2,
			"cross-hairs-thickness": 10,
			"lens-mode": true,
			"mag-factor": 12.2,
			"mouse-tracking": "push",
			"screen-position": "top-half",
			"scroll-at-edges": true,
			"show-cross-hairs": "9910192920"
                },

                options: {
                    schema: "org.gnome.desktop.a11y.magnifier"      
                }
	    }
        ]
    }

SET Response

    {
	"org.gnome.desktop.a11y.magnifier": [
                {
                settings: {
			"cross-hairs-clip": { "oldValue":  false, "value": true },
			"cross-hairs-color": { "oldValue":  "red", "value": "red", statusCode: 500, statusMessage: "Internal Error"},
			"cross-hairs-length": { "oldValue":  20, "value": 4096 },
			"cross-hairs-opacity": { "oldValue":  "0.1", "value": "0.2" },
			"cross-hairs-thickness": { "oldValue":  "3", "value": "10" },
			"lens-mode": { "oldValue":  false, "value": true },
			"mag-factor": { "oldValue":  "0.4", "value": "12.2" },
			"mouse-tracking": { "oldValue":  "centered", "value": "push" },
			"screen-position": { "oldValue":  "none", "value": "top-half" },
			"scroll-at-edges": { "oldValue":  false, "value": true },
			"show-cross-hairs": { "oldValue":  true, "value": true, statusCode: 400 }
                        }
		}
        ]
    }


More examples of SET payloads are available in the tests for settings handlers, e.g.: