Merge lp:~compiz-team/compiz-libcompizconfig/compiz-libcompizconfig.fix_873772 into lp:compiz-libcompizconfig

Proposed by Sam Spilsbury on 2011-10-15
Status: Superseded
Proposed branch: lp:~compiz-team/compiz-libcompizconfig/compiz-libcompizconfig.fix_873772
Merge into: lp:compiz-libcompizconfig
Diff against target: 1659 lines (+592/-333)
8 files modified
backend/src/ini.c (+13/-13)
include/ccs.h (+19/-13)
plugin/ccp/src/ccp.cpp (+1/-1)
src/CMakeLists.txt (+1/-0)
src/ccs-private.h (+6/-0)
src/compiz.cpp (+116/-109)
src/lists.c (+1/-1)
src/main.c (+435/-196)
To merge this branch: bzr merge lp:~compiz-team/compiz-libcompizconfig/compiz-libcompizconfig.fix_873772
Reviewer Review Type Date Requested Status
Compiz Maintainers 2011-10-15 Pending
Review via email: mp+79456@code.launchpad.net

This proposal has been superseded by a proposal from 2012-04-13.

Description of the change

To post a comment you must log in.
426. By Sam Spilsbury on 2011-10-26

Merge trunk, fix leaks and provide a way for distributions to lock down settings keys

Provide a file in DATADIR/compizconfig/lockdown/profile.lockdown , this file
will be used to read from in the even that any key value that the user has set
is read from (eg, not default). Provide an ini file of the same format as the
standard ini backend with the key values which will be enforced for that profile.

active_plugins is an exception, any items in active_plugins will be forced to be in
the list, but the user is allowed to enable other plugins as well. The list will
be automatically sorted.

Eg:

[core]
s0_active_plugins = core;composite;opengl;move;resize;decor;

[move]
s0_lazy_positioning = True

Will ensure that core, composite, opengl, move, resize, decor will always be
on, even if the user tries to turn them off for that profile. It will also
ensure that lazy positioning will always be on, even if the user tries to
turn it off.

Fixes LP#881904

Tim Penhey (thumper) wrote :

Your CMakeList.txt file has the datadir twice.

Also, can we get some tests to illustrate the override behaviour?

427. By Sam Spilsbury on 2012-01-21

Use some more descriptive names

Unmerged revisions

427. By Sam Spilsbury on 2012-01-21

Use some more descriptive names

426. By Sam Spilsbury on 2011-10-26

Merge trunk, fix leaks and provide a way for distributions to lock down settings keys

Provide a file in DATADIR/compizconfig/lockdown/profile.lockdown , this file
will be used to read from in the even that any key value that the user has set
is read from (eg, not default). Provide an ini file of the same format as the
standard ini backend with the key values which will be enforced for that profile.

active_plugins is an exception, any items in active_plugins will be forced to be in
the list, but the user is allowed to enable other plugins as well. The list will
be automatically sorted.

Eg:

[core]
s0_active_plugins = core;composite;opengl;move;resize;decor;

[move]
s0_lazy_positioning = True

Will ensure that core, composite, opengl, move, resize, decor will always be
on, even if the user tries to turn them off for that profile. It will also
ensure that lazy positioning will always be on, even if the user tries to
turn it off.

Fixes LP#881904

425. By Sam Spilsbury on 2011-10-14

Added a method for distributions to override the defaults specified
in plugin metadata

A profile.defaults file should be placed in DATADIR/compizconfig/defaults which
will be read from when defaults are being processed, eg, when a setting has
no user set value or when settings are being reset to the defaults

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'backend/src/ini.c'
2--- backend/src/ini.c 2011-08-20 19:03:37 +0000
3+++ backend/src/ini.c 2012-01-21 21:15:28 +0000
4@@ -275,7 +275,7 @@
5 if (ccsIniGetString (data->iniFile, setting->parent->name,
6 keyName, &value))
7 {
8- ccsSetString (setting, value, TRUE);
9+ ccsSetString (setting, value, SetTemporary);
10 free (value);
11 status = TRUE;
12 }
13@@ -287,7 +287,7 @@
14 if (ccsIniGetString (data->iniFile, setting->parent->name,
15 keyName, &value))
16 {
17- ccsSetMatch (setting, value, TRUE);
18+ ccsSetMatch (setting, value, SetTemporary);
19 free (value);
20 status = TRUE;
21 }
22@@ -299,7 +299,7 @@
23 if (ccsIniGetInt (data->iniFile, setting->parent->name,
24 keyName, &value))
25 {
26- ccsSetInt (setting, value, TRUE);
27+ ccsSetInt (setting, value, SetTemporary);
28 status = TRUE;
29 }
30 }
31@@ -310,7 +310,7 @@
32 if (ccsIniGetBool (data->iniFile, setting->parent->name,
33 keyName, &value))
34 {
35- ccsSetBool (setting, (value != 0), TRUE);
36+ ccsSetBool (setting, (value != 0), SetTemporary);
37 status = TRUE;
38 }
39 }
40@@ -321,7 +321,7 @@
41 if (ccsIniGetFloat (data->iniFile, setting->parent->name,
42 keyName, &value))
43 {
44- ccsSetFloat (setting, value, TRUE);
45+ ccsSetFloat (setting, value, SetTemporary);
46 status = TRUE;
47 }
48 }
49@@ -333,7 +333,7 @@
50 if (ccsIniGetColor (data->iniFile, setting->parent->name,
51 keyName, &color))
52 {
53- ccsSetColor (setting, color, TRUE);
54+ ccsSetColor (setting, color, SetTemporary);
55 status = TRUE;
56 }
57 }
58@@ -344,7 +344,7 @@
59 if (ccsIniGetKey (data->iniFile, setting->parent->name,
60 keyName, &key))
61 {
62- ccsSetKey (setting, key, TRUE);
63+ ccsSetKey (setting, key, SetTemporary);
64 status = TRUE;
65 }
66 }
67@@ -355,7 +355,7 @@
68 if (ccsIniGetButton (data->iniFile, setting->parent->name,
69 keyName, &button))
70 {
71- ccsSetButton (setting, button, TRUE);
72+ ccsSetButton (setting, button, SetTemporary);
73 status = TRUE;
74 }
75 }
76@@ -366,7 +366,7 @@
77 if (ccsIniGetEdge (data->iniFile, setting->parent->name,
78 keyName, &edges))
79 {
80- ccsSetEdge (setting, edges, TRUE);
81+ ccsSetEdge (setting, edges, SetTemporary);
82 status = TRUE;
83 }
84 }
85@@ -377,7 +377,7 @@
86 if (ccsIniGetBell (data->iniFile, setting->parent->name,
87 keyName, &bell))
88 {
89- ccsSetBell (setting, bell, TRUE);
90+ ccsSetBell (setting, bell, SetTemporary);
91 status = TRUE;
92 }
93 }
94@@ -388,8 +388,8 @@
95 if (ccsIniGetList (data->iniFile, setting->parent->name,
96 keyName, &value, setting))
97 {
98- ccsSetList (setting, value, TRUE);
99- ccsSettingValueListFree (value, TRUE);
100+ ccsSetList (setting, value, SetTemporary);
101+ ccsSettingValueListFree (value, SetTemporary);
102 status = TRUE;
103 }
104 }
105@@ -401,7 +401,7 @@
106 if (!status)
107 {
108 /* reset setting to default if it could not be read */
109- ccsResetToDefault (setting, TRUE);
110+ ccsResetToDefault (setting, SetTemporary);
111 }
112
113 if (keyName)
114
115=== modified file 'include/ccs.h'
116--- include/ccs.h 2011-08-20 19:03:37 +0000
117+++ include/ccs.h 2012-01-21 21:15:28 +0000
118@@ -484,45 +484,51 @@
119 void ccsFreeStrExtension (CCSStrExtension *extension);
120 void ccsFreeString (CCSString *str);
121
122+typedef enum
123+{
124+ SetTemporary = 0,
125+ ProcessChanged = 1
126+} CCSProcessing;
127+
128 /* Setting setters. Set <setting> to value <data>. Return TRUE if new value
129 matches data. If the new value doesn't match the old value, the setting
130 is added to the context's changedSettings list. */
131 Bool ccsSetInt (CCSSetting *setting,
132 int data,
133- Bool processChanged);
134+ CCSProcessing process);
135 Bool ccsSetFloat (CCSSetting *setting,
136 float data,
137- Bool processChanged);
138+ CCSProcessing process);
139 Bool ccsSetBool (CCSSetting *setting,
140 Bool data,
141- Bool processChanged);
142+ CCSProcessing process);
143 Bool ccsSetString (CCSSetting *setting,
144 const char *data,
145- Bool processChanged);
146+ CCSProcessing process);
147 Bool ccsSetColor (CCSSetting *setting,
148 CCSSettingColorValue data,
149- Bool processChanged);
150+ CCSProcessing process);
151 Bool ccsSetMatch (CCSSetting *setting,
152 const char *data,
153- Bool processChanged);
154+ CCSProcessing process);
155 Bool ccsSetKey (CCSSetting *setting,
156 CCSSettingKeyValue data,
157- Bool processChanged);
158+ CCSProcessing process);
159 Bool ccsSetButton (CCSSetting *setting,
160 CCSSettingButtonValue data,
161- Bool processChanged);
162+ CCSProcessing process);
163 Bool ccsSetEdge (CCSSetting *setting,
164 unsigned int data,
165- Bool processChanged);
166+ CCSProcessing process);
167 Bool ccsSetBell (CCSSetting *setting,
168 Bool data,
169- Bool processChanged);
170+ CCSProcessing process);
171 Bool ccsSetList (CCSSetting *setting,
172 CCSSettingValueList data,
173- Bool processChanged);
174+ CCSProcessing process);
175 Bool ccsSetValue (CCSSetting *setting,
176 CCSSettingValue *data,
177- Bool processChanged);
178+ CCSProcessing process);
179
180 /* Compares two setting values. Returns TRUE if values match,
181 FALSE otherwise. */
182@@ -711,7 +717,7 @@
183
184 /* Reset all settings to defaults. Settings that were non-default
185 previously are added to the changedSettings list of the context. */
186-void ccsResetToDefault (CCSSetting * setting, Bool processChanged);
187+void ccsResetToDefault (CCSSetting * setting, CCSProcessing process);
188
189 /* Exports a profile to a file. If skipDefaults is TRUE, only exports
190 non-default settings. Returns TRUE on successful export, FALSE otherwise. */
191
192=== modified file 'plugin/ccp/src/ccp.cpp'
193--- plugin/ccp/src/ccp.cpp 2011-08-20 19:03:37 +0000
194+++ plugin/ccp/src/ccp.cpp 2012-01-21 21:15:28 +0000
195@@ -336,7 +336,7 @@
196 else
197 ccpInitValue (value, v, s->type);
198
199- ccsSetValue (s, value, TRUE);
200+ ccsSetValue (s, value, ProcessChanged);
201 ccsFreeSettingValue (value);
202 }
203
204
205=== modified file 'src/CMakeLists.txt'
206--- src/CMakeLists.txt 2011-10-15 07:28:45 +0000
207+++ src/CMakeLists.txt 2012-01-21 21:15:28 +0000
208@@ -23,6 +23,7 @@
209 -DPLUGINDIR=\\\"${COMPIZ_PLUGINDIR}\\\"
210 -DIMAGEDIR=\\\"${COMPIZ_IMAGEDIR}\\\"
211 -DMETADATADIR=\\\"${COMPIZ_METADATADIR}\\\"
212+ -DDATADIR=\\\"${COMPIZ_DATADIR}\\\"
213 -DSYSCONFDIR=\\\"${COMPIZ_SYSCONFDIR}\\\"
214 -DDATADIR=\\\"${COMPIZ_DATADIR}\\\"
215 -DLIBDIR=\\\"${COMPIZ_LIBDIR}\\\"
216
217=== modified file 'src/ccs-private.h'
218--- src/ccs-private.h 2011-08-20 19:03:37 +0000
219+++ src/ccs-private.h 2012-01-21 21:15:28 +0000
220@@ -72,7 +72,11 @@
221 CCSSettingList replaceToValueSettings;
222 } CCSSettingsUpgrade;
223
224+Bool ccsReadLockdown (CCSContext *context,
225+ CCSSetting *setting);
226 Bool ccsCheckForSettingsUpgrade (CCSContext *context);
227+Bool ccsReadProfileDefault (CCSContext *context,
228+ CCSSetting *setting);
229
230 void ccsLoadPlugins (CCSContext * context);
231 void ccsLoadPluginSettings (CCSPlugin * plugin);
232@@ -94,4 +98,6 @@
233 unsigned int ccsAddConfigWatch (CCSContext *context,
234 FileWatchCallbackProc callback);
235
236+Bool ccsCheckValueEq (CCSSettingValue *, CCSSettingValue *);
237+
238 #endif
239
240=== modified file 'src/compiz.cpp'
241--- src/compiz.cpp 2011-08-22 10:55:07 +0000
242+++ src/compiz.cpp 2012-01-21 21:15:28 +0000
243@@ -23,6 +23,8 @@
244 #include <google/protobuf/io/zero_copy_stream_impl.h>
245 #endif
246
247+#include <string>
248+
249 extern "C"
250 {
251 #ifdef HAVE_CONFIG_H
252@@ -36,8 +38,6 @@
253 #include <sys/stat.h>
254 #include <errno.h>
255
256-#include <string>
257-
258 #include <libxslt/transform.h>
259 #include <libxslt/xsltutils.h>
260
261@@ -630,71 +630,74 @@
262 break;
263 }
264
265- if (option.default_value_size () > 0)
266+ if (!ccsReadProfileDefault (setting->parent->context, setting))
267 {
268- switch (setting->type)
269+ if (option.default_value_size () > 0)
270 {
271- case TypeInt:
272- initIntValuePB (&setting->defaultValue, &setting->info,
273- option.default_value (0));
274- break;
275- case TypeBool:
276- initBoolValuePB (&setting->defaultValue, option.default_value (0));
277- break;
278- case TypeFloat:
279- initFloatValuePB (&setting->defaultValue, &setting->info,
280- option.default_value (0));
281- break;
282- case TypeString:
283- initStringValuePB (&setting->defaultValue, &setting->info,
284- option.default_value (0));
285- break;
286- case TypeColor:
287- initColorValuePB (&setting->defaultValue, option.default_value (0));
288- break;
289- case TypeKey:
290- initKeyValuePB (&setting->defaultValue, &setting->info,
291- option.default_value (0));
292- break;
293- case TypeButton:
294- initButtonValuePB (&setting->defaultValue, &setting->info,
295- option.default_value (0));
296- break;
297- case TypeEdge:
298- initEdgeValuePB (&setting->defaultValue, &setting->info,
299- option.default_value (0));
300- break;
301- case TypeBell:
302- initBellValuePB (&setting->defaultValue, &setting->info,
303- option.default_value (0));
304- break;
305- case TypeMatch:
306- initMatchValuePB (&setting->defaultValue,
307- option.default_value (0));
308- break;
309- case TypeList:
310- initListValuePB (&setting->defaultValue, &setting->info,
311- option);
312- break;
313- case TypeAction: // do nothing and fall through
314- default:
315- break;
316+ switch (setting->type)
317+ {
318+ case TypeInt:
319+ initIntValuePB (&setting->defaultValue, &setting->info,
320+ option.default_value (0));
321+ break;
322+ case TypeBool:
323+ initBoolValuePB (&setting->defaultValue, option.default_value (0));
324+ break;
325+ case TypeFloat:
326+ initFloatValuePB (&setting->defaultValue, &setting->info,
327+ option.default_value (0));
328+ break;
329+ case TypeString:
330+ initStringValuePB (&setting->defaultValue, &setting->info,
331+ option.default_value (0));
332+ break;
333+ case TypeColor:
334+ initColorValuePB (&setting->defaultValue, option.default_value (0));
335+ break;
336+ case TypeKey:
337+ initKeyValuePB (&setting->defaultValue, &setting->info,
338+ option.default_value (0));
339+ break;
340+ case TypeButton:
341+ initButtonValuePB (&setting->defaultValue, &setting->info,
342+ option.default_value (0));
343+ break;
344+ case TypeEdge:
345+ initEdgeValuePB (&setting->defaultValue, &setting->info,
346+ option.default_value (0));
347+ break;
348+ case TypeBell:
349+ initBellValuePB (&setting->defaultValue, &setting->info,
350+ option.default_value (0));
351+ break;
352+ case TypeMatch:
353+ initMatchValuePB (&setting->defaultValue,
354+ option.default_value (0));
355+ break;
356+ case TypeList:
357+ initListValuePB (&setting->defaultValue, &setting->info,
358+ option);
359+ break;
360+ case TypeAction: // do nothing and fall through
361+ default:
362+ break;
363+ }
364 }
365- }
366- else
367- {
368- /* if we have no set defaults, we have at least to set
369- the string defaults to empty strings */
370- switch (setting->type)
371+ else
372 {
373- case TypeString:
374- setting->defaultValue.value.asString = strdup ("");
375- break;
376- case TypeMatch:
377- setting->defaultValue.value.asMatch = strdup ("");
378- break;
379- default:
380- break;
381+ /* if we have no set defaults, we have at least to set
382+ the string defaults to empty strings */
383+ switch (setting->type)
384+ {
385+ case TypeString:
386+ setting->defaultValue.value.asString = strdup ("");
387+ break;
388+ case TypeMatch:
389+ setting->defaultValue.value.asMatch = strdup ("");
390+ break;
391+ default:
392+ break;
393+ }
394 }
395 }
396
397@@ -2082,53 +2085,57 @@
398 if (optPB && setting->type != TypeList)
399 valuePBv = optPB->add_default_value ();
400 #endif
401- switch (setting->type)
402+ if (!ccsReadProfileDefault (setting->parent->context,
403+ setting))
404 {
405- case TypeInt:
406- initIntValue (&setting->defaultValue, &setting->info, nodes[0],
407- valuePBv);
408- break;
409- case TypeBool:
410- initBoolValue (&setting->defaultValue, nodes[0],
411- valuePBv);
412- break;
413- case TypeFloat:
414- initFloatValue (&setting->defaultValue, &setting->info, nodes[0],
415- valuePBv);
416- break;
417- case TypeString:
418- initStringValue (&setting->defaultValue, &setting->info, nodes[0],
419- valuePBv);
420- break;
421- case TypeColor:
422- initColorValue (&setting->defaultValue, nodes[0], valuePBv);
423- break;
424- case TypeKey:
425- initKeyValue (&setting->defaultValue, &setting->info, nodes[0],
426- valuePBv);
427- break;
428- case TypeButton:
429- initButtonValue (&setting->defaultValue, &setting->info, nodes[0],
430- valuePBv);
431- break;
432- case TypeEdge:
433- initEdgeValue (&setting->defaultValue, &setting->info, nodes[0],
434- valuePBv);
435- break;
436- case TypeBell:
437- initBellValue (&setting->defaultValue, &setting->info, nodes[0],
438- valuePBv);
439- break;
440- case TypeMatch:
441- initMatchValue (&setting->defaultValue, nodes[0],
442- valuePBv);
443- break;
444- case TypeList:
445- initListValue (&setting->defaultValue, &setting->info, nodes[0],
446- optionPBv);
447- break;
448- default:
449- break;
450+ switch (setting->type)
451+ {
452+ case TypeInt:
453+ initIntValue (&setting->defaultValue, &setting->info, nodes[0],
454+ valuePBv);
455+ break;
456+ case TypeBool:
457+ initBoolValue (&setting->defaultValue, nodes[0],
458+ valuePBv);
459+ break;
460+ case TypeFloat:
461+ initFloatValue (&setting->defaultValue, &setting->info, nodes[0],
462+ valuePBv);
463+ break;
464+ case TypeString:
465+ initStringValue (&setting->defaultValue, &setting->info, nodes[0],
466+ valuePBv);
467+ break;
468+ case TypeColor:
469+ initColorValue (&setting->defaultValue, nodes[0], valuePBv);
470+ break;
471+ case TypeKey:
472+ initKeyValue (&setting->defaultValue, &setting->info, nodes[0],
473+ valuePBv);
474+ break;
475+ case TypeButton:
476+ initButtonValue (&setting->defaultValue, &setting->info, nodes[0],
477+ valuePBv);
478+ break;
479+ case TypeEdge:
480+ initEdgeValue (&setting->defaultValue, &setting->info, nodes[0],
481+ valuePBv);
482+ break;
483+ case TypeBell:
484+ initBellValue (&setting->defaultValue, &setting->info, nodes[0],
485+ valuePBv);
486+ break;
487+ case TypeMatch:
488+ initMatchValue (&setting->defaultValue, nodes[0],
489+ valuePBv);
490+ break;
491+ case TypeList:
492+ initListValue (&setting->defaultValue, &setting->info, nodes[0],
493+ optionPBv);
494+ break;
495+ default:
496+ break;
497+ }
498 }
499 }
500 else
501
502=== modified file 'src/lists.c'
503--- src/lists.c 2011-08-20 19:03:37 +0000
504+++ src/lists.c 2012-01-21 21:15:28 +0000
505@@ -176,7 +176,7 @@
506 CCSLIST (String, CCSString, TRUE, strcmp (((CCSString *)data)->value, ((CCSString *)l->data)->value) == 0)
507 CCSLIST (Group, CCSGroup, FALSE, 0)
508 CCSLIST (SubGroup, CCSSubGroup, FALSE, 0)
509-CCSLIST (SettingValue, CCSSettingValue, FALSE, 0)
510+CCSLIST (SettingValue, CCSSettingValue, TRUE, ccsCheckValueEq ((CCSSettingValue *)data, (CCSSettingValue *)l->data));
511 CCSLIST (PluginConflict, CCSPluginConflict, FALSE, 0)
512 CCSLIST (BackendInfo, CCSBackendInfo, FALSE, 0)
513 CCSLIST (IntDesc, CCSIntDesc, FALSE, 0)
514
515=== modified file 'src/main.c'
516--- src/main.c 2011-11-10 00:58:18 +0000
517+++ src/main.c 2012-01-21 21:15:28 +0000
518@@ -275,9 +275,9 @@
519 }
520
521 subGroup = calloc (1, sizeof (CCSSubGroup));
522- subGroup->refCount = 1;
523 if (subGroup)
524 {
525+ subGroup->refCount = 1;
526 group->subGroups = ccsSubGroupListAppend (group->subGroups, subGroup);
527 subGroup->name = strdup (setting->subGroup);
528 subGroup->settings = ccsSettingListAppend (subGroup->settings, setting);
529@@ -951,13 +951,13 @@
530 }
531
532 void
533-ccsResetToDefault (CCSSetting * setting, Bool processChanged)
534+ccsResetToDefault (CCSSetting * setting, CCSProcessing process)
535 {
536 if (setting->value != &setting->defaultValue)
537 {
538 ccsFreeSettingValue (setting->value);
539
540- if (processChanged)
541+ if (process == ProcessChanged)
542 setting->parent->context->changedSettings =
543 ccsSettingListAppend (setting->parent->context->changedSettings,
544 setting);
545@@ -1023,7 +1023,7 @@
546 }
547
548 Bool
549-ccsSetInt (CCSSetting * setting, int data, Bool processChanged)
550+ccsSetInt (CCSSetting * setting, int data, CCSProcessing process)
551 {
552 if (setting->type != TypeInt)
553 return FALSE;
554@@ -1033,7 +1033,7 @@
555
556 if (!setting->isDefault && (setting->defaultValue.value.asInt == data))
557 {
558- ccsResetToDefault (setting, processChanged);
559+ ccsResetToDefault (setting, process);
560 return TRUE;
561 }
562
563@@ -1049,7 +1049,7 @@
564
565 setting->value->value.asInt = data;
566
567- if (processChanged)
568+ if (process == ProcessChanged)
569 setting->parent->context->changedSettings =
570 ccsSettingListAppend (setting->parent->context->changedSettings,
571 setting);
572@@ -1058,7 +1058,7 @@
573 }
574
575 Bool
576-ccsSetFloat (CCSSetting * setting, float data, Bool processChanged)
577+ccsSetFloat (CCSSetting * setting, float data, CCSProcessing process)
578 {
579 if (setting->type != TypeFloat)
580 return FALSE;
581@@ -1068,7 +1068,7 @@
582
583 if (!setting->isDefault && (setting->defaultValue.value.asFloat == data))
584 {
585- ccsResetToDefault (setting, processChanged);
586+ ccsResetToDefault (setting, process);
587 return TRUE;
588 }
589
590@@ -1086,7 +1086,7 @@
591
592 setting->value->value.asFloat = data;
593
594- if (processChanged)
595+ if (process == ProcessChanged)
596 setting->parent->context->changedSettings =
597 ccsSettingListAppend (setting->parent->context->changedSettings,
598 setting);
599@@ -1095,7 +1095,7 @@
600 }
601
602 Bool
603-ccsSetBool (CCSSetting * setting, Bool data, Bool processChanged)
604+ccsSetBool (CCSSetting * setting, Bool data, CCSProcessing process)
605 {
606 if (setting->type != TypeBool)
607 return FALSE;
608@@ -1109,7 +1109,7 @@
609 && ((setting->defaultValue.value.asBool && data)
610 || (!setting->defaultValue.value.asBool && !data)))
611 {
612- ccsResetToDefault (setting, processChanged);
613+ ccsResetToDefault (setting, process);
614 return TRUE;
615 }
616
617@@ -1122,7 +1122,7 @@
618
619 setting->value->value.asBool = data;
620
621- if (processChanged)
622+ if (process == ProcessChanged)
623 setting->parent->context->changedSettings =
624 ccsSettingListAppend (setting->parent->context->changedSettings,
625 setting);
626@@ -1131,7 +1131,7 @@
627 }
628
629 Bool
630-ccsSetString (CCSSetting * setting, const char *data, Bool processChanged)
631+ccsSetString (CCSSetting * setting, const char *data, CCSProcessing process)
632 {
633 if (setting->type != TypeString)
634 return FALSE;
635@@ -1146,7 +1146,7 @@
636
637 if (!setting->isDefault && isDefault)
638 {
639- ccsResetToDefault (setting, processChanged);
640+ ccsResetToDefault (setting, process);
641 return TRUE;
642 }
643
644@@ -1160,7 +1160,7 @@
645
646 setting->value->value.asString = strdup (data);
647
648- if (processChanged)
649+ if (process == ProcessChanged)
650 setting->parent->context->changedSettings =
651 ccsSettingListAppend (setting->parent->context->changedSettings,
652 setting);
653@@ -1169,7 +1169,7 @@
654 }
655
656 Bool
657-ccsSetColor (CCSSetting * setting, CCSSettingColorValue data, Bool processChanged)
658+ccsSetColor (CCSSetting * setting, CCSSettingColorValue data, CCSProcessing process)
659 {
660 if (setting->type != TypeColor)
661 return FALSE;
662@@ -1183,7 +1183,7 @@
663
664 if (!setting->isDefault && isDefault)
665 {
666- ccsResetToDefault (setting, processChanged);
667+ ccsResetToDefault (setting, process);
668 return TRUE;
669 }
670
671@@ -1195,7 +1195,7 @@
672
673 setting->value->value.asColor = data;
674
675- if (processChanged)
676+ if (process == ProcessChanged)
677 setting->parent->context->changedSettings =
678 ccsSettingListAppend (setting->parent->context->changedSettings,
679 setting);
680@@ -1204,7 +1204,7 @@
681 }
682
683 Bool
684-ccsSetMatch (CCSSetting * setting, const char *data, Bool processChanged)
685+ccsSetMatch (CCSSetting * setting, const char *data, CCSProcessing process)
686 {
687 if (setting->type != TypeMatch)
688 return FALSE;
689@@ -1219,7 +1219,7 @@
690
691 if (!setting->isDefault && isDefault)
692 {
693- ccsResetToDefault (setting, processChanged);
694+ ccsResetToDefault (setting, process);
695 return TRUE;
696 }
697
698@@ -1233,7 +1233,7 @@
699
700 setting->value->value.asMatch = strdup (data);
701
702- if (processChanged)
703+ if (process == ProcessChanged)
704 setting->parent->context->changedSettings =
705 ccsSettingListAppend (setting->parent->context->changedSettings,
706 setting);
707@@ -1242,7 +1242,7 @@
708 }
709
710 Bool
711-ccsSetKey (CCSSetting * setting, CCSSettingKeyValue data, Bool processChanged)
712+ccsSetKey (CCSSetting * setting, CCSSettingKeyValue data, CCSProcessing process)
713 {
714 if (setting->type != TypeKey)
715 return FALSE;
716@@ -1256,7 +1256,7 @@
717
718 if (!setting->isDefault && isDefault)
719 {
720- ccsResetToDefault (setting, processChanged);
721+ ccsResetToDefault (setting, process);
722 return TRUE;
723 }
724
725@@ -1269,7 +1269,7 @@
726 setting->value->value.asKey.keysym = data.keysym;
727 setting->value->value.asKey.keyModMask = data.keyModMask;
728
729- if (processChanged)
730+ if (process == ProcessChanged)
731 setting->parent->context->changedSettings =
732 ccsSettingListAppend (setting->parent->context->changedSettings,
733 setting);
734@@ -1278,7 +1278,7 @@
735 }
736
737 Bool
738-ccsSetButton (CCSSetting * setting, CCSSettingButtonValue data, Bool processChanged)
739+ccsSetButton (CCSSetting * setting, CCSSettingButtonValue data, CCSProcessing process)
740 {
741 if (setting->type != TypeButton)
742 return FALSE;
743@@ -1292,7 +1292,7 @@
744
745 if (!setting->isDefault && isDefault)
746 {
747- ccsResetToDefault (setting, processChanged);
748+ ccsResetToDefault (setting, process);
749 return TRUE;
750 }
751
752@@ -1306,7 +1306,7 @@
753 setting->value->value.asButton.buttonModMask = data.buttonModMask;
754 setting->value->value.asButton.edgeMask = data.edgeMask;
755
756- if (processChanged)
757+ if (process == ProcessChanged)
758 setting->parent->context->changedSettings =
759 ccsSettingListAppend (setting->parent->context->changedSettings,
760 setting);
761@@ -1315,7 +1315,7 @@
762 }
763
764 Bool
765-ccsSetEdge (CCSSetting * setting, unsigned int data, Bool processChanged)
766+ccsSetEdge (CCSSetting * setting, unsigned int data, CCSProcessing process)
767 {
768 if (setting->type != TypeEdge)
769 return FALSE;
770@@ -1327,7 +1327,7 @@
771
772 if (!setting->isDefault && isDefault)
773 {
774- ccsResetToDefault (setting, processChanged);
775+ ccsResetToDefault (setting, process);
776 return TRUE;
777 }
778
779@@ -1339,7 +1339,7 @@
780
781 setting->value->value.asEdge = data;
782
783- if (processChanged)
784+ if (process == ProcessChanged)
785 setting->parent->context->changedSettings =
786 ccsSettingListAppend (setting->parent->context->changedSettings,
787 setting);
788@@ -1348,7 +1348,7 @@
789 }
790
791 Bool
792-ccsSetBell (CCSSetting * setting, Bool data, Bool processChanged)
793+ccsSetBell (CCSSetting * setting, Bool data, CCSProcessing process)
794 {
795 if (setting->type != TypeBell)
796 return FALSE;
797@@ -1360,7 +1360,7 @@
798
799 if (!setting->isDefault && isDefault)
800 {
801- ccsResetToDefault (setting, processChanged);
802+ ccsResetToDefault (setting, process);
803 return TRUE;
804 }
805
806@@ -1372,7 +1372,7 @@
807
808 setting->value->value.asBell = data;
809
810- if (processChanged)
811+ if (process == ProcessChanged)
812 setting->parent->context->changedSettings =
813 ccsSettingListAppend (setting->parent->context->changedSettings,
814 setting);
815@@ -1445,7 +1445,7 @@
816 }
817
818 Bool
819-ccsSetList (CCSSetting * setting, CCSSettingValueList data, Bool processChanged)
820+ccsSetList (CCSSetting * setting, CCSSettingValueList data, CCSProcessing process)
821 {
822 if (setting->type != TypeList)
823 return FALSE;
824@@ -1457,7 +1457,7 @@
825 * when processChanged is off since use of that
826 * API wants direct access to ths list for
827 * temporary storage */
828- if (!processChanged)
829+ if (process == SetTemporary)
830 {
831 if (setting->isDefault && isDefault)
832 {
833@@ -1466,7 +1466,7 @@
834
835 if (!setting->isDefault && isDefault)
836 {
837- ccsResetToDefault (setting, processChanged);
838+ ccsResetToDefault (setting, process);
839 return TRUE;
840 }
841 }
842@@ -1485,7 +1485,7 @@
843 setting->value->value.asList = ccsCopyList (data, setting);
844
845 if ((strcmp (setting->name, "active_plugins") == 0) &&
846- (strcmp (setting->parent->name, "core") == 0) && processChanged)
847+ (strcmp (setting->parent->name, "core") == 0) && (process == ProcessChanged))
848 {
849 CCSStringList list;
850
851@@ -1494,7 +1494,7 @@
852 ccsStringListFree (list, TRUE);
853 }
854
855- if (processChanged)
856+ if (process == ProcessChanged)
857 setting->parent->context->changedSettings =
858 ccsSettingListAppend (setting->parent->context->changedSettings,
859 setting);
860@@ -1503,42 +1503,42 @@
861 }
862
863 Bool
864-ccsSetValue (CCSSetting * setting, CCSSettingValue * data, Bool processChanged)
865+ccsSetValue (CCSSetting * setting, CCSSettingValue * data, CCSProcessing process)
866 {
867 switch (setting->type)
868 {
869 case TypeInt:
870- return ccsSetInt (setting, data->value.asInt, processChanged);
871+ return ccsSetInt (setting, data->value.asInt, process);
872 break;
873 case TypeFloat:
874- return ccsSetFloat (setting, data->value.asFloat, processChanged);
875+ return ccsSetFloat (setting, data->value.asFloat, process);
876 break;
877 case TypeBool:
878- return ccsSetBool (setting, data->value.asBool, processChanged);
879+ return ccsSetBool (setting, data->value.asBool, process);
880 break;
881 case TypeColor:
882- return ccsSetColor (setting, data->value.asColor, processChanged);
883+ return ccsSetColor (setting, data->value.asColor, process);
884 break;
885 case TypeString:
886- return ccsSetString (setting, data->value.asString, processChanged);
887+ return ccsSetString (setting, data->value.asString, process);
888 break;
889 case TypeMatch:
890- return ccsSetMatch (setting, data->value.asMatch, processChanged);
891+ return ccsSetMatch (setting, data->value.asMatch, process);
892 break;
893 case TypeKey:
894- return ccsSetKey (setting, data->value.asKey, processChanged);
895+ return ccsSetKey (setting, data->value.asKey, process);
896 break;
897 case TypeButton:
898- return ccsSetButton (setting, data->value.asButton, processChanged);
899+ return ccsSetButton (setting, data->value.asButton, process);
900 break;
901 case TypeEdge:
902- return ccsSetEdge (setting, data->value.asEdge, processChanged);
903+ return ccsSetEdge (setting, data->value.asEdge, process);
904 break;
905 case TypeBell:
906- return ccsSetBell (setting, data->value.asBell, processChanged);
907+ return ccsSetBell (setting, data->value.asBell, process);
908 break;
909 case TypeList:
910- return ccsSetList (setting, data->value.asList, processChanged);
911+ return ccsSetList (setting, data->value.asList, process);
912 default:
913 break;
914 }
915@@ -2053,7 +2053,8 @@
916
917 while (sl)
918 {
919- (*cPrivate->backend->vTable->readSetting) (context, sl->data);
920+ if (!ccsReadLockdown (context, sl->data))
921+ (*cPrivate->backend->vTable->readSetting) (context, sl->data);
922 sl = sl->next;
923 }
924
925@@ -2087,7 +2088,8 @@
926 CCSSettingList sl = pPrivate->settings;
927 while (sl)
928 {
929- (*cPrivate->backend->vTable->readSetting) (plugin->context, sl->data);
930+ if (!ccsReadLockdown (plugin->context, sl->data))
931+ (*cPrivate->backend->vTable->readSetting) (plugin->context, sl->data);
932 sl = sl->next;
933 }
934
935@@ -2121,7 +2123,8 @@
936
937 while (sl)
938 {
939- (*cPrivate->backend->vTable->writeSetting) (context, sl->data);
940+ if (!ccsReadLockdown (context, sl->data))
941+ (*cPrivate->backend->vTable->writeSetting) (context, sl->data);
942 sl = sl->next;
943 }
944
945@@ -2159,7 +2162,8 @@
946
947 while (l)
948 {
949- (*cPrivate->backend->vTable->writeSetting) (context, l->data);
950+ if (!ccsReadLockdown (context, l->data))
951+ (*cPrivate->backend->vTable->writeSetting) (context, l->data);
952 l = l->next;
953 }
954 }
955@@ -2240,8 +2244,8 @@
956 sizeof (CCSPluginConflict));
957 if (conflict)
958 {
959+ conflict->value = strdup (((CCSString *)sl->data)->value);
960 conflict->refCount = 1;
961- conflict->value = strdup (((CCSString *)sl->data)->value);
962 conflict->type = ConflictPluginError;
963 conflict->plugins = NULL;
964 list = ccsPluginConflictListAppend (list, conflict);
965@@ -2836,7 +2840,7 @@
966 int value;
967 ccsIniParseInt (iniValue, &value);
968
969- ccsSetInt (newSetting, value, FALSE);
970+ ccsSetInt (newSetting, value, SetTemporary);
971 break;
972 }
973 case TypeBool:
974@@ -2844,7 +2848,7 @@
975 Bool value;
976 ccsIniParseBool (iniValue, &value);
977
978- ccsSetBool (newSetting, value, FALSE);
979+ ccsSetBool (newSetting, value, SetTemporary);
980 break;
981 }
982 case TypeFloat:
983@@ -2852,7 +2856,7 @@
984 float value;
985 ccsIniParseFloat (iniValue, &value);
986
987- ccsSetFloat (newSetting, value, FALSE);
988+ ccsSetFloat (newSetting, value, SetTemporary);
989 break;
990 }
991 case TypeString:
992@@ -2860,7 +2864,7 @@
993 char *value;
994 ccsIniParseString (iniValue, &value);
995
996- ccsSetString (newSetting, value, FALSE);
997+ ccsSetString (newSetting, value, SetTemporary);
998 free (value);
999 break;
1000 }
1001@@ -2869,7 +2873,7 @@
1002 CCSSettingColorValue value;
1003 ccsIniParseColor (iniValue, &value);
1004
1005- ccsSetColor (newSetting, value, FALSE);
1006+ ccsSetColor (newSetting, value, SetTemporary);
1007 break;
1008 }
1009 case TypeKey:
1010@@ -2877,7 +2881,7 @@
1011 CCSSettingKeyValue value;
1012 ccsIniParseKey (iniValue, &value);
1013
1014- ccsSetKey (newSetting, value, FALSE);
1015+ ccsSetKey (newSetting, value, SetTemporary);
1016 break;
1017 }
1018 case TypeButton:
1019@@ -2885,7 +2889,7 @@
1020 CCSSettingButtonValue value;
1021 ccsIniParseButton (iniValue, &value);
1022
1023- ccsSetButton (newSetting, value, FALSE);
1024+ ccsSetButton (newSetting, value, SetTemporary);
1025 break;
1026 }
1027 case TypeEdge:
1028@@ -2893,7 +2897,7 @@
1029 unsigned int value;
1030 ccsIniParseEdge (iniValue, &value);
1031
1032- ccsSetEdge (newSetting, value, FALSE);
1033+ ccsSetEdge (newSetting, value, SetTemporary);
1034 break;
1035 }
1036 case TypeBell:
1037@@ -2901,7 +2905,7 @@
1038 Bool value;
1039 ccsIniParseBool (iniValue, &value);
1040
1041- ccsSetBell (newSetting, value, FALSE);
1042+ ccsSetBell (newSetting, value, SetTemporary);
1043 break;
1044 }
1045 case TypeMatch:
1046@@ -2909,7 +2913,7 @@
1047 char *value;
1048 ccsIniParseString (iniValue, &value);
1049
1050- ccsSetMatch (newSetting, value, FALSE);
1051+ ccsSetMatch (newSetting, value, SetTemporary);
1052 free (value);
1053 break;
1054 }
1055@@ -2918,7 +2922,7 @@
1056 CCSSettingValueList value;
1057 ccsIniParseList (iniValue, &value, newSetting);
1058
1059- ccsSetList (newSetting, value, FALSE);
1060+ ccsSetList (newSetting, value, SetTemporary);
1061 ccsSettingValueListFree (value, TRUE);
1062 break;
1063 }
1064@@ -2988,7 +2992,7 @@
1065 int value;
1066 ccsIniParseInt (iniValue, &value);
1067
1068- ccsSetInt (newSetting, value, FALSE);
1069+ ccsSetInt (newSetting, value, SetTemporary);
1070 break;
1071 }
1072 case TypeBool:
1073@@ -2996,7 +3000,7 @@
1074 Bool value;
1075 ccsIniParseBool (iniValue, &value);
1076
1077- ccsSetBool (newSetting, value, FALSE);
1078+ ccsSetBool (newSetting, value, SetTemporary);
1079 break;
1080 }
1081 case TypeFloat:
1082@@ -3004,7 +3008,7 @@
1083 float value;
1084 ccsIniParseFloat (iniValue, &value);
1085
1086- ccsSetFloat (newSetting, value, FALSE);
1087+ ccsSetFloat (newSetting, value, SetTemporary);
1088 break;
1089 }
1090 case TypeString:
1091@@ -3012,7 +3016,7 @@
1092 char *value;
1093 ccsIniParseString (iniValue, &value);
1094
1095- ccsSetString (newSetting, value, FALSE);
1096+ ccsSetString (newSetting, value, SetTemporary);
1097 free (value);
1098 break;
1099 }
1100@@ -3021,7 +3025,7 @@
1101 CCSSettingColorValue value;
1102 ccsIniParseColor (iniValue, &value);
1103
1104- ccsSetColor (newSetting, value, FALSE);
1105+ ccsSetColor (newSetting, value, SetTemporary);
1106 break;
1107 }
1108 case TypeKey:
1109@@ -3029,7 +3033,7 @@
1110 CCSSettingKeyValue value;
1111 ccsIniParseKey (iniValue, &value);
1112
1113- ccsSetKey (newSetting, value, FALSE);
1114+ ccsSetKey (newSetting, value, SetTemporary);
1115 break;
1116 }
1117 case TypeButton:
1118@@ -3037,7 +3041,7 @@
1119 CCSSettingButtonValue value;
1120 ccsIniParseButton (iniValue, &value);
1121
1122- ccsSetButton (newSetting, value, FALSE);
1123+ ccsSetButton (newSetting, value, SetTemporary);
1124 break;
1125 }
1126 case TypeEdge:
1127@@ -3045,7 +3049,7 @@
1128 unsigned int value;
1129 ccsIniParseEdge (iniValue, &value);
1130
1131- ccsSetEdge (newSetting, value, FALSE);
1132+ ccsSetEdge (newSetting, value, SetTemporary);
1133 break;
1134 }
1135 case TypeBell:
1136@@ -3053,7 +3057,7 @@
1137 Bool value;
1138 ccsIniParseBool (iniValue, &value);
1139
1140- ccsSetBell (newSetting, value, FALSE);
1141+ ccsSetBell (newSetting, value, SetTemporary);
1142 break;
1143 }
1144 case TypeMatch:
1145@@ -3061,7 +3065,7 @@
1146 char *value;
1147 ccsIniParseString (iniValue, &value);
1148
1149- ccsSetMatch (newSetting, value, FALSE);
1150+ ccsSetMatch (newSetting, value, SetTemporary);
1151 free (value);
1152 break;
1153 }
1154@@ -3070,7 +3074,7 @@
1155 CCSSettingValueList value;
1156 ccsIniParseList (iniValue, &value, newSetting);
1157
1158- ccsSetList (newSetting, value, FALSE);
1159+ ccsSetList (newSetting, value, SetTemporary);
1160 ccsSettingValueListFree (value, TRUE);
1161 break;
1162 }
1163@@ -3503,6 +3507,357 @@
1164 }
1165
1166 Bool
1167+ccsIniReadValue (CCSContext *context,
1168+ CCSSetting *setting,
1169+ CCSSettingValue *settingValue,
1170+ IniDictionary *dictionary)
1171+{
1172+ char *keyName;
1173+
1174+ asprintf (&keyName, "s%d_%s",
1175+ context->screenNum, setting->name);
1176+
1177+ switch (setting->type)
1178+ {
1179+ case TypeBool:
1180+ {
1181+ Bool value;
1182+
1183+ if (ccsIniGetBool (dictionary, setting->parent->name,
1184+ keyName, &value))
1185+ {
1186+ settingValue->value.asBool = value;
1187+ free (keyName);
1188+ return TRUE;
1189+ }
1190+ }
1191+ break;
1192+ case TypeInt:
1193+ {
1194+ int value;
1195+
1196+ if (ccsIniGetInt (dictionary, setting->parent->name,
1197+ keyName, &value))
1198+ {
1199+ settingValue->value.asInt = value;
1200+ free (keyName);
1201+ return TRUE;
1202+ }
1203+ }
1204+ break;
1205+ case TypeFloat:
1206+ {
1207+ float value;
1208+
1209+ if (ccsIniGetFloat (dictionary, setting->parent->name,
1210+ keyName, &value))
1211+ {
1212+ settingValue->value.asFloat = value;
1213+ free (keyName);
1214+ return TRUE;
1215+ }
1216+ }
1217+ break;
1218+ case TypeString:
1219+ {
1220+ char *value;
1221+
1222+ if (ccsIniGetString (dictionary, setting->parent->name,
1223+ keyName, &value))
1224+ {
1225+ if (settingValue->value.asString)
1226+ free (settingValue->value.asString);
1227+ settingValue->value.asString = value;
1228+ free (keyName);
1229+ return TRUE;
1230+ }
1231+ }
1232+ break;
1233+ case TypeKey:
1234+ {
1235+ CCSSettingKeyValue value;
1236+
1237+ if (ccsIniGetKey (dictionary, setting->parent->name,
1238+ keyName, &value))
1239+ {
1240+ settingValue->value.asKey = value;
1241+ free (keyName);
1242+ return TRUE;
1243+ }
1244+ }
1245+ break;
1246+ case TypeButton:
1247+ {
1248+ CCSSettingButtonValue value;
1249+
1250+ if (ccsIniGetButton (dictionary, setting->parent->name,
1251+ keyName, &value))
1252+ {
1253+ settingValue->value.asButton = value;
1254+ free (keyName);
1255+ return TRUE;
1256+ }
1257+ }
1258+ break;
1259+ case TypeEdge:
1260+ {
1261+ unsigned int value;
1262+
1263+ if (ccsIniGetEdge (dictionary, setting->parent->name,
1264+ keyName, &value))
1265+ {
1266+ settingValue->value.asEdge = value;
1267+ free (keyName);
1268+ return TRUE;
1269+ }
1270+ }
1271+ break;
1272+ case TypeBell:
1273+ {
1274+ Bool value;
1275+
1276+ if (ccsIniGetBell (dictionary, setting->parent->name,
1277+ keyName, &value))
1278+ {
1279+ settingValue->value.asBell = value;
1280+ free (keyName);
1281+ return TRUE;
1282+ }
1283+ }
1284+ break;
1285+ case TypeColor:
1286+ {
1287+ CCSSettingColorValue value;
1288+
1289+ if (ccsIniGetColor (dictionary, setting->parent->name,
1290+ keyName, &value))
1291+ {
1292+ settingValue->value.asColor = value;
1293+ free (keyName);
1294+ return TRUE;
1295+ }
1296+ }
1297+ break;
1298+ case TypeMatch:
1299+ {
1300+ char *value;
1301+ if (ccsIniGetString (dictionary, setting->parent->name,
1302+ keyName, &value))
1303+ {
1304+ if (settingValue->value.asMatch)
1305+ free (settingValue->value.asMatch = value);
1306+
1307+ settingValue->value.asMatch = value;
1308+ free (keyName);
1309+ return TRUE;
1310+ }
1311+ }
1312+ break;
1313+ case TypeList:
1314+ {
1315+ CCSSettingValueList value;
1316+ if (ccsIniGetList (dictionary, setting->parent->name,
1317+ keyName, &value, setting))
1318+ {
1319+ if (settingValue->value.asList)
1320+ ccsSettingValueListFree (settingValue->value.asList, TRUE);
1321+ settingValue->value.asList = value;
1322+ free (keyName);
1323+ return TRUE;
1324+ }
1325+ }
1326+ break;
1327+ default:
1328+ break;
1329+ }
1330+
1331+ free (keyName);
1332+
1333+ return FALSE;
1334+}
1335+
1336+Bool
1337+ccsReadProfileDefault (CCSContext *context,
1338+ CCSSetting *setting)
1339+{
1340+ Bool status = FALSE;
1341+ FILE *fp;
1342+ char *fileName;
1343+ IniDictionary *defaultsFile;
1344+ Bool profileSet = TRUE;
1345+ char *profile = ((CCSContextPrivate *) context->ccsPrivate)->profile;
1346+
1347+ if (!strlen (profile))
1348+ {
1349+ profile = strdup ("default");
1350+ profileSet = FALSE;
1351+ }
1352+
1353+ asprintf (&fileName, DATADIR "/compizconfig/defaults/%s.defaults", profile);
1354+
1355+ fp = fopen (fileName, "r");
1356+
1357+ if (!fp)
1358+ {
1359+ free (fileName);
1360+
1361+ if (!profileSet)
1362+ free (profile);
1363+ return status;
1364+ }
1365+
1366+ fclose (fp);
1367+
1368+ defaultsFile = iniparser_new ((char *) fileName);
1369+ if (!defaultsFile)
1370+ return status;
1371+
1372+ status = ccsIniReadValue (context, setting, &setting->defaultValue, defaultsFile);
1373+ ccsIniClose (defaultsFile);
1374+
1375+ free (fileName);
1376+
1377+ if (!profileSet)
1378+ free (profile);
1379+
1380+ return status;
1381+}
1382+
1383+Bool
1384+ccsReadLockdown (CCSContext *context,
1385+ CCSSetting *setting)
1386+{
1387+ Bool status = FALSE;
1388+ FILE *fp;
1389+ char *fileName;
1390+ IniDictionary *lockdownFile;
1391+ Bool profileSet = TRUE;
1392+ char *profile = ((CCSContextPrivate *) context->ccsPrivate)->profile;
1393+
1394+ if (!strlen (profile))
1395+ {
1396+ profile = strdup ("default");
1397+ profileSet = FALSE;
1398+ }
1399+
1400+ asprintf (&fileName, DATADIR "/compizconfig/lockdown/%s.lockdown", profile);
1401+
1402+ fp = fopen (fileName, "r");
1403+
1404+ if (!fp)
1405+ {
1406+ free (fileName);
1407+
1408+ if (!profileSet)
1409+ free (profile);
1410+ return status;
1411+ }
1412+
1413+ fclose (fp);
1414+
1415+ lockdownFile = iniparser_new ((char *) fileName);
1416+ if (!lockdownFile)
1417+ return status;
1418+
1419+ CONTEXT_PRIV (context);
1420+
1421+ /* If this setting is the default then we need
1422+ * to attempt to read it as we may be overriding
1423+ * the read on startup and the value would not have
1424+ * been initialized to the stored one yet */
1425+
1426+ if (setting->value == &setting->defaultValue)
1427+ (*cPrivate->backend->vTable->readSetting) (context, setting);
1428+
1429+ if (strcmp (setting->parent->name, "core") == 0 &&
1430+ strcmp (setting->name, "active_plugins") == 0)
1431+ {
1432+ CCSSettingValue *vLockdown = calloc (1, sizeof (CCSSettingValue));
1433+
1434+ /* Now read the "mandatory" list */
1435+ status = ccsIniReadValue (context, setting, vLockdown, lockdownFile);
1436+
1437+ if (status)
1438+ {
1439+ CCSSettingValueList vOld;
1440+
1441+ ccsGetList (setting, &vOld);
1442+
1443+ /* Remove dupes */
1444+ CCSSettingValueList vo, vl = ccsCopyList (vLockdown->value.asList, setting);
1445+ CCSSettingValueList po, pl = ccsCopyList (vOld, setting);
1446+
1447+ vo = vl;
1448+ po = pl;
1449+
1450+ Bool appendedEntry = FALSE;
1451+
1452+ while (pl)
1453+ {
1454+ vl = ccsSettingValueListRemove (vl, pl->data, TRUE);
1455+ pl = pl->next;
1456+ }
1457+
1458+ pl = po;
1459+ vo = vl;
1460+
1461+ /* Append any other remaining entries */
1462+
1463+ while (vl)
1464+ {
1465+ D (D_FULL, "Forcing %s to on as per distributor requirements in %s\n", vl->data->value.asString, fileName);
1466+ pl = ccsSettingValueListAppend (pl, vl->data);
1467+ vl = vl->next;
1468+ appendedEntry = TRUE;
1469+ }
1470+
1471+ vl = vo;
1472+ po = pl;
1473+
1474+ /* If we had to modify the value, DONT write the old value out */
1475+ status = !appendedEntry;
1476+
1477+ ccsSetList (setting, pl, SetTemporary);
1478+
1479+ if (!status)
1480+ {
1481+ CCSSettingValueList vl;
1482+ CCSStringList list = ccsGetStringListFromValueList (pl);
1483+
1484+ ccsSetActivePluginList (context, list);
1485+ ccsStringListFree (list, TRUE);
1486+
1487+ list = ccsGetSortedPluginStringList (context);
1488+
1489+ vl = ccsGetValueListFromStringList (list, setting);
1490+ ccsSetList (setting, vl, FALSE);
1491+ ccsSettingValueListFree (vl, TRUE);
1492+ ccsStringListFree (list, TRUE);
1493+ (*cPrivate->backend->vTable->writeSetting) (context, setting);
1494+ }
1495+
1496+ ccsSettingValueListFree (vl, TRUE);
1497+ ccsSettingValueListFree (pl, TRUE);
1498+ }
1499+
1500+ status = FALSE;
1501+
1502+ ccsFreeSettingValue (vLockdown);
1503+ }
1504+ else
1505+ status = ccsIniReadValue (context, setting, setting->value, lockdownFile);
1506+
1507+ ccsIniClose (lockdownFile);
1508+
1509+ free (fileName);
1510+
1511+ if (!profileSet)
1512+ free (profile);
1513+
1514+ return status;
1515+}
1516+
1517+Bool
1518 ccsImportFromFile (CCSContext *context,
1519 const char *fileName,
1520 Bool overwriteNonDefault)
1521@@ -3512,7 +3867,6 @@
1522 CCSSettingList s;
1523 CCSPlugin *plugin;
1524 CCSSetting *setting;
1525- char *keyName;
1526 FILE *fp;
1527
1528 /* check if the file exists first */
1529@@ -3535,128 +3889,13 @@
1530
1531 for (s = pPrivate->settings; s; s = s->next)
1532 {
1533+ CCSSettingValue value;
1534 setting = s->data;
1535 if (!setting->isDefault && !overwriteNonDefault)
1536 continue;
1537
1538- asprintf (&keyName, "s%d_%s",
1539- context->screenNum, setting->name);
1540-
1541- switch (setting->type)
1542- {
1543- case TypeBool:
1544- {
1545- Bool value;
1546-
1547- if (ccsIniGetBool (importFile, plugin->name,
1548- keyName, &value))
1549- {
1550- ccsSetBool (setting, value, TRUE);
1551- }
1552- }
1553- break;
1554- case TypeInt:
1555- {
1556- int value;
1557-
1558- if (ccsIniGetInt (importFile, plugin->name,
1559- keyName, &value))
1560- ccsSetInt (setting, value, TRUE);
1561- }
1562- break;
1563- case TypeFloat:
1564- {
1565- float value;
1566-
1567- if (ccsIniGetFloat (importFile, plugin->name,
1568- keyName, &value))
1569- ccsSetFloat (setting, value, TRUE);
1570- }
1571- break;
1572- case TypeString:
1573- {
1574- char *value;
1575-
1576- if (ccsIniGetString (importFile, plugin->name,
1577- keyName, &value))
1578- {
1579- ccsSetString (setting, value, TRUE);
1580- free (value);
1581- }
1582- }
1583- break;
1584- case TypeKey:
1585- {
1586- CCSSettingKeyValue value;
1587-
1588- if (ccsIniGetKey (importFile, plugin->name,
1589- keyName, &value))
1590- ccsSetKey (setting, value, TRUE);
1591- }
1592- break;
1593- case TypeButton:
1594- {
1595- CCSSettingButtonValue value;
1596-
1597- if (ccsIniGetButton (importFile, plugin->name,
1598- keyName, &value))
1599- ccsSetButton (setting, value, TRUE);
1600- }
1601- break;
1602- case TypeEdge:
1603- {
1604- unsigned int value;
1605-
1606- if (ccsIniGetEdge (importFile, plugin->name,
1607- keyName, &value))
1608- ccsSetEdge (setting, value, TRUE);
1609- }
1610- break;
1611- case TypeBell:
1612- {
1613- Bool value;
1614-
1615- if (ccsIniGetBell (importFile, plugin->name,
1616- keyName, &value))
1617- ccsSetBell (setting, value, TRUE);
1618- }
1619- break;
1620- case TypeColor:
1621- {
1622- CCSSettingColorValue value;
1623-
1624- if (ccsIniGetColor (importFile, plugin->name,
1625- keyName, &value))
1626- ccsSetColor (setting, value, TRUE);
1627- }
1628- break;
1629- case TypeMatch:
1630- {
1631- char *value;
1632- if (ccsIniGetString (importFile, plugin->name,
1633- keyName, &value))
1634- {
1635- ccsSetMatch (setting, value, TRUE);
1636- free (value);
1637- }
1638- }
1639- break;
1640- case TypeList:
1641- {
1642- CCSSettingValueList value;
1643- if (ccsIniGetList (importFile, plugin->name,
1644- keyName, &value, setting))
1645- {
1646- ccsSetList (setting, value, TRUE);
1647- ccsSettingValueListFree (value, TRUE);
1648- }
1649- }
1650- break;
1651- default:
1652- break;
1653- }
1654-
1655- free (keyName);
1656+ if (ccsIniReadValue (context, setting, &value, importFile))
1657+ ccsSetValue (setting, &value, TRUE);
1658 }
1659 }
1660

Subscribers

People subscribed via source and target branches

to all changes: