summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSDPAttribute.cpp3
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
@@ -106,224 +106,227 @@ OTSDPAttribute::OTSDPAttribute( sdp_data_t * attrib ) {
case SDP_TEXT_STR_UNSPEC :
case SDP_TEXT_STR8 :
case SDP_TEXT_STR16 :
case SDP_TEXT_STR32 :
setString( QString(attrib->val.str) );
break;
case SDP_URL_STR_UNSPEC :
case SDP_URL_STR8 :
case SDP_URL_STR16 :
case SDP_URL_STR32 :
setURL( QString(attrib->val.str) );
break;
case SDP_BOOL:
setBool( attrib->val.int8 != 0);
break;
case SDP_SEQ_UNSPEC :
case SDP_SEQ8 :
case SDP_SEQ16 :
case SDP_SEQ32 :
case SDP_ALT_UNSPEC :
case SDP_ALT8 :
case SDP_ALT16 :
case SDP_ALT32 :
{ AttributeVector subAttribs;
OTSDPAttribute * Attr;
sdp_data_t* subAttrib = attrib->val.dataseq;
for (; subAttrib; subAttrib = subAttrib->next) {
Attr = new OTSDPAttribute(subAttrib);
subAttribs.resize( subAttribs.size() + 1 );
subAttribs.insert( subAttribs.size() - 1, Attr );
}
if( attrib->dtd == SDP_ALT_UNSPEC ||
attrib->dtd == SDP_ALT8 ||
attrib->dtd == SDP_ALT16 ||
attrib->dtd == SDP_ALT32 ) {
setAlternative(subAttribs);
} else {
setSequence(subAttribs);
}
break;
}
} // end case
}
QString OTSDPAttribute::toString( void ) {
QString S;
switch( type ) {
case INVALID :
S = "invalid";
break;
case NIL :
S = "NIL";
break;
case UINT :
S = Value.uintVal->toString();
break;
case INT :
S = Value.intVal->toString();
break;
case UUID :
S = Value.uuidVal->toString();
break;
case BOOLEAN :
S = (Value.boolVal) ? "true" : "false";
break;
case STRING :
S = *(Value.stringVal);
break;
case URL :
S = *(Value.stringVal);
break;
case SEQUENCE :
S.sprintf( "Sequence(%d)", Value.sequenceVal->count() );
break;
case ALTERNATIVE :
S.sprintf( "Alternative(%d)", Value.sequenceVal->count() );
break;
case UNKNOWN :
S = "unknown";
break;
}
return S;
}
void OTSDPAttribute::setNil() {
type = NIL;
}
void OTSDPAttribute::setInt(const OTSDPAttribute::int128_t & val) {
type = INT;
Value.intVal = new int128_t( val );
}
void OTSDPAttribute::setUInt(const uint128_t & val) {
type = UINT;
Value.uintVal = new uint128_t(val);
}
void OTSDPAttribute::setUUID(const OTUUID & val) {
type = UUID;
Value.uuidVal = new OTUUID( val );
}
void OTSDPAttribute::setBool(bool val) {
type = BOOLEAN;
Value.boolVal = val;
}
void OTSDPAttribute::setString( const QString & val) {
type = STRING;
Value.stringVal = new QString( val );
}
void OTSDPAttribute::setURL( const QString & val) {
type = URL;
Value.stringVal = new QString(val);
}
void OTSDPAttribute::setSequence(const AttributeVector& val) {
type = SEQUENCE;
Value.sequenceVal = new AttributeVector();
Value.sequenceVal->setAutoDelete( TRUE );
*Value.sequenceVal = val;
}
void OTSDPAttribute::setAlternative(const AttributeVector& val) {
type = ALTERNATIVE;
Value.sequenceVal = new AttributeVector();
Value.sequenceVal->setAutoDelete( TRUE );
*Value.sequenceVal = val;
}
QString OTSDPAttribute::getString() {
assert(type == STRING);
return *Value.stringVal;
}
QString OTSDPAttribute::getURL() {
assert(type == URL);
return *Value.stringVal;
}
const OTSDPAttribute::int128_t & OTSDPAttribute::getInt() {
assert(type == INT);
return *Value.intVal;
}
const OTSDPAttribute::uint128_t & OTSDPAttribute::getUInt() {
assert(type == UINT);
return *Value.uintVal;
}
const OTUUID & OTSDPAttribute::getUUID() {
assert(type == UUID);
return *Value.uuidVal;
}
bool OTSDPAttribute::getBool() {
assert(type == BOOLEAN);
return Value.boolVal;
}
AttributeVector * OTSDPAttribute::getSequence() {
assert(type == SEQUENCE);
return Value.sequenceVal;
}
AttributeVector * OTSDPAttribute::getAlternative() {
assert(type == ALTERNATIVE);
return Value.sequenceVal;
}
UUIDVector OTSDPAttribute::getAllUUIDs() {
UUIDVector uuids;
if (getType() == UUID) {
uuids.resize( uuids.size()+1 );
uuids[uuids.size()-1] = getUUID();
} else {
AttributeVector * subAttributes = 0 ;
if (getType() == SEQUENCE) {
subAttributes = getSequence();
} else if (getType() == ALTERNATIVE) {
subAttributes = getAlternative();
}
+ if (!subAttributes)
+ return 0;
+
int os;
for( unsigned int i = 0; i < subAttributes->count(); i++ ) {
UUIDVector subUUIDs = (*subAttributes)[i]->getAllUUIDs();
os = uuids.size();
uuids.resize( uuids.size()+subUUIDs.count() );
for( unsigned int k = 0; k < subUUIDs.count(); k++ ) {
uuids[os + k] = subUUIDs[k];
}
}
}
return uuids;
}
static char * Attr2String[] = {
"Invalid",
"Nil",
"UInt",
"int",
"UUID",
"Boolean",
"String",
"Sequence",
"Alternative",
"URL",
"Unknown"
};
const char * OTSDPAttribute::getTypeString() {
return Attr2String[type];
}