Diffstat (limited to 'noncore/settings/networksettings2') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp index 9069c09..3fd877f 100644 --- a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp | |||
@@ -202,128 +202,131 @@ void OTSDPAttribute::setInt(const OTSDPAttribute::int128_t & val) { | |||
202 | void OTSDPAttribute::setUInt(const uint128_t & val) { | 202 | void OTSDPAttribute::setUInt(const uint128_t & val) { |
203 | type = UINT; | 203 | type = UINT; |
204 | Value.uintVal = new uint128_t(val); | 204 | Value.uintVal = new uint128_t(val); |
205 | } | 205 | } |
206 | 206 | ||
207 | void OTSDPAttribute::setUUID(const OTUUID & val) { | 207 | void OTSDPAttribute::setUUID(const OTUUID & val) { |
208 | type = UUID; | 208 | type = UUID; |
209 | Value.uuidVal = new OTUUID( val ); | 209 | Value.uuidVal = new OTUUID( val ); |
210 | } | 210 | } |
211 | 211 | ||
212 | void OTSDPAttribute::setBool(bool val) { | 212 | void OTSDPAttribute::setBool(bool val) { |
213 | type = BOOLEAN; | 213 | type = BOOLEAN; |
214 | Value.boolVal = val; | 214 | Value.boolVal = val; |
215 | } | 215 | } |
216 | 216 | ||
217 | void OTSDPAttribute::setString( const QString & val) { | 217 | void OTSDPAttribute::setString( const QString & val) { |
218 | type = STRING; | 218 | type = STRING; |
219 | Value.stringVal = new QString( val ); | 219 | Value.stringVal = new QString( val ); |
220 | } | 220 | } |
221 | 221 | ||
222 | void OTSDPAttribute::setURL( const QString & val) { | 222 | void OTSDPAttribute::setURL( const QString & val) { |
223 | type = URL; | 223 | type = URL; |
224 | Value.stringVal = new QString(val); | 224 | Value.stringVal = new QString(val); |
225 | } | 225 | } |
226 | 226 | ||
227 | void OTSDPAttribute::setSequence(const AttributeVector& val) { | 227 | void OTSDPAttribute::setSequence(const AttributeVector& val) { |
228 | type = SEQUENCE; | 228 | type = SEQUENCE; |
229 | Value.sequenceVal = new AttributeVector(); | 229 | Value.sequenceVal = new AttributeVector(); |
230 | Value.sequenceVal->setAutoDelete( TRUE ); | 230 | Value.sequenceVal->setAutoDelete( TRUE ); |
231 | *Value.sequenceVal = val; | 231 | *Value.sequenceVal = val; |
232 | } | 232 | } |
233 | 233 | ||
234 | void OTSDPAttribute::setAlternative(const AttributeVector& val) { | 234 | void OTSDPAttribute::setAlternative(const AttributeVector& val) { |
235 | type = ALTERNATIVE; | 235 | type = ALTERNATIVE; |
236 | Value.sequenceVal = new AttributeVector(); | 236 | Value.sequenceVal = new AttributeVector(); |
237 | Value.sequenceVal->setAutoDelete( TRUE ); | 237 | Value.sequenceVal->setAutoDelete( TRUE ); |
238 | *Value.sequenceVal = val; | 238 | *Value.sequenceVal = val; |
239 | } | 239 | } |
240 | 240 | ||
241 | QString OTSDPAttribute::getString() { | 241 | QString OTSDPAttribute::getString() { |
242 | assert(type == STRING); | 242 | assert(type == STRING); |
243 | return *Value.stringVal; | 243 | return *Value.stringVal; |
244 | } | 244 | } |
245 | 245 | ||
246 | QString OTSDPAttribute::getURL() { | 246 | QString OTSDPAttribute::getURL() { |
247 | assert(type == URL); | 247 | assert(type == URL); |
248 | return *Value.stringVal; | 248 | return *Value.stringVal; |
249 | } | 249 | } |
250 | 250 | ||
251 | const OTSDPAttribute::int128_t & OTSDPAttribute::getInt() { | 251 | const OTSDPAttribute::int128_t & OTSDPAttribute::getInt() { |
252 | assert(type == INT); | 252 | assert(type == INT); |
253 | return *Value.intVal; | 253 | return *Value.intVal; |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | const OTSDPAttribute::uint128_t & OTSDPAttribute::getUInt() { | 257 | const OTSDPAttribute::uint128_t & OTSDPAttribute::getUInt() { |
258 | assert(type == UINT); | 258 | assert(type == UINT); |
259 | return *Value.uintVal; | 259 | return *Value.uintVal; |
260 | } | 260 | } |
261 | 261 | ||
262 | const OTUUID & OTSDPAttribute::getUUID() { | 262 | const OTUUID & OTSDPAttribute::getUUID() { |
263 | assert(type == UUID); | 263 | assert(type == UUID); |
264 | return *Value.uuidVal; | 264 | return *Value.uuidVal; |
265 | } | 265 | } |
266 | 266 | ||
267 | bool OTSDPAttribute::getBool() { | 267 | bool OTSDPAttribute::getBool() { |
268 | assert(type == BOOLEAN); | 268 | assert(type == BOOLEAN); |
269 | return Value.boolVal; | 269 | return Value.boolVal; |
270 | } | 270 | } |
271 | 271 | ||
272 | AttributeVector * OTSDPAttribute::getSequence() { | 272 | AttributeVector * OTSDPAttribute::getSequence() { |
273 | assert(type == SEQUENCE); | 273 | assert(type == SEQUENCE); |
274 | return Value.sequenceVal; | 274 | return Value.sequenceVal; |
275 | } | 275 | } |
276 | 276 | ||
277 | AttributeVector * OTSDPAttribute::getAlternative() { | 277 | AttributeVector * OTSDPAttribute::getAlternative() { |
278 | assert(type == ALTERNATIVE); | 278 | assert(type == ALTERNATIVE); |
279 | return Value.sequenceVal; | 279 | return Value.sequenceVal; |
280 | } | 280 | } |
281 | 281 | ||
282 | UUIDVector OTSDPAttribute::getAllUUIDs() { | 282 | UUIDVector OTSDPAttribute::getAllUUIDs() { |
283 | 283 | ||
284 | UUIDVector uuids; | 284 | UUIDVector uuids; |
285 | 285 | ||
286 | if (getType() == UUID) { | 286 | if (getType() == UUID) { |
287 | uuids.resize( uuids.size()+1 ); | 287 | uuids.resize( uuids.size()+1 ); |
288 | uuids[uuids.size()-1] = getUUID(); | 288 | uuids[uuids.size()-1] = getUUID(); |
289 | } else { | 289 | } else { |
290 | AttributeVector * subAttributes = 0 ; | 290 | AttributeVector * subAttributes = 0 ; |
291 | 291 | ||
292 | if (getType() == SEQUENCE) { | 292 | if (getType() == SEQUENCE) { |
293 | subAttributes = getSequence(); | 293 | subAttributes = getSequence(); |
294 | } else if (getType() == ALTERNATIVE) { | 294 | } else if (getType() == ALTERNATIVE) { |
295 | subAttributes = getAlternative(); | 295 | subAttributes = getAlternative(); |
296 | } | 296 | } |
297 | 297 | ||
298 | if (!subAttributes) | ||
299 | return 0; | ||
300 | |||
298 | int os; | 301 | int os; |
299 | for( unsigned int i = 0; i < subAttributes->count(); i++ ) { | 302 | for( unsigned int i = 0; i < subAttributes->count(); i++ ) { |
300 | UUIDVector subUUIDs = (*subAttributes)[i]->getAllUUIDs(); | 303 | UUIDVector subUUIDs = (*subAttributes)[i]->getAllUUIDs(); |
301 | 304 | ||
302 | os = uuids.size(); | 305 | os = uuids.size(); |
303 | uuids.resize( uuids.size()+subUUIDs.count() ); | 306 | uuids.resize( uuids.size()+subUUIDs.count() ); |
304 | 307 | ||
305 | for( unsigned int k = 0; k < subUUIDs.count(); k++ ) { | 308 | for( unsigned int k = 0; k < subUUIDs.count(); k++ ) { |
306 | uuids[os + k] = subUUIDs[k]; | 309 | uuids[os + k] = subUUIDs[k]; |
307 | } | 310 | } |
308 | } | 311 | } |
309 | } | 312 | } |
310 | return uuids; | 313 | return uuids; |
311 | } | 314 | } |
312 | 315 | ||
313 | static char * Attr2String[] = { | 316 | static char * Attr2String[] = { |
314 | "Invalid", | 317 | "Invalid", |
315 | "Nil", | 318 | "Nil", |
316 | "UInt", | 319 | "UInt", |
317 | "int", | 320 | "int", |
318 | "UUID", | 321 | "UUID", |
319 | "Boolean", | 322 | "Boolean", |
320 | "String", | 323 | "String", |
321 | "Sequence", | 324 | "Sequence", |
322 | "Alternative", | 325 | "Alternative", |
323 | "URL", | 326 | "URL", |
324 | "Unknown" | 327 | "Unknown" |
325 | }; | 328 | }; |
326 | 329 | ||
327 | const char * OTSDPAttribute::getTypeString() { | 330 | const char * OTSDPAttribute::getTypeString() { |
328 | return Attr2String[type]; | 331 | return Attr2String[type]; |
329 | } | 332 | } |