summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp62
-rw-r--r--noncore/net/opietooth/manager/popuphelper.cpp2
2 files changed, 47 insertions, 17 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 189001d..3f2f138 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -64,66 +64,68 @@ using namespace OpieTooth;
this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) );
connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ),
this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) );
connect( m_localDevice, SIGNAL( available( const QString&, bool ) ),
this, SLOT( deviceActive( const QString& , bool ) ) );
connect( m_localDevice, SIGNAL( connections( Connection::ValueList ) ),
this, SLOT( addConnectedDevices( Connection::ValueList ) ) );
//Load all icons needed
m_offPix = Resource::loadPixmap( "editdelete" );
m_onPix = Resource::loadPixmap( "installed" );
QPalette pal = this->palette();
QColor col = pal.color( QPalette::Active, QColorGroup::Background );
pal.setColor( QPalette::Active, QColorGroup::Button, col );
pal.setColor( QPalette::Inactive, QColorGroup::Button, col );
pal.setColor( QPalette::Normal, QColorGroup::Button, col );
pal.setColor( QPalette::Disabled, QColorGroup::Button, col );
this->setPalette( pal );
setCaption( tr( "Bluetooth Manager" ) );
readConfig();
initGui();
//TESTING
ListView2->setRootIsDecorated(true);
BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) );
topLV2->setPixmap( 1, m_onPix );
Services s1;
s1.setServiceName( "Serial" );
+ s1.insertClassId(1, "BlueNic");
(void) new BTServiceItem( topLV2, s1 );
s1.setServiceName( "BlueNic" );
+ s1.insertClassId(2, "Obex");
(void) new BTServiceItem( topLV2, s1 );
writeToHciConfig();
// search conncetions
addConnectedDevices();
m_iconLoader = new BTIconLoader();
}
/**
* Reads all options from the config file
*/
void BlueBase::readConfig() {
Config cfg( "bluetoothmanager" );
cfg.setGroup( "bluezsettings" );
m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with
m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak
m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE );
m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE );
m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE );
m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE );
}
/**
* Writes all options to the config file
*/
void BlueBase::writeConfig() {
Config cfg( "bluetoothmanager" );
cfg.setGroup( "bluezsettings" );
@@ -270,95 +272,121 @@ using namespace OpieTooth;
// 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:
+ case -1:
+
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
+ }
+ /**
+ * We got service sensitive PopupMenus in our factory
+ * We will create one through the factory and will insert
+ * our Separator + ShowInfo into the menu or create a new
+ * one if the factory returns 0
+ * PopupMenu deletion is kind of weird.
+ * If escaped( -1 ) or any of our items were chosen we'll
+ * delete the PopupMenu otherwise it's the responsibility of
+ * the PopupMenu to delete itself
+ *
+ */
+ else if ( ((BTListItem*)item)->type() == "service") {
+ BTServiceItem* service = (BTServiceItem*)item;
+ QMap<int, QString> list = service->services().classIdList();
+ QMap<int, QString>::Iterator it = list.begin();
+ QPopupMenu *popup =0l;
+ if ( it != list.end() )
+ popup = m_popHelper.find( it.key(),
+ service->services(),
+ service->parent() );
+
+ if ( popup == 0l ) {
+ qWarning("factory returned 0l");
+ popup = new QPopupMenu();
+ }
+
+ int test1 = popup->insertItem( tr("Test1:"), 0);
+ int con = popup->insertItem( tr("connect"), 1);
+ int del = popup->insertItem( tr("delete"), 2);
+
+ ret = popup->exec( point );
+
+ if ( ret == -1 )
+ delete popup;
+ else if ( ret == test1 )
+ delete popup;
+ else if ( ret == con )
+ delete popup;
+ else if ( ret == del ) {
+ // take item first? -zecke
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 );
diff --git a/noncore/net/opietooth/manager/popuphelper.cpp b/noncore/net/opietooth/manager/popuphelper.cpp
index d8404d6..26c4b02 100644
--- a/noncore/net/opietooth/manager/popuphelper.cpp
+++ b/noncore/net/opietooth/manager/popuphelper.cpp
@@ -1,28 +1,30 @@
#include "stdpopups.h"
#include "popuphelper.h"
using namespace OpieTooth;
PopupHelper::PopupHelper() {
init();
}
PopupHelper::~PopupHelper() {
}
void PopupHelper::insert( int id, popupFactory fact ) {
m_map.insert(id, fact );
}
QPopupMenu* PopupHelper::find( int id, const Services& ser, QListViewItem* item ) {
+ qWarning("find");
FactoryMap::Iterator it = m_map.find(id );
if ( it != m_map.end() ) {
+ qWarning("found");
popupFactory fact = it.data();
return (*fact)(ser, item);
}
return 0l;
}
void PopupHelper::init() {
insert( 1, newRfcComPopup );
insert(2, newObexPushPopup );
}