summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-03 20:14:29 (UTC)
committer zecke <zecke>2002-06-03 20:14:29 (UTC)
commit7080f9f10443d7a8e61d01b5a1c0e9c972f6baca (patch) (side-by-side diff)
tree36f8b2ab579028bba027c0432da2ae41f09b9b4d
parent8d5f42d770abca69d490774f4b1fc8284e7a86be (diff)
downloadopie-7080f9f10443d7a8e61d01b5a1c0e9c972f6baca.zip
opie-7080f9f10443d7a8e61d01b5a1c0e9c972f6baca.tar.gz
opie-7080f9f10443d7a8e61d01b5a1c0e9c972f6baca.tar.bz2
attaching and detaching is now working
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
@@ -9,4 +9,20 @@ 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;
@@ -22,3 +38,6 @@ Device::~Device(){
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();
@@ -34,2 +53,3 @@ void Device::attach(){
if(!m_process->start(KProcess::NotifyOnExit, KProcess::AllOutput ) ){
+ qWarning("Could not start" );
delete m_process;
@@ -43,5 +63,8 @@ void Device::detach(){
// kill the pid we got
- if(m_attached )
+ if(m_attached ){
//kill the pid
+ qWarning( "killing" );
kill(pid, 9);
+ }
+ qWarning("detached" );
}
@@ -55,2 +78,3 @@ void Device::slotExited( KProcess* proc)
{
+ qWarning("prcess exited" );
if(proc== m_process ){
@@ -59,2 +83,6 @@ void Device::slotExited( KProcess* proc)
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)
@@ -67,2 +95,7 @@ void Device::slotExited( KProcess* proc)
this, SLOT( slotExited(KProcess* ) ) );
+ if(!m_hci->start() ){
+ qWarning("could not start" );
+ m_attached = false;
+ emit device("hci0", false );
+ }
}else{
@@ -76,7 +109,12 @@ void Device::slotExited( KProcess* proc)
}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 );
@@ -91,2 +129,3 @@ void Device::slotStdOut(KProcess* proc, char* chars, int len)
{
+ qWarning("std out" );
if( len <1 )
@@ -94,6 +133,5 @@ void Device::slotStdOut(KProcess* proc, char* chars, int len)
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() );
}
@@ -102,3 +140,3 @@ 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
@@ -80,2 +80,3 @@ namespace OpieTooth {
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
@@ -2,4 +2,4 @@ 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
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
@@ -8,2 +8,5 @@
+#include "remotedevice.h"
+#include "services.h"
+
namespace OpieTooth {
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
@@ -15,3 +15,4 @@ namespace OpieTooth{
friend bool operator==(const RemoteDevices&, const RemoteDevices&);
- RemoteDevies &operator=(const RemoteDevices& );
+ RemoteDevices &operator=(const RemoteDevices& );
+ bool isEmpty()const;
QString mac()const;
@@ -20,2 +21,5 @@ namespace OpieTooth{
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
@@ -16,3 +16,3 @@ namespace OpieTooth {
*/
- class ProfileDesriptor{
+ class ProfileDescriptor{
public:
@@ -61,3 +61,3 @@ namespace OpieTooth {
*/
- ProfileDescriptor &operator=( const ProfileDescriptor );
+ ProfileDescriptor &operator=( const ProfileDescriptor& );
/**
@@ -66,2 +66,6 @@ namespace OpieTooth {
friend bool operator==(const ProfileDescriptor&, const ProfileDescriptor& );
+ private:
+ QString m_id;
+ uint m_idInt;
+ uint m_version;
};
@@ -83,3 +87,3 @@ namespace OpieTooth {
ProtocolDescriptor(const QString&, uint, uint channel ); // Q_UINT8 ?
- ProtocolDescriptot(const ProtocolDescriptor& );
+ ProtocolDescriptor(const ProtocolDescriptor& );
~ProtocolDescriptor();
@@ -92,4 +96,8 @@ namespace OpieTooth {
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;
};