summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/device.cc54
-rw-r--r--noncore/net/opietooth/lib/device.h1
-rw-r--r--noncore/net/opietooth/lib/lib.pro4
-rw-r--r--noncore/net/opietooth/lib/manager.h3
-rw-r--r--noncore/net/opietooth/lib/remotedevice.cc48
-rw-r--r--noncore/net/opietooth/lib/remotedevice.h6
-rw-r--r--noncore/net/opietooth/lib/services.cc168
-rw-r--r--noncore/net/opietooth/lib/services.h18
8 files changed, 286 insertions, 16 deletions
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index 468f191..e3d7f3b 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -7,8 +7,24 @@
using namespace OpieTooth;
+namespace {
+ int parsePid( const QCString& par ){
+ int id=0;
+ QString string( par );
+ QStringList list = QStringList::split( '\n', string );
+ for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
+ if( !(*it).startsWith("CSR") ){
+ id = (*it).toInt();
+ break;
+ }
+ }
+ return id;
+ }
+}
+
Device::Device(const QString &device, const QString &mode )
: QObject(0, "device" ) {
+ qWarning("OpieTooth::Device create" );
m_hci = 0;
m_process = 0;
m_attached = false;
@@ -20,7 +36,10 @@ Device::~Device(){
detach();
}
void Device::attach(){
- if(m_process != 0 ){
+ qWarning("attaching %s %s", m_device.latin1(), m_mode.latin1() );
+ if(m_process == 0 ){
+ m_output.resize(0);
+ qWarning("new process to create" );
m_process = new KProcess();
*m_process << "hciattach";
*m_process << "-p";
@@ -32,6 +51,7 @@ void Device::attach(){
connect(m_process, SIGNAL(receivedStderr(KProcess*, char*, int ) ),
this, SLOT(slotStdErr(KProcess*,char*,int) ) );
if(!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput ) ){
+ qWarning("Could not start" );
delete m_process;
m_process = 0;
}
@@ -41,9 +61,12 @@ void Device::detach(){
delete m_hci;
delete m_process;
// kill the pid we got
- if(m_attached )
+ if(m_attached ){
//kill the pid
+ qWarning( "killing" );
kill(pid, 9);
+ }
+ qWarning("detached" );
}
bool Device::isLoaded()const{
return m_attached;
@@ -53,10 +76,15 @@ QString Device::devName()const {
};
void Device::slotExited( KProcess* proc)
{
+ qWarning("prcess exited" );
if(proc== m_process ){
if( m_process->normalExit() ){ // normal exit
int ret = m_process->exitStatus();
if( ret == 0 ){ // attached
+ qWarning("attached" );
+ qWarning("Output: %s", m_output.data() );
+ pid = parsePid( m_output );
+ qWarning("Pid = %d", pid );
// now hciconfig hci0 up ( determine hciX FIXME)
// and call hciconfig hci0 up
// FIXME hardcoded to hci0 now :(
@@ -65,6 +93,11 @@ void Device::slotExited( KProcess* proc)
*m_hci << "hci0 up";
connect(m_hci, SIGNAL( processExited(KProcess*) ),
this, SLOT( slotExited(KProcess* ) ) );
+ if(!m_hci->start() ){
+ qWarning("could not start" );
+ m_attached = false;
+ emit device("hci0", false );
+ }
}else{
m_attached = false;
emit device("hci0", false );
@@ -74,11 +107,16 @@ void Device::slotExited( KProcess* proc)
delete m_process;
m_process = 0;
}else if(proc== m_hci ){
+ qWarning("M HCI exited" );
if( m_hci->normalExit() ){
- int ret = m_hci->normalExit();
+ qWarning("normal exit" );
+ int ret = m_hci->exitStatus();
if( ret == 0 ){
+ qWarning("attached really really attached" );
+ m_attached = true;
emit device("hci0", true );
}else{
+ qWarning( "failed" );
emit device("hci0", false );
m_attached = false;
}
@@ -89,16 +127,16 @@ void Device::slotExited( KProcess* proc)
}
void Device::slotStdOut(KProcess* proc, char* chars, int len)
{
+ qWarning("std out" );
if( len <1 )
return;
if(proc == m_process ){
- QCString string( chars, len+1 );
- if(string.left(3) != "CSR" ){ // it's the pid
- pid = string.toInt();
- };
+ QCString string( chars, len+1 ); // \0 == +1
+ qWarning("output: %s", string.data() );
+ m_output.append( string.data() );
}
}
void Device::slotStdErr(KProcess*, char*, int )
{
-
+ qWarning("std err" );
}
diff --git a/noncore/net/opietooth/lib/device.h b/noncore/net/opietooth/lib/device.h
index 010db40..8498b14 100644
--- a/noncore/net/opietooth/lib/device.h
+++ b/noncore/net/opietooth/lib/device.h
@@ -78,6 +78,7 @@ namespace OpieTooth {
QString m_devId;
QString m_mode;
pid_t pid;
+ QCString m_output;
};
};
diff --git a/noncore/net/opietooth/lib/lib.pro b/noncore/net/opietooth/lib/lib.pro
index 7cededf..a70c7ab 100644
--- a/noncore/net/opietooth/lib/lib.pro
+++ b/noncore/net/opietooth/lib/lib.pro
@@ -1,7 +1,7 @@
TEMPLATE = lib
CONFIG += qte warn_on release
-HEADERS = kprocctrl.h kprocess.h device.h
-SOURCES = kprocctrl.cpp kprocess.cpp device.cc
+HEADERS = kprocctrl.h kprocess.h device.h manager.h remotedevice.h services.h
+SOURCES = kprocctrl.cpp kprocess.cpp device.cc manager.cc remotedevice.cc services.cc
TARGET = opietooth
INCLUDEPATH += $(OPIEDIR)/include
DESTDIR = $(QTDIR)/lib$(PROJMAK)
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h
index 5586680..6c5e27f 100644
--- a/noncore/net/opietooth/lib/manager.h
+++ b/noncore/net/opietooth/lib/manager.h
@@ -6,6 +6,9 @@
#include <qstring.h>
#include <qvaluelist.h>
+#include "remotedevice.h"
+#include "services.h"
+
namespace OpieTooth {
class Device;
/** Manager manages a blueZ device (hci0 for example)
diff --git a/noncore/net/opietooth/lib/remotedevice.cc b/noncore/net/opietooth/lib/remotedevice.cc
new file mode 100644
index 0000000..0045904
--- a/dev/null
+++ b/noncore/net/opietooth/lib/remotedevice.cc
@@ -0,0 +1,48 @@
+
+#include "remotedevice.h"
+
+using namespace OpieTooth;
+
+bool operator==(const RemoteDevices& rem1, const RemoteDevices& rem2){
+ if( ( rem1.mac() == rem2.mac() ) && (rem1.name() == rem2.name() ) )
+ return true;
+
+ return false;
+}
+
+RemoteDevices::RemoteDevices(){
+
+}
+RemoteDevices::RemoteDevices(const RemoteDevices& ole ){
+ (*this) = ole;
+}
+RemoteDevices::RemoteDevices(const QString &mac, const QString& name ){
+ m_mac = mac;
+ m_name = name;
+}
+RemoteDevices::~RemoteDevices(){
+
+}
+bool RemoteDevices::isEmpty() const {
+ if( m_name.isEmpty() && m_mac.isEmpty() )
+ return true;
+ return false;
+};
+RemoteDevices& RemoteDevices::operator=( const RemoteDevices& rem1){
+ m_name = rem1.m_name;
+ m_mac = rem1.m_mac;
+ return *this;
+
+}
+QString RemoteDevices::mac() const {
+ return m_mac;
+}
+void RemoteDevices::setMac( const QString& mac ){
+ m_mac = mac;
+}
+QString RemoteDevices::name() const{
+ return m_name;
+}
+void RemoteDevices::setName( const QString& name ){
+ m_name = name;
+}
diff --git a/noncore/net/opietooth/lib/remotedevice.h b/noncore/net/opietooth/lib/remotedevice.h
index 8e5baa5..96a27de 100644
--- a/noncore/net/opietooth/lib/remotedevice.h
+++ b/noncore/net/opietooth/lib/remotedevice.h
@@ -13,11 +13,15 @@ namespace OpieTooth{
RemoteDevices(const QString &mac, const QString &name );
~RemoteDevices();
friend bool operator==(const RemoteDevices&, const RemoteDevices&);
- RemoteDevies &operator=(const RemoteDevices& );
+ RemoteDevices &operator=(const RemoteDevices& );
+ bool isEmpty()const;
QString mac()const;
void setMac(const QString& mac );
QString name()const;
void setName( const QString& name );
+ private:
+ QString m_name;
+ QString m_mac;
};
};
diff --git a/noncore/net/opietooth/lib/services.cc b/noncore/net/opietooth/lib/services.cc
new file mode 100644
index 0000000..75c1bd6
--- a/dev/null
+++ b/noncore/net/opietooth/lib/services.cc
@@ -0,0 +1,168 @@
+
+#include "services.h"
+
+using namespace OpieTooth;
+
+
+Services::ProfileDescriptor::ProfileDescriptor(){
+
+}
+Services::ProfileDescriptor::ProfileDescriptor(const QString &id, uint idInt, uint version ){
+ m_id = id;
+ m_idInt = idInt;
+ m_version = version;
+}
+Services::ProfileDescriptor::ProfileDescriptor( const ProfileDescriptor& rem){
+ (*this) = rem;
+}
+QString Services::ProfileDescriptor::id() const {
+ return m_id;
+}
+void Services::ProfileDescriptor::setId( const QString& id ){
+ m_id = id;
+}
+void Services::ProfileDescriptor::setId(uint id ){
+ m_idInt = id;
+}
+uint Services::ProfileDescriptor::idInt()const{
+ return m_idInt;
+}
+uint Services::ProfileDescriptor::version() const{
+ return m_version;
+}
+void Services::ProfileDescriptor::setVersion(uint version){
+ m_version = version;
+}
+Services::ProfileDescriptor& Services::ProfileDescriptor::operator=( const Services::ProfileDescriptor& prof){
+ m_id = prof.m_id;
+ m_idInt = prof.m_idInt;
+ m_version = prof.m_version;
+ return *this;
+}
+bool operator==(const Services::ProfileDescriptor& first,
+ const Services::ProfileDescriptor& second ){
+
+ if( (first.id() == second.id() ) &&
+ (first.version() == second.version() ) &&
+ (first.idInt() == second.idInt() ) )
+ return true;
+ return false;
+}
+
+Services::ProtocolDescriptor::ProtocolDescriptor(){
+ m_number = 0;
+ m_channel = 0;
+}
+Services::ProtocolDescriptor::ProtocolDescriptor(const QString& name,
+ uint number,
+ uint channel){
+ m_name = name;
+ m_number = number;
+ m_channel = channel;
+}
+Services::ProtocolDescriptor::ProtocolDescriptor( const ProtocolDescriptor& ole ){
+ (*this) = ole;
+}
+Services::ProtocolDescriptor::~ProtocolDescriptor(){
+
+}
+QString Services::ProtocolDescriptor::name() const{
+ return m_name;
+}
+void Services::ProtocolDescriptor::setName(const QString& name ){
+ m_name = name;
+}
+uint Services::ProtocolDescriptor::id()const {
+ return m_number;
+}
+void Services::ProtocolDescriptor::setId( uint id ){
+ m_number = id;
+}
+uint Services::ProtocolDescriptor::port()const {
+ return m_channel;
+}
+void Services::ProtocolDescriptor::setPort( uint port ){
+ m_channel = port;
+}
+Services::ProtocolDescriptor &Services::ProtocolDescriptor::operator=( const Services::ProtocolDescriptor& desc ){
+ m_name = desc.m_name;
+ m_channel = desc.m_channel;
+ m_number = desc.m_number;
+ return *this;
+}
+bool operator==( const Services::ProtocolDescriptor &first,
+ const Services::ProtocolDescriptor &second ){
+ if( ( first.name() == second.name() ) &&
+ ( first.id() == second.id() ) &&
+ ( first.port() == second.port() ) )
+ return true;
+
+ return false;
+
+}
+
+Services::Services(){
+
+}
+Services::Services(const Services& service ){
+
+}
+Services::~Services(){
+
+}
+Services &Services::operator=( const Services& ){
+ return *this;
+}
+bool operator==( const Services&,
+ const Services& ){
+ return false;
+}
+QString Services::serviceName() const{
+
+}
+void Services::setServiceName( const QString& service ){
+
+}
+int Services::recHandle() const{
+
+}
+void Services::setRecHandle( int ){
+
+}
+QString Services::classIdList() const{
+
+}
+void Services::setClassIdList( const QString& ){
+
+}
+int Services::classIdListInt() const{
+
+}
+void Services::setClassIdList(int ){
+
+}
+void Services::insertProtocolDescriptor( const ProtocolDescriptor& ){
+
+}
+void Services::clearProtocolDescriptorList(){
+
+}
+void Services::removeProtocolDescriptor( const ProtocolDescriptor& ){
+
+}
+Services::ProtocolDescriptor::ValueList Services::protocolDescriptorList()const{
+
+}
+
+void Services::insertProfileDescriptor( const ProfileDescriptor& ){
+
+}
+void Services::clearProfileDescriptorList(){
+
+}
+void Services::removeProfileDescriptor( const ProfileDescriptor& ){
+
+}
+Services::ProfileDescriptor::ValueList Services::profileDescriptor() const{
+
+}
diff --git a/noncore/net/opietooth/lib/services.h b/noncore/net/opietooth/lib/services.h
index 4a4dea8..8e9378a 100644
--- a/noncore/net/opietooth/lib/services.h
+++ b/noncore/net/opietooth/lib/services.h
@@ -14,7 +14,7 @@ namespace OpieTooth {
/** The profile descriptor
*
*/
- class ProfileDesriptor{
+ class ProfileDescriptor{
public:
/** typedef */
typedef QValueList<ProfileDescriptor> ValueList;
@@ -59,11 +59,15 @@ namespace OpieTooth {
/**
* copy operator
*/
- ProfileDescriptor &operator=( const ProfileDescriptor );
+ ProfileDescriptor &operator=( const ProfileDescriptor& );
/**
* operator==
*/
friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& );
+ private:
+ QString m_id;
+ uint m_idInt;
+ uint m_version;
};
/**
* Protocol Descriptor
@@ -81,7 +85,7 @@ namespace OpieTooth {
* channel/port
*/
ProtocolDescriptor(const QString&, uint, uint channel ); // Q_UINT8 ?
- ProtocolDescriptot(const ProtocolDescriptor& );
+ ProtocolDescriptor(const ProtocolDescriptor& );
~ProtocolDescriptor();
QString name()const;
void setName(const QString& );
@@ -90,8 +94,12 @@ namespace OpieTooth {
uint port()const;
void setPort(uint );
ProtocolDescriptor &operator=( const ProtocolDescriptor& );
- friend bool operator==( const ProtocolDescription&,
- const ProtocolDescription& );
+ friend bool operator==( const ProtocolDescriptor&,
+ const ProtocolDescriptor& );
+ private:
+ QString m_name;
+ uint m_number;
+ uint m_channel;
};
public: