author | ar <ar> | 2004-04-07 11:23:41 (UTC) |
---|---|---|
committer | ar <ar> | 2004-04-07 11:23:41 (UTC) |
commit | 0e2322d2bc926036d62153346bb03776df1ca987 (patch) (unidiff) | |
tree | 217ce66605d7b68252662942dc98524a7f2d872f | |
parent | 6095b1f70bcac407208e7473598f2bbf53339810 (diff) | |
download | opie-0e2322d2bc926036d62153346bb03776df1ca987.zip opie-0e2322d2bc926036d62153346bb03776df1ca987.tar.gz opie-0e2322d2bc926036d62153346bb03776df1ca987.tar.bz2 |
fix compile problem with gcc3.3.3
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/netnode.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.cpp b/noncore/settings/networksettings2/networksettings2/netnode.cpp index 417fba8..dc66aff 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.cpp +++ b/noncore/settings/networksettings2/networksettings2/netnode.cpp | |||
@@ -1,299 +1,299 @@ | |||
1 | #include <qpe/qpeapplication.h> | 1 | #include <qpe/qpeapplication.h> |
2 | #include <time.h> | 2 | #include <time.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qpixmap.h> | 4 | #include <qpixmap.h> |
5 | 5 | ||
6 | #include "resources.h" | 6 | #include "resources.h" |
7 | #include "netnode.h" | 7 | #include "netnode.h" |
8 | 8 | ||
9 | #include "asdevice.h" | 9 | #include "asdevice.h" |
10 | #include "asline.h" | 10 | #include "asline.h" |
11 | #include "asconnection.h" | 11 | #include "asconnection.h" |
12 | #include "asfullsetup.h" | 12 | #include "asfullsetup.h" |
13 | 13 | ||
14 | QString & deQuote( QString & X ) { | 14 | QString & deQuote( QString & X ) { |
15 | if( X[0] == '"' ) { | 15 | if( X[0] == '"' ) { |
16 | // remove end and trailing "" and \x -> x | 16 | // remove end and trailing "" and \x -> x |
17 | QChar R; | 17 | QChar R; |
18 | long idx; | 18 | long idx; |
19 | idx = X.length()-1; | 19 | idx = X.length()-1; |
20 | X = X.mid( 1, idx ); | 20 | X = X.mid( 1, idx ); |
21 | 21 | ||
22 | idx = 0; | 22 | idx = 0; |
23 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { | 23 | while( ( idx = X.find( '\\', idx ) ) >= 0 ) { |
24 | R = X[idx+1]; | 24 | R = X.at( idx + 1 ); |
25 | X.replace( idx, 2, &R, 1 ); | 25 | X.replace( idx, 2, &R, 1 ); |
26 | } | 26 | } |
27 | X = X.left( X.length()-1 ); | 27 | X = X.left( X.length()-1 ); |
28 | } | 28 | } |
29 | return X; | 29 | return X; |
30 | } | 30 | } |
31 | 31 | ||
32 | QString quote( QString X ) { | 32 | QString quote( QString X ) { |
33 | if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { | 33 | if( X.find( QRegExp( "[ \n\"\\\t]" ) ) >= 0 ) { |
34 | // need to quote this | 34 | // need to quote this |
35 | QString OutString = "\""; | 35 | QString OutString = "\""; |
36 | 36 | ||
37 | X.replace( QRegExp("\""), "\\\"" ); | 37 | X.replace( QRegExp("\""), "\\\"" ); |
38 | X.replace( QRegExp("\\"), "\\\\" ); | 38 | X.replace( QRegExp("\\"), "\\\\" ); |
39 | X.replace( QRegExp(" "), "\\ " ); | 39 | X.replace( QRegExp(" "), "\\ " ); |
40 | 40 | ||
41 | OutString += X; | 41 | OutString += X; |
42 | OutString += "\""; | 42 | OutString += "\""; |
43 | X = OutString; | 43 | X = OutString; |
44 | } | 44 | } |
45 | return X; | 45 | return X; |
46 | } | 46 | } |
47 | 47 | ||
48 | 48 | ||
49 | // | 49 | // |
50 | // | 50 | // |
51 | // ANETNODE | 51 | // ANETNODE |
52 | // | 52 | // |
53 | // | 53 | // |
54 | 54 | ||
55 | void ANetNode::saveAttributes( QTextStream & TS ) { | 55 | void ANetNode::saveAttributes( QTextStream & TS ) { |
56 | saveSpecificAttribute( TS ); | 56 | saveSpecificAttribute( TS ); |
57 | } | 57 | } |
58 | 58 | ||
59 | void ANetNode::setAttribute( QString & Attr, QString & Value ){ | 59 | void ANetNode::setAttribute( QString & Attr, QString & Value ){ |
60 | setSpecificAttribute( Attr, Value ); | 60 | setSpecificAttribute( Attr, Value ); |
61 | } | 61 | } |
62 | 62 | ||
63 | // | 63 | // |
64 | // | 64 | // |
65 | // ANETNODEINSTANCE | 65 | // ANETNODEINSTANCE |
66 | // | 66 | // |
67 | // | 67 | // |
68 | 68 | ||
69 | long ANetNodeInstance::InstanceCounter = -1; | 69 | long ANetNodeInstance::InstanceCounter = -1; |
70 | 70 | ||
71 | void ANetNodeInstance::initialize( void ) { | 71 | void ANetNodeInstance::initialize( void ) { |
72 | if( InstanceCounter == -1 ) | 72 | if( InstanceCounter == -1 ) |
73 | InstanceCounter = time(0); | 73 | InstanceCounter = time(0); |
74 | // set name | 74 | // set name |
75 | QString N; | 75 | QString N; |
76 | N.sprintf( "-%ld", InstanceCounter++ ); | 76 | N.sprintf( "-%ld", InstanceCounter++ ); |
77 | N.prepend( NodeType->name() ); | 77 | N.prepend( NodeType->name() ); |
78 | setName( N.latin1() ); | 78 | setName( N.latin1() ); |
79 | } | 79 | } |
80 | 80 | ||
81 | void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ | 81 | void ANetNodeInstance::setAttribute( QString & Attr, QString & Value ){ |
82 | if( Attr == "name" ) { | 82 | if( Attr == "name" ) { |
83 | setName( Value.latin1() ); | 83 | setName( Value.latin1() ); |
84 | } else { | 84 | } else { |
85 | setSpecificAttribute( Attr, Value ); | 85 | setSpecificAttribute( Attr, Value ); |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | void ANetNodeInstance::saveAttributes( QTextStream & TS ) { | 89 | void ANetNodeInstance::saveAttributes( QTextStream & TS ) { |
90 | TS << "name=" << name() << endl; | 90 | TS << "name=" << name() << endl; |
91 | saveSpecificAttribute( TS ); | 91 | saveSpecificAttribute( TS ); |
92 | } | 92 | } |
93 | 93 | ||
94 | ANetNodeInstance * ANetNodeInstance::nextNode( void ) { | 94 | ANetNodeInstance * ANetNodeInstance::nextNode( void ) { |
95 | return connection()->findNext( this ); | 95 | return connection()->findNext( this ); |
96 | } | 96 | } |
97 | 97 | ||
98 | // | 98 | // |
99 | // | 99 | // |
100 | // NODECOLLECTION | 100 | // NODECOLLECTION |
101 | // | 101 | // |
102 | // | 102 | // |
103 | 103 | ||
104 | long NodeCollection::MaxNr = -1; | 104 | long NodeCollection::MaxNr = -1; |
105 | 105 | ||
106 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { | 106 | NodeCollection::NodeCollection( void ) : QList<ANetNodeInstance>() { |
107 | IsModified = 0; | 107 | IsModified = 0; |
108 | Index = -1; | 108 | Index = -1; |
109 | Name=""; | 109 | Name=""; |
110 | IsNew = 1; | 110 | IsNew = 1; |
111 | CurrentState = Unchecked; | 111 | CurrentState = Unchecked; |
112 | } | 112 | } |
113 | 113 | ||
114 | NodeCollection::NodeCollection( QTextStream & TS ) : | 114 | NodeCollection::NodeCollection( QTextStream & TS ) : |
115 | QList<ANetNodeInstance>() { | 115 | QList<ANetNodeInstance>() { |
116 | long idx; | 116 | long idx; |
117 | bool InError = 0; | 117 | bool InError = 0; |
118 | QString S, A, N; | 118 | QString S, A, N; |
119 | IsModified = 0; | 119 | IsModified = 0; |
120 | Index = -1; | 120 | Index = -1; |
121 | Name=""; | 121 | Name=""; |
122 | IsNew = 0; | 122 | IsNew = 0; |
123 | CurrentState = Unchecked; | 123 | CurrentState = Unchecked; |
124 | 124 | ||
125 | do { | 125 | do { |
126 | S = TS.readLine(); | 126 | S = TS.readLine(); |
127 | if( S.isEmpty() ) { | 127 | if( S.isEmpty() ) { |
128 | if( InError ) { | 128 | if( InError ) { |
129 | // remove all nodes | 129 | // remove all nodes |
130 | clear(); | 130 | clear(); |
131 | } | 131 | } |
132 | // empty line | 132 | // empty line |
133 | break; | 133 | break; |
134 | } | 134 | } |
135 | 135 | ||
136 | idx = S.find('='); | 136 | idx = S.find('='); |
137 | S.stripWhiteSpace(); | 137 | S.stripWhiteSpace(); |
138 | A = S.left( idx ); | 138 | A = S.left( idx ); |
139 | A.lower(); | 139 | A.lower(); |
140 | N = S.mid( idx+1, S.length() ); | 140 | N = S.mid( idx+1, S.length() ); |
141 | N.stripWhiteSpace(); | 141 | N.stripWhiteSpace(); |
142 | N = deQuote( N ); | 142 | N = deQuote( N ); |
143 | 143 | ||
144 | if( A == "name" ) { | 144 | if( A == "name" ) { |
145 | Name = N; | 145 | Name = N; |
146 | } else if( A == "number" ) { | 146 | } else if( A == "number" ) { |
147 | setNumber( N.toLong() ); | 147 | setNumber( N.toLong() ); |
148 | } else if( A == "node" ) { | 148 | } else if( A == "node" ) { |
149 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); | 149 | ANetNodeInstance * NNI = NSResources->findNodeInstance( N ); |
150 | if( NNI && ! InError ) { | 150 | if( NNI && ! InError ) { |
151 | append( NSResources->findNodeInstance( N ) ); | 151 | append( NSResources->findNodeInstance( N ) ); |
152 | } else { | 152 | } else { |
153 | // could not find a node type -> collection invalid | 153 | // could not find a node type -> collection invalid |
154 | InError = 1; | 154 | InError = 1; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | } while( 1 ); | 157 | } while( 1 ); |
158 | } | 158 | } |
159 | 159 | ||
160 | 160 | ||
161 | NodeCollection::~NodeCollection( void ) { | 161 | NodeCollection::~NodeCollection( void ) { |
162 | } | 162 | } |
163 | 163 | ||
164 | const QString & NodeCollection::description( void ) { | 164 | const QString & NodeCollection::description( void ) { |
165 | ANetNodeInstance * NNI = getToplevel(); | 165 | ANetNodeInstance * NNI = getToplevel(); |
166 | return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; | 166 | return (NNI) ? NNI->runtime()->asFullSetup()->description() : Name; |
167 | } | 167 | } |
168 | 168 | ||
169 | void NodeCollection::append( ANetNodeInstance * NNI ) { | 169 | void NodeCollection::append( ANetNodeInstance * NNI ) { |
170 | NNI->setConnection( this ); | 170 | NNI->setConnection( this ); |
171 | QList<ANetNodeInstance>::append( NNI ); | 171 | QList<ANetNodeInstance>::append( NNI ); |
172 | } | 172 | } |
173 | 173 | ||
174 | void NodeCollection::save( QTextStream & TS ) { | 174 | void NodeCollection::save( QTextStream & TS ) { |
175 | 175 | ||
176 | TS << "name=" << quote( Name ) << endl; | 176 | TS << "name=" << quote( Name ) << endl; |
177 | TS << "number=" << number() << endl; | 177 | TS << "number=" << number() << endl; |
178 | ANetNodeInstance * NNI; | 178 | ANetNodeInstance * NNI; |
179 | for( QListIterator<ANetNodeInstance> it(*this); | 179 | for( QListIterator<ANetNodeInstance> it(*this); |
180 | it.current(); | 180 | it.current(); |
181 | ++it ) { | 181 | ++it ) { |
182 | NNI = it.current(); | 182 | NNI = it.current(); |
183 | TS << "node=" << NNI->name() << endl; | 183 | TS << "node=" << NNI->name() << endl; |
184 | } | 184 | } |
185 | TS << endl; | 185 | TS << endl; |
186 | IsNew = 0; | 186 | IsNew = 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | ANetNodeInstance * NodeCollection::getToplevel( void ) { | 189 | ANetNodeInstance * NodeCollection::getToplevel( void ) { |
190 | ANetNodeInstance * NNI = 0; | 190 | ANetNodeInstance * NNI = 0; |
191 | for( QListIterator<ANetNodeInstance> it(*this); | 191 | for( QListIterator<ANetNodeInstance> it(*this); |
192 | it.current(); | 192 | it.current(); |
193 | ++it ) { | 193 | ++it ) { |
194 | NNI = it.current(); | 194 | NNI = it.current(); |
195 | if( NNI->nodeClass()->isToplevel() ) | 195 | if( NNI->nodeClass()->isToplevel() ) |
196 | break; | 196 | break; |
197 | } | 197 | } |
198 | return NNI; | 198 | return NNI; |
199 | } | 199 | } |
200 | 200 | ||
201 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { | 201 | ANetNodeInstance * NodeCollection::findByName( const QString & S ) { |
202 | ANetNodeInstance * NNI = 0; | 202 | ANetNodeInstance * NNI = 0; |
203 | for( QListIterator<ANetNodeInstance> it(*this); | 203 | for( QListIterator<ANetNodeInstance> it(*this); |
204 | it.current(); | 204 | it.current(); |
205 | ++it ) { | 205 | ++it ) { |
206 | NNI = it.current(); | 206 | NNI = it.current(); |
207 | if( NNI->name() == S ) | 207 | if( NNI->name() == S ) |
208 | break; | 208 | break; |
209 | } | 209 | } |
210 | return NNI; | 210 | return NNI; |
211 | } | 211 | } |
212 | 212 | ||
213 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { | 213 | ANetNodeInstance * NodeCollection::findNext( ANetNodeInstance * NNI ) { |
214 | ANetNodeInstance * NNNI; | 214 | ANetNodeInstance * NNNI; |
215 | 215 | ||
216 | if( ! NNI ) | 216 | if( ! NNI ) |
217 | getToplevel(); | 217 | getToplevel(); |
218 | 218 | ||
219 | for( QListIterator<ANetNodeInstance> it(*this); | 219 | for( QListIterator<ANetNodeInstance> it(*this); |
220 | it.current(); | 220 | it.current(); |
221 | ++it ) { | 221 | ++it ) { |
222 | NNNI = it.current(); | 222 | NNNI = it.current(); |
223 | if( NNNI == NNI ) { | 223 | if( NNNI == NNI ) { |
224 | ++it; | 224 | ++it; |
225 | return it.current(); | 225 | return it.current(); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | return 0; // no more next | 228 | return 0; // no more next |
229 | } | 229 | } |
230 | 230 | ||
231 | int NodeCollection::compareItems( QCollection::Item I1, | 231 | int NodeCollection::compareItems( QCollection::Item I1, |
232 | QCollection::Item I2 ) { | 232 | QCollection::Item I2 ) { |
233 | ANetNodeInstance * NNI1, * NNI2; | 233 | ANetNodeInstance * NNI1, * NNI2; |
234 | NNI1 = (ANetNodeInstance *)I1; | 234 | NNI1 = (ANetNodeInstance *)I1; |
235 | NNI2 = (ANetNodeInstance *)I2; | 235 | NNI2 = (ANetNodeInstance *)I2; |
236 | return strcmp( NNI1->name(), NNI2->name() ); | 236 | return strcmp( NNI1->name(), NNI2->name() ); |
237 | } | 237 | } |
238 | 238 | ||
239 | static char * State2PixmapTbl[] = { | 239 | static char * State2PixmapTbl[] = { |
240 | "NULL", // Unchecked : no pixmap | 240 | "NULL", // Unchecked : no pixmap |
241 | "check", // Unknown | 241 | "check", // Unknown |
242 | "delete", // unavailable | 242 | "delete", // unavailable |
243 | "disabled", // disabled | 243 | "disabled", // disabled |
244 | "off", // off | 244 | "off", // off |
245 | "disconnected", // available | 245 | "disconnected", // available |
246 | "connected" // up | 246 | "connected" // up |
247 | }; | 247 | }; |
248 | 248 | ||
249 | QPixmap NodeCollection::devicePixmap( void ) { | 249 | QPixmap NodeCollection::devicePixmap( void ) { |
250 | return NSResources->getPixmap( | 250 | return NSResources->getPixmap( |
251 | device()->netNode()->pixmapName()+"-large" ); | 251 | device()->netNode()->pixmapName()+"-large" ); |
252 | } | 252 | } |
253 | 253 | ||
254 | QPixmap NodeCollection::statePixmap( State_t S) { | 254 | QPixmap NodeCollection::statePixmap( State_t S) { |
255 | return NSResources->getPixmap( State2PixmapTbl[S] ); | 255 | return NSResources->getPixmap( State2PixmapTbl[S] ); |
256 | } | 256 | } |
257 | 257 | ||
258 | QString NodeCollection::stateName( State_t S) { | 258 | QString NodeCollection::stateName( State_t S) { |
259 | switch( S ) { | 259 | switch( S ) { |
260 | case Unknown : | 260 | case Unknown : |
261 | return qApp->translate( "networksettings2", "Unknown"); | 261 | return qApp->translate( "networksettings2", "Unknown"); |
262 | case Unavailable : | 262 | case Unavailable : |
263 | return qApp->translate( "networksettings2", "Unavailable"); | 263 | return qApp->translate( "networksettings2", "Unavailable"); |
264 | case Disabled : | 264 | case Disabled : |
265 | return qApp->translate( "networksettings2", "Disabled"); | 265 | return qApp->translate( "networksettings2", "Disabled"); |
266 | case Off : | 266 | case Off : |
267 | return qApp->translate( "networksettings2", "Off"); | 267 | return qApp->translate( "networksettings2", "Off"); |
268 | case Available : | 268 | case Available : |
269 | return qApp->translate( "networksettings2", "Available"); | 269 | return qApp->translate( "networksettings2", "Available"); |
270 | case IsUp : | 270 | case IsUp : |
271 | return qApp->translate( "networksettings2", "IsUp"); | 271 | return qApp->translate( "networksettings2", "IsUp"); |
272 | case Unchecked : /* FT */ | 272 | case Unchecked : /* FT */ |
273 | default : | 273 | default : |
274 | break; | 274 | break; |
275 | } | 275 | } |
276 | return QString(""); | 276 | return QString(""); |
277 | } | 277 | } |
278 | 278 | ||
279 | void NodeCollection::reassign( void ) { | 279 | void NodeCollection::reassign( void ) { |
280 | for( QListIterator<ANetNodeInstance> it(*this); | 280 | for( QListIterator<ANetNodeInstance> it(*this); |
281 | it.current(); | 281 | it.current(); |
282 | ++it ) { | 282 | ++it ) { |
283 | it.current()->setConnection( this ); | 283 | it.current()->setConnection( this ); |
284 | } | 284 | } |
285 | } | 285 | } |
286 | 286 | ||
287 | // | 287 | // |
288 | // | 288 | // |
289 | // RUNTIMEINFO | 289 | // RUNTIMEINFO |
290 | // | 290 | // |
291 | // | 291 | // |
292 | 292 | ||
293 | InterfaceInfo * RuntimeInfo::assignedInterface( void ) { | 293 | InterfaceInfo * RuntimeInfo::assignedInterface( void ) { |
294 | return netNode()->nextNode()->runtime()->assignedInterface(); | 294 | return netNode()->nextNode()->runtime()->assignedInterface(); |
295 | } | 295 | } |
296 | 296 | ||
297 | AsDevice * RuntimeInfo::device( void ) { | 297 | AsDevice * RuntimeInfo::device( void ) { |
298 | return netNode()->nextNode()->runtime()->device(); | 298 | return netNode()->nextNode()->runtime()->device(); |
299 | } | 299 | } |