summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth
Side-by-side diff
Diffstat (limited to 'noncore/net/opietooth') (more/less context) (show 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 @@
+
+
#include <opie/oprocess.h>
+#include "parser.h"
#include "manager.h"
@@ -15,3 +18,3 @@ Manager::Manager( const QString& dev )
}
-Manager::Manager( Device* dev )
+Manager::Manager( Device* /*dev*/ )
: QObject()
@@ -34,3 +37,3 @@ void Manager::setDevice( const QString& dev ){
}
-void Manager::setDevice( Device* dev ){
+void Manager::setDevice( Device* /*dev*/ ){
@@ -49,3 +52,4 @@ void Manager::isAvailable( const QString& device ){
}
-void Manager::isAvailable( Device* dev ){
+
+void Manager::isAvailable( Device* /*dev*/ ){
@@ -70,3 +74,3 @@ void Manager::searchDevices( const QString& device ){
-void Manager::searchDevices(Device* d ){
+void Manager::searchDevices(Device* /*d*/ ){
@@ -117,7 +121,7 @@ void Manager::searchServices( const RemoteDevice& dev){
}
-QString Manager::toDevice( const QString& mac ){
-
+QString Manager::toDevice( const QString& /*mac*/ ){
+ return QString::null;
}
-QString Manager::toMac( const QString &device ){
-
+QString Manager::toMac( const QString &/*device*/ ){
+ return QString::null;
}
@@ -159,2 +163,4 @@ Services::ValueList Manager::parseSDPOutput( const QString& out ) {
Services::ValueList list;
+ Parser parser( out );
+ list = parser.services();
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;
+namespace {
+
+
+ // "Test Foo Bar" (0x3456)
+ // @param ret Test Foo Bar
+ // @eturn 13398
+ // tactic find " (
+int convert( const QString& line, QString& ret ) {
+ ret = QString::null;
+ int i = 0;
+ int pos = line.findRev("\" (");
+ if ( pos > 0 ) { // it shouldn't be at pos 0
+ ret = line.left(pos-1 ).stripWhiteSpace();
+ qWarning("ret: %s", ret.latin1() );
+ ret = ret.replace(QRegExp("[\"]"), "");
+ qWarning("ret: %s", ret.latin1() );
+ QString dummy = line.mid(pos + 4 );
+ qWarning("dummy: %s", dummy.latin1() );
+ dummy = dummy.remove( dummy.length() -1, 1 ); // remove the (
+ bool ok;
+ i = dummy.toInt(&ok, 16 );
+ }
+ return i;
+}
+
+};
+
+
Parser::Parser(const QString& output ) {
@@ -30,2 +58,3 @@ void Parser::parse( const QString& string) {
m_item = serv;
+ m_complete = true;
continue;
@@ -39,2 +68,6 @@ void Parser::parse( const QString& string) {
}
+ // missed the last one
+ if (m_complete) {
+ m_list.append(m_item );
+ }
}
@@ -69,15 +102,14 @@ bool Parser::parseClassId( const QString& str) {
m_classOver = false;
- QStringList list = QStringList::split('\n', str.stripWhiteSpace() );
-
- if ( list.count() == 2 ) {
- m_item.setClassIdList( list[0] );
- // now let's parse the number (0x1105)
- QString classId= list[1];
- int classIdInt;
- qWarning("%s", list[1].latin1() );
- classId = classId.remove(0, 3 );
- classId = classId.remove( classId.length()-1, 1 );
- qWarning("%s", classId.latin1() );
- m_item.setClassIdList( classId.toInt(&m_ok, 16 ) );
- }
+
+ // "Obex Object Push" (0x1105)
+ // find backwards the " and the from 0 to pos and the mid pos+1
+ // then stripWhiteSpace add name replace '"' with ""
+ // and then convert 0x1105 toInt()
+ QString classes;
+ int ids;
+ ids = convert( str, classes );
+ qWarning("ids %d", ids );
+ m_item.setClassIdList( classes );
+ m_item.setClassIdList( ids );
+
return true;
@@ -93,4 +125,5 @@ bool Parser::parseProtocol( const QString& str) {
- }else if (m_protocolOver && str.startsWith(" ") ) {
+ }else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100)
qWarning("double protocol filter");
+
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) {
m_protocolAdded = false;
+ { // the find function
+ m_protId = convert(str, m_protName );
+ }
return true;
@@ -104,2 +140,9 @@ bool Parser::parseProtocol( const QString& str) {
m_protocolAdded = true;
+ QString dummy = str.stripWhiteSpace();
+ int pos = dummy.findRev(':');
+ if ( pos > -1 ) {
+ int port = dummy.mid(pos+1 ).stripWhiteSpace().toInt();
+ Services::ProtocolDescriptor desc( m_protName, m_protId, port );
+ m_item.insertProtocolDescriptor( desc );
+ }
return true;
@@ -110,3 +153,20 @@ bool Parser::parseProtocol( const QString& str) {
}
-bool Parser::parseProfile( const QString& ) {
+bool Parser::parseProfile( const QString& str) {
+ if (str.startsWith("Profile Descriptor List:") ) {
+ m_profOver = true;
+ }else if ( m_profOver && str.startsWith(" ") ) {
+ m_profId = convert( str, m_profName );
+ }else if ( m_profOver && str.startsWith(" ") ) {
+ // now find
+ int pos = str.findRev(':');
+ if ( pos > 0 ) {
+ int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt();
+ qWarning("dummyInt:%d", dummy );
+ Services::ProfileDescriptor desc( m_profName, m_profId, dummy );
+ m_item.insertProfileDescriptor(desc);
+ }
+ }else
+ m_profOver = false;
+
+
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 {
bool m_classOver:1;
+ bool m_profOver:1;
bool m_protocolOver:1;
@@ -29,2 +30,4 @@ namespace OpieTooth {
int m_protId;
+ QString m_profName;
+ int m_profId;
};
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(){
Services::Services(const Services& service ){
-
+ (*this) = service;
}
@@ -112,7 +112,20 @@ Services::~Services(){
}
-Services &Services::operator=( const Services& ){
+Services &Services::operator=( const Services& ser){
+ m_name = ser.m_name;
+ m_recHandle = ser.m_recHandle;
+ m_classList = ser.m_classList;
+ m_classId = ser.m_classId;
+ m_protocols = ser.m_protocols;
+ m_profiles = ser.m_profiles;
return *this;
}
-bool operator==( const Services&,
- const Services& ){
+bool operator==( const Services& one,
+ const Services& two){
+ if ( ( one.recHandle() == two.recHandle() ) &&
+ ( one.classIdListInt() == two.classIdListInt() ) &&
+ ( one.serviceName() == two.serviceName() ) &&
+ ( one.classIdList() == two.classIdList() ) &&
+ ( one.protocolDescriptorList() == two.protocolDescriptorList() ) &&
+ ( one.profileDescriptor() == two.profileDescriptor() ) )
+ return true;
return false;
@@ -120,49 +133,50 @@ bool operator==( const Services&,
QString Services::serviceName() const{
-
+ return m_name;
}
void Services::setServiceName( const QString& service ){
-
+ m_name = service;
}
int Services::recHandle() const{
-
+ return m_recHandle;
}
-void Services::setRecHandle( int ){
-
+void Services::setRecHandle( int handle){
+ m_recHandle = handle;
}
QString Services::classIdList() const{
-
+ return m_classList;
}
-void Services::setClassIdList( const QString& ){
-
+void Services::setClassIdList( const QString& str){
+ m_classList = str;
}
int Services::classIdListInt() const{
-
+ return m_classId;
}
-void Services::setClassIdList(int ){
-
+void Services::setClassIdList(int id){
+ m_classId = id;
}
-void Services::insertProtocolDescriptor( const ProtocolDescriptor& ){
-
+void Services::insertProtocolDescriptor( const ProtocolDescriptor& prot){
+ m_protocols.append( prot );
}
void Services::clearProtocolDescriptorList(){
-
+ m_protocols.clear();
}
-void Services::removeProtocolDescriptor( const ProtocolDescriptor& ){
-
+void Services::removeProtocolDescriptor( const ProtocolDescriptor& prot){
+ m_protocols.remove( prot );
}
Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{
-
+ return m_protocols;
}
-void Services::insertProfileDescriptor( const ProfileDescriptor& ){
+void Services::insertProfileDescriptor( const ProfileDescriptor& prof){
+ m_profiles.append( prof );
}
void Services::clearProfileDescriptorList(){
-
+ m_profiles.clear();
}
-void Services::removeProfileDescriptor( const ProfileDescriptor& ){
-
+void Services::removeProfileDescriptor( const ProfileDescriptor& prof){
+ m_profiles.remove(prof );
}
Services::ProfileDescriptor::ValueList Services::profileDescriptor() const{
-
+ return m_profiles;
}
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 {
*/
- friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& );
+// friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& );
private:
@@ -96,4 +96,4 @@ namespace OpieTooth {
ProtocolDescriptor &operator=( const ProtocolDescriptor& );
- friend bool operator==( const ProtocolDescriptor&,
- const ProtocolDescriptor& );
+ //friend bool operator==( const ProtocolDescriptor&,
+ // const ProtocolDescriptor& );
private:
@@ -133,4 +133,9 @@ namespace OpieTooth {
-
-
+ private:
+ QString m_name;
+ int m_recHandle;
+ QString m_classList;
+ int m_classId;
+ QValueList<ProfileDescriptor> m_profiles;
+ QValueList<ProtocolDescriptor> m_protocols;
};