author | zecke <zecke> | 2002-06-20 22:23:44 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-20 22:23:44 (UTC) |
commit | 7b4a1dfd56b64e588d3fe6c75a51490df13e9797 (patch) (unidiff) | |
tree | 43db3e094004ad478c43d93ddeafed044534035e | |
parent | c2eb66bc5c5ac4225edff8b369026bd208f8c148 (diff) | |
download | opie-7b4a1dfd56b64e588d3fe6c75a51490df13e9797.zip opie-7b4a1dfd56b64e588d3fe6c75a51490df13e9797.tar.gz opie-7b4a1dfd56b64e588d3fe6c75a51490df13e9797.tar.bz2 |
German politicians suck
-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,83 +1,87 @@ | |||
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){ |
@@ -106,29 +110,29 @@ void Manager::searchServices( const QString& remDevice ){ | |||
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 | { |
@@ -148,24 +152,26 @@ void Manager::slotSDPExited( OProcess* proc) | |||
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() ); |
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,51 +1,84 @@ | |||
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(); |
@@ -58,56 +91,83 @@ bool Parser::parseRecHandle( const QString& str) { | |||
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 | |||
@@ -14,21 +14,24 @@ namespace OpieTooth { | |||
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 | |||
@@ -96,73 +96,87 @@ bool operator==( const Services::ProtocolDescriptor &first, | |||
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 | |||
@@ -54,25 +54,25 @@ namespace OpieTooth { | |||
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 | /** |
@@ -85,26 +85,26 @@ namespace OpieTooth { | |||
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 | ||
@@ -122,17 +122,22 @@ namespace OpieTooth { | |||
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 |