summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp2
-rw-r--r--noncore/net/opietooth/lib/device.cc11
-rw-r--r--noncore/net/opietooth/lib/lib.pro2
3 files changed, 11 insertions, 4 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index a380ac7..6e5ee82 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -63,33 +63,33 @@ namespace OpieTooth {
63 63
64 int BluezApplet::checkBluezStatus() { 64 int BluezApplet::checkBluezStatus() {
65 if (btDevice) { 65 if (btDevice) {
66 if (btDevice->isLoaded() ) { 66 if (btDevice->isLoaded() ) {
67 return 1; 67 return 1;
68 } else { 68 } else {
69 return 0; 69 return 0;
70 } 70 }
71 } else { 71 } else {
72 return 0; 72 return 0;
73 } 73 }
74 } 74 }
75 75
76 int BluezApplet::setBluezStatus(int c) { 76 int BluezApplet::setBluezStatus(int c) {
77 77
78 if (c == 1) { 78 if (c == 1) {
79 btDevice = new Device("/dev/ttySB0", "scr" ); 79 btDevice = new Device("/dev/ttySB0", "csr" );
80 // system("hciattach /dev/ttySB0 csr"); 80 // system("hciattach /dev/ttySB0 csr");
81 //system("hcid"); 81 //system("hcid");
82 } else { 82 } else {
83 if (btDevice) { 83 if (btDevice) {
84 delete btDevice; 84 delete btDevice;
85 } 85 }
86 //system("killall hciattach"); 86 //system("killall hciattach");
87 //system("killall hcid"); 87 //system("killall hcid");
88 } 88 }
89 return 0; 89 return 0;
90 } 90 }
91 91
92 int BluezApplet::checkBluezDiscoveryStatus() { 92 int BluezApplet::checkBluezDiscoveryStatus() {
93 } 93 }
94 94
95 int BluezApplet::setBluezDiscoveryStatus(int d) { 95 int BluezApplet::setBluezDiscoveryStatus(int d) {
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index 5234996..5edfc03 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -1,31 +1,32 @@
1 1
2#include <signal.h> 2#include <signal.h>
3 3
4#include <opie/oprocess.h> 4#include <opie/oprocess.h>
5 5
6#include "device.h" 6#include "device.h"
7 7
8using namespace OpieTooth; 8using namespace OpieTooth;
9 9
10namespace { 10namespace {
11 int parsePid( const QCString& par ){ 11 int parsePid( const QCString& par ){
12 int id=0; 12 int id=0;
13 QString string( par ); 13 QString string( par );
14 QStringList list = QStringList::split( '\n', string ); 14 QStringList list = QStringList::split( '\n', string );
15 for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){ 15 for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ){
16 qWarning("parsePID: %s", (*it).latin1() );
16 if( !(*it).startsWith("CSR") ){ 17 if( !(*it).startsWith("CSR") ){
17 id = (*it).toInt(); 18 id = (*it).toInt();
18 break; 19 break;
19 } 20 }
20 } 21 }
21 return id; 22 return id;
22 } 23 }
23} 24}
24 25
25Device::Device(const QString &device, const QString &mode ) 26Device::Device(const QString &device, const QString &mode )
26 : QObject(0, "device" ) { 27 : QObject(0, "device" ) {
27 qWarning("OpieTooth::Device create" ); 28 qWarning("OpieTooth::Device create" );
28 m_hci = 0; 29 m_hci = 0;
29 m_process = 0; 30 m_process = 0;
30 m_attached = false; 31 m_attached = false;
31 m_device = device; 32 m_device = device;
@@ -65,78 +66,84 @@ void Device::detach(){
65 //kill the pid 66 //kill the pid
66 qWarning( "killing" ); 67 qWarning( "killing" );
67 kill(pid, 9); 68 kill(pid, 9);
68 } 69 }
69 qWarning("detached" ); 70 qWarning("detached" );
70} 71}
71bool Device::isLoaded()const{ 72bool Device::isLoaded()const{
72 return m_attached; 73 return m_attached;
73} 74}
74QString Device::devName()const { 75QString Device::devName()const {
75 return QString::fromLatin1("hci0"); 76 return QString::fromLatin1("hci0");
76}; 77};
77void Device::slotExited( OProcess* proc) 78void Device::slotExited( OProcess* proc)
78{ 79{
79 qWarning("prcess exited" ); 80 qWarning("prcess exited" );
80 if(proc== m_process ){ 81 if(proc== m_process ){
82 qWarning("proc == m_process" );
81 if( m_process->normalExit() ){ // normal exit 83 if( m_process->normalExit() ){ // normal exit
84 qWarning("normalExit" );
82 int ret = m_process->exitStatus(); 85 int ret = m_process->exitStatus();
83 if( ret == 0 ){ // attached 86 if( ret == 0 ){ // attached
84 qWarning("attached" ); 87 qWarning("attached" );
85 qWarning("Output: %s", m_output.data() ); 88 qWarning("Output: %s", m_output.data() );
86 pid = parsePid( m_output ); 89 pid = parsePid( m_output );
87 qWarning("Pid = %d", pid ); 90 qWarning("Pid = %d", pid );
88 // now hciconfig hci0 up ( determine hciX FIXME) 91 // now hciconfig hci0 up ( determine hciX FIXME)
89 // and call hciconfig hci0 up 92 // and call hciconfig hci0 up
90 // FIXME hardcoded to hci0 now :( 93 // FIXME hardcoded to hci0 now :(
91 m_hci = new OProcess( ); 94 m_hci = new OProcess( );
92 *m_hci << "hciconfig"; 95 *m_hci << "hciconfig";
93 *m_hci << "hci0 up"; 96 *m_hci << "hci0 up";
94 connect(m_hci, SIGNAL( processExited(OProcess*) ), 97 connect(m_hci, SIGNAL( processExited(OProcess*) ),
95 this, SLOT( slotExited(OProcess* ) ) ); 98 this, SLOT( slotExited(OProcess* ) ) );
96 if(!m_hci->start() ){ 99 if(!m_hci->start() ){
97 qWarning("could not start" ); 100 qWarning("could not start" );
98 m_attached = false; 101 m_attached = false;
99 emit device("hci0", false ); 102 emit device("hci0", false );
100 } 103 }
101 }else{ 104 }else{
105 qWarning("crass" );
102 m_attached = false; 106 m_attached = false;
103 emit device("hci0", false ); 107 emit device("hci0", false );
104 108
105 } 109 }
106 } 110 }
107 delete m_process; 111 delete m_process;
108 m_process = 0; 112 m_process = 0;
109 }else if(proc== m_hci ){ 113 }else if(proc== m_hci ){
110 qWarning("M HCI exited" ); 114 qWarning("M HCI exited" );
111 if( m_hci->normalExit() ){ 115 if( m_hci->normalExit() ){
112 qWarning("normal exit" ); 116 qWarning("normal exit" );
113 int ret = m_hci->exitStatus(); 117 int ret = m_hci->exitStatus();
114 if( ret == 0 ){ 118 if( ret == 0 ){
115 qWarning("attached really really attached" ); 119 qWarning("attached really really attached" );
116 m_attached = true; 120 m_attached = true;
117 emit device("hci0", true ); 121 emit device("hci0", true );
118 }else{ 122 }else{
119 qWarning( "failed" ); 123 qWarning( "failed" );
120 emit device("hci0", false ); 124 emit device("hci0", false );
121 m_attached = false; 125 m_attached = false;
122 } 126 }
123 }// normal exit 127 }// normal exit
124 delete m_hci; 128 delete m_hci;
125 m_hci = 0; 129 m_hci = 0;
126 } 130 }
127} 131}
128void Device::slotStdOut(OProcess* proc, char* chars, int len) 132void Device::slotStdOut(OProcess* proc, char* chars, int len)
129{ 133{
130 qWarning("std out" ); 134 qWarning("std out" );
131 if( len <1 ) 135 if( len <1 ){
136 qWarning( "len < 1 " );
132 return; 137 return;
138 }
133 if(proc == m_process ){ 139 if(proc == m_process ){
134 QCString string( chars, len+1 ); // \0 == +1 140 QCString string( chars, len+1 ); // \0 == +1
135 qWarning("output: %s", string.data() ); 141 qWarning("output: %s", string.data() );
136 m_output.append( string.data() ); 142 m_output.append( string.data() );
137 } 143 }
138} 144}
139void Device::slotStdErr(OProcess*, char*, int ) 145void Device::slotStdErr(OProcess* proc, char* chars, int len)
140{ 146{
141 qWarning("std err" ); 147 qWarning("std err" );
148 slotStdOut( proc, chars, len );
142} 149}
diff --git a/noncore/net/opietooth/lib/lib.pro b/noncore/net/opietooth/lib/lib.pro
index f2cde06..ce36d66 100644
--- a/noncore/net/opietooth/lib/lib.pro
+++ b/noncore/net/opietooth/lib/lib.pro
@@ -1,9 +1,9 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qte warn_on release 2CONFIG += qte warn_on release
3 HEADERS = device.h manager.h remotedevice.h services.h 3 HEADERS = device.h manager.h remotedevice.h services.h
4 SOURCES = device.cc manager.cc remotedevice.cc services.cc 4 SOURCES = device.cc manager.cc remotedevice.cc services.cc
5 TARGET = opietooth 5 TARGET = opietooth
6INCLUDEPATH += $(OPIEDIR)/include 6INCLUDEPATH += $(OPIEDIR)/include
7DESTDIR = $(QTDIR)/lib$(PROJMAK) 7DESTDIR = $(QTDIR)/lib$(PROJMAK)
8LIBS = -lopie 8LIBS += -lopie
9#VERSION = 0.0.0 9#VERSION = 0.0.0