Diffstat (limited to 'noncore/settings/networksettings/interfaces/interfaces.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings/interfaces/interfaces.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/settings/networksettings/interfaces/interfaces.cpp b/noncore/settings/networksettings/interfaces/interfaces.cpp index e49998e..8f685fe 100644 --- a/noncore/settings/networksettings/interfaces/interfaces.cpp +++ b/noncore/settings/networksettings/interfaces/interfaces.cpp | |||
@@ -50,49 +50,49 @@ Interfaces::Interfaces(QString useInterfacesFile){ | |||
50 | **/ | 50 | **/ |
51 | QStringList Interfaces::getInterfaceList(){ | 51 | QStringList Interfaces::getInterfaceList(){ |
52 | QStringList list; | 52 | QStringList list; |
53 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 53 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
54 | QString line = (*it).simplifyWhiteSpace(); | 54 | QString line = (*it).simplifyWhiteSpace(); |
55 | if(line.contains(IFACE) && line.at(0) != '#'){ | 55 | if(line.contains(IFACE) && line.at(0) != '#'){ |
56 | line = line.mid(QString(IFACE).length() +1, line.length()); | 56 | line = line.mid(QString(IFACE).length() +1, line.length()); |
57 | line = line.simplifyWhiteSpace(); | 57 | line = line.simplifyWhiteSpace(); |
58 | int findSpace = line.find(" "); | 58 | int findSpace = line.find(" "); |
59 | if( findSpace >= 0){ | 59 | if( findSpace >= 0){ |
60 | line = line.mid(0, findSpace); | 60 | line = line.mid(0, findSpace); |
61 | list.append(line); | 61 | list.append(line); |
62 | } | 62 | } |
63 | } | 63 | } |
64 | } | 64 | } |
65 | return list; | 65 | return list; |
66 | } | 66 | } |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * Find out if interface is in an "auto" group or not. | 69 | * Find out if interface is in an "auto" group or not. |
70 | * Report any duplicates such as eth0 being in two differnt auto's | 70 | * Report any duplicates such as eth0 being in two differnt auto's |
71 | * @param interface interface to check to see if it is on or not. | 71 | * @param interface interface to check to see if it is on or not. |
72 | * @return true is interface is in auto | 72 | * @return true is interface is in auto |
73 | */ | 73 | */ |
74 | bool Interfaces::isAuto(const QString &interface){ | 74 | bool Interfaces::isAuto(const QString &interface) const { |
75 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); | 75 | QStringList autoLines = interfaces.grep(QRegExp(AUTO)); |
76 | QStringList awi = autoLines.grep(QRegExp(interface)); | 76 | QStringList awi = autoLines.grep(QRegExp(interface)); |
77 | if(awi.count() > 1) | 77 | if(awi.count() > 1) |
78 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); | 78 | qDebug(QString("Interfaces: Found more then auto group with interface: %1.").arg(interface).latin1()); |
79 | if(awi.count() < 1) | 79 | if(awi.count() < 1) |
80 | return false; | 80 | return false; |
81 | return true; | 81 | return true; |
82 | } | 82 | } |
83 | 83 | ||
84 | /** | 84 | /** |
85 | * Attempt to set the auto option for interface to setAuto. | 85 | * Attempt to set the auto option for interface to setAuto. |
86 | * @param interface the interface to set | 86 | * @param interface the interface to set |
87 | * @param setAuto the value to set interface to. | 87 | * @param setAuto the value to set interface to. |
88 | * @return false if already set to setAuto. | 88 | * @return false if already set to setAuto. |
89 | * */ | 89 | * */ |
90 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ | 90 | bool Interfaces::setAuto(const QString &interface, bool setAuto){ |
91 | // Don't need to set it if it is already set. | 91 | // Don't need to set it if it is already set. |
92 | if(isAuto(interface) == setAuto) | 92 | if(isAuto(interface) == setAuto) |
93 | return false; | 93 | return false; |
94 | 94 | ||
95 | bool changed = false; | 95 | bool changed = false; |
96 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { | 96 | for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end(); ++it ) { |
97 | if((*it).contains(AUTO)){ | 97 | if((*it).contains(AUTO)){ |
98 | //We know that they are not in any group so let add to this auto. | 98 | //We know that they are not in any group so let add to this auto. |
@@ -118,50 +118,50 @@ bool Interfaces::setAuto(const QString &interface, bool setAuto){ | |||
118 | } | 118 | } |
119 | // In the case where there is no AUTO field add one. | 119 | // In the case where there is no AUTO field add one. |
120 | if(!changed && setAuto) | 120 | if(!changed && setAuto) |
121 | interfaces.append(QString(AUTO" %1").arg(interface)); | 121 | interfaces.append(QString(AUTO" %1").arg(interface)); |
122 | return true; | 122 | return true; |
123 | } | 123 | } |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * Set the current interface to interface. This needs to be done before you | 126 | * Set the current interface to interface. This needs to be done before you |
127 | * can call getFamily(), getMethod, and get/setOption(). | 127 | * can call getFamily(), getMethod, and get/setOption(). |
128 | * @param interface the name of the interface to set. All whitespace is | 128 | * @param interface the name of the interface to set. All whitespace is |
129 | * removed from the interface name. | 129 | * removed from the interface name. |
130 | * @return bool true if it is successfull. | 130 | * @return bool true if it is successfull. |
131 | */ | 131 | */ |
132 | bool Interfaces::setInterface(QString interface){ | 132 | bool Interfaces::setInterface(QString interface){ |
133 | interface = interface.simplifyWhiteSpace(); | 133 | interface = interface.simplifyWhiteSpace(); |
134 | interface = interface.replace(QRegExp(" "), ""); | 134 | interface = interface.replace(QRegExp(" "), ""); |
135 | return setStanza(IFACE, interface, currentIface); | 135 | return setStanza(IFACE, interface, currentIface); |
136 | } | 136 | } |
137 | 137 | ||
138 | /** | 138 | /** |
139 | * A quick helper funtion to see if the current interface is set. | 139 | * A quick helper funtion to see if the current interface is set. |
140 | * @return bool true if set, false otherwise. | 140 | * @return bool true if set, false otherwise. |
141 | */ | 141 | */ |
142 | bool Interfaces::isInterfaceSet(){ | 142 | bool Interfaces::isInterfaceSet() const { |
143 | return (currentIface != interfaces.end()); | 143 | return (interfaces.end() != currentIface); |
144 | } | 144 | } |
145 | 145 | ||
146 | /** | 146 | /** |
147 | * Add a new interface of with the settings - family and method | 147 | * Add a new interface of with the settings - family and method |
148 | * @param interface the name of the interface to set. All whitespace is | 148 | * @param interface the name of the interface to set. All whitespace is |
149 | * removed from the interface name. | 149 | * removed from the interface name. |
150 | * @param family the family of this interface inet or inet, ipx or inet6 | 150 | * @param family the family of this interface inet or inet, ipx or inet6 |
151 | * Must of one of the families defined in interfaces.h | 151 | * Must of one of the families defined in interfaces.h |
152 | * @param method for the family. see interfaces man page for family methods. | 152 | * @param method for the family. see interfaces man page for family methods. |
153 | * @return true if successfull. | 153 | * @return true if successfull. |
154 | */ | 154 | */ |
155 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ | 155 | bool Interfaces::addInterface(const QString &interface, const QString &family, const QString &method){ |
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. |