author | wimpie <wimpie> | 2005-01-09 00:32:10 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-09 00:32:10 (UTC) |
commit | e54346d28b19d3ac671802a25e8c03f346693291 (patch) (side-by-side diff) | |
tree | 0f8d6561e24a7ba36fd8a6ab1869aa470e1fdb36 /noncore/settings/networksettings2/opietooth2 | |
parent | 60a617583d0ccc793d9ea4465998d90ec208db58 (diff) | |
download | opie-e54346d28b19d3ac671802a25e8c03f346693291.zip opie-e54346d28b19d3ac671802a25e8c03f346693291.tar.gz opie-e54346d28b19d3ac671802a25e8c03f346693291.tar.bz2 |
Updated dependencies
NS2->app requires OT2Lib and NS2Lib
OT2Lib requires NS2Lib
Most plugins only require NS2Lib
Except
BTPlugin which requires als OT2Lib
Also renamed owarn -> odebug
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2') (more/less context) (ignore whitespace changes)
11 files changed, 62 insertions, 55 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTDevice.cpp b/noncore/settings/networksettings2/opietooth2/OTDevice.cpp index 62f17a0..c6f7d5e 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDevice.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTDevice.cpp @@ -82,49 +82,49 @@ bool OTDevice::attach(){ // we need to start this in 'dontcare' mode because // if qpe exists we want the hci to keep running if( ! m_hciattach->start( OProcess::DontCare, OProcess::AllOutput ) ){ emit error( tr( "Could not start hciattach" ) ); delete m_hciattach; m_hciattach = 0; return FALSE; } } return TRUE; } bool OTDevice::detach(){ if( needsAttach() && m_hciattachPid ) { if( m_hciattach ) { delete m_hciattach; m_hciattach = 0; } if( kill( m_hciattachPid, 9) < 0 ) { - owarn << "could not stop " << errno << oendl; + odebug << "could not stop " << errno << oendl; emit error( tr( "Could not stop process" ) ); return FALSE; } m_hciattachPid = 0; emit isEnabled( m_deviceNr, 0 ); m_deviceNr = -1; } return TRUE; } bool OTDevice::isAttached()const{ return ! needsAttach() || m_hciattachPid != 0; } bool OTDevice::checkAttach(){ if( ! needsAttach() ) { m_deviceNr = 0; emit isEnabled( 0, 1 ); return TRUE; } if( m_hciattachPid ) { QString S; @@ -147,92 +147,92 @@ bool OTDevice::checkAttach(){ return m_hciattachPid != 0; } void OTDevice::slotStdOut(OProcess* proc, char* , int ) { if( proc == m_hciattach ) { m_hciattach->detach(); // system enabled // currently no way to figure out which attach produce which // hci if( m_deviceNr == -1 ) { m_deviceNr = 0; emit isEnabled( m_deviceNr, 1 ); } } } void OTDevice::slotStdErr(OProcess* proc, char* chars, int len) { if(proc == m_hciattach && len >= 1 ){ // collect output QCString string( chars, len+1 ); // \0 == +1 QString m_output; m_output.append( string.data() ); - owarn << m_output << oendl; + odebug << m_output << oendl; } } pid_t OTDevice::getPidOfHCIAttach( void ) { if( needsAttach() ) { // not yet attached -> perhaps now ? // load /proc dir and check if command name contains hciattach QRegExp R("[0-9]+"); QDir ProcDir( "/proc" ); QFileInfo FI; QStringList EL = ProcDir.entryList( QDir::Dirs ); // print it out for ( QStringList::Iterator it = EL.begin(); it != EL.end(); ++it ) { if( R.match( (*it) ) >= 0 ) { // is pid // get command being executed FI.setFile( ProcDir.path()+"/"+ (*it) + "/exe" ); // get the link if( FI.readLink().right( 9 ) == "hciattach" ) { // this is hci attach process return (*it).toULong(); break; } } } } return 0; } void OTDevice::detectDeviceType( QString & Device, QString & Mode, unsigned long & Speed ) { // detect device type and determine parms - owarn << "Detecting device" << oendl; + odebug << "Detecting device" << oendl; switch ( ODevice::inst()->model() ) { case Model_iPAQ_H39xx: Device = "/dev/tts/1"; Mode = "bcsp"; Speed = 921600; NeedsAttach = 1; break; case Model_iPAQ_H5xxx: Device = "/dev/tts/1"; Mode = "any"; Speed = 921600; NeedsAttach = 1; break; case Model_GenuineIntel : Device = ""; Mode = ""; Speed = 0; NeedsAttach = 0; break; default: Device = "/dev/ttySB0"; diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp index 8bd7919..a7ee662 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDriver.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTDriver.cpp @@ -129,49 +129,49 @@ static ClassMap_t MapPeripheralClass[] = { typedef struct { int Major; ClassMap_t * Map; } MainClassMap_t; static MainClassMap_t MainClasses[] = { { 0, MapMiscClass }, { 1, MapComputerClass }, { 2, MapPhoneClass }, { 3, 0 }, // special case { 4, MapAVClass }, { 5, MapPeripheralClass }, { 6, 0 }, // special case { 63, MapUnclassifiedClass }, { -1, 0 } }; OTDriver::OTDriver( OTGateway * _OT, struct hci_dev_info* di) : QObject( _OT ), Address() { OT = _OT; IsUp = 0; Socket = 0; init(di); - owarn << "Driver " << devname() << oendl; + odebug << "Driver " << devname() << oendl; AutoClose = new QTimer( this ); connect( AutoClose, SIGNAL( timeout() ), this, SLOT( SLOT_CloseFd() ) ); } OTDriver::~OTDriver() { closeSocket(); SLOT_CloseFd(); } void OTDriver::SLOT_CloseFd( void ){ if ( isOpen() ) { AutoClose->stop(); ::close( fd() ); setfd( -1 ); } } void OTDriver::init(struct hci_dev_info* di) { @@ -364,72 +364,72 @@ int OTDriver::reset() { if( ioctl(fd(), HCIDEVRESET, devId()) < 0 ) { if( errno != EALREADY ) { emit error( tr( "Reset failed for %1. %2 : %3" ). arg( devname() ). arg( errno ). arg( strerror(errno) ) ); if (errno == EACCES) { return EACCES; } } } return 0; } void OTDriver::setUp( bool M ) { if( M && ! isUp() ) { bringUp(); } else if( ! M && isUp() ) { bringDown(); } } void OTDriver::bringUp() { - owarn << "bringUp : " << Dev << oendl; + odebug << "bringUp : " << Dev << oendl; if( ! open() ) { return; } if (! isUp()) { if( ioctl(fd(), HCIDEVUP, devId()) < 0 ) { if( errno != EALREADY ) { emit error( tr( "Cannot bring interface %1 up. %2 : %3" ). arg( devname() ). arg( errno ). arg( strerror(errno) ) ); } return; } // have to wait a bit for the 'up' to become active QTimer::singleShot( 3000, this, SLOT( reinit() ) ); } } void OTDriver::bringDown() { - owarn << "bringDown : " << Dev << oendl; + odebug << "bringDown : " << Dev << oendl; if( ! open() ) { return; } if ( isUp() ) { if( ioctl(fd(), HCIDEVDOWN, devId()) < 0 ) { if( errno != EALREADY ) { emit error( tr( "Cannot bring interface %1 down. %2 : %3" ). arg( devname() ). arg( errno ). arg( strerror(errno) ) ); } return; } reinit(); } } void OTDriver::setScanMode(bool iscan, bool pscan) { struct hci_dev_req dr; if( ! open() ) { @@ -640,105 +640,105 @@ void OTDriver::getClass( QString & service, break; } MCM ++; } if( MCM->Major == -1 ) { device = "Unknown (reserved) minor device class"; } } QString OTDriver::strType() { return QString( hci_dtypetostr(Type) ); } void OTDriver::setFeatures( unsigned char * _f) { Features = lmp_featurestostr(_f, NULL, 255); } void OTDriver::setManufacturer(int compid) { Manufacturer = bt_compidtostr(compid); } OTHCISocket * OTDriver::openSocket( void ) { if( ! Socket ) { - owarn << "Open HCI socket to " << devname() << oendl; + odebug << "Open HCI socket to " << devname() << oendl; Socket = new OTHCISocket( this ); } return Socket; } void OTDriver::closeSocket( void ) { if( Socket ) { - owarn << "Close HCI socket to " << devname() << oendl; + odebug << "Close HCI socket to " << devname() << oendl; delete Socket; Socket = 0; } } QString OTDriver::getPeerName( const OTDeviceAddress & PAddr ) { QString S; char name[100 ]; if( ! open() ) { return QString("N/A"); } if( hci_read_remote_name( fd(), &(PAddr.getBDAddr()), sizeof(name), name, 100000 ) < 0 ) { return QString( "N/A" ); } return QString( name ); } long OTDriver::getLinkQuality( const OTDeviceAddress & Addr ) { struct hci_conn_info_req *cr; struct hci_request rq; read_rssi_rp rp; uint16_t handle; if( ! open() ) { return 0; } cr = (struct hci_conn_info_req *)malloc( sizeof(*cr) + sizeof(struct hci_conn_info)); if (!cr) return 0; bacpy( &(cr->bdaddr), &(Addr.getBDAddr()) ); cr->type = ACL_LINK; if (ioctl( fd(), HCIGETCONNINFO, (unsigned long) cr) < 0) { - owarn << "Get connection info failed" << oendl; + odebug << "Get connection info failed" << oendl; free(cr); return 0; } handle = htobs(cr->conn_info->handle); free(cr); memset(&rq, 0, sizeof(rq)); rq.ogf = OGF_STATUS_PARAM; rq.ocf = OCF_READ_RSSI; rq.cparam = &handle; rq.clen = 2; rq.rparam = &rp; rq.rlen = GET_LINK_QUALITY_RP_SIZE; if (hci_send_req( fd(), &rq, 100) < 0) { - owarn << "Get connection info failed" << oendl; + odebug << "Get connection info failed" << oendl; return 0; } if( rp.status ) { - owarn << QString().sprintf("HCI get_link_quality cmd failed (0x%2.2X)", rp.status) << oendl; + odebug << QString().sprintf("HCI get_link_quality cmd failed (0x%2.2X)", rp.status) << oendl; return 0; } return rp.rssi+50; } diff --git a/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp b/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp index f703834..e5af742 100644 --- a/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp @@ -32,55 +32,55 @@ void OTDriverList::update() { struct hci_dev_list_req *dl; struct hci_dev_req *dr; struct hci_dev_info di; int cur; dl = 0; cur = 0; do { cur += 5; dl = (struct hci_dev_list_req*) ::realloc( dl, sizeof( struct hci_dev_list_req ) + ( cur * sizeof(struct hci_dev_req) ) ); if( dl == 0 ) { // memory problem exit(1); } dl->dev_num = cur; if( ioctl( OT->getSocket(), HCIGETDEVLIST, (void*)dl) ) { - owarn << "WARNING : cannot read device list. " + odebug << "WARNING : cannot read device list. " << errno << strerror( errno ) << oendl; return; } // if num == cur perhaps we did not get all devices yet } while( dl->dev_num == cur ); if( dl->dev_num != count() ) { // new or missing devices clear(); dr = dl->dev_req; resize( dl->dev_num ); for( cur=0; cur < dl->dev_num; cur ++) { memset( &di, 0, sizeof( di ) ); di.dev_id = (dr+cur)->dev_id; // get device info if( ioctl( OT->getSocket(), HCIGETDEVINFO, (void*)&di) != 0 ) continue; // uh ? insert( cur, new OTDriver( OT, &di ) ); } - owarn << "Found " << count() << " devices" << oendl; + odebug << "Found " << count() << " devices" << oendl; ::free( dl ); } } diff --git a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp index 6531cf6..e8137dd 100644 --- a/noncore/settings/networksettings2/opietooth2/OTGateway.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTGateway.cpp @@ -133,49 +133,49 @@ void OTGateway::SLOT_SetEnabled( bool Mode ) { void OTGateway::SLOT_Enable() { getOTDevice()->attach(); } void OTGateway::SLOT_Disable() { getOTDevice()->detach(); } bool OTGateway::needsEnabling() { return getOTDevice()->needsAttach(); } bool OTGateway::isEnabled() { if( getOTDevice()->deviceNr() >= 0 && driver( getOTDevice()->deviceNr() )->isUp() ) return TRUE; // else check system return getOTDevice()->isAttached(); } void OTGateway::SLOT_ShowError( const QString & S ) { - owarn << S << oendl; + odebug << S << oendl; if( ErrorConnectCount > 0 ) { // pass error emit error( QString( "<p>" ) + S + "</p>" ); return; } QMessageBox::warning( 0, tr("OTGateway error"), S ); } void OTGateway::connectNotify( const char * S ) { if( S && strcmp( S, "error(const QString&)" ) == 0 ) { ErrorConnectCount ++; } } void OTGateway::disconnectNotify( const char * S ) { if( S && strcmp( S, "error(const QString&)" ) == 0 ) { ErrorConnectCount --; } } @@ -189,104 +189,104 @@ void OTGateway::timerEvent( QTimerEvent * ) { if( oldc != AllDrivers.count() ) { updateDrivers(); } else { for( unsigned int i = 0; i < AllDrivers.count(); i ++ ) { D = AllDrivers[i]; old = D->isUp(); if( D->currentState() >= 0 ) { if( old != D->isUp() ) { emit stateChange( D, D->isUp() ); } } else { // if one driver is unable to provide info // we refresh all devices updateDrivers(); return; } } } } void OTGateway::SLOT_Enabled( int id, bool Up ) { - owarn << "device " << id << " state " << Up << oendl; + odebug << "device " << id << " state " << Up << oendl; if( Up ) { // device is up -> detect it updateDrivers(); if( (unsigned)id >= AllDrivers.count() ) { // to make sure that the driver really IS detected AllDrivers[id]->bringUp(); } } // if DOWN device already down emit deviceEnabled( Up ); } void OTGateway::updateDrivers( void ) { OTDriver * D; AllDrivers.update(); - owarn << "updated drivers. now " << AllDrivers.count() << oendl; + odebug << "updated drivers. now " << AllDrivers.count() << oendl; // connect signals for each driver for( unsigned int i = 0; i < AllDrivers.count(); i ++ ) { D = AllDrivers[i]; connect( D, SIGNAL( error( const QString & ) ), this, SLOT( SLOT_ShowError( const QString & ) ) ); connect( D, SIGNAL( stateChange( OTDriver *, bool ) ), this, SIGNAL( stateChange( OTDriver *, bool ) ) ); connect( D, SIGNAL( driverDisappeared( OTDriver * ) ), this, SLOT( SLOT_DriverDisappeared( OTDriver * ) ) ); } // verify main device too if( TheOTDevice ) TheOTDevice->checkAttach(); // set to default scanning hardware setScanWith( 0 ); emit driverListChanged(); } void OTGateway::SLOT_DriverDisappeared( OTDriver * D ) { - owarn << "Driver " << D->devname() << " when offline" << oendl; + odebug << "Driver " << D->devname() << " when offline" << oendl; updateDrivers(); } void OTGateway::scanNeighbourhood( OTDriver * D ) { if( Scanning ) { stopScanOfNeighbourhood(); } if( D ) { setScanWith( D ); } Scanning = new OTInquiry( scanWith() ); connect( Scanning, SIGNAL( peerFound( OTPeer *, bool )), this, SLOT( SLOT_PeerDetected( OTPeer *, bool ) ) ); connect( Scanning, SIGNAL( finished()), this, SLOT( SLOT_FinishedDetecting() ) @@ -297,49 +297,49 @@ void OTGateway::scanNeighbourhood( OTDriver * D ) { } OTPeer* OTGateway::findPeer( const OTDeviceAddress & Addr ) { for( unsigned int i = 0 ; i < AllPeers.count(); i ++ ) { if( AllPeers[i]->address() == Addr ) { return AllPeers[i]; } } return 0; } OTDriver* OTGateway::findDriver( const OTDeviceAddress & Addr ) { for( unsigned int i = 0 ; i < AllDrivers.count(); i ++ ) { if( AllDrivers[i]->address() == Addr ) { return AllDrivers[i]; } } return 0; } void OTGateway::SLOT_PeerDetected( OTPeer * P, bool IsNew ) { if( IsNew ) { // new peer - owarn << "New peer " << P->name() << oendl; + odebug << "New peer " << P->name() << oendl; addPeer( P ); } emit detectedPeer( P, IsNew ); } void OTGateway::addPeer( OTPeer * P ) { AllPeers.resize( AllPeers.size()+1); AllPeers.insert( AllPeers.size()-1, P ); AllPeersModified = 1; } void OTGateway::removePeer( OTPeer * P ) { int i = AllPeers.find( P ); if( i ) { AllPeers.remove( i ); AllPeersModified = 1; } } void OTGateway::stopScanOfNeighbourhood( void ) { if( Scanning ) { delete Scanning; Scanning = 0; @@ -363,56 +363,56 @@ const char * OTGateway::deviceTypeToName( int cls ) { return "lan"; case 0x04: return "av"; case 0x05: return "peripheral"; case 0x06: return "imaging"; case 0x07: default : break; } return "unknown"; } PANConnectionVector OTGateway::getPANConnections( void ) { PANConnectionVector V; struct bnep_connlist_req req; struct bnep_conninfo ci[48]; V.setAutoDelete(TRUE); int ctl = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_BNEP); if (ctl < 0) { - owarn << "Failed to open control socket" << oendl; + odebug << "Failed to open control socket" << oendl; return V; } req.cnum = 48; req.ci = ci; if (ioctl(ctl, BNEPGETCONNLIST, &req)) { - owarn << "Failed to get connection list" << oendl; + odebug << "Failed to get connection list" << oendl; ::close( ctl ); return V; } for ( unsigned i=0; i < req.cnum; i++) { V.resize( V.size() + 1 ); if( ci[i].role == BNEP_SVC_PANU ) { // we are the client V.insert( V.size()-1, new OTPANConnection( ci[i].device, batostr((bdaddr_t *) ci[i].dst) ) ); } } ::close( ctl ); return V; } struct link_key { bdaddr_t sba; bdaddr_t dba; uint8_t key[16]; uint8_t type; diff --git a/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp b/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp index 471c3bf..1997b44 100644 --- a/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTHCISocket.cpp @@ -13,61 +13,61 @@ #include <qtimer.h> #include <qdatastream.h> #include <opie2/odebug.h> #include <bluezlib.h> // #include "deviceaddress.h" #include <OTHCISocket.h> #include <OTDriver.h> using namespace Opietooth2; OTHCISocket::OTHCISocket( OTDriver * D ) : QObject( D, D->devname() ) { BStatusSet = false; Driver = D; HCIReadNotifier = 0; } OTHCISocket::~OTHCISocket() { close(); } void OTHCISocket::close() { - owarn << "OTHCISocket::close()" << oendl; + odebug << "OTHCISocket::close()" << oendl; if( HCIReadNotifier ) { delete HCIReadNotifier; } if( HCISocket.isValid() ) { HCISocket.close(); } } bool OTHCISocket::open() { - owarn << "OTHCISocket::open()" << oendl; + odebug << "OTHCISocket::open()" << oendl; int s; s = ::socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (s < 0) { emit error( tr( "Error creating socket on %1 : %2 %3"). arg( Driver->devname() ). arg( errno ). arg( strerror(errno) ) ); return false; } /* Bind socket to the HCI device */ struct sockaddr_hci sa; sa.hci_family = AF_BLUETOOTH; sa.hci_dev = Driver->devId(); if (bind(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) { ::close(s); emit error( tr( "Error binding to socket to %1 : %2 %3"). arg( Driver->devname() ). arg( errno ). arg( strerror(errno) ) ); @@ -130,145 +130,145 @@ void OTHCISocket::slotSocketActivated() { //kdDebug() << "HCI socket ready read." << endl; unsigned char buf[512]; int psize = HCISocket.readBlock((char*)buf, 512); if (psize <= 0) { slotSocketError(HCISocket.error()); HCISocket.close(); return; } //unsigned char packetType = buf[0]; unsigned char eventCode = buf[1]; unsigned char len = buf[2]; if (psize-3 == len) { QByteArray databuf; databuf.duplicate((char*)(buf+3), len); emit event(eventCode, databuf); if (eventCode == EVT_CMD_STATUS) { updateStatus( databuf ); } } else { - owarn << "Error reading hci packet: packetSize(" + odebug << "Error reading hci packet: packetSize(" << psize << ")-3 != dataSize(" << len << ")" << oendl; } } else if (err == QSocketDevice::NoError) { slotConnectionClosed(); } else { HCISocket.close(); slotSocketError(err); } } void OTHCISocket::updateStatus(const QByteArray& data) { QDataStream stream(data, IO_ReadOnly); stream.setByteOrder(QDataStream::LittleEndian); Q_UINT8 status, dummy; Q_UINT16 opcode; BStatusSet = true; stream >> status >> dummy >> opcode; //kdDebug() << "updatestatus opcode=" << uint32_t(opcode) << endl; LastStatus = status; LastStatusOgf = cmd_opcode_ogf(opcode); LastStatusOcf = cmd_opcode_ocf(opcode); } void OTHCISocket::slotConnectionClosed() { - owarn << "HCI connection closed." << oendl; + odebug << "HCI connection closed." << oendl; emit connectionClosed(); } void OTHCISocket::readEvent() { if (HCIReadNotifier) { slotSocketActivated(); } } bool OTHCISocket::sendCommand( unsigned char ogf, unsigned short ocf, QByteArray buf ) { QBuffer packet; QDataStream stream(&packet); stream.setByteOrder(QDataStream::LittleEndian); packet.open(IO_WriteOnly); if (buf.size() > 255) return false; //kdDebug() << "sendCommand. ogf=" << ogf << " ocf=" << ocf << endl; Q_UINT16 opcode = cmd_opcode_pack(ogf, ocf); Q_UINT8 pType = HCI_COMMAND_PKT; Q_UINT8 buflen = buf.size(); stream << pType << opcode << buflen; stream.writeRawBytes(buf.data(), buflen); packet.close(); HCISocket.writeBlock((const char*)packet.buffer(), packet.buffer().size()); return true; } bool OTHCISocket::readStatus( unsigned char ogf, unsigned short ocf, int *status, int timeout_ms) { QTimer timer; timer.start(timeout_ms, true); BStatusSet = false; while (timer.isActive() && HCISocket.isValid()) { - owarn << "OTHCISocket::readStatus()" << oendl; + odebug << "OTHCISocket::readStatus()" << oendl; bool timeout = false; if( HCISocket.bytesAvailable() == 0) { int rv = HCISocket.waitForMore(timeout_ms); timeout = (rv == 0); } if (!timeout) { slotSocketActivated(); } if( BStatusSet == true && ogf == LastStatusOgf && ocf == LastStatusOcf) { *status = LastStatus; - owarn << "OTHCISocket::readStatus(ogf=" + odebug << "OTHCISocket::readStatus(ogf=" << ogf << ",ocf=" << ocf << ",timeout=" << LastStatus << ")" << oendl; return true; } } - owarn << "OTHCISocket::readStatus(ogf=" + odebug << "OTHCISocket::readStatus(ogf=" << ogf << ",ocf=" << ocf << ",timeout=" << LastStatus << ") : timeout " << oendl; return false; } int OTHCISocket::socket() { return HCISocket.socket(); } diff --git a/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp b/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp index 8e94bbc..2bc63c7 100644 --- a/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTInquiry.cpp @@ -38,182 +38,182 @@ OTInquiry::OTInquiry( OTDriver * Drv ) : QObject( Drv ) { InquiryTimeoutTimer = new QTimer(this); connect( InquiryTimeoutTimer, SIGNAL(timeout()), this, SLOT(slotInquiryTimeout())); Driver = Drv; Socket = Drv->openSocket(); Socket->open(); connect( Socket, SIGNAL( event(unsigned char, QByteArray)), this, SLOT(slotHCIEvent(unsigned char, QByteArray))); } OTInquiry::~OTInquiry() { stopInquiring(); } void OTInquiry::stopInquiring( void ) { if( Socket ) { - owarn << "Stop inquiry" << oendl; + odebug << "Stop inquiry" << oendl; Driver->closeSocket(); Socket = 0; } } bool OTInquiry::inquire( double timeout, int numResponses, int lap) { QByteArray cmdBuf(5); cmdBuf[0] = lap & 0xFF; cmdBuf[1] = (lap >> 8) & 0xFF; cmdBuf[2] = (lap >> 16) & 0xFF; cmdBuf[3] = max(0x01, min(0x30, int(timeout/1.28))); cmdBuf[4] = (unsigned char)numResponses; - owarn << "Send HCI inquiry command. wait for " << cmdBuf[3] << oendl; + odebug << "Send HCI inquiry command. wait for " << cmdBuf[3] << oendl; Socket->sendCommand(0x01, 0x0001, cmdBuf); int status; if( Socket->readStatus(0x01, 0x0001, &status)) { if (status == 0) { SuccessfullyStarted = true; InquiryTimeoutTimer->start( int(1000*(timeout+1.0)), true); return true; } else { QString S =QString().sprintf( "%x", status ); - owarn << "OTInquiry::inquiry() failed: 0x" << S << oendl; + odebug << "OTInquiry::inquiry() failed: 0x" << S << oendl; emit finished(); return false; } } else { - owarn << "OTInquiry::inquiry(): Timeout." << oendl; + odebug << "OTInquiry::inquiry(): Timeout." << oendl; return false; } } bool OTInquiry::isInquiring() { return InquiryTimeoutTimer->isActive(); } bool OTInquiry::isFinished() { return SuccessfullyStarted && SuccessfullyEnded; } void OTInquiry::reset() { SuccessfullyStarted = false; SuccessfullyEnded = false; //addrCache.clear(); //infoQueue.clear(); } void OTInquiry::onPeerFound( OTPeer * Peer, bool IsNew ) { emit peerFound( Peer, IsNew ); } void OTInquiry::slotInquiryTimeout() { emit error( tr( "Timeout while waiting for end of inquiry.") ); } void OTInquiry::slotHCIEvent(unsigned char eventCode, QByteArray buf) { - owarn << "OTInquiry: hci packet received: eventCode=" + odebug << "OTInquiry: hci packet received: eventCode=" << (unsigned int)eventCode << " packetLength=" << (unsigned int)buf.size() << oendl; unsigned char *data = (unsigned char*)buf.data(); switch (eventCode) { case EVT_INQUIRY_COMPLETE: { unsigned char status = data[0]; - owarn << "EVT_INQUIRY_COMPLETE status=" << status << oendl; + odebug << "EVT_INQUIRY_COMPLETE status=" << status << oendl; InquiryTimeoutTimer->stop(); if (status == 0) { if( SuccessfullyStarted == true) { - owarn << "OTInquiry ended successfully" << oendl; + odebug << "OTInquiry ended successfully" << oendl; SuccessfullyEnded = true; } emit finished(); } else { emit error( tr( "OTInquiry completed with error (code %1)" ). arg(status)); } } break; case EVT_INQUIRY_RESULT: { int numResults = data[0]; OTPeer * P = 0; bool IsNew; OTDeviceAddress Addr; QString N; inquiry_info *results = (inquiry_info*)(data+1); for (int n=0; n<numResults; n++) { Addr.setBDAddr( results[n].bdaddr ); - owarn << "INQUIRY_RESULT: " + odebug << "INQUIRY_RESULT: " << Addr.toString() << oendl; P = Driver->gateway()->findPeer( Addr ); if( P ) { // peer known if( P->state() != OTPeer::Peer_Up ) { P->setState( OTPeer::Peer_Up ); } IsNew = 0; } else { IsNew = 1; // push the address to the address queue // where it can be consumed by nextNeighbour() P = new OTPeer( Driver->gateway() ); P->setState( OTPeer::Peer_Up ); // we just detected it P->setAddress( Addr ); //if( addrCache.find(info.addr) == addrCache.end()) { // addrCache.insert(info.addr); P->setDeviceClass( (results[n].dev_class[0] << 16) | (results[n].dev_class[1] << 8) | (results[n].dev_class[2] << 0) ); // infoQueue.push_back(info); P->setName( Driver->getPeerName( Addr ) ); } // call the handler. Emits a signal if not overwritten onPeerFound( P, IsNew ); // } } } break; case EVT_CMD_STATUS : { int status = data[0]; int numHciCmdPkts = data[1]; int cmdOpcode = *((uint16_t*)(data+2)); - owarn << "EVT_CMD_STATUS status=" + odebug << "EVT_CMD_STATUS status=" << status << " numPkts=" << numHciCmdPkts << " cmdOpcode=" << cmdOpcode << oendl; if (cmdOpcode == OCF_INQUIRY) { } } break; } } diff --git a/noncore/settings/networksettings2/opietooth2/OTPeer.cpp b/noncore/settings/networksettings2/opietooth2/OTPeer.cpp index 0d7e943..2272f04 100644 --- a/noncore/settings/networksettings2/opietooth2/OTPeer.cpp +++ b/noncore/settings/networksettings2/opietooth2/OTPeer.cpp @@ -30,78 +30,78 @@ using namespace Opietooth2; OTPeer::OTPeer( OTGateway * _OT ) { OT = _OT; State = Peer_Unknown; ConnectedTo = 0; } OTPeer::OTPeer( QTextStream & TS, OTGateway * _OT ) { OT = _OT; State = Peer_Unknown; ConnectedTo = 0; load( TS ); } OTPeer::~OTPeer( ) { } void OTPeer::updateServices( void ) { sdp_session_t *session; serviceList.clear(); - owarn << "Get services from " << Addr.toString() << oendl; + odebug << "Get services from " << Addr.toString() << oendl; session = sdp_connect( &(OTDeviceAddress::any.getBDAddr()), &(Addr.getBDAddr()), 0); if (!session) { - owarn << "sdp_connect(" + odebug << "sdp_connect(" << Addr.toString() << ") failed" << oendl; return; // error } uint32_t range = 0x0000ffff; sdp_list_t* attrId = sdp_list_append(0, &range); // search all public features uuid_t grp; sdp_uuid16_create( &grp, PUBLIC_BROWSE_GROUP ); sdp_list_t * search = sdp_list_append(0, &grp ); // get data from peer sdp_list_t* seq; if (sdp_service_search_attr_req( session, search, SDP_ATTR_REQ_RANGE, attrId, &seq ) ) { - owarn << "Service Search failed" << oendl; + odebug << "Service Search failed" << oendl; sdp_close(session); return; } sdp_list_free(attrId, 0); sdp_list_free(search, 0); // process result sdp_list_t* next = NULL; for (; seq; seq = next) { sdp_record_t *rec = (sdp_record_t *) seq->data; sdp_list_t* attrlist = rec->attrlist; AttributeVector alist; OTSDPService * service; service = new OTSDPService(); for (; attrlist; attrlist = attrlist->next) { int attrID = ((sdp_data_t*)(attrlist->data))->attrId; service->addAttribute( attrID, new OTSDPAttribute( (sdp_data_t*)(attrlist->data) ) @@ -156,49 +156,49 @@ void OTPeer::load( QTextStream & TS ) { QString S; S = TS.readLine(); setAddress( OTDeviceAddress( S.mid( 7 ) ) ); S = TS.readLine(); setName( S.mid( 5 ) ); S = TS.readLine(); setDeviceClass( S.mid( 6 ).toLong() ); } #define MAGICNR -99999 #define POLLDELAY 1000 #define PREMAGICNR (MAGICNR+POLLDELAY) void OTPeer::findOutState( int timeoutInSec, bool Force ) { ProbeFD = -1; if( Force && ConnectedTo == 0 ) { State = OTPeer::Peer_Unknown; } // else keep state or is connected to us if( State == OTPeer::Peer_Unknown ) { ProbePhase = 0; ProbeTimeout = timeoutInSec*1000; - owarn << "Ping " << address().toString() << oendl; + odebug << "Ping " << address().toString() << oendl; startTimer( POLLDELAY ); } else { ProbeTimeout = 0; startTimer( 0 ); } } #define PINGSIZE 20 void OTPeer::timerEvent( QTimerEvent * ev ) { ProbeTimeout -= POLLDELAY; if( State == OTPeer::Peer_Unknown ) { switch( ProbePhase ) { case 0 : // connect nonblock { struct sockaddr_l2 addr; if (( ProbeFD = ::socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_L2CAP)) < 0) { ProbeTimeout = 0; break; } memset(&addr, 0, sizeof(addr)); @@ -214,144 +214,144 @@ void OTPeer::timerEvent( QTimerEvent * ev ) { if( ::fcntl( ProbeFD, F_SETFL, O_NONBLOCK ) < 0 ) { ProbeTimeout = 0; break; } // to this peer addr.l2_bdaddr = address().getBDAddr(); if( ::connect( ProbeFD, (struct sockaddr *) &addr, sizeof(addr)) < 0) { if( errno != EAGAIN && errno != EINPROGRESS ) { ProbeTimeout = 0; break; } // wait for connect to fail or succeed } } ProbePhase = 1; // wait for connect break; case 1 : { struct pollfd pf[1]; char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20]; int n; pf[0].fd = ProbeFD; pf[0].events = POLLOUT; if( (n = ::poll(pf, 1, 0)) < 0 ) { - owarn << address().toString() + odebug << address().toString() << " : errno " << errno << " " << strerror(errno)<<oendl; ProbeTimeout = 0; break; } if( ! n ) { // not ready -> try again break; } // send ping for( unsigned int i = L2CAP_CMD_HDR_SIZE; i < sizeof(buf); i++) buf[i] = (i % 40) + 'A'; l2cap_cmd_hdr *cmd = (l2cap_cmd_hdr *) buf; /* Build command header */ cmd->code = L2CAP_ECHO_REQ; cmd->ident = *(char *)this; // get some byte cmd->len = PINGSIZE; /* Send Echo Request */ if( ::send(ProbeFD, buf, PINGSIZE + L2CAP_CMD_HDR_SIZE, 0) <= 0) { if( errno == EACCES ) { // permission denied means that we could not // connect because the device does not allow us // but it is UP - owarn << address().toString() + odebug << address().toString() << " good send error " << errno << " " << strerror( errno) << oendl; State = OTPeer::Peer_Up; ProbeTimeout = 0; break; } else if( errno != EBUSY ) { - owarn << address().toString() + odebug << address().toString() << " : errno " << errno << " " << strerror(errno) << oendl; ProbeTimeout = 0; break; } // else want some more } ProbePhase = 2; // wait for ping reply } break; case 2 : // wait for reply { struct pollfd pf[1]; char buf[L2CAP_CMD_HDR_SIZE + PINGSIZE + 20]; l2cap_cmd_hdr *cmd = (l2cap_cmd_hdr *) buf; int n; pf[0].fd = ProbeFD; pf[0].events = POLLIN; if( (n = ::poll(pf, 1, 0)) < 0 ) { - owarn << address().toString() + odebug << address().toString() << " : errno " << errno << " " << strerror(errno) <<oendl; ProbeTimeout = 0; break; } if( ! n ) { // not ready -> try again break; } if( (n = ::recv( ProbeFD, buf, sizeof(buf), 0)) < 0) { - owarn << address().toString() + odebug << address().toString() << "errno " << errno << " " << strerror(errno) << oendl; ProbeTimeout = 0; break; } /* Check for our id */ if( cmd->ident != *(char *)this ) // not our reply break; - owarn << "reply from " + odebug << "reply from " << address().toString() << oendl; // whatever reply we get is a valid reply State = OTPeer::Peer_Up; ProbeTimeout = 0; } break; } if( State != OTPeer::Peer_Unknown ) { ProbeTimeout = 0; } } if( ProbeTimeout <= 0 ) { // regular timeout emit peerStateReport( this ); if( State == Peer_Unknown ) { State = Peer_Down; } if( ProbeFD >= 0 ) { // requested to stop by caller -> stop probing ::close( ProbeFD ); } diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index b14cc2f..8323549 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp @@ -516,118 +516,118 @@ void OTScan::SLOT_DoScan( bool DoIt ) { // double clicked on a device void OTScan::SLOT_Selected( QListViewItem * it ) { if( ! it ) return; if( Filter.count() > 0 ) { // filter on service if( it->depth() == 0 ) { // select a service and not a device return; } // store result SelectedPeer = ((PeerLVI *)it->parent())->peer(); SelectedChannel = ((ChannelLVI *)it)->channel(); } else { // click on device if( it->depth() != 0 ) { return; } SelectedPeer = ((PeerLVI *)it)->peer(); SelectedChannel = 0; } - owarn << "Selected " << SelectedPeer->address().toString() << + odebug << "Selected " << SelectedPeer->address().toString() << " Channel " << SelectedChannel << oendl; emit selected(); } void OTScan::SLOT_FinishedDetecting( ) { scanMode( false ); } void OTScan::SLOT_CleanupOld( ) { // iterate over all peers and find those that // are down and have no pairing info OTPeer * TheP; const LinkKeyArray & Keys = OT->getLinkKeys(); QListViewItem * Lit = DetectedPeers_LV->firstChild(); while( Lit ) { TheP = ((PeerLVI *)Lit)->peer(); if( TheP->state() == OTPeer::Peer_Down ) { unsigned int k; // what about linkkeys ? for( k = 0; k < Keys.count(); k ++ ) { if( TheP->address() == Keys[k].to() || TheP->address() == Keys[k].from() ) { // part of linkkey - owarn << "LINKKEY " << TheP->address().toString() << oendl; + odebug << "LINKKEY " << TheP->address().toString() << oendl; break; } } if( k == Keys.count() ) { - owarn << "RM LINKKEY " << TheP->address().toString() << oendl; + odebug << "RM LINKKEY " << TheP->address().toString() << oendl; // not found -> remember to remove this peer QListViewItem * Nit; OT->removePeer( TheP ); Nit = Lit->nextSibling(); delete Lit; Lit = Nit; continue; } } else { - owarn << "NODOWN " << TheP->address().toString() << oendl; + odebug << "NODOWN " << TheP->address().toString() << oendl; } Lit = Lit->nextSibling(); } } void OTScan::SLOT_NewPeer( OTPeer * P, bool IsNew ){ PeerLVI * it = 0; if( IsNew ) { it = new PeerLVI( P, DetectedPeers_LV ); } else { // find peer in table QListViewItem * Lit = DetectedPeers_LV->firstChild(); while( Lit ) { if( ((PeerLVI *)Lit)->peer() == P ) { // this item it = (PeerLVI *)Lit; break; } Lit = Lit->nextSibling(); } if( ! it ) { - owarn << "Should not occur" << oendl; + odebug << "Should not occur" << oendl; return; } } // update/show info it->setText( 0, P->name() ); it->setPixmap(0, Icons->deviceIcon( OT->deviceTypeToName( P->deviceClass() ) ) ); // tell peer to report its state async connect( P, SIGNAL( peerStateReport( OTPeer *)), this, SLOT( SLOT_PeerState( OTPeer *)) ); if( IsNew ) { // find state refreshState( (PeerLVI *)it, 1 ); } else { // update staet SLOT_PeerState( P ); } } @@ -908,49 +908,49 @@ OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : AllDrivers_LV->header()->hide(); } OTManage::~OTManage() { if( MyIcons ) delete Icons; OTGateway::releaseOTGateway(); } void OTManage::SLOT_ShowDriver( QListViewItem * It ) { if( It == 0 || It->depth() > 0 ) // not toplevel return; DriverLVI * it = (DriverLVI *) It; DriverIsUp_CB->setChecked( it->driver()->isUp() ); } void OTManage::SLOT_UpDriver( bool Up ) { QListViewItem * it = AllDrivers_LV->firstChild(); while( it ) { if( it->isSelected() ) { OTDriver * D = ((DriverLVI *)it)->driver(); - owarn << "UP driver " << D->devname() << oendl; + odebug << "UP driver " << D->devname() << oendl; // this D->setUp( Up ); return; } it = it->nextSibling(); } } void OTManage::SLOT_StateChange( OTDriver * D, bool Up ) { QListViewItem * it = AllDrivers_LV->firstChild(); while( it ) { if( ((DriverLVI *)it)->driver() == D ) { it->setPixmap( 0, Icons->loadPixmap( ( Up ) ? "bluezon" : "bluezoff" ) ); return; } it = it->nextSibling(); } } void OTManage::SLOT_DriverListChanged( ) { DriverLVI * It; QListViewItem * Sub; QListViewItem * First = 0; diff --git a/noncore/settings/networksettings2/opietooth2/config.in b/noncore/settings/networksettings2/opietooth2/config.in index 720f49a..084e8c0 100644 --- a/noncore/settings/networksettings2/opietooth2/config.in +++ b/noncore/settings/networksettings2/opietooth2/config.in @@ -1,5 +1,5 @@ config NS2OPIETOOTH - boolean "opie-networksettings2 bluetooth library" + boolean "Opietooth2 bluetooth library" default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE + depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBBLUEZ_DEP && NS2CORE diff --git a/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst b/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst index cd605c2..2713c61 100755 --- a/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst +++ b/noncore/settings/networksettings2/opietooth2/libopietooth2.postinst @@ -1,10 +1,10 @@ #!/bin/sh QTPB=/opt/QtPalmtop/bin [ ! -L ${QTPB}/networksettings2-opietooth ] && ln -sf ${QTPB}/networksettings2 ${QTPB}/networksettings2-opietooth # qcop QPE/Taskbar "linkChanged(opietooth)" -qcop QPE/Taskbar "reloadApps()" +${QTPB}/qcop QPE/Taskbar "reloadApps()" exit 0 diff --git a/noncore/settings/networksettings2/opietooth2/opietooth2.pro b/noncore/settings/networksettings2/opietooth2/opietooth2.pro index e0057a9..16277cf 100644 --- a/noncore/settings/networksettings2/opietooth2/opietooth2.pro +++ b/noncore/settings/networksettings2/opietooth2/opietooth2.pro @@ -14,24 +14,31 @@ HEADERS = OTDevice.h \ OTSDPService.h \ OTPeer.h \ Opietooth.h SOURCES = OTDevice.cpp \ OTDriver.cpp \ OTDriverList.cpp \ OTHCISocket.cpp \ OTInquiry.cpp \ OTDeviceAddress.cpp \ OTUUID.cpp \ OTSDPAttribute.cpp \ OTSDPService.cpp \ OTIcons.cpp \ OTPeer.cpp \ OTGateway.cpp \ Opietooth.cpp INCLUDEPATH += $(OPIEDIR)/include ../networksettings2 DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -lbluetooth -lnetworksettings2 INTERFACES = OTMainGUI.ui OTSniffGUI.ui OTScanGUI.ui OTManageGUI.ui OTPairingGUI.ui TARGET = opietooth2 VERSION = 1.0.0 include ( $(OPIEDIR)/include.pro ) + +!isEmpty( LIBBLUEZ_INC_DIR ) { + INCLUDEPATH += $$LIBBLUEZ_INC_DIR +} +!isEmpty( LIBBLUEZ_LIB_DIR ) { + LIBS += -L$$LIBBLUEZ_LIB_DIR +} |