Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/systemfile.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/systemfile.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp index b3fc1a5..2b40834 100644 --- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp +++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp | |||
@@ -8,13 +8,15 @@ | |||
8 | #include "resources.h" | 8 | #include "resources.h" |
9 | #include "systemfile.h" | 9 | #include "systemfile.h" |
10 | 10 | ||
11 | #define TEMPLATEDIR "networktemplates/" | 11 | #define TEMPLATEDIR "networktemplates/" |
12 | QString TemplDir; | 12 | QString TemplDir; |
13 | 13 | ||
14 | SystemFile::SystemFile( const QString & N, const QString & P ){ | 14 | SystemFile::SystemFile( const QString & N, |
15 | const QString & P, | ||
16 | bool KDI ){ | ||
15 | Name = N; | 17 | Name = N; |
16 | Path = P; | 18 | Path = P; |
17 | F = 0; | 19 | F = 0; |
18 | // get template info | 20 | // get template info |
19 | { QString S; | 21 | { QString S; |
20 | QFileInfo FI; | 22 | QFileInfo FI; |
@@ -54,12 +56,14 @@ SystemFile::SystemFile( const QString & N, const QString & P ){ | |||
54 | FI.setFile( S ); | 56 | FI.setFile( S ); |
55 | hasPreDeviceSection = ( FI.exists() && FI.isReadable() ); | 57 | hasPreDeviceSection = ( FI.exists() && FI.isReadable() ); |
56 | S = TemplDir + Name + "/postdevicesection"; | 58 | S = TemplDir + Name + "/postdevicesection"; |
57 | FI.setFile( S ); | 59 | FI.setFile( S ); |
58 | hasPostDeviceSection = ( FI.exists() && FI.isReadable() ); | 60 | hasPostDeviceSection = ( FI.exists() && FI.isReadable() ); |
59 | } | 61 | } |
62 | |||
63 | KnowsDeviceInstances = KDI; | ||
60 | } | 64 | } |
61 | 65 | ||
62 | SystemFile::~SystemFile( void ) { | 66 | SystemFile::~SystemFile( void ) { |
63 | if( F ) | 67 | if( F ) |
64 | delete F; | 68 | delete F; |
65 | } | 69 | } |
@@ -93,93 +97,93 @@ bool SystemFile::close( void ) { | |||
93 | } | 97 | } |
94 | 98 | ||
95 | bool SystemFile::preSection( void ) { | 99 | bool SystemFile::preSection( void ) { |
96 | if( hasPreSection ) { | 100 | if( hasPreSection ) { |
97 | QFile Fl( TemplDir + Name + "/presection" ); | 101 | QFile Fl( TemplDir + Name + "/presection" ); |
98 | if( ! Fl.open( IO_ReadOnly ) ) | 102 | if( ! Fl.open( IO_ReadOnly ) ) |
99 | return 1; // error | 103 | return 0; // error |
100 | // copy file to this file | 104 | // copy file to this file |
101 | F->writeBlock( Fl.readAll() ); | 105 | F->writeBlock( Fl.readAll() ); |
102 | } | 106 | } |
103 | return 0; | 107 | return 1; |
104 | } | 108 | } |
105 | 109 | ||
106 | bool SystemFile::postSection( void ) { | 110 | bool SystemFile::postSection( void ) { |
107 | if( hasPostSection ) { | 111 | if( hasPostSection ) { |
108 | QFile Fl( TemplDir + Name + "/postsection" ); | 112 | QFile Fl( TemplDir + Name + "/postsection" ); |
109 | if( ! Fl.open( IO_ReadOnly ) ) | 113 | if( ! Fl.open( IO_ReadOnly ) ) |
110 | return 1; // error | 114 | return 0; // error |
111 | // copy file to this file | 115 | // copy file to this file |
112 | F->writeBlock( Fl.readAll() ); | 116 | F->writeBlock( Fl.readAll() ); |
113 | } | 117 | } |
114 | return 0; | 118 | return 1; |
115 | } | 119 | } |
116 | 120 | ||
117 | bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { | 121 | bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) { |
118 | if( hasPreNodeSection ) { | 122 | if( hasPreNodeSection ) { |
119 | QFile Fl( TemplDir + Name + "/prenodesection" ); | 123 | QFile Fl( TemplDir + Name + "/prenodesection" ); |
120 | if( ! Fl.open( IO_ReadOnly ) ) | 124 | if( ! Fl.open( IO_ReadOnly ) ) |
121 | return 1; // error | 125 | return 0; // error |
122 | QTextStream TX( &Fl ); | 126 | QTextStream TX( &Fl ); |
123 | QString Out; | 127 | QString Out; |
124 | QString S = TX.readLine(); | 128 | QString S = TX.readLine(); |
125 | while( ! TX.eof() ) { | 129 | while( ! TX.eof() ) { |
126 | Out = S. | 130 | Out = S. |
127 | arg(NNI->nodeClass()->name()); | 131 | arg(NNI->nodeClass()->name()); |
128 | (*this) << Out << endl; | 132 | (*this) << Out << endl; |
129 | S = TX.readLine(); | 133 | S = TX.readLine(); |
130 | } | 134 | } |
131 | } | 135 | } |
132 | return 0; | 136 | return 1; |
133 | } | 137 | } |
134 | 138 | ||
135 | bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) { | 139 | bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) { |
136 | if( hasPostNodeSection ) { | 140 | if( hasPostNodeSection ) { |
137 | QFile Fl( TemplDir + Name + "/postnodesection" ); | 141 | QFile Fl( TemplDir + Name + "/postnodesection" ); |
138 | if( ! Fl.open( IO_ReadOnly ) ) | 142 | if( ! Fl.open( IO_ReadOnly ) ) |
139 | return 1; // error | 143 | return 0; // error |
140 | QTextStream TX( &Fl ); | 144 | QTextStream TX( &Fl ); |
141 | QString Out; | 145 | QString Out; |
142 | QString S = TX.readLine(); | 146 | QString S = TX.readLine(); |
143 | while( ! TX.eof() ) { | 147 | while( ! TX.eof() ) { |
144 | Out = S. | 148 | Out = S. |
145 | arg(NNI->name()); | 149 | arg(NNI->name()); |
146 | (*this) << Out << endl; | 150 | (*this) << Out << endl; |
147 | S = TX.readLine(); | 151 | S = TX.readLine(); |
148 | } | 152 | } |
149 | } | 153 | } |
150 | return 0; | 154 | return 1; |
151 | } | 155 | } |
152 | 156 | ||
153 | bool SystemFile::preDeviceSection( ANetNode * NN ) { | 157 | bool SystemFile::preDeviceSection( ANetNode * NN ) { |
154 | if( hasPreDeviceSection ) { | 158 | if( hasPreDeviceSection ) { |
155 | QFile Fl( TemplDir + Name + "/predevicesection" ); | 159 | QFile Fl( TemplDir + Name + "/predevicesection" ); |
156 | if( ! Fl.open( IO_ReadOnly ) ) | 160 | if( ! Fl.open( IO_ReadOnly ) ) |
157 | return 1; // error | 161 | return 0; // error |
158 | QTextStream TX( &Fl ); | 162 | QTextStream TX( &Fl ); |
159 | QString Out; | 163 | QString Out; |
160 | QString S = TX.readLine(); | 164 | QString S = TX.readLine(); |
161 | while( ! TX.eof() ) { | 165 | while( ! TX.eof() ) { |
162 | Out = S.arg(NN->name()); | 166 | Out = S.arg(NN->name()); |
163 | (*this) << Out << endl; | 167 | (*this) << Out << endl; |
164 | S = TX.readLine(); | 168 | S = TX.readLine(); |
165 | } | 169 | } |
166 | } | 170 | } |
167 | return 0; | 171 | return 1; |
168 | } | 172 | } |
169 | 173 | ||
170 | bool SystemFile::postDeviceSection( ANetNode * NN ) { | 174 | bool SystemFile::postDeviceSection( ANetNode * NN ) { |
171 | if( hasPostDeviceSection ) { | 175 | if( hasPostDeviceSection ) { |
172 | QFile Fl( TemplDir + Name + "/postdevicesection" ); | 176 | QFile Fl( TemplDir + Name + "/postdevicesection" ); |
173 | if( ! Fl.open( IO_ReadOnly ) ) | 177 | if( ! Fl.open( IO_ReadOnly ) ) |
174 | return 1; // error | 178 | return 0; // error |
175 | QTextStream TX( &Fl ); | 179 | QTextStream TX( &Fl ); |
176 | QString Out; | 180 | QString Out; |
177 | QString S = TX.readLine(); | 181 | QString S = TX.readLine(); |
178 | while( ! TX.eof() ) { | 182 | while( ! TX.eof() ) { |
179 | Out = S.arg(NN->name()); | 183 | Out = S.arg(NN->name()); |
180 | (*this) << Out << endl; | 184 | (*this) << Out << endl; |
181 | S = TX.readLine(); | 185 | S = TX.readLine(); |
182 | } | 186 | } |
183 | } | 187 | } |
184 | return 0; | 188 | return 1; |
185 | } | 189 | } |