Compiz Configuration Library

Merge lp:~smspillaz/compiz-libcompizconfig/compiz-libcompizconfig.fix_873772.2 into lp:compiz-libcompizconfig

Proposed by Sam Spilsbury on 2012-04-13
Status: Superseded
Proposed branch: lp:~smspillaz/compiz-libcompizconfig/compiz-libcompizconfig.fix_873772.2
Merge into: lp:compiz-libcompizconfig
Diff against target: 1749 lines (+618/-337) 10 files modified
To merge this branch: bzr merge lp:~smspillaz/compiz-libcompizconfig/compiz-libcompizconfig.fix_873772.2
Reviewer Review Type Date Requested Status
Compiz Maintainers 2012-04-13 Pending
Review via email: mp+101860@code.launchpad.net

This proposal supersedes a proposal from 2011-10-15.

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

Description of the Change

Bug 873772

== Problem ==

Distro needs a way to do two things:
1) Override the upstream defaults
2) Override keys entirely

== Solution ==

Added a framework to do both.

Place a profile.defaults in DATADIR/compizconfig/defaults using the ini format to override the default values for settings.
Place a profile.lockdown in DATADIR/compizconfig/lockdown using the ini format to override the values entirely (except for lists, where you can mandate content to be in a list, but appending is allowed)

Also did some cleanup and fixed some obscure bugs in the guest session.

== Testing ==

Probably need to mock out the settings backend to do any kind of meaningful testing.

To post a comment you must log in.
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

Your CMakeList.txt file has the datadir twice.

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

Unmerged revisions

432. By Sam Spilsbury on 2012-04-13

Merged from lp:~compiz-team/compiz-libcompizconfig/compiz-libcompizconfig.fix_873772
and cleanup

431. By Sam Spilsbury on 2012-04-13

Don't require ccp to be built

Preview Diff

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

Subscribers

People subscribed via source and target branches