author | zecke <zecke> | 2002-07-13 12:54:47 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-07-13 12:54:47 (UTC) |
commit | d7f3722f9b7913731978437085b14cc2cccbfa24 (patch) (unidiff) | |
tree | 1b190105693609cc01d1ad9730e8925e957209c9 | |
parent | 8be0a8e108eaf8ff99301aa175298ddeb48eae67 (diff) | |
download | opie-d7f3722f9b7913731978437085b14cc2cccbfa24.zip opie-d7f3722f9b7913731978437085b14cc2cccbfa24.tar.gz opie-d7f3722f9b7913731978437085b14cc2cccbfa24.tar.bz2 |
LIB updates
Class IdList per Service can have more than one line
-rw-r--r-- | noncore/net/opietooth/lib/parser.cc | 8 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/services.cc | 26 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/services.h | 13 |
3 files changed, 22 insertions, 25 deletions
diff --git a/noncore/net/opietooth/lib/parser.cc b/noncore/net/opietooth/lib/parser.cc index 00ec84a..0699309 100644 --- a/noncore/net/opietooth/lib/parser.cc +++ b/noncore/net/opietooth/lib/parser.cc | |||
@@ -1,196 +1,194 @@ | |||
1 | 1 | ||
2 | #include <qstringlist.h> | 2 | #include <qstringlist.h> |
3 | 3 | ||
4 | #include "parser.h" | 4 | #include "parser.h" |
5 | 5 | ||
6 | using namespace OpieTooth; | 6 | using namespace OpieTooth; |
7 | 7 | ||
8 | namespace { | 8 | namespace { |
9 | 9 | ||
10 | 10 | ||
11 | // "Test Foo Bar" (0x3456) | 11 | // "Test Foo Bar" (0x3456) |
12 | // @param ret Test Foo Bar | 12 | // @param ret Test Foo Bar |
13 | // @eturn 13398 | 13 | // @eturn 13398 |
14 | // tactic find " ( | 14 | // tactic find " ( |
15 | int convert( const QString& line, QString& ret ) { | 15 | int convert( const QString& line, QString& ret ) { |
16 | // qWarning("called"); | 16 | // qWarning("called"); |
17 | ret = QString::null; | 17 | ret = QString::null; |
18 | int i = 0; | 18 | int i = 0; |
19 | int pos = line.findRev("\" ("); | 19 | int pos = line.findRev("\" ("); |
20 | if ( pos > 0 ) { // it shouldn't be at pos 0 | 20 | if ( pos > 0 ) { // it shouldn't be at pos 0 |
21 | ret = line.left(pos ).stripWhiteSpace(); | 21 | ret = line.left(pos ).stripWhiteSpace(); |
22 | // qWarning("ret: %s", ret.latin1() ); | 22 | // qWarning("ret: %s", ret.latin1() ); |
23 | ret = ret.replace(QRegExp("[\"]"), ""); | 23 | ret = ret.replace(QRegExp("[\"]"), ""); |
24 | //qWarning("ret: %s", ret.latin1() ); | 24 | //qWarning("ret: %s", ret.latin1() ); |
25 | QString dummy = line.mid(pos + 5 ); | 25 | QString dummy = line.mid(pos + 5 ); |
26 | //qWarning("dummy: %s", dummy.latin1() ); | 26 | //qWarning("dummy: %s", dummy.latin1() ); |
27 | dummy = dummy.replace(QRegExp("[)]"), ""); | 27 | dummy = dummy.replace(QRegExp("[)]"), ""); |
28 | //qWarning("dummy: %s", dummy.latin1() ); | 28 | //qWarning("dummy: %s", dummy.latin1() ); |
29 | // dummy = dummy.remove( dummy.length() -2, 1 ); // remove the ) | 29 | // dummy = dummy.remove( dummy.length() -2, 1 ); // remove the ) |
30 | bool ok; | 30 | bool ok; |
31 | i = dummy.toInt(&ok, 16 ); | 31 | i = dummy.toInt(&ok, 16 ); |
32 | //if (ok ) { | 32 | //if (ok ) { |
33 | // qWarning("converted %d", i); | 33 | // qWarning("converted %d", i); |
34 | //}else qWarning("failed" ); | 34 | //}else qWarning("failed" ); |
35 | //qWarning("exiting"); | 35 | //qWarning("exiting"); |
36 | return i; | 36 | return i; |
37 | } | 37 | } |
38 | //qWarning("output %d", i ); | 38 | //qWarning("output %d", i ); |
39 | return i; | 39 | return i; |
40 | } | 40 | } |
41 | 41 | ||
42 | }; | 42 | }; |
43 | 43 | ||
44 | 44 | ||
45 | Parser::Parser(const QString& output ) { | 45 | Parser::Parser(const QString& output ) { |
46 | parse( output ); | 46 | parse( output ); |
47 | } | 47 | } |
48 | void Parser::setText(const QString& output) { | 48 | void Parser::setText(const QString& output) { |
49 | parse( output ); | 49 | parse( output ); |
50 | } | 50 | } |
51 | Services::ValueList Parser::services() const { | 51 | Services::ValueList Parser::services() const { |
52 | return m_list; | 52 | return m_list; |
53 | } | 53 | } |
54 | void Parser::parse( const QString& string) { | 54 | void Parser::parse( const QString& string) { |
55 | m_list.clear(); | 55 | m_list.clear(); |
56 | m_complete = true; | 56 | m_complete = true; |
57 | QStringList list = QStringList::split('\n', string,TRUE ); | 57 | QStringList list = QStringList::split('\n', string,TRUE ); |
58 | QStringList::Iterator it; | 58 | QStringList::Iterator it; |
59 | for (it = list.begin(); it != list.end(); ++it ) { | 59 | for (it = list.begin(); it != list.end(); ++it ) { |
60 | qWarning("line:%s:line", (*it).latin1() ); | 60 | qWarning("line:%s:line", (*it).latin1() ); |
61 | if ( (*it).startsWith("Browsing") ) continue; | 61 | if ( (*it).startsWith("Browsing") ) continue; |
62 | 62 | ||
63 | if ( (*it).stripWhiteSpace().isEmpty() ) { // line is empty because a new Service begins | 63 | if ( (*it).stripWhiteSpace().isEmpty() ) { // line is empty because a new Service begins |
64 | qWarning("could add"); | 64 | qWarning("could add"); |
65 | // now see if complete and add | 65 | // now see if complete and add |
66 | if (m_complete ) { | 66 | if (m_complete ) { |
67 | if (!m_item.serviceName().isEmpty() ) | 67 | if (!m_item.serviceName().isEmpty() ) |
68 | m_list.append( m_item ); | 68 | m_list.append( m_item ); |
69 | Services serv; | 69 | Services serv; |
70 | m_item = serv; | 70 | m_item = serv; |
71 | m_complete = true; | 71 | m_complete = true; |
72 | continue; | 72 | continue; |
73 | } | 73 | } |
74 | } | 74 | } |
75 | if (parseName( (*it) ) ) ;//continue; | 75 | if (parseName( (*it) ) ) ;//continue; |
76 | if (parseRecHandle( (*it) ) ) ;//continue; | 76 | if (parseRecHandle( (*it) ) ) ;//continue; |
77 | if (parseClassId( (*it) ) ) ;//continue; | 77 | if (parseClassId( (*it) ) ) ;//continue; |
78 | if (parseProtocol( (*it) ) ) ;//continue; | 78 | if (parseProtocol( (*it) ) ) ;//continue; |
79 | if (parseProfile( (*it) ) ) ;//continue; | 79 | if (parseProfile( (*it) ) ) ;//continue; |
80 | } | 80 | } |
81 | // missed the last one | 81 | // missed the last one |
82 | if (m_complete) { | 82 | if (m_complete) { |
83 | qWarning("adding"); | 83 | qWarning("adding"); |
84 | if (!m_item.serviceName().isEmpty() ) | 84 | if (!m_item.serviceName().isEmpty() ) |
85 | m_list.append(m_item ); | 85 | m_list.append(m_item ); |
86 | } | 86 | } |
87 | QValueList<Services>::Iterator it2; | 87 | QValueList<Services>::Iterator it2; |
88 | 88 | ||
89 | if (m_list.isEmpty() ) | 89 | if (m_list.isEmpty() ) |
90 | qWarning("m_list is empty"); | 90 | qWarning("m_list is empty"); |
91 | for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { | 91 | for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { |
92 | qWarning("name %s", (*it2).serviceName().latin1() ); | 92 | qWarning("name %s", (*it2).serviceName().latin1() ); |
93 | } | 93 | } |
94 | } | 94 | } |
95 | bool Parser::parseName( const QString& str) { | 95 | bool Parser::parseName( const QString& str) { |
96 | if (str.startsWith("Service Name:") ) { | 96 | if (str.startsWith("Service Name:") ) { |
97 | m_item.setServiceName( str.mid(13).stripWhiteSpace() ); | 97 | m_item.setServiceName( str.mid(13).stripWhiteSpace() ); |
98 | qWarning(m_item.serviceName() ); | 98 | qWarning(m_item.serviceName() ); |
99 | return true; | 99 | return true; |
100 | } | 100 | } |
101 | return false; | 101 | return false; |
102 | } | 102 | } |
103 | bool Parser::parseRecHandle( const QString& str) { | 103 | bool Parser::parseRecHandle( const QString& str) { |
104 | if (str.startsWith("Service RecHandle:" ) ) { | 104 | if (str.startsWith("Service RecHandle:" ) ) { |
105 | QString out = str.mid(18 ).stripWhiteSpace(); | 105 | QString out = str.mid(18 ).stripWhiteSpace(); |
106 | qWarning("out %s", out.latin1() ); | 106 | qWarning("out %s", out.latin1() ); |
107 | int value = out.mid(2).toInt(&m_ok, 16 ); | 107 | int value = out.mid(2).toInt(&m_ok, 16 ); |
108 | if (m_ok && (value != -1) ) | 108 | if (m_ok && (value != -1) ) |
109 | m_complete = true; | 109 | m_complete = true; |
110 | else | 110 | else |
111 | m_complete = false; | 111 | m_complete = false; |
112 | qWarning("rec handle %d", value); | 112 | qWarning("rec handle %d", value); |
113 | m_item.setRecHandle( value ); | 113 | m_item.setRecHandle( value ); |
114 | return true; | 114 | return true; |
115 | 115 | ||
116 | } | 116 | } |
117 | return false; | 117 | return false; |
118 | } | 118 | } |
119 | bool Parser::parseClassId( const QString& str) { | 119 | bool Parser::parseClassId( const QString& str) { |
120 | if (str.startsWith("Service Class ID List:") ) { | 120 | if (str.startsWith("Service Class ID List:") ) { |
121 | m_classOver = true; | 121 | m_classOver = true; |
122 | return true; | 122 | return true; |
123 | }else if ( m_classOver ) { // ok now are the informations in place | 123 | }else if ( m_classOver && str.startsWith(" " ) ){ // ok now are the informations in place |
124 | 124 | ||
125 | m_classOver = false; | ||
126 | 125 | ||
127 | // "Obex Object Push" (0x1105) | 126 | // "Obex Object Push" (0x1105) |
128 | // find backwards the " and the from 0 to pos and the mid pos+1 | 127 | // find backwards the " and the from 0 to pos and the mid pos+1 |
129 | // then stripWhiteSpace add name replace '"' with "" | 128 | // then stripWhiteSpace add name replace '"' with "" |
130 | // and then convert 0x1105 toInt() | 129 | // and then convert 0x1105 toInt() |
131 | QString classes; | 130 | QString classes; |
132 | int ids; | 131 | int ids; |
133 | ids = convert( str, classes ); | 132 | ids = convert( str, classes ); |
134 | qWarning("ids %d", ids ); | 133 | qWarning("ids %d", ids ); |
135 | m_item.setClassIdList( classes ); | 134 | m_item.insertClassId( ids, classes ); |
136 | m_item.setClassIdList( ids ); | ||
137 | 135 | ||
138 | return true; | 136 | return true; |
139 | }else | 137 | }else |
140 | m_classOver = true; | 138 | m_classOver = false; |
141 | return false; | 139 | return false; |
142 | } | 140 | } |
143 | bool Parser::parseProtocol( const QString& str) { | 141 | bool Parser::parseProtocol( const QString& str) { |
144 | if (str.startsWith("Protocol Descriptor List:") ) { | 142 | if (str.startsWith("Protocol Descriptor List:") ) { |
145 | m_protocolOver = true; | 143 | m_protocolOver = true; |
146 | m_protocolAdded = false; | 144 | m_protocolAdded = false; |
147 | return true; | 145 | return true; |
148 | 146 | ||
149 | }else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100) | 147 | }else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100) |
150 | qWarning("double protocol filter"); | 148 | qWarning("double protocol filter"); |
151 | 149 | ||
152 | if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now | 150 | if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now |
153 | Services::ProtocolDescriptor desc( m_protName, m_protId ); | 151 | Services::ProtocolDescriptor desc( m_protName, m_protId ); |
154 | m_item.insertProtocolDescriptor( desc ); | 152 | m_item.insertProtocolDescriptor( desc ); |
155 | } | 153 | } |
156 | m_protocolAdded = false; | 154 | m_protocolAdded = false; |
157 | { // the find function | 155 | { // the find function |
158 | m_protId = convert(str, m_protName ); | 156 | m_protId = convert(str, m_protName ); |
159 | } | 157 | } |
160 | return true; | 158 | return true; |
161 | }else if (m_protocolOver && str.startsWith(" ") ) { | 159 | }else if (m_protocolOver && str.startsWith(" ") ) { |
162 | qWarning("tripple protocol filter"); | 160 | qWarning("tripple protocol filter"); |
163 | m_protocolAdded = true; | 161 | m_protocolAdded = true; |
164 | QString dummy = str.stripWhiteSpace(); | 162 | QString dummy = str.stripWhiteSpace(); |
165 | int pos = dummy.findRev(':'); | 163 | int pos = dummy.findRev(':'); |
166 | if ( pos > -1 ) { | 164 | if ( pos > -1 ) { |
167 | int port = dummy.mid(pos+1 ).stripWhiteSpace().toInt(); | 165 | int port = dummy.mid(pos+1 ).stripWhiteSpace().toInt(); |
168 | Services::ProtocolDescriptor desc( m_protName, m_protId, port ); | 166 | Services::ProtocolDescriptor desc( m_protName, m_protId, port ); |
169 | m_item.insertProtocolDescriptor( desc ); | 167 | m_item.insertProtocolDescriptor( desc ); |
170 | } | 168 | } |
171 | return true; | 169 | return true; |
172 | }else if (m_protocolOver ) { | 170 | }else if (m_protocolOver ) { |
173 | m_protocolOver = false; | 171 | m_protocolOver = false; |
174 | } | 172 | } |
175 | return false; | 173 | return false; |
176 | } | 174 | } |
177 | bool Parser::parseProfile( const QString& str) { | 175 | bool Parser::parseProfile( const QString& str) { |
178 | if (str.startsWith("Profile Descriptor List:") ) { | 176 | if (str.startsWith("Profile Descriptor List:") ) { |
179 | m_profOver = true; | 177 | m_profOver = true; |
180 | }else if ( m_profOver && str.startsWith(" ") ) { | 178 | }else if ( m_profOver && str.startsWith(" ") ) { |
181 | m_profId = convert( str, m_profName ); | 179 | m_profId = convert( str, m_profName ); |
182 | }else if ( m_profOver && str.startsWith(" ") ) { | 180 | }else if ( m_profOver && str.startsWith(" ") ) { |
183 | // now find | 181 | // now find |
184 | int pos = str.findRev(':'); | 182 | int pos = str.findRev(':'); |
185 | if ( pos > 0 ) { | 183 | if ( pos > 0 ) { |
186 | int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt(); | 184 | int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt(); |
187 | qWarning("dummyInt:%d", dummy ); | 185 | qWarning("dummyInt:%d", dummy ); |
188 | Services::ProfileDescriptor desc( m_profName, m_profId, dummy ); | 186 | Services::ProfileDescriptor desc( m_profName, m_profId, dummy ); |
189 | m_item.insertProfileDescriptor(desc); | 187 | m_item.insertProfileDescriptor(desc); |
190 | } | 188 | } |
191 | }else | 189 | }else |
192 | m_profOver = false; | 190 | m_profOver = false; |
193 | 191 | ||
194 | 192 | ||
195 | return false; | 193 | return false; |
196 | } | 194 | } |
diff --git a/noncore/net/opietooth/lib/services.cc b/noncore/net/opietooth/lib/services.cc index 93ee70a..23b760b 100644 --- a/noncore/net/opietooth/lib/services.cc +++ b/noncore/net/opietooth/lib/services.cc | |||
@@ -1,182 +1,180 @@ | |||
1 | 1 | ||
2 | #include "services.h" | 2 | #include "services.h" |
3 | 3 | ||
4 | using namespace OpieTooth; | 4 | using namespace OpieTooth; |
5 | 5 | ||
6 | 6 | ||
7 | Services::ProfileDescriptor::ProfileDescriptor(){ | 7 | Services::ProfileDescriptor::ProfileDescriptor(){ |
8 | 8 | ||
9 | } | 9 | } |
10 | Services::ProfileDescriptor::ProfileDescriptor(const QString &id, int idInt, int version ){ | 10 | Services::ProfileDescriptor::ProfileDescriptor(const QString &id, int idInt, int version ){ |
11 | m_id = id; | 11 | m_id = id; |
12 | m_idInt = idInt; | 12 | m_idInt = idInt; |
13 | m_version = version; | 13 | m_version = version; |
14 | } | 14 | } |
15 | Services::ProfileDescriptor::ProfileDescriptor( const ProfileDescriptor& rem){ | 15 | Services::ProfileDescriptor::ProfileDescriptor( const ProfileDescriptor& rem){ |
16 | (*this) = rem; | 16 | (*this) = rem; |
17 | } | 17 | } |
18 | QString Services::ProfileDescriptor::id() const { | 18 | QString Services::ProfileDescriptor::id() const { |
19 | return m_id; | 19 | return m_id; |
20 | } | 20 | } |
21 | void Services::ProfileDescriptor::setId( const QString& id ){ | 21 | void Services::ProfileDescriptor::setId( const QString& id ){ |
22 | m_id = id; | 22 | m_id = id; |
23 | } | 23 | } |
24 | void Services::ProfileDescriptor::setId(int id ){ | 24 | void Services::ProfileDescriptor::setId(int id ){ |
25 | m_idInt = id; | 25 | m_idInt = id; |
26 | } | 26 | } |
27 | int Services::ProfileDescriptor::idInt()const{ | 27 | int Services::ProfileDescriptor::idInt()const{ |
28 | return m_idInt; | 28 | return m_idInt; |
29 | } | 29 | } |
30 | int Services::ProfileDescriptor::version() const{ | 30 | int Services::ProfileDescriptor::version() const{ |
31 | return m_version; | 31 | return m_version; |
32 | } | 32 | } |
33 | void Services::ProfileDescriptor::setVersion(int version){ | 33 | void Services::ProfileDescriptor::setVersion(int version){ |
34 | m_version = version; | 34 | m_version = version; |
35 | } | 35 | } |
36 | Services::ProfileDescriptor& Services::ProfileDescriptor::operator=( const Services::ProfileDescriptor& prof){ | 36 | Services::ProfileDescriptor& Services::ProfileDescriptor::operator=( const Services::ProfileDescriptor& prof){ |
37 | m_id = prof.m_id; | 37 | m_id = prof.m_id; |
38 | m_idInt = prof.m_idInt; | 38 | m_idInt = prof.m_idInt; |
39 | m_version = prof.m_version; | 39 | m_version = prof.m_version; |
40 | return *this; | 40 | return *this; |
41 | } | 41 | } |
42 | bool operator==(const Services::ProfileDescriptor& first, | 42 | bool operator==(const Services::ProfileDescriptor& first, |
43 | const Services::ProfileDescriptor& second ){ | 43 | const Services::ProfileDescriptor& second ){ |
44 | 44 | ||
45 | if( (first.id() == second.id() ) && | 45 | if( (first.id() == second.id() ) && |
46 | (first.version() == second.version() ) && | 46 | (first.version() == second.version() ) && |
47 | (first.idInt() == second.idInt() ) ) | 47 | (first.idInt() == second.idInt() ) ) |
48 | return true; | 48 | return true; |
49 | return false; | 49 | return false; |
50 | } | 50 | } |
51 | 51 | ||
52 | Services::ProtocolDescriptor::ProtocolDescriptor(){ | 52 | Services::ProtocolDescriptor::ProtocolDescriptor(){ |
53 | m_number = 0; | 53 | m_number = 0; |
54 | m_channel = 0; | 54 | m_channel = 0; |
55 | } | 55 | } |
56 | Services::ProtocolDescriptor::ProtocolDescriptor(const QString& name, | 56 | Services::ProtocolDescriptor::ProtocolDescriptor(const QString& name, |
57 | int number, | 57 | int number, |
58 | int channel){ | 58 | int channel){ |
59 | m_name = name; | 59 | m_name = name; |
60 | m_number = number; | 60 | m_number = number; |
61 | m_channel = channel; | 61 | m_channel = channel; |
62 | } | 62 | } |
63 | Services::ProtocolDescriptor::ProtocolDescriptor( const ProtocolDescriptor& ole ){ | 63 | Services::ProtocolDescriptor::ProtocolDescriptor( const ProtocolDescriptor& ole ){ |
64 | (*this) = ole; | 64 | (*this) = ole; |
65 | } | 65 | } |
66 | Services::ProtocolDescriptor::~ProtocolDescriptor(){ | 66 | Services::ProtocolDescriptor::~ProtocolDescriptor(){ |
67 | 67 | ||
68 | } | 68 | } |
69 | QString Services::ProtocolDescriptor::name() const{ | 69 | QString Services::ProtocolDescriptor::name() const{ |
70 | return m_name; | 70 | return m_name; |
71 | } | 71 | } |
72 | void Services::ProtocolDescriptor::setName(const QString& name ){ | 72 | void Services::ProtocolDescriptor::setName(const QString& name ){ |
73 | m_name = name; | 73 | m_name = name; |
74 | } | 74 | } |
75 | int Services::ProtocolDescriptor::id()const { | 75 | int Services::ProtocolDescriptor::id()const { |
76 | return m_number; | 76 | return m_number; |
77 | } | 77 | } |
78 | void Services::ProtocolDescriptor::setId( int id ){ | 78 | void Services::ProtocolDescriptor::setId( int id ){ |
79 | m_number = id; | 79 | m_number = id; |
80 | } | 80 | } |
81 | int Services::ProtocolDescriptor::port()const { | 81 | int Services::ProtocolDescriptor::port()const { |
82 | return m_channel; | 82 | return m_channel; |
83 | } | 83 | } |
84 | void Services::ProtocolDescriptor::setPort( int port ){ | 84 | void Services::ProtocolDescriptor::setPort( int port ){ |
85 | m_channel = port; | 85 | m_channel = port; |
86 | } | 86 | } |
87 | Services::ProtocolDescriptor &Services::ProtocolDescriptor::operator=( const Services::ProtocolDescriptor& desc ){ | 87 | Services::ProtocolDescriptor &Services::ProtocolDescriptor::operator=( const Services::ProtocolDescriptor& desc ){ |
88 | m_name = desc.m_name; | 88 | m_name = desc.m_name; |
89 | m_channel = desc.m_channel; | 89 | m_channel = desc.m_channel; |
90 | m_number = desc.m_number; | 90 | m_number = desc.m_number; |
91 | return *this; | 91 | return *this; |
92 | } | 92 | } |
93 | bool operator==( const Services::ProtocolDescriptor &first, | 93 | bool operator==( const Services::ProtocolDescriptor &first, |
94 | const Services::ProtocolDescriptor &second ){ | 94 | const Services::ProtocolDescriptor &second ){ |
95 | if( ( first.name() == second.name() ) && | 95 | if( ( first.name() == second.name() ) && |
96 | ( first.id() == second.id() ) && | 96 | ( first.id() == second.id() ) && |
97 | ( first.port() == second.port() ) ) | 97 | ( first.port() == second.port() ) ) |
98 | return true; | 98 | return true; |
99 | 99 | ||
100 | return false; | 100 | return false; |
101 | 101 | ||
102 | } | 102 | } |
103 | 103 | ||
104 | Services::Services(){ | 104 | Services::Services(){ |
105 | 105 | ||
106 | } | 106 | } |
107 | Services::Services(const Services& service ){ | 107 | Services::Services(const Services& service ){ |
108 | (*this) = service; | 108 | (*this) = service; |
109 | } | 109 | } |
110 | Services::~Services(){ | 110 | Services::~Services(){ |
111 | 111 | ||
112 | } | 112 | } |
113 | Services &Services::operator=( const Services& ser){ | 113 | Services &Services::operator=( const Services& ser){ |
114 | m_name = ser.m_name; | 114 | m_name = ser.m_name; |
115 | m_recHandle = ser.m_recHandle; | 115 | m_recHandle = ser.m_recHandle; |
116 | m_classList = ser.m_classList; | 116 | m_classIds = ser.m_classIds; |
117 | m_classId = ser.m_classId; | ||
118 | m_protocols = ser.m_protocols; | 117 | m_protocols = ser.m_protocols; |
119 | m_profiles = ser.m_profiles; | 118 | m_profiles = ser.m_profiles; |
120 | return *this; | 119 | return *this; |
121 | } | 120 | } |
122 | bool operator==( const Services& one, | 121 | bool operator==( const Services& one, |
123 | const Services& two){ | 122 | const Services& two){ |
124 | if ( ( one.recHandle() == two.recHandle() ) && | 123 | if ( ( one.recHandle() == two.recHandle() ) && |
125 | ( one.classIdListInt() == two.classIdListInt() ) && | ||
126 | ( one.serviceName() == two.serviceName() ) && | 124 | ( one.serviceName() == two.serviceName() ) && |
127 | ( one.classIdList() == two.classIdList() ) && | ||
128 | ( one.protocolDescriptorList() == two.protocolDescriptorList() ) && | 125 | ( one.protocolDescriptorList() == two.protocolDescriptorList() ) && |
129 | ( one.profileDescriptor() == two.profileDescriptor() ) ) | 126 | ( one.profileDescriptor() == two.profileDescriptor() ) |
127 | /* ( one.classIdList() == two.classIdList() ) */ ) | ||
130 | return true; | 128 | return true; |
131 | return false; | 129 | return false; |
132 | } | 130 | } |
133 | QString Services::serviceName() const{ | 131 | QString Services::serviceName() const{ |
134 | return m_name; | 132 | return m_name; |
135 | } | 133 | } |
136 | void Services::setServiceName( const QString& service ){ | 134 | void Services::setServiceName( const QString& service ){ |
137 | m_name = service; | 135 | m_name = service; |
138 | } | 136 | } |
139 | int Services::recHandle() const{ | 137 | int Services::recHandle() const{ |
140 | return m_recHandle; | 138 | return m_recHandle; |
141 | } | 139 | } |
142 | void Services::setRecHandle( int handle){ | 140 | void Services::setRecHandle( int handle){ |
143 | m_recHandle = handle; | 141 | m_recHandle = handle; |
144 | } | 142 | } |
145 | QString Services::classIdList() const{ | 143 | QMap<int, QString> Services::classIdList()const { |
146 | return m_classList; | 144 | return m_classIds; |
145 | }; | ||
146 | void Services::insertClassId( int id, const QString& str ) { | ||
147 | m_classIds.insert( id, str ); | ||
147 | } | 148 | } |
148 | void Services::setClassIdList( const QString& str){ | 149 | void Services::removeClassId(int id) { |
149 | m_classList = str; | 150 | m_classIds.remove( id ); |
150 | } | 151 | } |
151 | int Services::classIdListInt() const{ | 152 | void Services::clearClassId() { |
152 | return m_classId; | 153 | m_classIds.clear(); |
153 | } | ||
154 | void Services::setClassIdList(int id){ | ||
155 | m_classId = id; | ||
156 | } | 154 | } |
157 | void Services::insertProtocolDescriptor( const ProtocolDescriptor& prot){ | 155 | void Services::insertProtocolDescriptor( const ProtocolDescriptor& prot){ |
158 | m_protocols.append( prot ); | 156 | m_protocols.append( prot ); |
159 | } | 157 | } |
160 | void Services::clearProtocolDescriptorList(){ | 158 | void Services::clearProtocolDescriptorList(){ |
161 | m_protocols.clear(); | 159 | m_protocols.clear(); |
162 | } | 160 | } |
163 | void Services::removeProtocolDescriptor( const ProtocolDescriptor& prot){ | 161 | void Services::removeProtocolDescriptor( const ProtocolDescriptor& prot){ |
164 | m_protocols.remove( prot ); | 162 | m_protocols.remove( prot ); |
165 | } | 163 | } |
166 | Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{ | 164 | Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{ |
167 | return m_protocols; | 165 | return m_protocols; |
168 | } | 166 | } |
169 | 167 | ||
170 | 168 | ||
171 | void Services::insertProfileDescriptor( const ProfileDescriptor& prof){ | 169 | void Services::insertProfileDescriptor( const ProfileDescriptor& prof){ |
172 | m_profiles.append( prof ); | 170 | m_profiles.append( prof ); |
173 | } | 171 | } |
174 | void Services::clearProfileDescriptorList(){ | 172 | void Services::clearProfileDescriptorList(){ |
175 | m_profiles.clear(); | 173 | m_profiles.clear(); |
176 | } | 174 | } |
177 | void Services::removeProfileDescriptor( const ProfileDescriptor& prof){ | 175 | void Services::removeProfileDescriptor( const ProfileDescriptor& prof){ |
178 | m_profiles.remove(prof ); | 176 | m_profiles.remove(prof ); |
179 | } | 177 | } |
180 | Services::ProfileDescriptor::ValueList Services::profileDescriptor() const{ | 178 | Services::ProfileDescriptor::ValueList Services::profileDescriptor() const{ |
181 | return m_profiles; | 179 | return m_profiles; |
182 | } | 180 | } |
diff --git a/noncore/net/opietooth/lib/services.h b/noncore/net/opietooth/lib/services.h index 881d383..7cce5e1 100644 --- a/noncore/net/opietooth/lib/services.h +++ b/noncore/net/opietooth/lib/services.h | |||
@@ -1,143 +1,144 @@ | |||
1 | 1 | ||
2 | #ifndef OpieToothServices_H | 2 | #ifndef OpieToothServices_H |
3 | #define OpieToothServices_H | 3 | #define OpieToothServices_H |
4 | 4 | ||
5 | #include <qmap.h> | ||
5 | #include <qvaluelist.h> | 6 | #include <qvaluelist.h> |
6 | 7 | ||
7 | namespace OpieTooth { | 8 | namespace OpieTooth { |
8 | /** | 9 | /** |
9 | * Services lets shows you all available services | 10 | * Services lets shows you all available services |
10 | * on a remote device | 11 | * on a remote device |
11 | */ | 12 | */ |
12 | class Services { | 13 | class Services { |
13 | 14 | ||
14 | /** The profile descriptor | 15 | /** The profile descriptor |
15 | * | 16 | * |
16 | */ | 17 | */ |
17 | class ProfileDescriptor{ | 18 | class ProfileDescriptor{ |
18 | public: | 19 | public: |
19 | /** typedef */ | 20 | /** typedef */ |
20 | typedef QValueList<ProfileDescriptor> ValueList; | 21 | typedef QValueList<ProfileDescriptor> ValueList; |
21 | /** c'tor for QValueList */ | 22 | /** c'tor for QValueList */ |
22 | ProfileDescriptor(); | 23 | ProfileDescriptor(); |
23 | /** | 24 | /** |
24 | * c'tor | 25 | * c'tor |
25 | * @param id The id or name ("Lan Access Using PPP") | 26 | * @param id The id or name ("Lan Access Using PPP") |
26 | * @param idInt The id as uint ( 0x1102 ) | 27 | * @param idInt The id as uint ( 0x1102 ) |
27 | * @param version Version of the Profile ( 1 ) | 28 | * @param version Version of the Profile ( 1 ) |
28 | */ | 29 | */ |
29 | ProfileDescriptor(const QString &id, int idInt, int version ); | 30 | ProfileDescriptor(const QString &id, int idInt, int version ); |
30 | /** | 31 | /** |
31 | * copy c'tor | 32 | * copy c'tor |
32 | */ | 33 | */ |
33 | ProfileDescriptor(const ProfileDescriptor& ); | 34 | ProfileDescriptor(const ProfileDescriptor& ); |
34 | /** | 35 | /** |
35 | * returns the id | 36 | * returns the id |
36 | */ | 37 | */ |
37 | QString id()const; | 38 | QString id()const; |
38 | /** | 39 | /** |
39 | * sets the id | 40 | * sets the id |
40 | */ | 41 | */ |
41 | void setId(const QString& id); | 42 | void setId(const QString& id); |
42 | 43 | ||
43 | /** | 44 | /** |
44 | * sets the int id | 45 | * sets the int id |
45 | */ | 46 | */ |
46 | void setId(int ); | 47 | void setId(int ); |
47 | /** | 48 | /** |
48 | * reutns the id as int | 49 | * reutns the id as int |
49 | */ | 50 | */ |
50 | int idInt()const; | 51 | int idInt()const; |
51 | /** | 52 | /** |
52 | * returns the version | 53 | * returns the version |
53 | */ | 54 | */ |
54 | int version()const; | 55 | int version()const; |
55 | /** | 56 | /** |
56 | * sets the Version | 57 | * sets the Version |
57 | */ | 58 | */ |
58 | void setVersion(int version ); | 59 | void setVersion(int version ); |
59 | /** | 60 | /** |
60 | * copy operator | 61 | * copy operator |
61 | */ | 62 | */ |
62 | ProfileDescriptor &operator=( const ProfileDescriptor& ); | 63 | ProfileDescriptor &operator=( const ProfileDescriptor& ); |
63 | /** | 64 | /** |
64 | * operator== | 65 | * operator== |
65 | */ | 66 | */ |
66 | // friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& ); | 67 | // friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& ); |
67 | private: | 68 | private: |
68 | QString m_id; | 69 | QString m_id; |
69 | int m_idInt; | 70 | int m_idInt; |
70 | int m_version; | 71 | int m_version; |
71 | }; | 72 | }; |
72 | /** | 73 | /** |
73 | * Protocol Descriptor | 74 | * Protocol Descriptor |
74 | */ | 75 | */ |
75 | class ProtocolDescriptor { | 76 | class ProtocolDescriptor { |
76 | public: | 77 | public: |
77 | typedef QValueList<ProtocolDescriptor> ValueList; | 78 | typedef QValueList<ProtocolDescriptor> ValueList; |
78 | /** | 79 | /** |
79 | * c'tor | 80 | * c'tor |
80 | */ | 81 | */ |
81 | ProtocolDescriptor(); | 82 | ProtocolDescriptor(); |
82 | /** | 83 | /** |
83 | * name | 84 | * name |
84 | * number | 85 | * number |
85 | * channel/port | 86 | * channel/port |
86 | */ | 87 | */ |
87 | ProtocolDescriptor(const QString&, int, int port = -1 ); // Q_UINT8 ? | 88 | ProtocolDescriptor(const QString&, int, int port = -1 ); // Q_UINT8 ? |
88 | ProtocolDescriptor(const ProtocolDescriptor& ); | 89 | ProtocolDescriptor(const ProtocolDescriptor& ); |
89 | ~ProtocolDescriptor(); | 90 | ~ProtocolDescriptor(); |
90 | QString name()const; | 91 | QString name()const; |
91 | void setName(const QString& ); | 92 | void setName(const QString& ); |
92 | int id()const; | 93 | int id()const; |
93 | void setId(int ); | 94 | void setId(int ); |
94 | int port()const; | 95 | int port()const; |
95 | void setPort(int ); | 96 | void setPort(int ); |
96 | ProtocolDescriptor &operator=( const ProtocolDescriptor& ); | 97 | ProtocolDescriptor &operator=( const ProtocolDescriptor& ); |
97 | //friend bool operator==( const ProtocolDescriptor&, | 98 | //friend bool operator==( const ProtocolDescriptor&, |
98 | // const ProtocolDescriptor& ); | 99 | // const ProtocolDescriptor& ); |
99 | private: | 100 | private: |
100 | QString m_name; | 101 | QString m_name; |
101 | int m_number; | 102 | int m_number; |
102 | int m_channel; | 103 | int m_channel; |
103 | }; | 104 | }; |
104 | 105 | ||
105 | public: | 106 | public: |
106 | typedef QValueList<Services> ValueList; | 107 | typedef QValueList<Services> ValueList; |
107 | Services(); | 108 | Services(); |
108 | Services(const Services& service ); | 109 | Services(const Services& service ); |
109 | ~Services(); | 110 | ~Services(); |
110 | 111 | ||
111 | Services &operator=( const Services& ); | 112 | Services &operator=( const Services& ); |
112 | friend bool operator==(const Services&, const Services& ); | 113 | friend bool operator==(const Services&, const Services& ); |
113 | QString serviceName()const; | 114 | QString serviceName()const; |
114 | void setServiceName( const QString& service ); | 115 | void setServiceName( const QString& service ); |
115 | 116 | ||
116 | int recHandle()const; | 117 | int recHandle()const; |
117 | void setRecHandle( int ); | 118 | void setRecHandle( int ); |
118 | 119 | ||
119 | QString classIdList()const; | 120 | |
120 | void setClassIdList( const QString& ); | 121 | QMap<int, QString> classIdList()const; |
121 | int classIdListInt()const; | 122 | void insertClassId( int id, const QString& className ); |
122 | void setClassIdList(int ); | 123 | void removeClassId( int id ); |
124 | void clearClassId(); | ||
123 | 125 | ||
124 | void insertProtocolDescriptor(const ProtocolDescriptor& ); | 126 | void insertProtocolDescriptor(const ProtocolDescriptor& ); |
125 | void clearProtocolDescriptorList(); | 127 | void clearProtocolDescriptorList(); |
126 | void removeProtocolDescriptor( const ProtocolDescriptor& ); | 128 | void removeProtocolDescriptor( const ProtocolDescriptor& ); |
127 | ProtocolDescriptor::ValueList protocolDescriptorList()const; | 129 | ProtocolDescriptor::ValueList protocolDescriptorList()const; |
128 | 130 | ||
129 | void insertProfileDescriptor( const ProfileDescriptor& ); | 131 | void insertProfileDescriptor( const ProfileDescriptor& ); |
130 | void clearProfileDescriptorList(); | 132 | void clearProfileDescriptorList(); |
131 | void removeProfileDescriptor(const ProfileDescriptor& ); | 133 | void removeProfileDescriptor(const ProfileDescriptor& ); |
132 | ProfileDescriptor::ValueList profileDescriptor()const; | 134 | ProfileDescriptor::ValueList profileDescriptor()const; |
133 | 135 | ||
134 | private: | 136 | private: |
137 | QMap<int, QString> m_classIds; | ||
135 | QString m_name; | 138 | QString m_name; |
136 | int m_recHandle; | 139 | int m_recHandle; |
137 | QString m_classList; | ||
138 | int m_classId; | ||
139 | QValueList<ProfileDescriptor> m_profiles; | 140 | QValueList<ProfileDescriptor> m_profiles; |
140 | QValueList<ProtocolDescriptor> m_protocols; | 141 | QValueList<ProtocolDescriptor> m_protocols; |
141 | }; | 142 | }; |
142 | }; | 143 | }; |
143 | #endif | 144 | #endif |