summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h140
1 files changed, 140 insertions, 0 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
new file mode 100644
index 0000000..e79e33d
--- a/dev/null
+++ b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
@@ -0,0 +1,140 @@
1//-*-c++-*-
2/***************************************************************************
3 * Copyright (C) 2003 by Fred Schaettgen *
4 * kdebluetooth@schaettgen.de *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 ***************************************************************************/
11
12#ifndef OTATTRIBUTE_H
13#define OTATTRIBUTE_H
14
15#include <stdio.h>
16#include <qstring.h>
17#include <qarray.h>
18#include <qvector.h>
19#include <bluezlib.h>
20#include <OTUUID.h>
21
22namespace Opietooth2 {
23
24class OTSDPAttribute;
25class OTUUID;
26
27typedef QVector<OTSDPAttribute> AttributeVector;
28
29/**
30@author Fred Schaettgen
31*/
32class OTSDPAttribute {
33
34public:
35
36 enum AttrType {
37 INVALID = 0,
38 NIL = 1,
39 UINT = 2,
40 INT = 3,
41 UUID = 4,
42 BOOLEAN = 5,
43 STRING = 6,
44 SEQUENCE = 7,
45 ALTERNATIVE = 8,
46 URL = 9,
47 UNKNOWN = 10
48 };
49
50 class int128_t {
51 public :
52 int128_t(int64_t l=0, int64_t h=0) {
53 hi = h;
54 lo = l;
55 }
56 int128_t(const OTSDPAttribute::int128_t & l) {
57 hi = l.hi;
58 lo = l.lo;
59 }
60 QString toString() const {
61 char Buf[50];
62 sprintf( Buf, "%lld%lld", hi, lo );
63 return QString( Buf );
64 }
65 int64_t hi;
66 int64_t lo;
67 };
68
69 class uint128_t {
70 public :
71 uint128_t( uint64_t l=0, uint64_t h=0) {
72 hi = h;
73 lo = l;
74 }
75 uint128_t( const OTSDPAttribute::uint128_t & l) {
76 hi = l.hi;
77 lo = l.lo;
78 }
79 QString toString() const {
80 char Buf[50];
81 sprintf( Buf, "%llu%llu", hi, lo );
82 return QString( Buf );
83 }
84 uint64_t hi;
85 uint64_t lo;
86 };
87
88public:
89
90 OTSDPAttribute();
91 OTSDPAttribute( sdp_data_t * D );
92 ~OTSDPAttribute();
93
94 QString toString( void );
95
96 void setNil();
97 void setInt(const OTSDPAttribute::int128_t & val);
98 void setUInt(const OTSDPAttribute::uint128_t & val);
99 void setUUID( const OTUUID & val);
100 void setBool(bool val);
101 void setString(const QString & val);
102 void setURL(const QString & val);
103 void setSequence(const AttributeVector& val);
104 void setAlternative(const AttributeVector& val);
105
106 QString getString();
107 QString getURL();
108 const OTSDPAttribute::int128_t & getInt();
109 const OTSDPAttribute::uint128_t & getUInt();
110 const OTUUID & getUUID();
111 bool getBool();
112 AttributeVector * getSequence();
113 AttributeVector * getAlternative();
114
115 UUIDVector getAllUUIDs();
116
117 inline AttrType getType()
118 { return type; }
119
120 //QString getValString();
121 const char * getTypeString();
122
123private:
124
125 AttrType type;
126
127 union {
128 OTSDPAttribute::int128_t * intVal;
129 OTSDPAttribute::uint128_t * uintVal;
130 OTUUID * uuidVal;
131 bool boolVal;
132 QString * stringVal; // strings and urls
133 AttributeVector * sequenceVal; // sequences and alternatives
134 } Value;
135
136};
137
138}
139
140#endif