Transformer Payload Examples

From wiki.gpii
Jump to: navigation, search

See Example Payloads.

See also Antranig's mail from 23 March 2012 and Kasper's response for comments on the payloads.

Transformer.transformSettings()

The input to the Settings Transformer is an object containing two things:

  1. The user's complete Preference Profile object
  2. The Solutions Specification for each solution matched by the Match Maker
{
    "preferences": {
        "display": {
            "screenEnhancement": {
                "magnification": 2,
                "tracking": "mouse",
                "applications": [
                    {
                        "name": "GNOME Shell Magnifier",
                        "id": "org.gnome.desktop.a11y.magnifier",
                        "priority": 100,
                        "parameters": {
                            "show-cross-hairs": true
                        }
                    }
                ]
            }
        }
    },

    "solutions": [
        {
            "id": "org.gnome.desktop.a11y.magnifier",
            "settingsHandlers": [
                {
                    "type": "gpii.settings.gsettings",
                    "settingsTransformationMap": {
                        "mag-factor": "display.screenEnhancement.magnification",
                        "mouse-tracking": {
                            "expander": {
                                "type": "gpii.transform.valueMapper",
                                "inputPath": "display.screenEnhancement.tracking",
                                "options": {
                                    "valueMap": {
                                        "mouse": "centered"
                                    }
                                }
                            }
                        }
                    }
                }
            ],

            "launchHandlers": [
                {
                    "type": "gpii.launch.gsettings",
                    "start": {
                        "schema": "org.gnome.desktop.a11y.applications",
                        "key": "screen-magnifier-enabled",
                        "value": true
                    },
                    "stop": {
                        "schema": "org.gnome.desktop.a11y.applications",
                        "key": "screen-magnifier-enabled",
                        "value": false
                    }
                }
            ]
        }
    ]
}

Output

The response of the Settings Transformer is a list of modified Solutions Specifications containing concrete settings for the solution in question.

[
    {
        "id": "org.gnome.desktop.a11y.magnifier",
        "settingsHandlers": [
            {
                "type": "gpii.settings.gsettingsHandler",
                // Notice that the capabilities block is no longer present here, and has been replaced with the actual settings for the solution.
                "settings": {
                    "mag-factor": 200,
                    "mouse-tracking": "centered",
                    "show-cross-hairs": true
                },
                "options": {}
            }
        ]
    
        "launchHandlers": [
            {
                "type": "gpii.launch.gsettings",
                "start": {
                    "schema": "org.gnome.desktop.a11y.applications",
                    "key": "screen-magnifier-enabled",
                    "value": true
                },
                "stop": {
                    "schema": "org.gnome.desktop.a11y.applications",
                    "key": "screen-magnifier-enabled",
                    "value": false
                }
            }
        ]
    }
]