-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 10 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bticonloader.cpp | 61 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bticonloader.h | 8 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btserviceitem.cpp | 3 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/btserviceitem.h | 1 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/stdpopups.cpp | 5 |
6 files changed, 52 insertions, 36 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 9cfeaa2..189001d 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -125,352 +125,360 @@ using namespace OpieTooth; void BlueBase::writeConfig() { Config cfg( "bluetoothmanager" ); cfg.setGroup( "bluezsettings" ); cfg.writeEntry( "name" , m_deviceName ); cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); cfg.writeEntry( "useEncryption" , m_useEncryption ); cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); cfg.writeEntry( "enablePagescan" , m_enablePagescan ); cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); writeToHciConfig(); } void BlueBase::writeToHciConfig() { HciConfWrapper hciconf ( "/tmp/hcid.conf" ); hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); // hciconf->setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); hciconf.setName( m_deviceName ); hciconf.setEncrypt( m_useEncryption ); hciconf.setAuth( m_enableAuthentification ); hciconf.setPscan( m_enablePagescan ); hciconf.setIscan( m_enableInquiryscan ); } /** * Read the list of allready known devices * */ void BlueBase::readSavedDevices() { QValueList<RemoteDevice> loadedDevices; QDir deviceListSave( QDir::homeDirPath() + "/Settings/bluetooth/"); // list of .conf files QStringList devicesFileList = deviceListSave.entryList(); // cut .conf of to get the mac and also read the name entry in it. for ( QStringList::Iterator it = devicesFileList.begin(); it != devicesFileList.end(); ++it ) { QString name; QString mac; qDebug((*it).latin1() ); Config conf((*it)); conf.setGroup("Info"); name = conf.readEntry("name", "Error"); qDebug("MAC: " + mac); qDebug("NAME: " + name); RemoteDevice currentDevice( mac , name ); loadedDevices.append( currentDevice ); } addSearchedDevices( loadedDevices ); } /** * Write the list of allready known devices * */ void BlueBase::writeSavedDevices() { QListViewItemIterator it( ListView2 ); BTListItem* item; BTDeviceItem* device; for ( ; it.current(); ++it ) { item = (BTListItem*)it.current(); if(item->typeId() != BTListItem::Device ) continue; device = (BTDeviceItem*)item; // seperate config file for each device, to store more information in future. qDebug( "/Settings/bluetooth/" + device->mac() + ".conf"); Config conf( QDir::homeDirPath() + "/Settings/bluetooth/" + device->mac() + ".conf", Config::File ); conf.setGroup( "Info" ); conf.writeEntry( "name", device->name() ); } } /** * Set up the gui */ void BlueBase::initGui() { StatusLabel->setText( status() ); // maybe move it to getStatus() cryptCheckBox->setChecked( m_useEncryption ); authCheckBox->setChecked( m_enableAuthentification ); pagescanCheckBox->setChecked( m_enablePagescan ); inquiryscanCheckBox->setChecked( m_enableInquiryscan ); deviceNameLine->setText( m_deviceName ); passkeyLine->setText( m_defaultPasskey ); // set info tab setInfo(); } /** * Get the status informations and returns it * @return QString the status informations gathered */ QString BlueBase::status()const{ QString infoString = tr( "<b>Device name : </b> Ipaq" ); infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); return (infoString); } /** * Read the current values from the gui and invoke writeConfig() */ void BlueBase::applyConfigChanges() { m_deviceName = deviceNameLine->text(); m_defaultPasskey = passkeyLine->text(); m_useEncryption = cryptCheckBox->isChecked(); m_enableAuthentification = authCheckBox->isChecked(); m_enablePagescan = pagescanCheckBox->isChecked(); m_enableInquiryscan = inquiryscanCheckBox->isChecked(); writeConfig(); QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); } /** * Add fresh found devices from scan dialog to the listing * */ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { BTDeviceItem * deviceItem; QValueList<RemoteDevice>::ConstIterator it; for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { deviceItem = new BTDeviceItem( ListView2 , (*it) ); deviceItem->setExpandable ( true ); // look if device is avail. atm, async deviceActive( (*it) ); // ggf auch hier? addServicesToDevice( deviceItem ); } } /** * Action that is toggled on entrys on click */ void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { } /** * Action that are toggled on hold (mostly QPopups i guess) */ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { QPopupMenu *menu = new QPopupMenu(); int ret=0; if ( ((BTListItem*)item)->type() == "device") { QPopupMenu *groups = new QPopupMenu(); menu->insertItem( tr("rescan sevices:"), 0); menu->insertItem( tr("to group"), groups , 1); menu->insertItem( tr("bound device"), 2); menu->insertItem( tr("delete"), 3); ret = menu->exec( point , 0); switch(ret) { case 0: break; case 1: break; case 2: // make connection break; case 3: // delete childs too delete item; break; } delete groups; } else if ( ((BTListItem*)item)->type() == "service") { + menu->insertItem( tr("Test1:"), 0); menu->insertItem( tr("connect"), 1); menu->insertItem( tr("delete"), 2); ret = menu->exec( point , 0); switch(ret) { case 0: break; case 1: break; case 2: // delete childs too delete item; break; } } delete menu; } /** * Search and display avail. services for a device (on expand from device listing) * */ void BlueBase::addServicesToDevice( BTDeviceItem * item ) { qDebug("addServicesToDevice"); // row of mac adress text(3) RemoteDevice device = item->remoteDevice(); m_deviceList.insert( item->mac() , item ); // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back m_localDevice->searchServices( device ); } /** * Overloaded. This one it the one that is connected to the foundServices signal * @param device the mac address of the remote device * @param servicesList the list with the service the device has. */ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { qDebug("fill services list"); QMap<QString,BTDeviceItem*>::Iterator it; BTDeviceItem* deviceItem = 0; // get the right devices which requested the search it = m_deviceList.find( device ); if( it == m_deviceList.end() ) return; deviceItem = it.data(); QValueList<OpieTooth::Services>::Iterator it2; BTServiceItem * serviceItem; if (!servicesList.isEmpty() ) { // add services + QMap<int, QString> list; + QMap<int, QString>::Iterator classIt; for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { serviceItem = new BTServiceItem( deviceItem , (*it2) ); - serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( (*it2).classIdList() ) ); + list = (*it2).classIdList(); + classIt = list.begin(); + int classId; + if ( classIt != list.end() ) + classId = classIt.key(); + serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); } } else { Services s1; s1.setServiceName( tr("no serives found") ); serviceItem = new BTServiceItem( deviceItem, s1 ); } // now remove them from the list m_deviceList.remove( it ); } /** * Add the existing connections (pairs) to the connections tab. * This one triggers the search */ void BlueBase::addConnectedDevices() { m_localDevice->searchConnections(); } void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { QValueList<OpieTooth::ConnectionState>::Iterator it; BTConnectionItem * connectionItem; if ( !connectionList.isEmpty() ) { for (it = connectionList.begin(); it != connectionList.end(); ++it) { connectionItem = new BTConnectionItem( ListView4 , (*it) ); } } else { ConnectionState con; con.setMac( tr("No connections found") ); connectionItem = new BTConnectionItem( ListView4 , con ); } // recall connection search after some time QTimer::singleShot( 20000, this, SLOT( addConnectedDevices() ) ); } /** * Find out if a device can currently be reached */ void BlueBase::deviceActive( const RemoteDevice &device ) { // search by mac, async, gets a signal back // We should have a BTDeviceItem there or where does it get added to the map -zecke m_localDevice->isAvailable( device.mac() ); } /** * The signal catcher. Set the avail. status on device. * @param device - the mac address * @param connected - if it is avail. or not */ void BlueBase::deviceActive( const QString& device, bool connected ) { qDebug("deviceActive slot"); QMap<QString,BTDeviceItem*>::Iterator it; it = m_deviceList.find( device ); if( it == m_deviceList.end() ) return; BTDeviceItem* deviceItem = it.data(); if ( connected ) { deviceItem->setPixmap( 1, m_onPix ); } else { deviceItem->setPixmap( 1, m_offPix ); } m_deviceList.remove( it ); } /** * Open the "scan for devices" dialog */ void BlueBase::startScan() { ScanDialog *scan = new ScanDialog( this, "ScanDialog", true, WDestructiveClose ); QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); scan->showMaximized(); } /** * Set the informations about the local device in information Tab */ void BlueBase::setInfo() { StatusLabel->setText( status() ); } /** * Decontructor */ BlueBase::~BlueBase() { writeSavedDevices(); delete m_iconLoader; } diff --git a/noncore/net/opietooth/manager/bticonloader.cpp b/noncore/net/opietooth/manager/bticonloader.cpp index 3fb0edd..f299117 100644 --- a/noncore/net/opietooth/manager/bticonloader.cpp +++ b/noncore/net/opietooth/manager/bticonloader.cpp @@ -1,77 +1,78 @@ #include "bticonloader.h" #include <qpixmap.h> #include <qpe/resource.h> namespace OpieTooth { BTIconLoader::BTIconLoader() { // still need to find out real ids - deviceIcons.insert( "100" , "computer_16" ); - deviceIcons.insert( "101" , "phone_16" ); - deviceIcons.insert( "102" , "brain_16" ); - deviceIcons.insert( "103" , "conduit_16" ); - - - serviceIcons.insert( "0x1105" , "obex_16" ); //OBEXObjectPush - serviceIcons.insert( "0x1106" , "obex_16" ); //OBEXFileTransfer - serviceIcons.insert( "0x1111" , "print_16" ); //Fax - serviceIcons.insert( "0x1101" , "serial_16" ); //SerialPort - serviceIcons.insert( "0x1104" , "sync_16" ); //IrMCSync - serviceIcons.insert( "0x1107" , "sync_16" ); //IrMCSyncCommand - serviceIcons.insert( "0x1102" , "network_16" ); //LANAccessUsingPPP - serviceIcons.insert( "0x1103" , "network_16"); //DialupNetworking - serviceIcons.insert( "0x1108" , "phone_16"); // Headset - serviceIcons.insert( "0x1112" , "audio_16"); //HeadsetAudioGateway - serviceIcons.insert( "0x1109" , "phone_16"); // CordlessTelephony - serviceIcons.insert( "0x110A" , "audio_16"); // AudioSource - serviceIcons.insert( "0x110B" , "audio_16"); // AudioSink - serviceIcons.insert( "0x1126" , "print_16" ); //HCR_Print - serviceIcons.insert( "0x1128" , "phone_16" ); //Common_ISDN_Access - - serviceIcons.insert( "0x1201" , "network_16" ); //GenericNetworking - serviceIcons.insert( "0x1202" , "folder_16" ); //GenericFileTransfer - serviceIcons.insert( "0x1128" , "audio_16" ); //GenericAudio - serviceIcons.insert( "0x1128" , "phone_16" ); //GenericTelephony + deviceIcons.insert( 100 , "computer_16" ); + deviceIcons.insert( 101 , "phone_16" ); + deviceIcons.insert( 102 , "brain_16" ); + deviceIcons.insert( 103 , "conduit_16" ); + + + serviceIcons.insert( 4357 , "obex_16" ); //OBEXObjectPush + serviceIcons.insert( 4358 , "obex_16" ); //OBEXFileTransfer + serviceIcons.insert( 4369 , "print_16" ); //Fax + serviceIcons.insert( 4353 , "serial_16" ); //SerialPort + serviceIcons.insert( 4356 , "sync_16" ); //IrMCSync + serviceIcons.insert( 4359 , "sync_16" ); //IrMCSyncCommand + serviceIcons.insert( 4354 , "network_16" ); //LANAccessUsingPPP + serviceIcons.insert( 4355 , "network_16"); //DialupNetworking + serviceIcons.insert( 4360 , "phone_16"); // Headset + serviceIcons.insert( 4370 , "audio_16"); //HeadsetAudioGateway + serviceIcons.insert( 4361 , "phone_16"); // CordlessTelephony + serviceIcons.insert( 4362 , "audio_16"); // AudioSource + serviceIcons.insert( 4363 , "audio_16"); // AudioSink + serviceIcons.insert( 4390 , "print_16" ); //HCR_Print + serviceIcons.insert( 4392 , "phone_16" ); //Common_ISDN_Access + + serviceIcons.insert( 4609 , "network_16" ); //GenericNetworking + serviceIcons.insert( 4610 , "folder_16" ); //GenericFileTransfer + serviceIcons.insert( 4392 , "audio_16" ); //GenericAudio + // serviceIcons.insert( 4392 , "phone_16" ); //GenericTelephony + // the above is duplicated? -zecke //serviceIcons.insert( "106" , "link_16" ); //serviceIcons.insert( "107" , "misc_16" ); } BTIconLoader::~BTIconLoader() { } - QPixmap BTIconLoader::deviceIcon( const QString &deviceClass ) { + QPixmap BTIconLoader::deviceIcon( int deviceClass ) { QString iconName; - QMap<QString, QString>::Iterator it; + QMap<int, QString>::Iterator it; it = deviceIcons.find( deviceClass ); iconName = it.data(); if ( iconName.isEmpty() ) { iconName = "unknown_16"; } return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); } - QPixmap BTIconLoader::serviceIcon( const QString &serviceClass ) { + QPixmap BTIconLoader::serviceIcon( int serviceClass ) { QString iconName; - QMap<QString, QString>::Iterator it; + QMap<int, QString>::Iterator it; it = deviceIcons.find( serviceClass ); iconName = it.data(); if ( iconName.isEmpty() ) { iconName = "unknown_16"; } return( Resource::loadPixmap( "opietooth/icons/" + iconName ) ); } } diff --git a/noncore/net/opietooth/manager/bticonloader.h b/noncore/net/opietooth/manager/bticonloader.h index 1b48009..9951c4c 100644 --- a/noncore/net/opietooth/manager/bticonloader.h +++ b/noncore/net/opietooth/manager/bticonloader.h @@ -1,37 +1,37 @@ #ifndef BTICONLOADER_H #define BTICONLOADER_H #include <qpixmap.h> #include <qmap.h> namespace OpieTooth { class BTIconLoader { public: BTIconLoader(); ~BTIconLoader(); /** * Returns an icon depending on device class * @param deviceClass the device class id * @return the pixmap */ - QPixmap deviceIcon( const QString &deviceClass ); + QPixmap deviceIcon( int ); /** * Returns an icon depending on service id * @param serviceClass the service id * @return the pixmap */ - QPixmap serviceIcon( const QString &serviceClass ); + QPixmap serviceIcon( int ); private: // first ist id, second is icon name - QMap<QString,QString> deviceIcons; - QMap<QString,QString> serviceIcons; + QMap<int,QString> deviceIcons; + QMap<int,QString> serviceIcons; }; } #endif diff --git a/noncore/net/opietooth/manager/btserviceitem.cpp b/noncore/net/opietooth/manager/btserviceitem.cpp index 352e793..7db93c9 100644 --- a/noncore/net/opietooth/manager/btserviceitem.cpp +++ b/noncore/net/opietooth/manager/btserviceitem.cpp @@ -1,23 +1,26 @@ #include <qobject.h> #include "btserviceitem.h" using namespace OpieTooth; BTServiceItem::BTServiceItem( QListViewItem* item, const Services& serv ) : BTListItem( item ) { m_service = serv; setText(0, QObject::tr(serv.serviceName() ) ); } BTServiceItem::~BTServiceItem() { } QString BTServiceItem::type() const { return QString::fromLatin1("service"); } int BTServiceItem::typeId() const { return Service; } Services BTServiceItem::services() const { return m_service; } +int BTServiceItem::serviceId() const { + return m_service.recHandle(); +}; diff --git a/noncore/net/opietooth/manager/btserviceitem.h b/noncore/net/opietooth/manager/btserviceitem.h index 6dbd8f1..625a5f7 100644 --- a/noncore/net/opietooth/manager/btserviceitem.h +++ b/noncore/net/opietooth/manager/btserviceitem.h @@ -1,26 +1,27 @@ #ifndef OPIE_TOOTH_BT_SERVICE_ITEM #define OPIE_TOOTH_BT_SERVICE_ITEM #include <services.h> #include "btlistitem.h" namespace OpieTooth { class BTServiceItem : public BTListItem { public: BTServiceItem( QListViewItem* item, const Services& ); ~BTServiceItem(); QString type() const; int typeId() const; Services services() const; + int serviceId() const; private: Services m_service; }; }; #endif diff --git a/noncore/net/opietooth/manager/stdpopups.cpp b/noncore/net/opietooth/manager/stdpopups.cpp index 43a0f62..f462368 100644 --- a/noncore/net/opietooth/manager/stdpopups.cpp +++ b/noncore/net/opietooth/manager/stdpopups.cpp @@ -1,10 +1,13 @@ +//#include "rfccompopup.h" + #include "stdpopups.h" -QPopupMenu* newRfcComPopup( const OpieTooth::Services&, QListViewItem* ) { +QPopupMenu* newRfcComPopup( const OpieTooth::Services& servive, QListViewItem* item ) { + // return OpieTooth::RfcComPopup( servive, item ); return 0l; } QPopupMenu* newObexPushPopup( const OpieTooth::Services&, QListViewItem* ) { return 0l; } |