1all_plugins = [
2    ['a11y-settings', 'A11ySettings', 'GNOME accessibility'],
3    ['color', 'Color', 'GNOME color management'],
4    ['datetime', 'Datetime', 'GNOME date & time'],
5    ['power', 'Power', 'GNOME power management'],
6    ['housekeeping', 'Housekeeping', 'GNOME maintenance of expirable data'],
7    ['keyboard', 'Keyboard', 'GNOME keyboard configuration'],
8    ['screensaver-proxy', 'ScreensaverProxy', 'GNOME FreeDesktop screensaver'],
9    ['sharing', 'Sharing', 'GNOME file sharing'],
10    ['usb-protection', 'UsbProtection', 'GNOME USB protection'],
11    ['xsettings', 'XSettings', 'GNOME XSettings'],
12    ['smartcard', 'Smartcard', 'GNOME smartcard'],
13    ['wacom', 'Wacom', 'GNOME Wacom tablet support'],
14    ['print-notifications', 'PrintNotifications', 'GNOME printer notifications'],
15    ['rfkill', 'Rfkill', 'GNOME RFKill support'],
16    ['wwan', 'Wwan', 'GNOME WWan support'],
17]
18
19disabled_plugins = []
20
21if not enable_smartcard
22    disabled_plugins += ['smartcard']
23endif
24
25if not enable_usb_protection
26    disabled_plugins += ['usb-protection']
27endif
28
29if not enable_wacom
30    disabled_plugins += ['wacom']
31endif
32
33if not enable_cups
34    disabled_plugins += ['cups']
35endif
36
37if not enable_rfkill
38    disabled_plugins += ['rfkill']
39endif
40
41if not enable_wwan
42    disabled_plugins += ['wwan']
43endif
44
45if not enable_colord
46  disabled_plugins += ['color']
47endif
48
49if not enable_cups
50  disabled_plugins += ['print-notifications']
51endif
52
53# Specify futher required units, 'before' or 'after' may be specified if ordering is needed
54plugin_gate_units = {
55    'xsettings': [
56      # Both after/before. after for stopping reliably, before for synchronisation
57      ['gnome-session-x11-services.target', 'after'],
58      ['gnome-session-x11-services-ready.target', 'before'],
59    ],
60#    'wacom': [['wacom.target']],
61#    'smartcard': [['smartcard.target']],
62}
63
64# Restart=on-failure is the default
65plugin_restart_rule = {
66    'xsettings' : 'on-abnormal',
67}
68
69plugins_conf = configuration_data()
70plugins_conf.set('libexecdir', gsd_libexecdir)
71
72plugins_deps = [libgsd_dep]
73
74plugins_cflags = ['-DGNOME_SETTINGS_LOCALEDIR="@0@"'.format(gsd_localedir)]
75
76all_plugins_file = []
77
78cflags = [
79    '-DG_LOG_DOMAIN="common"'
80] + plugins_cflags
81plugin_name = 'common'
82subdir('common')
83
84foreach plugin: all_plugins
85    plugin_name = plugin[0]
86    plugin_name_case = plugin[1]
87    plugin_description = plugin[2]
88    plugin_dbus_name='org.gnome.SettingsDaemon.@0@'.format(plugin_name_case)
89
90    desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])
91
92    if disabled_plugins.contains(plugin_name)
93        desktop_in_file = files('org.gnome.SettingsDaemon.Dummy.desktop.in')
94    else
95        desktop_in_file = files('org.gnome.SettingsDaemon.Real.desktop.in')
96    endif
97
98    cflags = [
99        '-DG_LOG_DOMAIN="@0@-plugin"'.format(plugin_name),
100        '-DPLUGIN_NAME="@0@"'.format(plugin_name),
101        '-DPLUGIN_DBUS_NAME="@0@"'.format(plugin_dbus_name),
102    ] + plugins_cflags
103
104    desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])
105    desktop_conf = configuration_data()
106    desktop_conf.set('libexecdir', gsd_libexecdir)
107    desktop_conf.set('systemd_hidden', enable_systemd ? 'true' : 'false')
108    desktop_conf.set('pluginname', plugin_name)
109    desktop_conf.set('description', plugin_description)
110    configure_file(
111        input: desktop_in_file,
112        output: desktop,
113        configuration: desktop_conf,
114        install: true,
115        install_dir: gsd_xdg_autostart
116    )
117
118    if not disabled_plugins.contains(plugin_name)
119        user_target = 'org.gnome.SettingsDaemon.@0@.target'.format(plugin[1])
120        user_service = 'org.gnome.SettingsDaemon.@0@.service'.format(plugin[1])
121
122        unit_conf = configuration_data()
123        unit_conf.set('plugin_name', plugin_name)
124        unit_conf.set('description', plugin_description)
125        unit_conf.set('libexecdir', gsd_libexecdir)
126        unit_conf.set('plugin_dbus_name', plugin_dbus_name)
127        unit_conf.set('plugin_restart', plugin_restart_rule.get(plugin_name, 'on-failure'))
128
129        gates_all = []
130        gates_after = []
131        gates_before = []
132        foreach gate: plugin_gate_units.get(plugin_name, [])
133            gates_all += [gate[0]]
134            if gate.length() > 1
135                if gate[1] == 'before'
136                    gates_before += [gate[0]]
137                elif gate[1] == 'after'
138                    gates_after += [gate[0]]
139                else
140                    error('Ordering key must be either "before" or "after"')
141                endif
142            endif
143        endforeach
144        gate_unit_section = []
145        if gates_all.length() > 0
146            gate_unit_section += ['Requisite=' + ' '.join(gates_all)]
147            gate_unit_section += ['PartOf=' + ' '.join(gates_all)]
148
149            if gates_after.length() > 0
150                gate_unit_section += ['After=' + ' '.join(gates_after)]
151            endif
152            if gates_before.length() > 0
153                gate_unit_section += ['Before=' + ' '.join(gates_before)]
154            endif
155        endif
156        unit_conf.set('plugin_gate_units_section', '\n'.join(gate_unit_section))
157
158        if enable_systemd
159            configure_file(
160                input: 'gsd.service.in',
161                output: user_service,
162                configuration: unit_conf,
163                install: true,
164                install_dir: systemd_userunitdir
165            )
166            configure_file(
167                input: 'gsd.target.in',
168                output: user_target,
169                configuration: unit_conf,
170                install: true,
171                install_dir: systemd_userunitdir
172            )
173
174            # Wipe out old target names if our prefix differes from the
175            # systemd one, i.e. we are probably in a virtual environment and
176            # may be picking up old units from a system installation.
177            # This saves a lot of pain when running a new g-s-d inside
178            # jhbuild on an old host.
179            # TODO: Should be deleted once we can assume developers have 3.38
180            #       installed on their machines.
181            if gsd_prefix != systemd_dep.get_pkgconfig_variable('prefix')
182                meson.add_install_script('sh', '-c', 'ln -vfs /dev/null "${DESTDIR:-}$1"', 'sh', systemd_userunitdir / 'gsd-@0@.target'.format(plugin_name))
183            endif
184
185            foreach target: gates_all
186                meson.add_install_script('meson-add-wants.sh', systemd_userunitdir, target + '.wants/', user_service)
187            endforeach
188        endif
189
190        subdir(plugin_name)
191    endif
192endforeach
193