summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc22
-rw-r--r--noncore/net/opietooth/lib/parser.cc90
-rw-r--r--noncore/net/opietooth/lib/parser.h3
-rw-r--r--noncore/net/opietooth/lib/services.cc66
-rw-r--r--noncore/net/opietooth/lib/services.h15
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,3 +1,6 @@
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"
@@ -15,3 +18,3 @@ Manager::Manager( const QString& dev )
15} 18}
16Manager::Manager( Device* dev ) 19Manager::Manager( Device* /*dev*/ )
17 : QObject() 20 : QObject()
@@ -34,3 +37,3 @@ void Manager::setDevice( const QString& dev ){
34} 37}
35void Manager::setDevice( Device* dev ){ 38void Manager::setDevice( Device* /*dev*/ ){
36 39
@@ -49,3 +52,4 @@ void Manager::isAvailable( const QString& device ){
49} 52}
50void Manager::isAvailable( Device* dev ){ 53
54void Manager::isAvailable( Device* /*dev*/ ){
51 55
@@ -70,3 +74,3 @@ void Manager::searchDevices( const QString& device ){
70 74
71void Manager::searchDevices(Device* d ){ 75void Manager::searchDevices(Device* /*d*/ ){
72 76
@@ -117,7 +121,7 @@ void Manager::searchServices( const RemoteDevice& dev){
117} 121}
118QString Manager::toDevice( const QString& mac ){ 122QString Manager::toDevice( const QString& /*mac*/ ){
119 123 return QString::null;
120} 124}
121QString Manager::toMac( const QString &device ){ 125QString Manager::toMac( const QString &/*device*/ ){
122 126 return QString::null;
123} 127}
@@ -159,2 +163,4 @@ 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;
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
@@ -7,2 +7,30 @@ using namespace OpieTooth;
7 7
8namespace {
9
10
11 // "Test Foo Bar" (0x3456)
12 // @param ret Test Foo Bar
13 // @eturn 13398
14 // tactic find " (
15int 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
8Parser::Parser(const QString& output ) { 36Parser::Parser(const QString& output ) {
@@ -30,2 +58,3 @@ void Parser::parse( const QString& string) {
30 m_item = serv; 58 m_item = serv;
59 m_complete = true;
31 continue; 60 continue;
@@ -39,2 +68,6 @@ void Parser::parse( const QString& string) {
39 } 68 }
69 // missed the last one
70 if (m_complete) {
71 m_list.append(m_item );
72 }
40} 73}
@@ -69,15 +102,14 @@ bool Parser::parseClassId( const QString& str) {
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;
@@ -93,4 +125,5 @@ bool Parser::parseProtocol( const QString& str) {
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
@@ -100,2 +133,5 @@ bool Parser::parseProtocol( const QString& str) {
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;
@@ -104,2 +140,9 @@ bool Parser::parseProtocol( const QString& str) {
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;
@@ -110,3 +153,20 @@ bool Parser::parseProtocol( const QString& str) {
110} 153}
111bool Parser::parseProfile( const QString& ) { 154bool 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;
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
@@ -25,2 +25,3 @@ namespace OpieTooth {
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;
@@ -29,2 +30,4 @@ namespace OpieTooth {
29 int m_protId; 30 int m_protId;
31 QString m_profName;
32 int m_profId;
30 }; 33 };
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
@@ -107,3 +107,3 @@ Services::Services(){
107Services::Services(const Services& service ){ 107Services::Services(const Services& service ){
108 108 (*this) = service;
109} 109}
@@ -112,7 +112,20 @@ Services::~Services(){
112} 112}
113Services &Services::operator=( const Services& ){ 113Services &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}
116bool operator==( const Services&, 122bool 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;
@@ -120,49 +133,50 @@ bool operator==( const Services&,
120QString Services::serviceName() const{ 133QString Services::serviceName() const{
121 134 return m_name;
122} 135}
123void Services::setServiceName( const QString& service ){ 136void Services::setServiceName( const QString& service ){
124 137 m_name = service;
125} 138}
126int Services::recHandle() const{ 139int Services::recHandle() const{
127 140 return m_recHandle;
128} 141}
129void Services::setRecHandle( int ){ 142void Services::setRecHandle( int handle){
130 143 m_recHandle = handle;
131} 144}
132QString Services::classIdList() const{ 145QString Services::classIdList() const{
133 146 return m_classList;
134} 147}
135void Services::setClassIdList( const QString& ){ 148void Services::setClassIdList( const QString& str){
136 149 m_classList = str;
137} 150}
138int Services::classIdListInt() const{ 151int Services::classIdListInt() const{
139 152 return m_classId;
140} 153}
141void Services::setClassIdList(int ){ 154void Services::setClassIdList(int id){
142 155 m_classId = id;
143} 156}
144void Services::insertProtocolDescriptor( const ProtocolDescriptor& ){ 157void Services::insertProtocolDescriptor( const ProtocolDescriptor& prot){
145 158 m_protocols.append( prot );
146} 159}
147void Services::clearProtocolDescriptorList(){ 160void Services::clearProtocolDescriptorList(){
148 161 m_protocols.clear();
149} 162}
150void Services::removeProtocolDescriptor( const ProtocolDescriptor& ){ 163void Services::removeProtocolDescriptor( const ProtocolDescriptor& prot){
151 164 m_protocols.remove( prot );
152} 165}
153Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{ 166Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{
154 167 return m_protocols;
155} 168}
156 169
157void Services::insertProfileDescriptor( const ProfileDescriptor& ){
158 170
171void Services::insertProfileDescriptor( const ProfileDescriptor& prof){
172 m_profiles.append( prof );
159} 173}
160void Services::clearProfileDescriptorList(){ 174void Services::clearProfileDescriptorList(){
161 175 m_profiles.clear();
162} 176}
163void Services::removeProfileDescriptor( const ProfileDescriptor& ){ 177void Services::removeProfileDescriptor( const ProfileDescriptor& prof){
164 178 m_profiles.remove(prof );
165} 179}
166Services::ProfileDescriptor::ValueList Services::profileDescriptor() const{ 180Services::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
@@ -65,3 +65,3 @@ namespace OpieTooth {
65 */ 65 */
66 friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& ); 66// friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& );
67 private: 67 private:
@@ -96,4 +96,4 @@ namespace OpieTooth {
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:
@@ -133,4 +133,9 @@ namespace OpieTooth {
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 };