-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 22 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/parser.cc | 90 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/parser.h | 3 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/services.cc | 66 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/services.h | 15 |
5 files changed, 142 insertions, 54 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index fcd21f6..177c94e 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc | |||
@@ -1,213 +1,219 @@ | |||
1 | |||
2 | |||
1 | #include <opie/oprocess.h> | 3 | #include <opie/oprocess.h> |
2 | 4 | ||
5 | #include "parser.h" | ||
3 | #include "manager.h" | 6 | #include "manager.h" |
4 | 7 | ||
5 | 8 | ||
6 | using namespace OpieTooth; | 9 | using namespace OpieTooth; |
7 | 10 | ||
8 | Manager::Manager( const QString& dev ) | 11 | Manager::Manager( const QString& dev ) |
9 | : QObject() | 12 | : QObject() |
10 | { | 13 | { |
11 | qWarning("created"); | 14 | qWarning("created"); |
12 | m_device = dev; | 15 | m_device = dev; |
13 | m_hcitool = 0; | 16 | m_hcitool = 0; |
14 | m_sdp = 0; | 17 | m_sdp = 0; |
15 | } | 18 | } |
16 | Manager::Manager( Device* dev ) | 19 | Manager::Manager( Device* /*dev*/ ) |
17 | : QObject() | 20 | : QObject() |
18 | { | 21 | { |
19 | m_hcitool = 0; | 22 | m_hcitool = 0; |
20 | m_sdp = 0; | 23 | m_sdp = 0; |
21 | } | 24 | } |
22 | Manager::Manager() | 25 | Manager::Manager() |
23 | : QObject() | 26 | : QObject() |
24 | { | 27 | { |
25 | m_hcitool = 0; | 28 | m_hcitool = 0; |
26 | m_sdp = 0; | 29 | m_sdp = 0; |
27 | } | 30 | } |
28 | Manager::~Manager(){ | 31 | Manager::~Manager(){ |
29 | delete m_hcitool; | 32 | delete m_hcitool; |
30 | delete m_sdp; | 33 | delete m_sdp; |
31 | } | 34 | } |
32 | void Manager::setDevice( const QString& dev ){ | 35 | void Manager::setDevice( const QString& dev ){ |
33 | m_device = dev; | 36 | m_device = dev; |
34 | } | 37 | } |
35 | void Manager::setDevice( Device* dev ){ | 38 | void Manager::setDevice( Device* /*dev*/ ){ |
36 | 39 | ||
37 | } | 40 | } |
38 | void Manager::isAvailable( const QString& device ){ | 41 | void Manager::isAvailable( const QString& device ){ |
39 | OProcess* l2ping = new OProcess(); | 42 | OProcess* l2ping = new OProcess(); |
40 | l2ping->setName( device.latin1() ); | 43 | l2ping->setName( device.latin1() ); |
41 | *l2ping << "l2ping" << "-c1" << device; | 44 | *l2ping << "l2ping" << "-c1" << device; |
42 | connect(l2ping, SIGNAL(processExited(OProcess* ) ), | 45 | connect(l2ping, SIGNAL(processExited(OProcess* ) ), |
43 | this, SLOT(slotProcessExited(OProcess*) ) ); | 46 | this, SLOT(slotProcessExited(OProcess*) ) ); |
44 | if (!l2ping->start() ) { | 47 | if (!l2ping->start() ) { |
45 | emit available( device, false ); | 48 | emit available( device, false ); |
46 | delete l2ping; | 49 | delete l2ping; |
47 | } | 50 | } |
48 | 51 | ||
49 | } | 52 | } |
50 | void Manager::isAvailable( Device* dev ){ | 53 | |
54 | void Manager::isAvailable( Device* /*dev*/ ){ | ||
51 | 55 | ||
52 | 56 | ||
53 | } | 57 | } |
54 | void Manager::searchDevices( const QString& device ){ | 58 | void Manager::searchDevices( const QString& device ){ |
55 | qWarning("search devices"); | 59 | qWarning("search devices"); |
56 | OProcess* hcitool = new OProcess(); | 60 | OProcess* hcitool = new OProcess(); |
57 | hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); | 61 | hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); |
58 | *hcitool << "hcitool" << "scan"; | 62 | *hcitool << "hcitool" << "scan"; |
59 | connect( hcitool, SIGNAL(processExited(OProcess*) ) , | 63 | connect( hcitool, SIGNAL(processExited(OProcess*) ) , |
60 | this, SLOT(slotHCIExited(OProcess* ) ) ); | 64 | this, SLOT(slotHCIExited(OProcess* ) ) ); |
61 | connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 65 | connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
62 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); | 66 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); |
63 | if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 67 | if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
64 | qWarning("could not start"); | 68 | qWarning("could not start"); |
65 | RemoteDevice::ValueList list; | 69 | RemoteDevice::ValueList list; |
66 | emit foundDevices( device, list ); | 70 | emit foundDevices( device, list ); |
67 | delete hcitool; | 71 | delete hcitool; |
68 | } | 72 | } |
69 | } | 73 | } |
70 | 74 | ||
71 | void Manager::searchDevices(Device* d ){ | 75 | void Manager::searchDevices(Device* /*d*/ ){ |
72 | 76 | ||
73 | 77 | ||
74 | } | 78 | } |
75 | void Manager::addService(const QString& name ){ | 79 | void Manager::addService(const QString& name ){ |
76 | OProcess proc; | 80 | OProcess proc; |
77 | proc << "sdptool" << "add" << name; | 81 | proc << "sdptool" << "add" << name; |
78 | bool bo = true; | 82 | bool bo = true; |
79 | if (!proc.start(OProcess::DontCare ) ) | 83 | if (!proc.start(OProcess::DontCare ) ) |
80 | bo = false; | 84 | bo = false; |
81 | emit addedService( name, bo ); | 85 | emit addedService( name, bo ); |
82 | } | 86 | } |
83 | void Manager::addServices(const QStringList& list){ | 87 | void Manager::addServices(const QStringList& list){ |
84 | QStringList::ConstIterator it; | 88 | QStringList::ConstIterator it; |
85 | for (it = list.begin(); it != list.end(); ++it ) | 89 | for (it = list.begin(); it != list.end(); ++it ) |
86 | addService( (*it) ); | 90 | addService( (*it) ); |
87 | } | 91 | } |
88 | void Manager::removeService( const QString& name ){ | 92 | void Manager::removeService( const QString& name ){ |
89 | OProcess prc; | 93 | OProcess prc; |
90 | prc << "sdptool" << "del" << name; | 94 | prc << "sdptool" << "del" << name; |
91 | bool bo = true; | 95 | bool bo = true; |
92 | if (!prc.start(OProcess::DontCare ) ) | 96 | if (!prc.start(OProcess::DontCare ) ) |
93 | bo = false; | 97 | bo = false; |
94 | emit removedService( name, bo ); | 98 | emit removedService( name, bo ); |
95 | } | 99 | } |
96 | void Manager::removeServices( const QStringList& list){ | 100 | void Manager::removeServices( const QStringList& list){ |
97 | QStringList::ConstIterator it; | 101 | QStringList::ConstIterator it; |
98 | for (it = list.begin(); it != list.end(); ++it ) | 102 | for (it = list.begin(); it != list.end(); ++it ) |
99 | removeService( (*it) ); | 103 | removeService( (*it) ); |
100 | } | 104 | } |
101 | void Manager::searchServices( const QString& remDevice ){ | 105 | void Manager::searchServices( const QString& remDevice ){ |
102 | OProcess *m_sdp =new OProcess(); | 106 | OProcess *m_sdp =new OProcess(); |
103 | *m_sdp << "sdptool" << "browse" << remDevice; | 107 | *m_sdp << "sdptool" << "browse" << remDevice; |
104 | m_sdp->setName( remDevice.latin1() ); | 108 | m_sdp->setName( remDevice.latin1() ); |
105 | connect(m_sdp, SIGNAL(processExited(OProcess*) ), | 109 | connect(m_sdp, SIGNAL(processExited(OProcess*) ), |
106 | this, SLOT(slotSDPExited(OProcess* ) ) ); | 110 | this, SLOT(slotSDPExited(OProcess* ) ) ); |
107 | connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 111 | connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
108 | this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); | 112 | this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); |
109 | if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 113 | if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
110 | delete m_sdp; | 114 | delete m_sdp; |
111 | Services::ValueList list; | 115 | Services::ValueList list; |
112 | emit foundServices( remDevice, list ); | 116 | emit foundServices( remDevice, list ); |
113 | } | 117 | } |
114 | } | 118 | } |
115 | void Manager::searchServices( const RemoteDevice& dev){ | 119 | void Manager::searchServices( const RemoteDevice& dev){ |
116 | searchServices( dev.mac() ); | 120 | searchServices( dev.mac() ); |
117 | } | 121 | } |
118 | QString Manager::toDevice( const QString& mac ){ | 122 | QString Manager::toDevice( const QString& /*mac*/ ){ |
119 | 123 | return QString::null; | |
120 | } | 124 | } |
121 | QString Manager::toMac( const QString &device ){ | 125 | QString Manager::toMac( const QString &/*device*/ ){ |
122 | 126 | return QString::null; | |
123 | } | 127 | } |
124 | void Manager::slotProcessExited(OProcess* proc ) { | 128 | void Manager::slotProcessExited(OProcess* proc ) { |
125 | bool conn= false; | 129 | bool conn= false; |
126 | if (proc->normalExit() && proc->exitStatus() == 0 ) | 130 | if (proc->normalExit() && proc->exitStatus() == 0 ) |
127 | conn = true; | 131 | conn = true; |
128 | 132 | ||
129 | QString name = QString::fromLatin1(proc->name() ); | 133 | QString name = QString::fromLatin1(proc->name() ); |
130 | emit available( name, conn ); | 134 | emit available( name, conn ); |
131 | delete proc; | 135 | delete proc; |
132 | } | 136 | } |
133 | void Manager::slotSDPOut(OProcess* proc, char* ch, int len) | 137 | void Manager::slotSDPOut(OProcess* proc, char* ch, int len) |
134 | { | 138 | { |
135 | QCString str(ch, len+1 ); | 139 | QCString str(ch, len+1 ); |
136 | QMap<QString, QString>::Iterator it; | 140 | QMap<QString, QString>::Iterator it; |
137 | it = m_out.find(proc->name() ); | 141 | it = m_out.find(proc->name() ); |
138 | if ( it != m_out.end() ) { | 142 | if ( it != m_out.end() ) { |
139 | QString string = it.data(); | 143 | QString string = it.data(); |
140 | string.append( str ); | 144 | string.append( str ); |
141 | m_out.replace( proc->name(), string ); | 145 | m_out.replace( proc->name(), string ); |
142 | } | 146 | } |
143 | 147 | ||
144 | } | 148 | } |
145 | void Manager::slotSDPExited( OProcess* proc) | 149 | void Manager::slotSDPExited( OProcess* proc) |
146 | { | 150 | { |
147 | Services::ValueList list; | 151 | Services::ValueList list; |
148 | if (proc->normalExit() ) { | 152 | if (proc->normalExit() ) { |
149 | QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); | 153 | QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); |
150 | if ( it != m_out.end() ) { | 154 | if ( it != m_out.end() ) { |
151 | list = parseSDPOutput( it.data() ); | 155 | list = parseSDPOutput( it.data() ); |
152 | m_out.remove( it ); | 156 | m_out.remove( it ); |
153 | } | 157 | } |
154 | } | 158 | } |
155 | emit foundServices( proc->name(), list ); | 159 | emit foundServices( proc->name(), list ); |
156 | delete proc; | 160 | delete proc; |
157 | } | 161 | } |
158 | Services::ValueList Manager::parseSDPOutput( const QString& out ) { | 162 | Services::ValueList Manager::parseSDPOutput( const QString& out ) { |
159 | Services::ValueList list; | 163 | Services::ValueList list; |
164 | Parser parser( out ); | ||
165 | list = parser.services(); | ||
160 | return list; | 166 | return list; |
161 | } | 167 | } |
162 | 168 | ||
163 | void Manager::slotHCIExited(OProcess* proc ) { | 169 | void Manager::slotHCIExited(OProcess* proc ) { |
164 | qWarning("process exited"); | 170 | qWarning("process exited"); |
165 | RemoteDevice::ValueList list; | 171 | RemoteDevice::ValueList list; |
166 | if (proc->normalExit() ) { | 172 | if (proc->normalExit() ) { |
167 | qWarning("normalExit %s", proc->name() ); | 173 | qWarning("normalExit %s", proc->name() ); |
168 | QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); | 174 | QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); |
169 | if (it != m_devices.end() ) { | 175 | if (it != m_devices.end() ) { |
170 | qWarning("!= end ;)"); | 176 | qWarning("!= end ;)"); |
171 | list = parseHCIOutput( it.data() ); | 177 | list = parseHCIOutput( it.data() ); |
172 | m_devices.remove( it ); | 178 | m_devices.remove( it ); |
173 | } | 179 | } |
174 | } | 180 | } |
175 | emit foundDevices( proc->name(), list ); | 181 | emit foundDevices( proc->name(), list ); |
176 | delete proc; | 182 | delete proc; |
177 | } | 183 | } |
178 | void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { | 184 | void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { |
179 | QCString str( ch, len+1 ); | 185 | QCString str( ch, len+1 ); |
180 | qWarning("hci: %s", str.data() ); | 186 | qWarning("hci: %s", str.data() ); |
181 | QMap<QString, QString>::Iterator it; | 187 | QMap<QString, QString>::Iterator it; |
182 | it = m_devices.find( proc->name() ); | 188 | it = m_devices.find( proc->name() ); |
183 | qWarning("proc->name %s", proc->name() ); | 189 | qWarning("proc->name %s", proc->name() ); |
184 | QString string; | 190 | QString string; |
185 | if (it != m_devices.end() ) { | 191 | if (it != m_devices.end() ) { |
186 | qWarning("slotHCIOut "); | 192 | qWarning("slotHCIOut "); |
187 | string = it.data(); | 193 | string = it.data(); |
188 | } | 194 | } |
189 | string.append( str ); | 195 | string.append( str ); |
190 | 196 | ||
191 | m_devices.replace( proc->name(), string ); | 197 | m_devices.replace( proc->name(), string ); |
192 | } | 198 | } |
193 | RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { | 199 | RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { |
194 | qWarning("parseHCI %s", output.latin1() ); | 200 | qWarning("parseHCI %s", output.latin1() ); |
195 | RemoteDevice::ValueList list; | 201 | RemoteDevice::ValueList list; |
196 | QStringList strList = QStringList::split('\n', output ); | 202 | QStringList strList = QStringList::split('\n', output ); |
197 | QStringList::Iterator it; | 203 | QStringList::Iterator it; |
198 | QString str; | 204 | QString str; |
199 | for ( it = strList.begin(); it != strList.end(); ++it ) { | 205 | for ( it = strList.begin(); it != strList.end(); ++it ) { |
200 | str = (*it).stripWhiteSpace(); | 206 | str = (*it).stripWhiteSpace(); |
201 | qWarning("OpieTooth %s", str.latin1() ); | 207 | qWarning("OpieTooth %s", str.latin1() ); |
202 | int pos = str.findRev(':' ); | 208 | int pos = str.findRev(':' ); |
203 | if ( pos > 0 ) { | 209 | if ( pos > 0 ) { |
204 | QString mac = str.left(17 ); | 210 | QString mac = str.left(17 ); |
205 | str.remove( 0, 17 ); | 211 | str.remove( 0, 17 ); |
206 | qWarning("mac %s", mac.latin1() ); | 212 | qWarning("mac %s", mac.latin1() ); |
207 | qWarning("rest:%s", str.latin1() ); | 213 | qWarning("rest:%s", str.latin1() ); |
208 | RemoteDevice rem( mac , str.stripWhiteSpace() ); | 214 | RemoteDevice rem( mac , str.stripWhiteSpace() ); |
209 | list.append( rem ); | 215 | list.append( rem ); |
210 | } | 216 | } |
211 | } | 217 | } |
212 | return list; | 218 | return list; |
213 | } | 219 | } |
diff --git a/noncore/net/opietooth/lib/parser.cc b/noncore/net/opietooth/lib/parser.cc index 452917b..18d534e 100644 --- a/noncore/net/opietooth/lib/parser.cc +++ b/noncore/net/opietooth/lib/parser.cc | |||
@@ -1,113 +1,173 @@ | |||
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 { | ||
9 | |||
10 | |||
11 | // "Test Foo Bar" (0x3456) | ||
12 | // @param ret Test Foo Bar | ||
13 | // @eturn 13398 | ||
14 | // tactic find " ( | ||
15 | int convert( const QString& line, QString& ret ) { | ||
16 | ret = QString::null; | ||
17 | int i = 0; | ||
18 | int pos = line.findRev("\" ("); | ||
19 | if ( pos > 0 ) { // it shouldn't be at pos 0 | ||
20 | ret = line.left(pos-1 ).stripWhiteSpace(); | ||
21 | qWarning("ret: %s", ret.latin1() ); | ||
22 | ret = ret.replace(QRegExp("[\"]"), ""); | ||
23 | qWarning("ret: %s", ret.latin1() ); | ||
24 | QString dummy = line.mid(pos + 4 ); | ||
25 | qWarning("dummy: %s", dummy.latin1() ); | ||
26 | dummy = dummy.remove( dummy.length() -1, 1 ); // remove the ( | ||
27 | bool ok; | ||
28 | i = dummy.toInt(&ok, 16 ); | ||
29 | } | ||
30 | return i; | ||
31 | } | ||
32 | |||
33 | }; | ||
34 | |||
35 | |||
8 | Parser::Parser(const QString& output ) { | 36 | Parser::Parser(const QString& output ) { |
9 | parse( output ); | 37 | parse( output ); |
10 | } | 38 | } |
11 | void Parser::setText(const QString& output) { | 39 | void Parser::setText(const QString& output) { |
12 | parse( output ); | 40 | parse( output ); |
13 | } | 41 | } |
14 | Services::ValueList Parser::services() const { | 42 | Services::ValueList Parser::services() const { |
15 | return m_list; | 43 | return m_list; |
16 | } | 44 | } |
17 | void Parser::parse( const QString& string) { | 45 | void Parser::parse( const QString& string) { |
18 | m_list.clear(); | 46 | m_list.clear(); |
19 | m_complete = true; | 47 | m_complete = true; |
20 | QStringList list = QStringList::split('\n', string ); | 48 | QStringList list = QStringList::split('\n', string ); |
21 | QStringList::Iterator it; | 49 | QStringList::Iterator it; |
22 | for (it = list.begin(); it != list.end(); ++it ) { | 50 | for (it = list.begin(); it != list.end(); ++it ) { |
23 | if ( (*it).startsWith("Browsing") ) continue; | 51 | if ( (*it).startsWith("Browsing") ) continue; |
24 | 52 | ||
25 | if ( (*it).isEmpty() ) { // line is empty because a new Service begins | 53 | if ( (*it).isEmpty() ) { // line is empty because a new Service begins |
26 | // now see if complete and add | 54 | // now see if complete and add |
27 | if (m_complete ) { | 55 | if (m_complete ) { |
28 | m_list.append( m_item ); | 56 | m_list.append( m_item ); |
29 | Services serv; | 57 | Services serv; |
30 | m_item = serv; | 58 | m_item = serv; |
59 | m_complete = true; | ||
31 | continue; | 60 | continue; |
32 | } | 61 | } |
33 | } | 62 | } |
34 | if (parseName( (*it) ) ) ;//continue; | 63 | if (parseName( (*it) ) ) ;//continue; |
35 | if (parseRecHandle( (*it) ) ) ;//continue; | 64 | if (parseRecHandle( (*it) ) ) ;//continue; |
36 | if (parseClassId( (*it) ) ) ;//continue; | 65 | if (parseClassId( (*it) ) ) ;//continue; |
37 | if (parseProtocol( (*it) ) ) ;//continue; | 66 | if (parseProtocol( (*it) ) ) ;//continue; |
38 | if (parseProfile( (*it) ) ) ;//continue; | 67 | if (parseProfile( (*it) ) ) ;//continue; |
39 | } | 68 | } |
69 | // missed the last one | ||
70 | if (m_complete) { | ||
71 | m_list.append(m_item ); | ||
72 | } | ||
40 | } | 73 | } |
41 | bool Parser::parseName( const QString& str) { | 74 | bool Parser::parseName( const QString& str) { |
42 | if (str.startsWith("Service Name:") ) { | 75 | if (str.startsWith("Service Name:") ) { |
43 | m_item.setServiceName( str.mid(13).stripWhiteSpace() ); | 76 | m_item.setServiceName( str.mid(13).stripWhiteSpace() ); |
44 | qWarning(m_item.serviceName() ); | 77 | qWarning(m_item.serviceName() ); |
45 | return true; | 78 | return true; |
46 | } | 79 | } |
47 | return false; | 80 | return false; |
48 | } | 81 | } |
49 | bool Parser::parseRecHandle( const QString& str) { | 82 | bool Parser::parseRecHandle( const QString& str) { |
50 | if (str.startsWith("Service RecHandle:" ) ) { | 83 | if (str.startsWith("Service RecHandle:" ) ) { |
51 | QString out = str.mid(18 ).stripWhiteSpace(); | 84 | QString out = str.mid(18 ).stripWhiteSpace(); |
52 | qWarning("out %s", out.latin1() ); | 85 | qWarning("out %s", out.latin1() ); |
53 | int value = out.toInt(&m_ok, 16 ); | 86 | int value = out.toInt(&m_ok, 16 ); |
54 | if (m_ok && (value != -1) ) | 87 | if (m_ok && (value != -1) ) |
55 | m_complete = true; | 88 | m_complete = true; |
56 | else | 89 | else |
57 | m_complete = false; | 90 | m_complete = false; |
58 | return true; | 91 | return true; |
59 | m_item.setRecHandle( value ); | 92 | m_item.setRecHandle( value ); |
60 | } | 93 | } |
61 | return false; | 94 | return false; |
62 | } | 95 | } |
63 | bool Parser::parseClassId( const QString& str) { | 96 | bool Parser::parseClassId( const QString& str) { |
64 | if (str.startsWith("Service Class ID List:") ) { | 97 | if (str.startsWith("Service Class ID List:") ) { |
65 | m_classOver = true; | 98 | m_classOver = true; |
66 | return true; | 99 | return true; |
67 | }else if ( m_classOver ) { // ok now are the informations in place | 100 | }else if ( m_classOver ) { // ok now are the informations in place |
68 | 101 | ||
69 | m_classOver = false; | 102 | m_classOver = false; |
70 | QStringList list = QStringList::split('\n', str.stripWhiteSpace() ); | 103 | |
71 | 104 | // "Obex Object Push" (0x1105) | |
72 | if ( list.count() == 2 ) { | 105 | // find backwards the " and the from 0 to pos and the mid pos+1 |
73 | m_item.setClassIdList( list[0] ); | 106 | // then stripWhiteSpace add name replace '"' with "" |
74 | // now let's parse the number (0x1105) | 107 | // and then convert 0x1105 toInt() |
75 | QString classId= list[1]; | 108 | QString classes; |
76 | int classIdInt; | 109 | int ids; |
77 | qWarning("%s", list[1].latin1() ); | 110 | ids = convert( str, classes ); |
78 | classId = classId.remove(0, 3 ); | 111 | qWarning("ids %d", ids ); |
79 | classId = classId.remove( classId.length()-1, 1 ); | 112 | m_item.setClassIdList( classes ); |
80 | qWarning("%s", classId.latin1() ); | 113 | m_item.setClassIdList( ids ); |
81 | m_item.setClassIdList( classId.toInt(&m_ok, 16 ) ); | 114 | |
82 | } | ||
83 | return true; | 115 | return true; |
84 | }else | 116 | }else |
85 | m_classOver = true; | 117 | m_classOver = true; |
86 | return false; | 118 | return false; |
87 | } | 119 | } |
88 | bool Parser::parseProtocol( const QString& str) { | 120 | bool Parser::parseProtocol( const QString& str) { |
89 | if (str.startsWith("Protocol Descriptor List:") ) { | 121 | if (str.startsWith("Protocol Descriptor List:") ) { |
90 | m_protocolOver = true; | 122 | m_protocolOver = true; |
91 | m_protocolAdded = false; | 123 | m_protocolAdded = false; |
92 | return true; | 124 | return true; |
93 | 125 | ||
94 | }else if (m_protocolOver && str.startsWith(" ") ) { | 126 | }else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100) |
95 | qWarning("double protocol filter"); | 127 | qWarning("double protocol filter"); |
128 | |||
96 | if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now | 129 | if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now |
97 | Services::ProtocolDescriptor desc( m_protName, m_protId ); | 130 | Services::ProtocolDescriptor desc( m_protName, m_protId ); |
98 | m_item.insertProtocolDescriptor( desc ); | 131 | m_item.insertProtocolDescriptor( desc ); |
99 | } | 132 | } |
100 | m_protocolAdded = false; | 133 | m_protocolAdded = false; |
134 | { // the find function | ||
135 | m_protId = convert(str, m_protName ); | ||
136 | } | ||
101 | return true; | 137 | return true; |
102 | }else if (m_protocolOver && str.startsWith(" ") ) { | 138 | }else if (m_protocolOver && str.startsWith(" ") ) { |
103 | qWarning("tripple protocol filter"); | 139 | qWarning("tripple protocol filter"); |
104 | m_protocolAdded = true; | 140 | m_protocolAdded = true; |
141 | QString dummy = str.stripWhiteSpace(); | ||
142 | int pos = dummy.findRev(':'); | ||
143 | if ( pos > -1 ) { | ||
144 | int port = dummy.mid(pos+1 ).stripWhiteSpace().toInt(); | ||
145 | Services::ProtocolDescriptor desc( m_protName, m_protId, port ); | ||
146 | m_item.insertProtocolDescriptor( desc ); | ||
147 | } | ||
105 | return true; | 148 | return true; |
106 | }else if (m_protocolOver ) { | 149 | }else if (m_protocolOver ) { |
107 | m_protocolOver = false; | 150 | m_protocolOver = false; |
108 | } | 151 | } |
109 | return false; | 152 | return false; |
110 | } | 153 | } |
111 | bool Parser::parseProfile( const QString& ) { | 154 | bool Parser::parseProfile( const QString& str) { |
155 | if (str.startsWith("Profile Descriptor List:") ) { | ||
156 | m_profOver = true; | ||
157 | }else if ( m_profOver && str.startsWith(" ") ) { | ||
158 | m_profId = convert( str, m_profName ); | ||
159 | }else if ( m_profOver && str.startsWith(" ") ) { | ||
160 | // now find | ||
161 | int pos = str.findRev(':'); | ||
162 | if ( pos > 0 ) { | ||
163 | int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt(); | ||
164 | qWarning("dummyInt:%d", dummy ); | ||
165 | Services::ProfileDescriptor desc( m_profName, m_profId, dummy ); | ||
166 | m_item.insertProfileDescriptor(desc); | ||
167 | } | ||
168 | }else | ||
169 | m_profOver = false; | ||
170 | |||
171 | |||
112 | return false; | 172 | return false; |
113 | } | 173 | } |
diff --git a/noncore/net/opietooth/lib/parser.h b/noncore/net/opietooth/lib/parser.h index 7642ac3..520a725 100644 --- a/noncore/net/opietooth/lib/parser.h +++ b/noncore/net/opietooth/lib/parser.h | |||
@@ -1,34 +1,37 @@ | |||
1 | 1 | ||
2 | #ifndef OpieToothParser_H | 2 | #ifndef OpieToothParser_H |
3 | #define OpieToothParser_H | 3 | #define OpieToothParser_H |
4 | 4 | ||
5 | #include <services.h> | 5 | #include <services.h> |
6 | 6 | ||
7 | namespace OpieTooth { | 7 | namespace OpieTooth { |
8 | class Parser{ | 8 | class Parser{ |
9 | public: | 9 | public: |
10 | Parser(const QString& output ); | 10 | Parser(const QString& output ); |
11 | ~Parser() {}; | 11 | ~Parser() {}; |
12 | void setText(const QString& output ); | 12 | void setText(const QString& output ); |
13 | Services::ValueList services()const; | 13 | Services::ValueList services()const; |
14 | private: | 14 | private: |
15 | Services::ValueList m_list; | 15 | Services::ValueList m_list; |
16 | Services m_item; | 16 | Services m_item; |
17 | void parse( const QString& ); | 17 | void parse( const QString& ); |
18 | bool parseName(const QString& ); | 18 | bool parseName(const QString& ); |
19 | bool parseRecHandle( const QString& ); | 19 | bool parseRecHandle( const QString& ); |
20 | bool parseClassId( const QString& ); | 20 | bool parseClassId( const QString& ); |
21 | bool parseProtocol( const QString& id ); | 21 | bool parseProtocol( const QString& id ); |
22 | bool parseProfile( const QString& ) ; | 22 | bool parseProfile( const QString& ) ; |
23 | bool m_complete:1; | 23 | bool m_complete:1; |
24 | bool m_ok; | 24 | bool m_ok; |
25 | bool m_classOver:1; | 25 | bool m_classOver:1; |
26 | bool m_profOver:1; | ||
26 | bool m_protocolOver:1; | 27 | bool m_protocolOver:1; |
27 | bool m_protocolAdded:1; | 28 | bool m_protocolAdded:1; |
28 | QString m_protName; | 29 | QString m_protName; |
29 | int m_protId; | 30 | int m_protId; |
31 | QString m_profName; | ||
32 | int m_profId; | ||
30 | }; | 33 | }; |
31 | }; | 34 | }; |
32 | 35 | ||
33 | 36 | ||
34 | #endif | 37 | #endif |
diff --git a/noncore/net/opietooth/lib/services.cc b/noncore/net/opietooth/lib/services.cc index d91e4a1..93ee70a 100644 --- a/noncore/net/opietooth/lib/services.cc +++ b/noncore/net/opietooth/lib/services.cc | |||
@@ -12,157 +12,171 @@ Services::ProfileDescriptor::ProfileDescriptor(const QString &id, int idInt, int | |||
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 | 108 | (*this) = service; | |
109 | } | 109 | } |
110 | Services::~Services(){ | 110 | Services::~Services(){ |
111 | 111 | ||
112 | } | 112 | } |
113 | Services &Services::operator=( const Services& ){ | 113 | Services &Services::operator=( const Services& ser){ |
114 | m_name = ser.m_name; | ||
115 | m_recHandle = ser.m_recHandle; | ||
116 | m_classList = ser.m_classList; | ||
117 | m_classId = ser.m_classId; | ||
118 | m_protocols = ser.m_protocols; | ||
119 | m_profiles = ser.m_profiles; | ||
114 | return *this; | 120 | return *this; |
115 | } | 121 | } |
116 | bool operator==( const Services&, | 122 | bool operator==( const Services& one, |
117 | const Services& ){ | 123 | const Services& two){ |
124 | if ( ( one.recHandle() == two.recHandle() ) && | ||
125 | ( one.classIdListInt() == two.classIdListInt() ) && | ||
126 | ( one.serviceName() == two.serviceName() ) && | ||
127 | ( one.classIdList() == two.classIdList() ) && | ||
128 | ( one.protocolDescriptorList() == two.protocolDescriptorList() ) && | ||
129 | ( one.profileDescriptor() == two.profileDescriptor() ) ) | ||
130 | return true; | ||
118 | return false; | 131 | return false; |
119 | } | 132 | } |
120 | QString Services::serviceName() const{ | 133 | QString Services::serviceName() const{ |
121 | 134 | return m_name; | |
122 | } | 135 | } |
123 | void Services::setServiceName( const QString& service ){ | 136 | void Services::setServiceName( const QString& service ){ |
124 | 137 | m_name = service; | |
125 | } | 138 | } |
126 | int Services::recHandle() const{ | 139 | int Services::recHandle() const{ |
127 | 140 | return m_recHandle; | |
128 | } | 141 | } |
129 | void Services::setRecHandle( int ){ | 142 | void Services::setRecHandle( int handle){ |
130 | 143 | m_recHandle = handle; | |
131 | } | 144 | } |
132 | QString Services::classIdList() const{ | 145 | QString Services::classIdList() const{ |
133 | 146 | return m_classList; | |
134 | } | 147 | } |
135 | void Services::setClassIdList( const QString& ){ | 148 | void Services::setClassIdList( const QString& str){ |
136 | 149 | m_classList = str; | |
137 | } | 150 | } |
138 | int Services::classIdListInt() const{ | 151 | int Services::classIdListInt() const{ |
139 | 152 | return m_classId; | |
140 | } | 153 | } |
141 | void Services::setClassIdList(int ){ | 154 | void Services::setClassIdList(int id){ |
142 | 155 | m_classId = id; | |
143 | } | 156 | } |
144 | void Services::insertProtocolDescriptor( const ProtocolDescriptor& ){ | 157 | void Services::insertProtocolDescriptor( const ProtocolDescriptor& prot){ |
145 | 158 | m_protocols.append( prot ); | |
146 | } | 159 | } |
147 | void Services::clearProtocolDescriptorList(){ | 160 | void Services::clearProtocolDescriptorList(){ |
148 | 161 | m_protocols.clear(); | |
149 | } | 162 | } |
150 | void Services::removeProtocolDescriptor( const ProtocolDescriptor& ){ | 163 | void Services::removeProtocolDescriptor( const ProtocolDescriptor& prot){ |
151 | 164 | m_protocols.remove( prot ); | |
152 | } | 165 | } |
153 | Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{ | 166 | Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{ |
154 | 167 | return m_protocols; | |
155 | } | 168 | } |
156 | 169 | ||
157 | void Services::insertProfileDescriptor( const ProfileDescriptor& ){ | ||
158 | 170 | ||
171 | void Services::insertProfileDescriptor( const ProfileDescriptor& prof){ | ||
172 | m_profiles.append( prof ); | ||
159 | } | 173 | } |
160 | void Services::clearProfileDescriptorList(){ | 174 | void Services::clearProfileDescriptorList(){ |
161 | 175 | m_profiles.clear(); | |
162 | } | 176 | } |
163 | void Services::removeProfileDescriptor( const ProfileDescriptor& ){ | 177 | void Services::removeProfileDescriptor( const ProfileDescriptor& prof){ |
164 | 178 | m_profiles.remove(prof ); | |
165 | } | 179 | } |
166 | Services::ProfileDescriptor::ValueList Services::profileDescriptor() const{ | 180 | Services::ProfileDescriptor::ValueList Services::profileDescriptor() const{ |
167 | 181 | return m_profiles; | |
168 | } | 182 | } |
diff --git a/noncore/net/opietooth/lib/services.h b/noncore/net/opietooth/lib/services.h index 65de049..881d383 100644 --- a/noncore/net/opietooth/lib/services.h +++ b/noncore/net/opietooth/lib/services.h | |||
@@ -1,138 +1,143 @@ | |||
1 | 1 | ||
2 | #ifndef OpieToothServices_H | 2 | #ifndef OpieToothServices_H |
3 | #define OpieToothServices_H | 3 | #define OpieToothServices_H |
4 | 4 | ||
5 | #include <qvaluelist.h> | 5 | #include <qvaluelist.h> |
6 | 6 | ||
7 | namespace OpieTooth { | 7 | namespace OpieTooth { |
8 | /** | 8 | /** |
9 | * Services lets shows you all available services | 9 | * Services lets shows you all available services |
10 | * on a remote device | 10 | * on a remote device |
11 | */ | 11 | */ |
12 | class Services { | 12 | class Services { |
13 | 13 | ||
14 | /** The profile descriptor | 14 | /** The profile descriptor |
15 | * | 15 | * |
16 | */ | 16 | */ |
17 | class ProfileDescriptor{ | 17 | class ProfileDescriptor{ |
18 | public: | 18 | public: |
19 | /** typedef */ | 19 | /** typedef */ |
20 | typedef QValueList<ProfileDescriptor> ValueList; | 20 | typedef QValueList<ProfileDescriptor> ValueList; |
21 | /** c'tor for QValueList */ | 21 | /** c'tor for QValueList */ |
22 | ProfileDescriptor(); | 22 | ProfileDescriptor(); |
23 | /** | 23 | /** |
24 | * c'tor | 24 | * c'tor |
25 | * @param id The id or name ("Lan Access Using PPP") | 25 | * @param id The id or name ("Lan Access Using PPP") |
26 | * @param idInt The id as uint ( 0x1102 ) | 26 | * @param idInt The id as uint ( 0x1102 ) |
27 | * @param version Version of the Profile ( 1 ) | 27 | * @param version Version of the Profile ( 1 ) |
28 | */ | 28 | */ |
29 | ProfileDescriptor(const QString &id, int idInt, int version ); | 29 | ProfileDescriptor(const QString &id, int idInt, int version ); |
30 | /** | 30 | /** |
31 | * copy c'tor | 31 | * copy c'tor |
32 | */ | 32 | */ |
33 | ProfileDescriptor(const ProfileDescriptor& ); | 33 | ProfileDescriptor(const ProfileDescriptor& ); |
34 | /** | 34 | /** |
35 | * returns the id | 35 | * returns the id |
36 | */ | 36 | */ |
37 | QString id()const; | 37 | QString id()const; |
38 | /** | 38 | /** |
39 | * sets the id | 39 | * sets the id |
40 | */ | 40 | */ |
41 | void setId(const QString& id); | 41 | void setId(const QString& id); |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * sets the int id | 44 | * sets the int id |
45 | */ | 45 | */ |
46 | void setId(int ); | 46 | void setId(int ); |
47 | /** | 47 | /** |
48 | * reutns the id as int | 48 | * reutns the id as int |
49 | */ | 49 | */ |
50 | int idInt()const; | 50 | int idInt()const; |
51 | /** | 51 | /** |
52 | * returns the version | 52 | * returns the version |
53 | */ | 53 | */ |
54 | int version()const; | 54 | int version()const; |
55 | /** | 55 | /** |
56 | * sets the Version | 56 | * sets the Version |
57 | */ | 57 | */ |
58 | void setVersion(int version ); | 58 | void setVersion(int version ); |
59 | /** | 59 | /** |
60 | * copy operator | 60 | * copy operator |
61 | */ | 61 | */ |
62 | ProfileDescriptor &operator=( const ProfileDescriptor& ); | 62 | ProfileDescriptor &operator=( const ProfileDescriptor& ); |
63 | /** | 63 | /** |
64 | * operator== | 64 | * operator== |
65 | */ | 65 | */ |
66 | friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& ); | 66 | // friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& ); |
67 | private: | 67 | private: |
68 | QString m_id; | 68 | QString m_id; |
69 | int m_idInt; | 69 | int m_idInt; |
70 | int m_version; | 70 | int m_version; |
71 | }; | 71 | }; |
72 | /** | 72 | /** |
73 | * Protocol Descriptor | 73 | * Protocol Descriptor |
74 | */ | 74 | */ |
75 | class ProtocolDescriptor { | 75 | class ProtocolDescriptor { |
76 | public: | 76 | public: |
77 | typedef QValueList<ProtocolDescriptor> ValueList; | 77 | typedef QValueList<ProtocolDescriptor> ValueList; |
78 | /** | 78 | /** |
79 | * c'tor | 79 | * c'tor |
80 | */ | 80 | */ |
81 | ProtocolDescriptor(); | 81 | ProtocolDescriptor(); |
82 | /** | 82 | /** |
83 | * name | 83 | * name |
84 | * number | 84 | * number |
85 | * channel/port | 85 | * channel/port |
86 | */ | 86 | */ |
87 | ProtocolDescriptor(const QString&, int, int port = -1 ); // Q_UINT8 ? | 87 | ProtocolDescriptor(const QString&, int, int port = -1 ); // Q_UINT8 ? |
88 | ProtocolDescriptor(const ProtocolDescriptor& ); | 88 | ProtocolDescriptor(const ProtocolDescriptor& ); |
89 | ~ProtocolDescriptor(); | 89 | ~ProtocolDescriptor(); |
90 | QString name()const; | 90 | QString name()const; |
91 | void setName(const QString& ); | 91 | void setName(const QString& ); |
92 | int id()const; | 92 | int id()const; |
93 | void setId(int ); | 93 | void setId(int ); |
94 | int port()const; | 94 | int port()const; |
95 | void setPort(int ); | 95 | void setPort(int ); |
96 | ProtocolDescriptor &operator=( const ProtocolDescriptor& ); | 96 | ProtocolDescriptor &operator=( const ProtocolDescriptor& ); |
97 | friend bool operator==( const ProtocolDescriptor&, | 97 | //friend bool operator==( const ProtocolDescriptor&, |
98 | const ProtocolDescriptor& ); | 98 | // const ProtocolDescriptor& ); |
99 | private: | 99 | private: |
100 | QString m_name; | 100 | QString m_name; |
101 | int m_number; | 101 | int m_number; |
102 | int m_channel; | 102 | int m_channel; |
103 | }; | 103 | }; |
104 | 104 | ||
105 | public: | 105 | public: |
106 | typedef QValueList<Services> ValueList; | 106 | typedef QValueList<Services> ValueList; |
107 | Services(); | 107 | Services(); |
108 | Services(const Services& service ); | 108 | Services(const Services& service ); |
109 | ~Services(); | 109 | ~Services(); |
110 | 110 | ||
111 | Services &operator=( const Services& ); | 111 | Services &operator=( const Services& ); |
112 | friend bool operator==(const Services&, const Services& ); | 112 | friend bool operator==(const Services&, const Services& ); |
113 | QString serviceName()const; | 113 | QString serviceName()const; |
114 | void setServiceName( const QString& service ); | 114 | void setServiceName( const QString& service ); |
115 | 115 | ||
116 | int recHandle()const; | 116 | int recHandle()const; |
117 | void setRecHandle( int ); | 117 | void setRecHandle( int ); |
118 | 118 | ||
119 | QString classIdList()const; | 119 | QString classIdList()const; |
120 | void setClassIdList( const QString& ); | 120 | void setClassIdList( const QString& ); |
121 | int classIdListInt()const; | 121 | int classIdListInt()const; |
122 | void setClassIdList(int ); | 122 | void setClassIdList(int ); |
123 | 123 | ||
124 | void insertProtocolDescriptor(const ProtocolDescriptor& ); | 124 | void insertProtocolDescriptor(const ProtocolDescriptor& ); |
125 | void clearProtocolDescriptorList(); | 125 | void clearProtocolDescriptorList(); |
126 | void removeProtocolDescriptor( const ProtocolDescriptor& ); | 126 | void removeProtocolDescriptor( const ProtocolDescriptor& ); |
127 | ProtocolDescriptor::ValueList protocolDescriptorList()const; | 127 | ProtocolDescriptor::ValueList protocolDescriptorList()const; |
128 | 128 | ||
129 | void insertProfileDescriptor( const ProfileDescriptor& ); | 129 | void insertProfileDescriptor( const ProfileDescriptor& ); |
130 | void clearProfileDescriptorList(); | 130 | void clearProfileDescriptorList(); |
131 | void removeProfileDescriptor(const ProfileDescriptor& ); | 131 | void removeProfileDescriptor(const ProfileDescriptor& ); |
132 | ProfileDescriptor::ValueList profileDescriptor()const; | 132 | ProfileDescriptor::ValueList profileDescriptor()const; |
133 | 133 | ||
134 | 134 | private: | |
135 | 135 | QString m_name; | |
136 | int m_recHandle; | ||
137 | QString m_classList; | ||
138 | int m_classId; | ||
139 | QValueList<ProfileDescriptor> m_profiles; | ||
140 | QValueList<ProtocolDescriptor> m_protocols; | ||
136 | }; | 141 | }; |
137 | }; | 142 | }; |
138 | #endif | 143 | #endif |