summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings/interfaces/interfaces.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfaces.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings/interfaces/interfaces.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp
index 436e449..6b161ae 100644
--- a/noncore/settings/networksettings/interfaces/interfaces.cpp
+++ b/noncore/settings/networksettings/interfaces/interfaces.cpp
@@ -1,712 +1,712 @@
1#include "interfaces.h" 1#include "interfaces.h"
2 2
3#include <qcheckbox.h> 3#include <qcheckbox.h>
4#include <qfile.h> 4#include <qfile.h>
5#include <qtextstream.h> 5#include <qtextstream.h>
6#include <qregexp.h> 6#include <qregexp.h>
7 7
8// The three stanza's 8// The three stanza's
9#define AUTO "auto" 9#define AUTO "auto"
10#define IFACE "iface" 10#define IFACE "iface"
11#define MAPPING "mapping" 11#define MAPPING "mapping"
12 12
13/** 13/**
14 * Constructor. Reads in the interfaces file and then split the file up by 14 * Constructor. Reads in the interfaces file and then split the file up by
15 * the \n for interfaces variable. 15 * the \n for interfaces variable.
16 * @param useInterfacesFile if an interface file other then the default is 16 * @param useInterfacesFile if an interface file other then the default is
17 * desired to be used it should be passed in. 17 * desired to be used it should be passed in.
18 */ 18 */
19Interfaces::Interfaces(QString useInterfacesFile){ 19Interfaces::Interfaces(QString useInterfacesFile){
20 acceptedFamily.append(INTERFACES_FAMILY_INET); 20 acceptedFamily.append(INTERFACES_FAMILY_INET);
21 acceptedFamily.append(INTERFACES_FAMILY_IPX); 21 acceptedFamily.append(INTERFACES_FAMILY_IPX);
22 acceptedFamily.append(INTERFACES_FAMILY_INET6); 22 acceptedFamily.append(INTERFACES_FAMILY_INET6);
23 23
24 interfacesFile = useInterfacesFile; 24 interfacesFile = useInterfacesFile;
25 QFile file(interfacesFile); 25 QFile file(interfacesFile);
26 if (!file.open(IO_ReadOnly)){ 26 if (!file.open(IO_ReadOnly)){
27 qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() ); 27 qDebug("Interfaces: Can't open file: %s for reading.", interfacesFile.latin1() );
28 currentIface = interfaces.end(); 28 currentIface = interfaces.end();
29 currentMapping = interfaces.end(); 29 currentMapping = interfaces.end();
30 return; 30 return;
31 } 31 }
32 QTextStream stream( &file ); 32 QTextStream stream( &file );
33 QString line; 33 QString line;
34 while ( !stream.eof() ) { 34 while ( !stream.eof() ) {
35 line += stream.readLine(); 35 line += stream.readLine();
36 line += "\n"; 36 line += "\n";
37 } 37 }
38 file.close(); 38 file.close();
39 interfaces = QStringList::split("\n", line, true); 39 interfaces = QStringList::split("\n", line, true);
40 40
41 currentIface = interfaces.end(); 41 currentIface = interfaces.end();
42 currentMapping = interfaces.end(); 42 currentMapping = interfaces.end();
43} 43}
44 44
45 45
46/** 46/**
47 * Get a list of all interfaces in the interface file. Usefull for 47 * Get a list of all interfaces in the interface file. Useful for
48 * hardware that is not currently connected such as an 802.11b card 48 * hardware that is not currently connected such as an 802.11b card
49 * not plugged in, but configured for when it is plugged in. 49 * not plugged in, but configured for when it is plugged in.
50 * @return Return string list of interfaces. 50 * @return Return string list of interfaces.
51 **/ 51 **/
52QStringList Interfaces::getInterfaceList(){ 52QStringList Interfaces::getInterfaceList(){
53 QStringList list; 53 QStringList list;
54 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 54 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
55 QString line = (*it).simplifyWhiteSpace(); 55 QString line = (*it).simplifyWhiteSpace();
56 if(line.contains(IFACE) && line.at(0) != '#'){ 56 if(line.contains(IFACE) && line.at(0) != '#'){
57 line = line.mid(QString(IFACE).length() +1, line.length()); 57 line = line.mid(QString(IFACE).length() +1, line.length());
58 line = line.simplifyWhiteSpace(); 58 line = line.simplifyWhiteSpace();
59 int findSpace = line.find(" "); 59 int findSpace = line.find(" ");
60 if( findSpace >= 0){ 60 if( findSpace >= 0){
61 line = line.mid(0, findSpace); 61 line = line.mid(0, findSpace);
62 list.append(line); 62 list.append(line);
63 } 63 }
64 } 64 }
65 } 65 }
66 return list; 66 return list;
67} 67}
68 68
69/** 69/**
70 * Find out if interface is in an "auto" group or not. 70 * Find out if interface is in an "auto" group or not.
71 * Report any duplicates such as eth0 being in two differnt auto's 71 * Report any duplicates such as eth0 being in two differnt auto's
72 * @param interface interface to check to see if it is on or not. 72 * @param interface interface to check to see if it is on or not.
73 * @return true is interface is in auto 73 * @return true is interface is in auto
74 */ 74 */
75bool Interfaces::isAuto(const QString &interface) const { 75bool Interfaces::isAuto(const QString &interface) const {
76 QStringList autoLines = interfaces.grep(QRegExp(AUTO)); 76 QStringList autoLines = interfaces.grep(QRegExp(AUTO));
77 QStringList awi = autoLines.grep(QRegExp(interface)); 77 QStringList awi = autoLines.grep(QRegExp(interface));
78 if(awi.count() > 1) 78 if(awi.count() > 1)
79 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); 79 qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1());
80 return awi.count() > 0; 80 return awi.count() > 0;
81} 81}
82 82
83/** 83/**
84 * Attempt to set the auto option for interface to setAuto. 84 * Attempt to set the auto option for interface to setAuto.
85 * @param interface the interface to set 85 * @param interface the interface to set
86 * @param setAuto the value to set interface to. 86 * @param setAuto the value to set interface to.
87 * @return false if already set to setAuto. 87 * @return false if already set to setAuto.
88 * */ 88 * */
89bool Interfaces::setAuto(const QString &interface, bool setAuto){ 89bool Interfaces::setAuto(const QString &interface, bool setAuto){
90 // Don't need to set it if it is already set. 90 // Don't need to set it if it is already set.
91 if(isAuto(interface) == setAuto) 91 if(isAuto(interface) == setAuto)
92 return false; 92 return false;
93 93
94 bool changed = false; 94 bool changed = false;
95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 95 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
96 if((*it).contains(AUTO)){ 96 if((*it).contains(AUTO)){
97 //We know that they are not in any group so let add to this auto. 97 //We know that they are not in any group so let add to this auto.
98 if(setAuto){ 98 if(setAuto){
99 (*it) = (*it) += " " + interface; 99 (*it) = (*it) += " " + interface;
100 // Don't care to have such thins as: auto eth0 lo usb0 100 // Don't care to have such thins as: auto eth0 lo usb0
101 (*it) = (*it).simplifyWhiteSpace(); 101 (*it) = (*it).simplifyWhiteSpace();
102 changed = true; 102 changed = true;
103 break; 103 break;
104 } 104 }
105 // else see if we need to remove from this one 105 // else see if we need to remove from this one
106 else{ 106 else{
107 if((*it).contains(interface)){ 107 if((*it).contains(interface)){
108 (*it) = (*it).replace(QRegExp(interface), ""); 108 (*it) = (*it).replace(QRegExp(interface), "");
109 // if AUTO is the only thing left clear the line 109 // if AUTO is the only thing left clear the line
110 if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO) 110 if(((*it).simplifyWhiteSpace()).replace(QRegExp(" "),"") == AUTO)
111 (*it) = ""; 111 (*it) = "";
112 changed = true; 112 changed = true;
113 // Don't break because we want to make sure we remove all cases. 113 // Don't break because we want to make sure we remove all cases.
114 } 114 }
115 } 115 }
116 } 116 }
117 } 117 }
118 // In the case where there is no AUTO field add one. 118 // In the case where there is no AUTO field add one.
119 if(!changed && setAuto) 119 if(!changed && setAuto)
120 interfaces.append(QString(AUTO" %1").arg(interface)); 120 interfaces.append(QString(AUTO" %1").arg(interface));
121 return true; 121 return true;
122} 122}
123 123
124/** 124/**
125 * Set the current interface to interface. This needs to be done before you 125 * Set the current interface to interface. This needs to be done before you
126 * can call getFamily(), getMethod, and get/setOption(). 126 * can call getFamily(), getMethod, and get/setOption().
127 * @param interface the name of the interface to set. All whitespace is 127 * @param interface the name of the interface to set. All whitespace is
128 * removed from the interface name. 128 * removed from the interface name.
129 * @return bool true if it is successfull. 129 * @return bool true if it is successful.
130 */ 130 */
131bool Interfaces::setInterface(QString interface){ 131bool Interfaces::setInterface(QString interface){
132 interface = interface.simplifyWhiteSpace(); 132 interface = interface.simplifyWhiteSpace();
133 interface = interface.replace(QRegExp(" "), ""); 133 interface = interface.replace(QRegExp(" "), "");
134 return setStanza(IFACE, interface, currentIface); 134 return setStanza(IFACE, interface, currentIface);
135} 135}
136 136
137/** 137/**
138 * A quick helper funtion to see if the current interface is set. 138 * A quick helper funtion to see if the current interface is set.
139 * @return bool true if set, false otherwise. 139 * @return bool true if set, false otherwise.
140 */ 140 */
141bool Interfaces::isInterfaceSet() const { 141bool Interfaces::isInterfaceSet() const {
142 return (interfaces.end() != currentIface); 142 return (interfaces.end() != currentIface);
143} 143}
144 144
145/** 145/**
146 * Add a new interface of with the settings - family and method 146 * Add a new interface of with the settings - family and method
147 * @param interface the name of the interface to set. All whitespace is 147 * @param interface the name of the interface to set. All whitespace is
148 * removed from the interface name. 148 * removed from the interface name.
149 * @param family the family of this interface inet or inet, ipx or inet6 149 * @param family the family of this interface inet or inet, ipx or inet6
150 * Must of one of the families defined in interfaces.h 150 * Must of one of the families defined in interfaces.h
151 * @param method for the family. see interfaces man page for family methods. 151 * @param method for the family. see interfaces man page for family methods.
152 * @return true if successfull. 152 * @return true if successful.
153 */ 153 */
154bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ 154bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){
155 qDebug("Interfaces::addInterface(%s)",interface.latin1()); 155 qDebug("Interfaces::addInterface(%s)",interface.latin1());
156 if(0 == acceptedFamily.contains(family)) 156 if(0 == acceptedFamily.contains(family))
157 return false; 157 return false;
158 QString newInterface = interface.simplifyWhiteSpace(); 158 QString newInterface = interface.simplifyWhiteSpace();
159 newInterface = newInterface.replace(QRegExp(" "), ""); 159 newInterface = newInterface.replace(QRegExp(" "), "");
160 interfaces.append(""); 160 interfaces.append("");
161 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method)); 161 interfaces.append(QString(IFACE " %1 %2 %3").arg(newInterface).arg(family).arg(method));
162 return true; 162 return true;
163} 163}
164 164
165/** 165/**
166 * Copies interface with name interface to name newInterface 166 * Copies interface with name interface to name newInterface
167 * @param newInterface name of the new interface. 167 * @param newInterface name of the new interface.
168 * @return bool true if successfull 168 * @return bool true if successful
169 */ 169 */
170bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){ 170bool Interfaces::copyInterface(const QString &interface, const QString &newInterface){
171 qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1()); 171 qDebug("copy interface %s to %s", interface.latin1(), newInterface.latin1());
172 if(!setInterface(interface)) 172 if(!setInterface(interface))
173 return false; 173 return false;
174 174
175 // Store the old interface and bump past the stanza line. 175 // Store the old interface and bump past the stanza line.
176 QStringList::Iterator it = currentIface; 176 QStringList::Iterator it = currentIface;
177 it++; 177 it++;
178 178
179 // Add the new interface 179 // Add the new interface
180 bool error; 180 bool error;
181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error)); 181 addInterface(newInterface, getInterfaceFamily(error), getInterfaceMethod(error));
182 if(!setInterface(newInterface)) 182 if(!setInterface(newInterface))
183 return false; 183 return false;
184 184
185 QStringList::Iterator newIface = currentIface; 185 QStringList::Iterator newIface = currentIface;
186 newIface++; 186 newIface++;
187 187
188 // Copy all of the lines 188 // Copy all of the lines
189 for ( ; it != interfaces.end(); ++it ){ 189 for ( ; it != interfaces.end(); ++it ){
190 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO))) 190 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)))
191 break; 191 break;
192 newIface = interfaces.insert(newIface, *it); 192 newIface = interfaces.insert(newIface, *it);
193 } 193 }
194 194
195 return true; 195 return true;
196} 196}
197 197
198/** 198/**
199 * Remove the currently selected interface and all of its options. 199 * Remove the currently selected interface and all of its options.
200 * @return bool if successfull or not. 200 * @return bool if successful or not.
201 */ 201 */
202bool Interfaces::removeInterface(){ 202bool Interfaces::removeInterface(){
203 return removeStanza(currentIface); 203 return removeStanza(currentIface);
204} 204}
205 205
206/** 206/**
207 * Gets the hardware name of the interface that is currently selected. 207 * Gets the hardware name of the interface that is currently selected.
208 * @return QString name of the hardware interface (eth0, usb2, wlan1...). 208 * @return QString name of the hardware interface (eth0, usb2, wlan1...).
209 * @param error set to true if any error occurs, false otherwise. 209 * @param error set to true if any error occurs, false otherwise.
210 */ 210 */
211QString Interfaces::getInterfaceName(bool &error){ 211QString Interfaces::getInterfaceName(bool &error){
212 if(currentIface == interfaces.end()){ 212 if(currentIface == interfaces.end()){
213 error = true; 213 error = true;
214 return QString(); 214 return QString();
215 } 215 }
216 QString line = (*currentIface); 216 QString line = (*currentIface);
217 line = line.mid(QString(IFACE).length() +1, line.length()); 217 line = line.mid(QString(IFACE).length() +1, line.length());
218 line = line.simplifyWhiteSpace(); 218 line = line.simplifyWhiteSpace();
219 int findSpace = line.find(" "); 219 int findSpace = line.find(" ");
220 if( findSpace < 0){ 220 if( findSpace < 0){
221 error = true; 221 error = true;
222 return QString(); 222 return QString();
223 } 223 }
224 error = false; 224 error = false;
225 return line.mid(0, findSpace); 225 return line.mid(0, findSpace);
226} 226}
227 227
228/** 228/**
229 * Gets the family name of the interface that is currently selected. 229 * Gets the family name of the interface that is currently selected.
230 * @return QString name of the family (inet, inet6, ipx). 230 * @return QString name of the family (inet, inet6, ipx).
231 * @param error set to true if any error occurs, false otherwise. 231 * @param error set to true if any error occurs, false otherwise.
232 */ 232 */
233QString Interfaces::getInterfaceFamily(bool &error){ 233QString Interfaces::getInterfaceFamily(bool &error){
234 QString name = getInterfaceName(error); 234 QString name = getInterfaceName(error);
235 if(error) 235 if(error)
236 return QString(); 236 return QString();
237 QString line = (*currentIface); 237 QString line = (*currentIface);
238 line = line.mid(QString(IFACE).length() +1, line.length()); 238 line = line.mid(QString(IFACE).length() +1, line.length());
239 line = line.mid(name.length()+1, line.length()); 239 line = line.mid(name.length()+1, line.length());
240 line = line.simplifyWhiteSpace(); 240 line = line.simplifyWhiteSpace();
241 int findSpace = line.find(" "); 241 int findSpace = line.find(" ");
242 if( findSpace < 0){ 242 if( findSpace < 0){
243 error = true; 243 error = true;
244 return QString(); 244 return QString();
245 } 245 }
246 error = false; 246 error = false;
247 return line.mid(0, findSpace); 247 return line.mid(0, findSpace);
248} 248}
249 249
250/** 250/**
251 * Gets the method of the interface that is currently selected. 251 * Gets the method of the interface that is currently selected.
252 * @return QString name of the method such as staic or dhcp. 252 * @return QString name of the method such as staic or dhcp.
253 * See the man page of interfaces for possible methods depending on the family. 253 * See the man page of interfaces for possible methods depending on the family.
254 * @param error set to true if any error occurs, false otherwise. 254 * @param error set to true if any error occurs, false otherwise.
255 */ 255 */
256QString Interfaces::getInterfaceMethod(bool &error){ 256QString Interfaces::getInterfaceMethod(bool &error){
257 QString name = getInterfaceName(error); 257 QString name = getInterfaceName(error);
258 if(error) 258 if(error)
259 return QString(); 259 return QString();
260 QString family = getInterfaceFamily(error); 260 QString family = getInterfaceFamily(error);
261 if(error) 261 if(error)
262 return QString(); 262 return QString();
263 QString line = (*currentIface); 263 QString line = (*currentIface);
264 line = line.mid(QString(IFACE).length()+1, line.length()); 264 line = line.mid(QString(IFACE).length()+1, line.length());
265 line = line.mid(name.length()+1, line.length()); 265 line = line.mid(name.length()+1, line.length());
266 line = line.mid(family.length()+1, line.length()); 266 line = line.mid(family.length()+1, line.length());
267 line = line.simplifyWhiteSpace(); 267 line = line.simplifyWhiteSpace();
268 error = false; 268 error = false;
269 return line; 269 return line;
270} 270}
271 271
272/** 272/**
273 * Sets the interface name to newName. 273 * Sets the interface name to newName.
274 * @param newName the new name of the interface. All whitespace is removed. 274 * @param newName the new name of the interface. All whitespace is removed.
275 * @return bool true if successfull. 275 * @return bool true if successful.
276 */ 276 */
277bool Interfaces::setInterfaceName(const QString &newName){ 277bool Interfaces::setInterfaceName(const QString &newName){
278 qDebug("setInterfaceName %s", newName.latin1()); 278 qDebug("setInterfaceName %s", newName.latin1());
279 if(currentIface == interfaces.end()) 279 if(currentIface == interfaces.end())
280 return false; 280 return false;
281 QString name = newName.simplifyWhiteSpace(); 281 QString name = newName.simplifyWhiteSpace();
282 name = name.replace(QRegExp(" "), ""); 282 name = name.replace(QRegExp(" "), "");
283 bool returnValue = false; 283 bool returnValue = false;
284 QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue)); 284 QString tmp = QString("iface %1 %2 %3").arg(name).arg(getInterfaceFamily(returnValue)).arg(getInterfaceMethod(returnValue));
285 qDebug("setting %s",tmp.latin1()); 285 qDebug("setting %s",tmp.latin1());
286 286
287 (*currentIface) = tmp; 287 (*currentIface) = tmp;
288 return !returnValue; 288 return !returnValue;
289} 289}
290 290
291/** 291/**
292 * Sets the interface family to newName. 292 * Sets the interface family to newName.
293 * @param newName the new name of the interface. Must be one of the families 293 * @param newName the new name of the interface. Must be one of the families
294 * defined in the interfaces.h file. 294 * defined in the interfaces.h file.
295 * @return bool true if successfull. 295 * @return bool true if successful.
296 */ 296 */
297bool Interfaces::setInterfaceFamily(const QString &newName){ 297bool Interfaces::setInterfaceFamily(const QString &newName){
298 if(currentIface == interfaces.end()) 298 if(currentIface == interfaces.end())
299 return false; 299 return false;
300 if(acceptedFamily.contains(newName)==0) 300 if(acceptedFamily.contains(newName)==0)
301 return false; 301 return false;
302 bool returnValue = false; 302 bool returnValue = false;
303 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue)); 303 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(newName).arg(getInterfaceMethod(returnValue));
304 return !returnValue; 304 return !returnValue;
305} 305}
306 306
307/** 307/**
308 * Sets the interface method to newName 308 * Sets the interface method to newName
309 * @param newName the new name of the interface 309 * @param newName the new name of the interface
310 * @return bool true if successfull. 310 * @return bool true if successful.
311 */ 311 */
312bool Interfaces::setInterfaceMethod(const QString &newName){ 312bool Interfaces::setInterfaceMethod(const QString &newName){
313 if(currentIface == interfaces.end()) 313 if(currentIface == interfaces.end())
314 return false; 314 return false;
315 bool returnValue = false; 315 bool returnValue = false;
316 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName); 316 (*currentIface) = QString("iface %1 %2 %3").arg(getInterfaceName(returnValue)).arg(getInterfaceFamily(returnValue)).arg(newName);
317 return !returnValue; 317 return !returnValue;
318} 318}
319 319
320/** 320/**
321 * Get a value for an option in the currently selected interface. For example 321 * Get a value for an option in the currently selected interface. For example
322 * calling getInterfaceOption("address") on the following stanza would 322 * calling getInterfaceOption("address") on the following stanza would
323 * return 192.168.1.1. 323 * return 192.168.1.1.
324 * iface eth0 static 324 * iface eth0 static
325 * address 192.168.1.1 325 * address 192.168.1.1
326 * @param option the options to get the value. 326 * @param option the options to get the value.
327 * @param error set to true if any error occurs, false otherwise. 327 * @param error set to true if any error occurs, false otherwise.
328 * @return QString the options value. QString::null if error == true 328 * @return QString the options value. QString::null if error == true
329 */ 329 */
330QString Interfaces::getInterfaceOption(const QString &option, bool &error){ 330QString Interfaces::getInterfaceOption(const QString &option, bool &error){
331 return getOption(currentIface, option, error); 331 return getOption(currentIface, option, error);
332} 332}
333 333
334/** 334/**
335 * Set a value for an option in the currently selected interface. If option 335 * Set a value for an option in the currently selected interface. If option
336 * doesn't exist then it is added along with the value. 336 * doesn't exist then it is added along with the value.
337 * If value isEmpty() then we will remove the option 337 * If value isEmpty() then we will remove the option
338 * 338 *
339 * @param option the options to set the value. 339 * @param option the options to set the value.
340 * @param value the value that option should be set to. 340 * @param value the value that option should be set to.
341 * @param error set to true if any error occurs, false otherwise. 341 * @param error set to true if any error occurs, false otherwise.
342 * @return QString the options value. QString::null if error == true 342 * @return QString the options value. QString::null if error == true
343 */ 343 */
344bool Interfaces::setInterfaceOption(const QString &option, const QString &value){ 344bool Interfaces::setInterfaceOption(const QString &option, const QString &value){
345 if( value.stripWhiteSpace().isEmpty() ) 345 if( value.stripWhiteSpace().isEmpty() )
346 return removeInterfaceOption( option ); 346 return removeInterfaceOption( option );
347 347
348 qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1()); 348 qDebug("iface >%s< option >%s< value >%s<", (*currentIface).latin1(), option.latin1(),value.latin1());
349 return setOption(currentIface, option, value); 349 return setOption(currentIface, option, value);
350} 350}
351 351
352/** 352/**
353 * Removes a value for an option in the currently selected interface. 353 * Removes a value for an option in the currently selected interface.
354 * @param option the options to set the value. 354 * @param option the options to set the value.
355 * @param error set to true if any error occurs, false otherwise. 355 * @param error set to true if any error occurs, false otherwise.
356 * @return QString the options value. QString::null if error == true 356 * @return QString the options value. QString::null if error == true
357 */ 357 */
358bool Interfaces::removeInterfaceOption(const QString &option){ 358bool Interfaces::removeInterfaceOption(const QString &option){
359 return removeOption(currentIface, option); 359 return removeOption(currentIface, option);
360} 360}
361 361
362/** 362/**
363 * Removes a value for an option in the currently selected interface. 363 * Removes a value for an option in the currently selected interface.
364 * @param option the options to set the value. 364 * @param option the options to set the value.
365 * @param value the value that option should be set to. 365 * @param value the value that option should be set to.
366 * @param error set to true if any error occurs, false otherwise. 366 * @param error set to true if any error occurs, false otherwise.
367 * @return QString the options value. QString::null if error == true 367 * @return QString the options value. QString::null if error == true
368 */ 368 */
369bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){ 369bool Interfaces::removeInterfaceOption(const QString &option, const QString &value){
370 return removeOption(currentIface, option, value); 370 return removeOption(currentIface, option, value);
371} 371}
372 372
373/** 373/**
374 * Removes all of the options from the currently selected interface. 374 * Removes all of the options from the currently selected interface.
375 * @return bool error if if successfull 375 * @return bool error if if successful
376 */ 376 */
377bool Interfaces::removeAllInterfaceOptions(){ 377bool Interfaces::removeAllInterfaceOptions(){
378 return removeAllOptions(currentIface); 378 return removeAllOptions(currentIface);
379} 379}
380 380
381/** 381/**
382 * Set the current map to interface's map. This needs to be done before you 382 * Set the current map to interface's map. This needs to be done before you
383 * can call addMapping(), set/getMap(), and get/setScript(). 383 * can call addMapping(), set/getMap(), and get/setScript().
384 * @param interface the name of the interface to set. All whitespace is 384 * @param interface the name of the interface to set. All whitespace is
385 * removed from the interface name. 385 * removed from the interface name.
386 * @return bool true if it is successfull. 386 * @return bool true if it is successful.
387 */ 387 */
388bool Interfaces::setMapping(const QString &interface){ 388bool Interfaces::setMapping(const QString &interface){
389 QString interfaceName = interface.simplifyWhiteSpace(); 389 QString interfaceName = interface.simplifyWhiteSpace();
390 interfaceName = interfaceName.replace(QRegExp(" "), ""); 390 interfaceName = interfaceName.replace(QRegExp(" "), "");
391 return setStanza(MAPPING, interfaceName, currentMapping); 391 return setStanza(MAPPING, interfaceName, currentMapping);
392} 392}
393 393
394/** 394/**
395 * Adds a new Mapping to the interfaces file with interfaces. 395 * Adds a new Mapping to the interfaces file with interfaces.
396 * @param interface the name(s) of the interfaces to set to this mapping 396 * @param interface the name(s) of the interfaces to set to this mapping
397 */ 397 */
398void Interfaces::addMapping(const QString &option){ 398void Interfaces::addMapping(const QString &option){
399 interfaces.append(""); 399 interfaces.append("");
400 interfaces.append(QString(MAPPING " %1").arg(option)); 400 interfaces.append(QString(MAPPING " %1").arg(option));
401} 401}
402 402
403/** 403/**
404 * Remove the currently selected map and all of its options. 404 * Remove the currently selected map and all of its options.
405 * @return bool if successfull or not. 405 * @return bool if successful or not.
406 */ 406 */
407bool Interfaces::removeMapping(){ 407bool Interfaces::removeMapping(){
408 return removeStanza(currentMapping); 408 return removeStanza(currentMapping);
409} 409}
410 410
411/** 411/**
412 * Set a map option within a mapping. 412 * Set a map option within a mapping.
413 * @param map map to use 413 * @param map map to use
414 * @param value value to go with map 414 * @param value value to go with map
415 * @return bool true if it is successfull. 415 * @return bool true if it is successful.
416 */ 416 */
417bool Interfaces::setMap(const QString &map, const QString &value){ 417bool Interfaces::setMap(const QString &map, const QString &value){
418 return setOption(currentMapping, map, value); 418 return setOption(currentMapping, map, value);
419} 419}
420 420
421/** 421/**
422 * Removes a map option within a mapping. 422 * Removes a map option within a mapping.
423 * @param map map to use 423 * @param map map to use
424 * @param value value to go with map 424 * @param value value to go with map
425 * @return bool true if it is successfull. 425 * @return bool true if it is successful.
426 */ 426 */
427bool Interfaces::removeMap(const QString &map, const QString &value){ 427bool Interfaces::removeMap(const QString &map, const QString &value){
428 return removeOption(currentMapping, map, value); 428 return removeOption(currentMapping, map, value);
429} 429}
430 430
431/** 431/**
432 * Get a map value within a mapping. 432 * Get a map value within a mapping.
433 * @param map map to get value of 433 * @param map map to get value of
434 * @param bool true if it is successfull. 434 * @param bool true if it is successful.
435 * @return value that goes to the map 435 * @return value that goes to the map
436 */ 436 */
437QString Interfaces::getMap(const QString &map, bool &error){ 437QString Interfaces::getMap(const QString &map, bool &error){
438 return getOption(currentMapping, map, error); 438 return getOption(currentMapping, map, error);
439} 439}
440 440
441/** 441/**
442 * Sets a script value of the current mapping to argument. 442 * Sets a script value of the current mapping to argument.
443 * @param argument the script name. 443 * @param argument the script name.
444 * @return true if successfull. 444 * @return true if successful.
445 */ 445 */
446bool Interfaces::setScript(const QString &argument){ 446bool Interfaces::setScript(const QString &argument){
447 return setOption(currentMapping, "script", argument); 447 return setOption(currentMapping, "script", argument);
448} 448}
449 449
450/** 450/**
451 * @param error true if could not retrieve the current script argument. 451 * @param error true if could not retrieve the current script argument.
452 * @return QString the argument of the script for the current mapping. 452 * @return QString the argument of the script for the current mapping.
453 */ 453 */
454QString Interfaces::getScript(bool &error){ 454QString Interfaces::getScript(bool &error){
455 return getOption(currentMapping, "script", error); 455 return getOption(currentMapping, "script", error);
456} 456}
457 457
458 458
459 459
460/** 460/**
461 * Helper function used to parse through the QStringList and put pointers in 461 * Helper function used to parse through the QStringList and put pointers in
462 * the correct place. 462 * the correct place.
463 * @param stanza The stanza (auto, iface, mapping) to look for. 463 * @param stanza The stanza (auto, iface, mapping) to look for.
464 * @param option string that must be in the stanza's main line. 464 * @param option string that must be in the stanza's main line.
465 * @param interator interator to place at location of stanza if successfull. 465 * @param interator interator to place at location of stanza if successful.
466 * @return bool true if the stanza is found. 466 * @return bool true if the stanza is found.
467 */ 467 */
468bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){ 468bool Interfaces::setStanza(const QString &stanza, const QString &option, QStringList::Iterator &iterator){
469 bool found = false; 469 bool found = false;
470 iterator = interfaces.end(); 470 iterator = interfaces.end();
471 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 471 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
472 QString line = (*it).simplifyWhiteSpace(); 472 QString line = (*it).simplifyWhiteSpace();
473 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){ 473 if(line.contains(stanza) && line.contains(option) && line.at(0) != '#'){
474 uint point = line.find(option); 474 uint point = line.find(option);
475 bool valid = true; 475 bool valid = true;
476 if(point > 0){ 476 if(point > 0){
477 // There are more chars in the line. check +1 477 // There are more chars in the line. check +1
478 if(line.at(point-1) != ' ') 478 if(line.at(point-1) != ' ')
479 valid = false; 479 valid = false;
480 } 480 }
481 point += option.length(); 481 point += option.length();
482 if(point < line.length()-1){ 482 if(point < line.length()-1){
483 // There are more chars in the line. check -1 483 // There are more chars in the line. check -1
484 if(line.at(point) != ' ') 484 if(line.at(point) != ' ')
485 valid = false; 485 valid = false;
486 } 486 }
487 if(valid){ 487 if(valid){
488 if(found == true){ 488 if(found == true){
489 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1()); 489 qDebug(QString("Interfaces: Found multiple stanza's for search: %1 %2").arg(stanza).arg(option).latin1());
490 } 490 }
491 found = true; 491 found = true;
492 iterator = it; 492 iterator = it;
493 } 493 }
494 } 494 }
495 } 495 }
496 return found; 496 return found;
497} 497}
498 498
499/** 499/**
500 * Sets a value of an option in a stanza 500 * Sets a value of an option in a stanza
501 * @param start the start of the stanza 501 * @param start the start of the stanza
502 * @param option the option to use when setting value. 502 * @param option the option to use when setting value.
503 * @return bool true if successfull, false otherwise. 503 * @return bool true if successful, false otherwise.
504 */ 504 */
505bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 505bool Interfaces::setOption(const QStringList::Iterator &start, const QString &option, const QString &value){
506 if(start == interfaces.end()) 506 if(start == interfaces.end())
507 return false; 507 return false;
508 qDebug("setting option"); 508 qDebug("setting option");
509 bool found = false; 509 bool found = false;
510 bool replaced = false; 510 bool replaced = false;
511 QStringList::Iterator insertAt = NULL; 511 QStringList::Iterator insertAt = NULL;
512 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 512 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
513 qDebug(" Interfaces::setOption got line >%s<",(*it).latin1()); 513 qDebug(" Interfaces::setOption got line >%s<",(*it).latin1());
514 // FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line 514 // FIXME: was not completly stupid just wrong sice all options got inserted bevore the iface line
515 // but since it works with an empty interfaces file I (tille) will not do anything more 515 // but since it works with an empty interfaces file I (tille) will not do anything more
516 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){ 516 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) ){
517 if (found) break; 517 if (found) break;
518// && it != start){ 518// && it != start){
519// if(!found && value != ""){ 519// if(!found && value != ""){
520// // Got to the end of the stanza without finding it, so append it. 520// // Got to the end of the stanza without finding it, so append it.
521// qDebug(" Got to the end of the stanza without finding it, so append it."); 521// qDebug(" Got to the end of the stanza without finding it, so append it.");
522// interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value)); 522// interfaces.insert(--it, QString("\t%1 %2").arg(option).arg(value));
523// } 523// }
524 qDebug("found 1"); 524 qDebug("found 1");
525// interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value)); 525// interfaces.insert(++it, QString("\t%1 %2").arg(option).arg(value));
526 found = true; 526 found = true;
527 insertAt = it; 527 insertAt = it;
528 528
529 } 529 }
530 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 530 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
531 // Found it in stanza so replace it. 531 // Found it in stanza so replace it.
532 qDebug("found 2"); 532 qDebug("found 2");
533 if(found) 533 if(found)
534 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 534 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
535 found = true; 535 found = true;
536 replaced = true; 536 replaced = true;
537 (*it) = QString("\t%1 %2").arg(option).arg(value); 537 (*it) = QString("\t%1 %2").arg(option).arg(value);
538 } 538 }
539 } 539 }
540 if(!found){ 540 if(!found){
541 qDebug("! found insert anyway"); 541 qDebug("! found insert anyway");
542 QStringList::Iterator p = start; 542 QStringList::Iterator p = start;
543 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value)); 543 interfaces.insert(++p, QString("\t%1 %2").arg(option).arg(value));
544 found = true; 544 found = true;
545 } 545 }
546 546
547 if(found && !replaced){ 547 if(found && !replaced){
548 qDebug("found iface but not the option so insert it here..."); 548 qDebug("found iface but not the option so insert it here...");
549 interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value)); 549 interfaces.insert(++insertAt, QString("\t%1 %2").arg(option).arg(value));
550 } 550 }
551 return found; 551 return found;
552} 552}
553 553
554/** 554/**
555 * Removes a stanza and all of its options 555 * Removes a stanza and all of its options
556 * @param stanza the stanza to remove 556 * @param stanza the stanza to remove
557 * @return bool true if successfull. 557 * @return bool true if successful.
558 */ 558 */
559bool Interfaces::removeStanza(QStringList::Iterator &stanza){ 559bool Interfaces::removeStanza(QStringList::Iterator &stanza){
560 if(stanza == interfaces.end()) 560 if(stanza == interfaces.end())
561 return false; 561 return false;
562 (*stanza) = ""; 562 (*stanza) = "";
563 return removeAllOptions(stanza); 563 return removeAllOptions(stanza);
564} 564}
565 565
566/** 566/**
567 * Removes a option in a stanza 567 * Removes a option in a stanza
568 * @param start the start of the stanza 568 * @param start the start of the stanza
569 * @param option the option to remove 569 * @param option the option to remove
570 * @return bool true if successfull, false otherwise. 570 * @return bool true if successful, false otherwise.
571 */ 571 */
572bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){ 572bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option){
573 if(start == interfaces.end()) 573 if(start == interfaces.end())
574 return false; 574 return false;
575 575
576 bool found = false; 576 bool found = false;
577 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 577 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
578 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 578 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
579 // got to the end without finding it 579 // got to the end without finding it
580 break; 580 break;
581 } 581 }
582 if((*it).contains(option) && it != start && (*it).at(0) != '#'){ 582 if((*it).contains(option) && it != start && (*it).at(0) != '#'){
583 // Found it in stanza so replace it. 583 // Found it in stanza so replace it.
584 if(found) 584 if(found)
585 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 585 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
586 found = true; 586 found = true;
587 it = interfaces.remove( it ); // we really want to remove the line 587 it = interfaces.remove( it ); // we really want to remove the line
588 --it; // we do ++it later in the head of the for loop 588 --it; // we do ++it later in the head of the for loop
589 } 589 }
590 } 590 }
591 return found; 591 return found;
592} 592}
593 593
594/** 594/**
595 * Removes a option in a stanza 595 * Removes a option in a stanza
596 * @param start the start of the stanza 596 * @param start the start of the stanza
597 * @param option the option to use when setting value. 597 * @param option the option to use when setting value.
598 * @return bool true if successfull, false otherwise. 598 * @return bool true if successful, false otherwise.
599 */ 599 */
600bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){ 600bool Interfaces::removeOption(const QStringList::Iterator &start, const QString &option, const QString &value){
601 if(start == interfaces.end()) 601 if(start == interfaces.end())
602 return false; 602 return false;
603 603
604 bool found = false; 604 bool found = false;
605 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 605 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
606 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 606 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
607 // got to the end without finding it 607 // got to the end without finding it
608 break; 608 break;
609 } 609 }
610 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){ 610 if((*it).contains(option) && (*it).contains(value) && it != start && (*it).at(0) != '#'){
611 // Found it in stanza so replace it. 611 // Found it in stanza so replace it.
612 if(found) 612 if(found)
613 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1()); 613 qDebug(QString("Interfaces: Set Options found more then one value for option: %1 in stanza: %1").arg(option).arg((*start)).latin1());
614 found = true; 614 found = true;
615 it = interfaces.remove( it ); // we really want to remove the line 615 it = interfaces.remove( it ); // we really want to remove the line
616 --it; // we do ++it later in the head of the for loop 616 --it; // we do ++it later in the head of the for loop
617 } 617 }
618 } 618 }
619 return found; 619 return found;
620} 620}
621 621
622/** 622/**
623 * Removes all options in a stanza 623 * Removes all options in a stanza
624 * @param start the start of the stanza 624 * @param start the start of the stanza
625 * @return bool true if successfull, false otherwise. 625 * @return bool true if successful, false otherwise.
626 */ 626 */
627bool Interfaces::removeAllOptions(const QStringList::Iterator &start){ 627bool Interfaces::removeAllOptions(const QStringList::Iterator &start){
628 if(start == interfaces.end()) 628 if(start == interfaces.end())
629 return false; 629 return false;
630 630
631 QStringList::Iterator it = start; 631 QStringList::Iterator it = start;
632 it = ++it; 632 it = ++it;
633 for (; it != interfaces.end(); ++it ) { 633 for (; it != interfaces.end(); ++it ) {
634 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 634 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
635 break; 635 break;
636 } 636 }
637 it = interfaces.remove(it); 637 it = interfaces.remove(it);
638 it = --it; 638 it = --it;
639 } 639 }
640 // Leave a space between this interface and the next. 640 // Leave a space between this interface and the next.
641 interfaces.insert(it, QString("")); 641 interfaces.insert(it, QString(""));
642 return true; 642 return true;
643} 643}
644 644
645/** 645/**
646 * Gets a value of an option in a stanza 646 * Gets a value of an option in a stanza
647 * @param start the start of the stanza 647 * @param start the start of the stanza
648 * @param option the option to use when getting the value. 648 * @param option the option to use when getting the value.
649 * @param bool true if errors false otherwise. 649 * @param bool true if errors false otherwise.
650 * @return QString the value of option QString::null() if error == true. 650 * @return QString the value of option QString::null() if error == true.
651 */ 651 */
652QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){ 652QString Interfaces::getOption(const QStringList::Iterator &start, const QString &option, bool &error){
653 if(start == interfaces.end()){ 653 if(start == interfaces.end()){
654 error = false; 654 error = false;
655 return QString(); 655 return QString();
656 } 656 }
657 657
658 QString value; 658 QString value;
659 bool found = false; 659 bool found = false;
660 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) { 660 for ( QStringList::Iterator it = start; it != interfaces.end(); ++it ) {
661 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){ 661 if(((*it).contains(IFACE) || (*it).contains(MAPPING) || (*it).contains(AUTO)) && it != start){
662 break; 662 break;
663 } 663 }
664 if((*it).contains(option) && (*it).at(0) != '#'){ 664 if((*it).contains(option) && (*it).at(0) != '#'){
665 if(found) 665 if(found)
666 qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1()); 666 qDebug(QString("Interfaces: getOption found more then one value: %1 for option: %2 in stanza %3").arg((*it)).arg(option).arg((*start)).latin1());
667 found = true; 667 found = true;
668 QString line = (*it).simplifyWhiteSpace(); 668 QString line = (*it).simplifyWhiteSpace();
669 int space = line.find(" ", option.length()); 669 int space = line.find(" ", option.length());
670 if(space != -1){ 670 if(space != -1){
671 value = line.mid(space+1, line.length()); 671 value = line.mid(space+1, line.length());
672 break; 672 break;
673 } 673 }
674 } 674 }
675 } 675 }
676 error = !found; 676 error = !found;
677 return value; 677 return value;
678} 678}
679 679
680/** 680/**
681 * Write out the interfaces file to the file passed into the constructor. 681 * Write out the interfaces file to the file passed into the constructor.
682 * Removes any excess blank lines over 1 line long. 682 * Removes any excess blank lines over 1 line long.
683 * @return bool true if successfull, false if not. 683 * @return bool true if successful, false if not.
684 */ 684 */
685bool Interfaces::write(){ 685bool Interfaces::write(){
686 QFile::remove(interfacesFile); 686 QFile::remove(interfacesFile);
687 QFile file(interfacesFile); 687 QFile file(interfacesFile);
688 688
689 if (!file.open(IO_ReadWrite)){ 689 if (!file.open(IO_ReadWrite)){
690 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1()); 690 qDebug(QString("Interfaces: Can't open file: %1 for writing.").arg(interfacesFile).latin1());
691 return false; 691 return false;
692 } 692 }
693 QTextStream stream( &file ); 693 QTextStream stream( &file );
694 int whiteSpaceCount = 0; 694 int whiteSpaceCount = 0;
695 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { 695 for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) {
696 QString line = (*it).simplifyWhiteSpace(); 696 QString line = (*it).simplifyWhiteSpace();
697 line = line.replace(QRegExp(" "),""); 697 line = line.replace(QRegExp(" "),"");
698 if(line.length() == 0) 698 if(line.length() == 0)
699 whiteSpaceCount++; 699 whiteSpaceCount++;
700 else 700 else
701 whiteSpaceCount = 0; 701 whiteSpaceCount = 0;
702 if(whiteSpaceCount < 2){ 702 if(whiteSpaceCount < 2){
703 qDebug((*it).latin1()); 703 qDebug((*it).latin1());
704 stream << (*it) << '\n'; 704 stream << (*it) << '\n';
705 } 705 }
706 } 706 }
707 file.close(); 707 file.close();
708 return true; 708 return true;
709} 709}
710 710
711// interfaces.cpp 711// interfaces.cpp
712 712