1 /* This file is part of LED Pattern Editor.
3 * Copyright (C) 2010 Philipp Zabel
5 * LED Pattern Editor is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * LED Pattern Editor is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with LED Pattern Editor. If not, see <http://www.gnu.org/licenses/>.
24 static const DeviceType device = DeviceType.RX51;
26 List<LedPattern> mce_ini_parse () {
27 var list = new List<LedPattern> ();
28 var f = FileStream.open ("/etc/mce/mce.ini", "r");
29 string pattern_section = null;
33 pattern_section = "[LEDPatternNJoyRX44]";
36 pattern_section = "[LEDPatternLystiRX51]";
40 var line = f.read_line ();
41 while (line != null) {
42 if (line == pattern_section) {
43 line = f.read_line ();
44 while ((line != null) && (line[0] != '[')) {
45 if (line.has_prefix ("Pattern")) {
46 LedPattern pattern = null;
49 pattern = new LedPatternRX44 ();
52 pattern = new LedPatternRX51 ();
56 list.append (pattern);
58 line = f.read_line ();
61 line = f.read_line ();
67 void mce_ini_store (List<LedPattern> list) {
68 var f = FileStream.open ("/etc/mce/mce.ini", "r");
69 var g = FileStream.open ("/tmp/mce.ini", "w");
70 string pattern_section = null;
74 pattern_section = "[LEDPatternNJoyRX44]";
77 pattern_section = "[LEDPatternLystiRX51]";
81 var line = f.read_line ();
82 while (line != null) {
83 if (line == pattern_section) {
84 g.printf ("%s\n", line);
85 line = f.read_line ();
86 while ((line != null) && (line[0] != '[')) {
87 if (line.has_prefix ("Pattern")) {
88 unowned List<LedPattern> node;
89 for (node = list.first (); node != null; node = node.next) {
90 if (line.has_prefix (node.data.name + "=")) {
91 g.printf ("%s\n", node.data.dump ());
96 g.printf ("%s\n", line);
99 g.printf ("%s\n", line);
101 line = f.read_line ();
104 g.printf ("%s\n", line);
106 g.printf ("%s\n", line);
108 line = f.read_line ();