-rw-r--r-- | noncore/multimedia/opieplayer2/playlistselection.cpp | 35 | ||||
-rw-r--r-- | noncore/settings/networksettings2/editconnection.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/networksettings2/opietooth2/Opietooth.cpp | 2 |
3 files changed, 14 insertions, 28 deletions
diff --git a/noncore/multimedia/opieplayer2/playlistselection.cpp b/noncore/multimedia/opieplayer2/playlistselection.cpp index 678ebdf..780d705 100644 --- a/noncore/multimedia/opieplayer2/playlistselection.cpp +++ b/noncore/multimedia/opieplayer2/playlistselection.cpp @@ -1,211 +1,196 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "playlistselection.h" /* OPIE */ #include <opie2/odebug.h> using namespace Opie::Core; /* QT */ #include <qheader.h> /* STD */ #include <stdlib.h> class PlayListSelectionItem : public QListViewItem { public: PlayListSelectionItem( QListView *parent, const DocLnk *f ) : QListViewItem( parent ), fl( f ) { setText( 0, f->name() ); setPixmap( 0, f->pixmap() ); } ~PlayListSelectionItem() { }; const DocLnk *file() const { return fl; } private: const DocLnk *fl; }; PlayListSelection::PlayListSelection( QWidget *parent, const char *name ) : QListView( parent, name ) { // odebug << "starting playlistselector" << oendl; -// #ifdef USE_PLAYLIST_BACKGROUND -// setStaticBackground( TRUE ); -// setBackgroundPixmap( Resource::loadPixmap( "opieplayer/background" ) ); - -// setBackgroundPixmap( Resource::loadPixmap( "launcher/opielogo" ) ); -// #endif -// addColumn("Title",236); -// setAllColumnsShowFocus( TRUE ); addColumn( tr( "Playlist Selection" ) ); header()->hide(); setSorting( -1, FALSE ); } PlayListSelection::~PlayListSelection() { } -// #ifdef USE_PLAYLIST_BACKGROUND void PlayListSelection::drawBackground( QPainter *p, const QRect &r ) { // odebug << "drawBackground" << oendl; p->fillRect( r, QBrush( white ) ); -// QImage logo = Resource::loadImage( "launcher/opielogo" ); -// if ( !logo.isNull() ) -// p->drawImage( (width() - logo.width()) / 2, (height() - logo.height()) / 2, logo ); } -// #endif void PlayListSelection::contentsMouseMoveEvent( QMouseEvent *event ) { if ( event->state() == QMouseEvent::LeftButton ) { QListViewItem *currentItem = selectedItem(); QListViewItem *itemUnder = itemAt( QPoint( event->pos().x(), event->pos().y() - contentsY() ) ); if ( currentItem && currentItem->itemAbove() == itemUnder ) moveSelectedUp(); else if ( currentItem && currentItem->itemBelow() == itemUnder ) moveSelectedDown(); } } const DocLnk *PlayListSelection::current() { PlayListSelectionItem *item = (PlayListSelectionItem *)selectedItem(); if ( item ) - return item->file(); + return item->file(); return NULL; } void PlayListSelection::addToSelection( const DocLnk &lnk ) { PlayListSelectionItem *item = new PlayListSelectionItem( this, new DocLnk( lnk ) ); QListViewItem *current = selectedItem(); if ( current ) item->moveItem( current ); setSelected( item, TRUE ); ensureItemVisible( selectedItem() ); } void PlayListSelection::removeSelected() { QListViewItem *item = selectedItem(); delete item; setSelected( currentItem(), TRUE ); ensureItemVisible( selectedItem() ); } void PlayListSelection::moveSelectedUp() { QListViewItem *item = selectedItem(); if ( item && item->itemAbove() ) - item->itemAbove()->moveItem( item ); + item->itemAbove()->moveItem( item ); ensureItemVisible( selectedItem() ); } void PlayListSelection::moveSelectedDown() { QListViewItem *item = selectedItem(); if ( item && item->itemBelow() ) item->moveItem( item->itemBelow() ); ensureItemVisible( selectedItem() ); } bool PlayListSelection::prev() { QListViewItem *item = selectedItem(); if ( item && item->itemAbove() ) setSelected( item->itemAbove(), TRUE ); else - return FALSE; + return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } bool PlayListSelection::next() { QListViewItem *item = selectedItem(); if ( item && item->itemBelow() ) setSelected( item->itemBelow(), TRUE ); else - return FALSE; + return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } bool PlayListSelection::first() { QListViewItem *item = firstChild(); if ( item ) setSelected( item, TRUE ); else - return FALSE; + return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } bool PlayListSelection::last() { QListViewItem *prevItem = NULL; QListViewItem *item = firstChild(); while ( ( item = item->nextSibling() ) ) - prevItem = item; + prevItem = item; if ( prevItem ) setSelected( prevItem, TRUE ); else - return FALSE; + return FALSE; ensureItemVisible( selectedItem() ); return TRUE; } void PlayListSelection::unSelect() { - //QListViewItem *item = selectedItem(); setSelected( currentItem(), FALSE); } void PlayListSelection::writeCurrent( Config& cfg ) { cfg.setGroup("PlayList"); QListViewItem *item = selectedItem(); - if ( item ) + if ( item ) { cfg.writeEntry("current", item->text(0) ); - odebug << item->text(0) << oendl; + odebug << item->text(0) << oendl; + } } void PlayListSelection::setSelectedItem(const QString &strk ) { unSelect(); QListViewItemIterator it( this ); for ( ; it.current(); ++it ) { // odebug << it.current()->text(0) << oendl; if( strk == it.current()->text(0)) { // odebug << "We have a match "+strk << oendl; setSelected( it.current(), TRUE); ensureItemVisible( it.current() ); return; } } -// setSelected( item, TRUE ); -// ensureItemVisible( selectedItem() ); } diff --git a/noncore/settings/networksettings2/editconnection.cpp b/noncore/settings/networksettings2/editconnection.cpp index a9bef65..d948fb9 100644 --- a/noncore/settings/networksettings2/editconnection.cpp +++ b/noncore/settings/networksettings2/editconnection.cpp @@ -1,646 +1,647 @@ #include <opie2/odebug.h> #include <qlistview.h> #include <qwidgetstack.h> #include <qframe.h> #include <qcombobox.h> #include <qtabwidget.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qheader.h> #include <qpainter.h> #include <qcheckbox.h> #include <qlabel.h> #include "editconnection.h" #include "resources.h" #include "netnode.h" // // // THESE TO GIVE BETTER FEEDBACK ABOUT DISABLED ITEMS // // class MyQCheckListItem : public QCheckListItem { public: MyQCheckListItem( QListView *parent, const QString & S, Type T ) : QCheckListItem( parent, S, T ) { } MyQCheckListItem( QCheckListItem *parent, const QString & S, Type T ) : QCheckListItem( parent, S, T ) { } MyQCheckListItem( QListViewItem *parent, const QString & S, Type T ) : QCheckListItem( parent, S, T ) { } MyQCheckListItem( QListView *parent, const QString & S ) : QCheckListItem( parent, S, QCheckListItem::Controller ) { } MyQCheckListItem( QCheckListItem *parent, const QString & S ) : QCheckListItem( parent, S, QCheckListItem::Controller ) { } MyQCheckListItem( QListViewItem *parent, const QString & S ) : QCheckListItem( parent, S, QCheckListItem::Controller ) { } virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); }; void MyQCheckListItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) { QColorGroup _cg( cg ); QColor c = _cg.text(); if ( ! isSelectable() ) _cg.setColor( QColorGroup::Text, Qt::lightGray ); QCheckListItem::paintCell( p, _cg, column, width, alignment ); _cg.setColor( QColorGroup::Text, c ); } class MyQListViewItem : public QListViewItem { public: MyQListViewItem( QListView *parent, const QString & S ) : QListViewItem( parent, S ) { } MyQListViewItem( QListViewItem *parent, const QString & S ) : QListViewItem( parent, S ) { } virtual void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); }; void MyQListViewItem::paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ) { QColorGroup _cg( cg ); QColor c = _cg.text(); if ( ! isSelectable() ) _cg.setColor( QColorGroup::Text, Qt::lightGray ); QListViewItem::paintCell( p, _cg, column, width, alignment ); _cg.setColor( QColorGroup::Text, c ); } // // // REAL GUI // // bool EditNetworkSetup::AutoCollapse = 1; EditNetworkSetup::EditNetworkSetup( QWidget* parent ) : EditNetworkSetupGUI( parent, 0, TRUE ), TmpCollection() { Tab_TB->setTabEnabled( Setup_FRM, FALSE ); Setup_FRM->setEnabled( FALSE ); TmpIsValid = 0; SelectedNodes = 0; AutoCollapse_CB->setChecked( AutoCollapse ); Mapping = new QPtrDict<ANetNode>; Mapping->setAutoDelete( FALSE ); Nodes_LV->header()->hide(); // popluate tree with all NetNodes buildFullTree(); } NetworkSetup * EditNetworkSetup::getTmpCollection( void ) { if( TmpIsValid ) // content is stil OK return &(TmpCollection); // reset collection -> delete all NEW NetNodes for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { if( it.current()->isNew() ) { delete it.current(); } } TmpCollection.clear(); if( SelectedNodes ) { // initialize like original TmpCollection.copyFrom( *SelectedNodes ); } // update content QListViewItem * it = Nodes_LV->firstChild(); ANetNode * NN; // start iter (if there is a collection) /* a node collection is sorted from the toplevel node to the deepest node */ ANetNodeInstance * NNI = (SelectedNodes) ? SelectedNodes->first() : 0 ; TmpCollection.setModified( 0 ); // the listview always starts with the toplevel // hierarchy. This is always a controller item while ( it ) { NN = (*Mapping)[it]; if( NN == 0 ) { // this item is a controller -> // has radio items as children -> // find selected one it = it->firstChild(); while( it ) { if( ((QCheckListItem *)it)->isOn() ) { // this radio is selected -> go deeper break; } it = it->nextSibling(); } if( ! it ) { TmpIsValid = 0; return 0; } // it now contains selected radio NN = (*Mapping)[it]; } // NN here contains the netnode of the // current item -> this node needs to // be stored in the collection if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { // new item not in previous collection ANetNodeInstance * NNI = NN->createInstance(); NNI->initialize(); // this node type not in collection TmpCollection.append( NNI ); // master collection changed because new item in it TmpCollection.setModified( 1 ); // no more valid items in old list NNI = 0; } else { // already in list -> copy pointer TmpCollection.append( NNI ); NNI = SelectedNodes->next(); } // go deeper to next level // this level is can be a new controller // or an item it = it->firstChild(); } TmpIsValid = 1; return &(TmpCollection); } // pass a NetworkSetup NetworkSetup to be edited void EditNetworkSetup::setNetworkSetup( NetworkSetup * NC ) { ANetNodeInstance * NNI; ANetNode * NN; SelectedNodes = NC; Name_LE->setText( NC->name() ); NNI = NC->first(); // show configure tabl Tab_TB->setCurrentPage( 1 ); // valid colledction Tab_TB->setTabEnabled( Setup_FRM, FALSE ); Setup_FRM->setEnabled( FALSE ); // select items in collection QListViewItem * it = Nodes_LV->firstChild(); bool Found; TmpIsValid = 0; while ( it ) { NN = (*Mapping)[it]; if( NN == 0 ) { // this item is a controller -> // has radio items as children -> // find selected one it = it->firstChild(); Found = 0; while( it ) { if( NNI && it->text(0) == NNI->nodeClass()->name() ) { // this radio is part of the collection ((QCheckListItem *)it)->setOn( 1 ); updateGUI( it, NNI->nodeClass() ); // check its children Found = 1; it = it->firstChild(); NNI = SelectedNodes->next(); // do not bother to check other items break; } it = it->nextSibling(); } if( ! Found ) { // this means that this level is NOT present in collection - // probably INCOMPATIBEL collection OR Missing plugin + // probably INCOMPATIBLE collection OR Missing plugin + QString pluginName = NNI ? NNI->nodeClass()->name() : ""; QMessageBox::warning( 0, tr( "Error presentig NetworkSetup" ), tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). - arg(NNI->nodeClass()->name()) ); + arg(pluginName) ); return; } // it now contains selected radio NN = (*Mapping)[it]; } else { // automatic selection if( NNI == 0 || it->text(0) != NNI->nodeClass()->name() ) { // should exist and be the same if( NNI ) { QMessageBox::warning( 0, tr( "Error presentig NetworkSetup" ), tr( "<p>Old NetworkSetup or missing plugin \"<i>%1</i>\"</p>" ). arg(NNI->nodeClass()->name()) ); } else { QMessageBox::warning( 0, tr( "Error presentig NetworkSetup" ), tr( "<p>Missing NetworkSetup\"<i>%1</i>\"</p>" ). arg(it->text(0)) ); } return; } it = it->firstChild(); } } } // get result of editing (either new OR updated collection NetworkSetup * EditNetworkSetup::networkSetup( void ) { if( SelectedNodes == 0 ) { // new collection SelectedNodes = new NetworkSetup; } // clean out old entries SelectedNodes->clear(); // transfer for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { SelectedNodes->append( it.current() ); } if( TmpCollection.isModified() ) SelectedNodes->setModified( 1 ); if( SelectedNodes->name() != Name_LE->text() ) { SelectedNodes->setName( Name_LE->text() ); SelectedNodes->setModified( 1 ); } return SelectedNodes; } // Build device tree -> start void EditNetworkSetup::buildFullTree( void ) { ANetNode * NN; // toplevel item MyQCheckListItem * TheTop = new MyQCheckListItem( Nodes_LV, NSResources->netNode2Name("fullsetup"), QCheckListItem::Controller ); TheTop->setOpen( TRUE ); Description_LBL->setText( NSResources->netNode2Description( "fullsetup" ) ); Nodes_LV->setSelected( TheTop, TRUE ); // find all Nodes that are toplevel nodes -> ie provide // TCP/IP NetworkSetup for( QDictIterator<ANetNode> Iter(NSResources->netNodes()); Iter.current(); ++Iter ) { NN = Iter.current(); if( ! NN->isToplevel() ) { continue; } MyQCheckListItem * it = new MyQCheckListItem( TheTop, NN->name(), QCheckListItem::RadioButton ); it->setPixmap( 0, NSResources->getPixmap( NN->pixmapName() ) ); // remember that this node maps to this listitem Mapping->insert( it, NN ); buildSubTree( it, NN ); } } // Build device tree -> help function void EditNetworkSetup::buildSubTree( QListViewItem * it, ANetNode *NN ) { ANetNode::NetNodeList & NNL = NN->alternatives(); if( NNL.size() > 1 ) { // this node has alternatives -> needs radio buttons it = new MyQCheckListItem( it, NSResources->netNode2Name(NN->needs()[0]), QCheckListItem::Controller ); it->setSelectable( FALSE ); } for ( unsigned int i=0; i < NNL.size(); i++ ) { QListViewItem * CI; if( NNL.size() > 1 ) { // generate radio buttons CI = new MyQCheckListItem( (QCheckListItem *)it, NNL[i]->name(), QCheckListItem::RadioButton ); // remember that this node maps to this listitem CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); Mapping->insert( CI, NNL[i] ); CI->setSelectable( FALSE ); } else { // Single item CI = new MyQListViewItem( it, NNL[i]->name() ); // remember that this node maps to this listitem Mapping->insert( CI, NNL[i] ); CI->setSelectable( FALSE ); CI->setPixmap( 0, NSResources->getPixmap( NNL[i]->pixmapName() ) ); } buildSubTree( CI, NNL[i] ); } } // Clicked ok OK button void EditNetworkSetup::accept( void ) { if( ! haveCompleteConfig( 0 ) || Name_LE->text().isEmpty() ) { QMessageBox::warning( 0, tr( "Closing NetworkSetup Setup" ), tr( "Definition not complete or no name" ) ); return; } // check if all devices have acceptable input getTmpCollection(); { ANetNodeInstance * NNI; QString S; for( QListIterator<ANetNodeInstance> it(TmpCollection); it.current(); ++it ) { NNI = it.current(); // widget must show its own problems S = NNI->acceptable(); if( ! S.isEmpty() ) { QMessageBox::warning( 0, tr( "Cannot save" ), S ); return; } NNI->commit(); if( NNI->isModified() ) { TmpCollection.setModified( 1 ); // commit the data } } } QDialog::accept(); } // triggered by CB void EditNetworkSetup::SLOT_AutoCollapse( bool b ) { AutoCollapse = b; } // clicked on node in tree -> update GUI void EditNetworkSetup::SLOT_SelectNode( QListViewItem * it ) { ANetNode * NN; if( it == 0 || it->depth() == 0 ) { Description_LBL->setText( NSResources->netNode2Description( "fullsetup" ) ); // topevel or no selection return; } // store conversion from lvitem to node NN = (*Mapping)[ it ]; if( ! NN ) { // intermediate (controller) node NN = (*Mapping)[ it->parent() ]; if( NN ) { // figure out type of this node -> produce message Description_LBL->setText( NSResources->netNode2Description( NN->needs()[0]) ); } else { Description_LBL->setText( "" ); } return; } // clicked on regular node Description_LBL->setText( NN->nodeDescription() ); if( ! it->isSelectable() ) { return; } ANetNode::NetNodeList & NNL = NN->alternatives(); if( NNL.size() == 0 ) { // this item has no alternatives -> end node TmpIsValid = 0; updateGUI( it, NN ); return; } if( ! ((MyQCheckListItem *)it)->isOn() ) { // not clicked on Check or Radio item return; } // item has really changed -> update TmpIsValid = 0; updateGUI( it, NN ); } // cliecked on TAB to go to setup void EditNetworkSetup::SLOT_AlterTab( const QString & S ) { if( S == tr( "Setup" ) && Setup_FRM->isEnabled() ) { // switched to setup -> update CB and populate ws with // forms for devices if( ! TmpIsValid ) { getTmpCollection(); // clear CB and Ws { QWidget * W; int i = 0; Devices_CB->clear(); while( ( W = Setup_WS->widget( i ) ) ) { Setup_WS->removeWidget( W ); i ++; } } // update CB // and populate WidgetStack { ANetNodeInstance * NNI; QListIterator<ANetNodeInstance> it(TmpCollection); int i = 0; QWidget * W; for ( ; it.current(); ++it ) { NNI = it.current(); Devices_CB->insertItem( NSResources->getPixmap( NNI->nodeClass()->pixmapName() ), NNI->nodeClass()->name() ); // add edit widget W = NNI->edit( Setup_WS ); if( ! W) { W = new QLabel( Setup_WS, tr("No configuration required")); } Setup_WS->addWidget( W , i ); i ++; } } Setup_WS->raiseWidget( 0 ); } // still valid } } // update visual feedback of selection state void EditNetworkSetup::updateGUI( QListViewItem * it, ANetNode * NN ) { bool HCC = haveCompleteConfig( it ); Tab_TB->setTabEnabled( Setup_FRM, HCC ); Log(( "COMPLETE CONFIG %d\n", HCC )); Setup_FRM->setEnabled( HCC ); // disable children of all siblings at same level QListViewItem * Sbl = it->parent()->firstChild(); while( Sbl ) { if ( Sbl != it ) { disableTree( Sbl->firstChild(), FALSE ); Sbl->setSelectable( TRUE ); if( AutoCollapse ) Sbl->setOpen( FALSE ); } Sbl = Sbl->nextSibling(); } // enable selected path (as deep as it goes it->setOpen( TRUE ); enablePath( it->firstChild(), (it->depth()==1) ? 1 : // toplevel always alternatives (NN->alternatives().size() > 1) ); } void EditNetworkSetup::disableTree( QListViewItem * it, bool Mode ) { while( it ) { // disable sbl's chidren it->setSelectable( Mode ); if( AutoCollapse ) it->setOpen( Mode ); disableTree( it->firstChild(), Mode ); it = it->nextSibling(); } } // pah : ParentHasAlternatives void EditNetworkSetup::enablePath( QListViewItem * it, bool pha ) { while( it ) { ANetNode * NN; NN = (*Mapping)[it]; if( NN ) { if( pha ) { bool doOn = ((QCheckListItem *)it)->isOn(); // we are a checklistitem for sure it->setSelectable( TRUE ); if( AutoCollapse && ! doOn ) it->setOpen( doOn ); if( doOn ) { // selected alternative enablePath( it->firstChild(), NN->alternatives().size() > 1); } else { // non-selected alternative disableTree( it->firstChild(), FALSE); } } else { // we are single subitem it->setSelectable( TRUE ); it->setOpen( TRUE ); enablePath( it->firstChild(), NN->alternatives().size() > 1); } } else { // controller node it->setSelectable( TRUE ); it->setOpen( TRUE ); enablePath( it->firstChild(), pha ); } it = it->nextSibling(); } } // do we have a complete configuration (all needs are provided for ?) bool EditNetworkSetup::haveCompleteConfig( QListViewItem * it ) { // check if all below this level is selected it = ( it ) ?it : Nodes_LV->firstChild(); ANetNode *NN; bool Found; while ( it ) { NN = (*Mapping)[it]; if( NN == 0 ) { // this item is a controller -> // has radio items as children -> // find selected one it = it->firstChild(); Found = 0; while( it ) { if( ((QCheckListItem *)it)->isOn() ) { Found = 1; // go deeper it = it->firstChild(); break; } it = it->nextSibling(); } if( ! Found ) { Log(( "Setup not complete\n" )); return 0; // no not complete -> a radio should have been chkd } // it now contains selected radio NN = (*Mapping)[it]; } else { // automatic selection it = it->firstChild(); } } return 1; } diff --git a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp index fc30bf8..e23fc9c 100644 --- a/noncore/settings/networksettings2/opietooth2/Opietooth.cpp +++ b/noncore/settings/networksettings2/opietooth2/Opietooth.cpp @@ -1,1175 +1,1175 @@ #include <opie2/odebug.h> #include <opie2/oledbox.h> #include <opie2/ofiledialog.h> using namespace Opie::Core; using namespace Opie::Ui; #include <qpe/resource.h> #include <qapplication.h> #include <qcheckbox.h> #include <qcombobox.h> #include <qdialog.h> #include <qdir.h> #include <qfile.h> #include <qgroupbox.h> #include <qheader.h> #include <qlabel.h> #include <qlayout.h> #include <qlistbox.h> #include <qlistview.h> #include <qmessagebox.h> #include <qprogressbar.h> #include <qpushbutton.h> #include <qscrollbar.h> #include <qtextstream.h> #include <qtextview.h> #include <Opietooth.h> #include <OTDriver.h> #include <OTPeer.h> #include <OTGateway.h> #include <OTSDPAttribute.h> #include <OTSDPService.h> #include <OTInquiry.h> #include <system.h> using namespace Opietooth2; namespace Opietooth2 { class PeerLVI : public QListViewItem { public : PeerLVI( OTPeer * P, QListView * it ) : QListViewItem (it) { Peer = P; } ~PeerLVI( void ) { } inline OTPeer * peer( void ) { return Peer; } private : OTPeer * Peer; }; class ChannelLVI : public QListViewItem { public : ChannelLVI( int Ch, QListViewItem * it ) : QListViewItem (it) { Channel = Ch; } ~ChannelLVI( void ) { } inline int channel( void ) { return Channel; } private : int Channel; }; class DriverLVI : public QListViewItem { public : DriverLVI( OTDriver * P, QListView * it ) : QListViewItem (it) { Driver = P; } ~DriverLVI( void ) { } inline OTDriver * driver( void ) { return Driver; } private : OTDriver * Driver; }; class LinkKeyLVI : public QListViewItem { public : LinkKeyLVI( int Ch, QListView * it ) : QListViewItem (it) { LinkKey = Ch; } ~LinkKeyLVI( void ) { } inline int index( void ) { return LinkKey; } private : int LinkKey; }; }; // // // // // OTSniffing::OTSniffing( QWidget * parent ) : OTSniffGUI( parent ) { OT = OTGateway::getOTGateway(); HciDump = 0; } OTSniffing::~OTSniffing() { SLOT_Trace( 0 ); } void OTSniffing::SLOT_Trace( bool Run ) { if( ! Run ) { if ( HciDump ) { HciDump->process().kill(); delete HciDump; } HciDump = 0; return; } HciDump = new MyProcess(); QStringList SL; SL << "/usr/sbin/hcidump"; switch( DataFormat_CB->currentItem() ) { case 0 : // Hex SL << "-x"; break; case 1 : // Ascii SL << "-a"; break; case 2 : // both SL << "-X"; break; } SL << "-i"; SL << OT->scanWith()->devname(); connect( HciDump, SIGNAL( stdoutLine( const QString & ) ), this, SLOT( SLOT_Show( const QString & ) ) ); connect( HciDump, SIGNAL(processExited(MyProcess*) ), this, SLOT( SLOT_ProcessExited(MyProcess*) ) ); HciDump->process() << SL; if( ! HciDump->process().start( OProcess::DontCare, OProcess::AllOutput ) ) { QMessageBox::warning(0, tr("Run hcidump"), tr("Cannot start %1").arg(SL.join(" ")) ); delete HciDump; HciDump = 0; } } void OTSniffing::SLOT_Show( const QString & S ) { Output_TV->setText( Output_TV->text() + S + "\n" ); QScrollBar *scroll = Output_TV->verticalScrollBar(); scroll->setValue(scroll->maxValue()); //Output_LB->insertItem( S ); //Output_LB->setCurrentItem( Output_LB->count()-1 ); //Output_LB->ensureCurrentVisible(); } void OTSniffing::SLOT_ProcessExited( MyProcess * ) { printf( "Exited\n" ); delete HciDump; HciDump = 0; } void OTSniffing::SLOT_Save( void ) { QString S = OFileDialog::getSaveFileName( OFileSelector::Extended, QDir::home().path(), QString::null, MimeTypes(), this ); if( ! S.isEmpty() ) { QFile F( S ); if( ! F.open( IO_WriteOnly ) ) { QMessageBox::warning(0, tr("Save log"), tr("Cannot open %1").arg(S) ); return; } QTextStream TS( &F ); TS << S << endl; } } void OTSniffing::SLOT_Load( void ) { QString S = OFileDialog::getOpenFileName( OFileSelector::Extended, QDir::home().path(), QString::null, MimeTypes(), this ); if( ! S.isEmpty() ) { QFile F( S ); if( ! F.open( IO_ReadOnly ) ) { QMessageBox::warning(0, tr("Save log"), tr("Cannot open %1").arg(S) ); return; } QTextStream TS ( &F ); SLOT_ClearLog(); S = TS.read(); // Output_LB->insertStringList( QStringList::split( "\n", S ) ); Output_TV->setText( S ); } } void OTSniffing::SLOT_ClearLog( void ) { // Output_LB->clear(); Output_TV->setText( "" ); } // // // // // OTPairing::OTPairing( QWidget * parent, OTIcons * _IC ) : OTPairingGUI( parent ) { OT = OTGateway::getOTGateway(); Icons = (_IC ) ? _IC : new OTIcons(); MyIcons = (_IC == 0 ); // unpairing can only be done if bluetooth is disabled Unpair_But->setEnabled( ! OT->isEnabled() ); if( ! OT->isEnabled() ) { Unpair_LBL->hide(); } else { Unpair_LBL->show(); } // open linkkey file and load pairs LinkKeyArray Keys = OT->getLinkKeys(); LinkKeyLVI * it; OTPeer * P; OTDriver * D; for( unsigned int i = 0 ; i < Keys.count(); i ++ ) { it = new LinkKeyLVI( i, Pairs_LV ); P = 0; D = OT->findDriver( Keys[i].from() ); if( D ) { it->setText( 0, D->devname() ); // we are source P = OT->findPeer( Keys[i].to() ); if( P ) { // put name it->setText( 1, P->name() ); } else { // unknown it->setText( 1, Keys[i].to().toString() ); } // and put address as sub QListViewItem * Sub = new QListViewItem( it ); Sub->setText( 0, D->address().toString() ); Sub->setText( 1, Keys[i].to().toString() ); } else { // perhaps we are destination D = OT->findDriver( Keys[i].to() ); if( D ) { it->setText( 1, D->devname() ); // we are source P = OT->findPeer( Keys[i].from() ); if( P ) { // put name it->setText( 0, P->name() ); } else { // unknown it->setText( 0, Keys[i].from().toString() ); } // and put address as sub QListViewItem * Sub = new QListViewItem( it ); Sub->setText( 0, Keys[i].from().toString() ); Sub->setText( 1, D->address().toString() ); } else { // nor source nor destination -> unknown it->setText( 0, Keys[i].from().toString() ); it->setText( 1, Keys[i].to().toString() ); } } } } OTPairing::~OTPairing() { if( MyIcons ) delete Icons; OTGateway::releaseOTGateway(); } void OTPairing::SLOT_Unpair( ) { // find selected pair QListViewItem * it = Pairs_LV->firstChild(); while( it ) { if( it->isSelected() ) { // confirm ? if( QMessageBox::warning(0, tr("Break pairing"), tr("Sure ?"), tr("Yes, break"), tr("No, don't break") ) == 0 ) { LinkKeyLVI * KPIt = (LinkKeyLVI *)it; // break OT->removeLinkKey( KPIt->index() ); delete KPIt; } return; } it= it->nextSibling(); } } // // // // // OTScan::OTScan( QWidget * parent, OTIcons * _IC ) : OTScanGUI( parent ), Filter() { OT = OTGateway::getOTGateway(); Icons = (_IC ) ? _IC : new OTIcons(); MyIcons = (_IC == 0 ); DetectedPeers_LV->header()->hide(); Current = 0; SelectedPeer = 0; SelectedChannel = 0; StrengthTimer = new QTimer( this ); connect( StrengthTimer, SIGNAL( timeout()), this, SLOT( SLOT_UpdateStrength()) ); connect( OT, SIGNAL( detectedPeer( OTPeer *, bool )), this, SLOT( SLOT_NewPeer( OTPeer *, bool )) ); connect( OT, SIGNAL( finishedDetecting()), this, SLOT( SLOT_FinishedDetecting()) ); // populate with peers we already know about const PeerVector & P = OT->peers(); for( unsigned int i = 0; i < P.count(); i ++ ) { SLOT_NewPeer( P[i], TRUE ); } // populate State fram { QHBoxLayout * H =new QHBoxLayout( State_Frm ); Paired_Led = new OLedBox( green, State_Frm ); QLabel * L1 = new QLabel( tr( "Paired" ), State_Frm ); H->addWidget( Paired_Led ); H->addWidget( L1 ); H->addStretch( 1 ); } } OTScan::~OTScan() { if( MyIcons ) delete Icons; OTGateway::releaseOTGateway(); // send all peers that we do not care about states QListViewItem * Lit = DetectedPeers_LV->firstChild(); while( Lit ) { ((PeerLVI *)Lit)->peer()->stopFindingOutState( ); Lit = Lit->nextSibling(); } } // static scan dialog function int OTScan::getDevice( OTPeer *& Peer, int & Channel, OTGateway * OT, const UUIDVector & Filter, QWidget* Parent ) { bool IsUp = 0; unsigned int i; - if( ! OT->isEnabled() ) { + if( ! OT || ! OT->isEnabled() ) { QMessageBox::warning( 0, tr("Scanning problem"), tr("Bluetooth not enabled" ) ); return QDialog::Rejected; } // check if bluetooth is up OTDriverList & DL = OT->getDriverList(); for( i = 0; i < DL.count(); i ++ ) { if( DL[i]->isUp() ) { // one device that is up found IsUp = 1; break; } } // use this driver OT->setScanWith( OT->driver(i) ); // create dialog QDialog * Dlg = new QDialog( Parent, 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); OTScan * Scn = new OTScan( Dlg ); connect( Scn, SIGNAL( selected() ), Dlg, SLOT( accept() ) ); if( Filter ) { Scn->setScanFilter( Filter ); } V->addWidget( Scn ); Dlg->setCaption( tr("Scan Neighbourhood" ) ); Dlg->showMaximized(); int rv = Dlg->exec(); if( rv == QDialog::Accepted ) { // get peer Peer = Scn->selectedPeer(); if( Peer == 0 ) { // no peer selected rv = QDialog::Rejected; } else { Channel = Scn->selectedChannel(); } } delete Dlg; return rv; } void OTScan::setScanFilter( const UUIDVector & V ) { Filter = V; } void OTScan::resetScanFilter( void ) { Filter.truncate(0); } void OTScan::SLOT_DoScan( bool DoIt ) { if( DoIt ) { OT->scanNeighbourhood(); } else { OT->stopScanOfNeighbourhood(); } scanMode( 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; } 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 odebug << "LINKKEY " << TheP->address().toString() << oendl; break; } } if( k == Keys.count() ) { 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 { 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 ) { 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 ); } } void OTScan::SLOT_PeerState( OTPeer * P ) { PeerLVI * it = (PeerLVI *)DetectedPeers_LV->firstChild(); while( it ) { if( it->peer() == P ) { break; } it = (PeerLVI * )it->nextSibling(); } if( ! it ) return; switch( P->state() ) { case OTPeer::Peer_Unknown : case OTPeer::Peer_Down : it->setPixmap( 1, 0 ); break; case OTPeer::Peer_Up : it->setPixmap( 1, Icons->loadPixmap( ( P->connectedTo() ) ? "connected" : "notconnected" ) ); if( it == Current && ! StrengthTimer->isActive() ) { // start showing strength StrengthTimer->start( 1000, FALSE ); SLOT_UpdateStrength(); } break; } } void OTScan::SLOT_RefreshState( void ) { QListViewItem * it = DetectedPeers_LV->firstChild(); while( it ) { if( it->isSelected() ) { break; } it = it->nextSibling(); } if( ! it ) return; refreshState( (PeerLVI *)it, 1 ); } void OTScan::refreshState( PeerLVI * it, bool Force ) { it->setPixmap( 1, Icons->loadPixmap( "find" ) ); it->peer()->findOutState( 30, Force ); } void OTScan::SLOT_Show( QListViewItem * it ) { if( ! it || it->depth() > 0 ) return; QString S; Current = (PeerLVI *)it; Strength_PB->setProgress( 0 ); // reset Address_LBL->setText( Current->peer()->address().toString() ); Peer_GB->setTitle( Current->peer()->name() ); const LinkKeyArray & Keys = OT->getLinkKeys(); Paired_Led->setOn( FALSE ); for( unsigned int i = 0; i < Keys.count(); i ++ ) { if( Current->peer()->address() == Keys[i].to() ) { Paired_Led->setOn( TRUE ); break; } } if( Current->peer()->state() == OTPeer::Peer_Up ) { RefreshServices_But->setEnabled( TRUE ); StrengthTimer->start( 1000, FALSE ); SLOT_UpdateStrength(); } else { RefreshServices_But->setEnabled( FALSE ); } } void OTScan::SLOT_UpdateStrength( void ) { OTDriver * D = Current->peer()->connectedTo(); if( D ) { long Q = D->getLinkQuality( Current->peer()->address() ); Strength_PB->setProgress( Q ); if( ! Q ) { // no quality Strength_PB->setEnabled( TRUE ); StrengthTimer->stop(); } } else { Strength_PB->setEnabled( FALSE ); Strength_PB->setProgress( 0 ); // no point in continuing StrengthTimer->stop(); } } void OTScan::SLOT_RefreshServices( void ) { QListViewItem * it = DetectedPeers_LV->firstChild(); while( it ) { if( it->isSelected() ) { break; } it = it->nextSibling(); } if( ! it ) return; QString S; PeerLVI * PI = (PeerLVI *)it; scanMode( true ); qApp->processEvents(0); ServiceVector & V = PI->peer()->services(); while( PI->firstChild() ) { // remove children delete PI->firstChild(); } for( unsigned int i = 0 ; i < V.count(); i ++ ) { QString S; S = V[i]->name(); if( S.isEmpty() ) { continue; } { QListViewItem * SIt; UUIDVector UIDV; QPixmap Pm; bool Done = 0; bool R; short ID; SIt = 0; UIDV = V[i]->classIDList(); // first all UUID ! 1200 12ff (Genericprofiles) for( unsigned int j = 0; j < UIDV.count(); j ++ ) { if( Filter.count() ) { bool FilterOut = 1; // filter out if not in list for( unsigned int ff = 0; ff < Filter.count(); ff ++ ) { if( UIDV[j] == Filter[ff] ) { FilterOut = 0; break; } } if( FilterOut ) { // not in filter list continue; } } // else show ID = UIDV[j].toShort(); if( ID < 0x1200 || ID > 0x12ff ) { // use this profile if( R ) { unsigned int ch; bool has; has = V[i]->rfcommChannel( ch ); SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); SIt->setText(0, V[i]->name() ); Pm = Icons->serviceIcon( ID, R ); SIt->setPixmap(0, Pm ); Done = 1; break; } } } if( ! Done ) { // check other range too for( unsigned int j = 0; j < UIDV.count(); j ++ ) { if( Filter.count() ) { bool FilterOut = 1; // filter out if not in list for( unsigned int ff = 0; ff < Filter.count(); ff ++ ) { if( UIDV[j] == Filter[ff] ) { FilterOut = 0; break; } } if( FilterOut ) { // not in filter list continue; } } // else show ID = UIDV[j].toShort(); if( ID >= 0x1200 && ID <= 0x12ff ) { // use this profile unsigned int ch; bool has; has = V[i]->rfcommChannel( ch ); SIt = new ChannelLVI( (has) ? (int)ch : -1 , PI ); SIt->setText(0, V[i]->name() ); Pm = Icons->serviceIcon( ID, R ); SIt->setPixmap(0, Pm ); break; } } } } } scanMode( false ); } void OTScan::scanMode( bool M ) { // avoid infinite loop because it triggers DoScan Detect_But->blockSignals( TRUE ); Detect_But->setOn( M ); Detect_But->setText( (M) ? tr("Scanning") : tr("Scan") ); Detect_But->blockSignals( FALSE ); } // // // // // OTManage::OTManage( QWidget * parent, OTIcons * _IC ) : OTManageGUI( parent ) { OT = OTGateway::getOTGateway(); Icons = (_IC ) ? _IC : new OTIcons(); MyIcons = (_IC == 0 ); AllDrivers_LV->setSorting(-1); connect( OT, SIGNAL( driverListChanged() ), this, SLOT( SLOT_DriverListChanged() ) ); connect( OT, SIGNAL( stateChange( OTDriver *, bool ) ), this, SLOT( SLOT_StateChange( OTDriver *, bool ) ) ); SLOT_DriverListChanged(); 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(); 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; OTDriver* D; OTDriverList & DL = OT->getDriverList(); AllDrivers_LV->clear(); for( unsigned int i = 0; i < DL.count(); i ++ ) { D = DL[i]; It = new DriverLVI( D, AllDrivers_LV ); if( ! First ) First = It; It->setText( 0, D->devname() ); It->setPixmap( 0, Icons->loadPixmap( (D->isUp()) ? "bluezon" : "bluezoff" ) ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Name" ) ); Sub->setText( 1, D->name() ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Address" ) ); Sub->setText( 1, D->address().toString() ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Revision" ) ); Sub->setText( 1, D->revision() ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Manufacturer" ) ); Sub->setText( 1, D->manufacturer() ); QString Service, Device; D->getClass( Service, Device ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Service classes" ) ); Sub->setText( 1, Service ); Sub = new QListViewItem( It ); Sub->setText( 0, tr( "Device class" ) ); Sub->setText( 1, Device ); } if( DL.count() ) { AllDrivers_LV->setCurrentItem( First ); DriverIsUp_CB->setEnabled( TRUE ); } else { DriverIsUp_CB->setChecked( FALSE ); DriverIsUp_CB->setEnabled( FALSE ); } } void OTManage::SLOT_SetRefreshTimer( int v ) { OT->setRefreshTimer( v * 1000 ); } // // // // // OTMain::OTMain( QWidget * parent ) : OTMainGUI( parent ) { Icons = new OTIcons(); SnifWindow = 0; OT = OTGateway::getOTGateway(); connect( OT, SIGNAL( deviceEnabled( bool ) ), this, SLOT( SLOT_DeviceIsEnabled( bool ) ) ); connect( OT, SIGNAL( driverListChanged() ), this, SLOT( SLOT_DriverListChanged() ) ); connect( OT, SIGNAL( stateChange( OTDriver *, bool ) ), this, SLOT( SLOT_StateChange( OTDriver *, bool ) ) ); if( ! OT->needsEnabling() ) { MustBeEnabled_CB->hide(); } else { // detect current state MustBeEnabled_CB->setChecked( OT->isEnabled() ); } SLOT_DriverListChanged(); } OTMain::~OTMain() { OTGateway::releaseOTGateway(); delete Icons; } void OTMain::SLOT_DriverListChanged() { OTDriver * D; OTDriverList & DL = OT->getDriverList(); DeviceList_CB->clear(); for( unsigned int i = 0; i < DL.count(); i ++ ) { D = DL[i]; DeviceList_CB->insertItem( Icons->loadPixmap( (D->isUp()) ? "bluezon" : "bluezoff" ), D->devname() ); if( D == OT->scanWith() ) { DeviceList_CB->setCurrentItem( i ); } } Scan_But->setEnabled( OT->getDriverList().count() > 0 ); DeviceList_CB->setEnabled( OT->getDriverList().count() > 0 ); } void OTMain::SLOT_EnableBluetooth( bool Up ) { OT->SLOT_SetEnabled( Up ); } void OTMain::SLOT_DeviceIsEnabled( bool Up ) { MustBeEnabled_CB->blockSignals( TRUE ); MustBeEnabled_CB->setChecked( Up ); MustBeEnabled_CB->blockSignals( FALSE ); } void OTMain::SLOT_Manage( void ) { QDialog * Dlg = new QDialog( this, 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); OTManage * Mng = new OTManage( Dlg, Icons ); V->addWidget( Mng ); Dlg->setCaption( tr("Manage local devices" ) ); Dlg->showMaximized(); Dlg->exec(); delete Dlg; } void OTMain::SLOT_Scan( void ) { OTDriverList & DL = OT->getDriverList(); for( unsigned int i = 0; i < DL.count(); i ++ ) { if( DL[i]->isUp() && DL[i]->devname() == DeviceList_CB->currentText() ) { QDialog * Dlg = new QDialog( this, 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); OTScan * Scn = new OTScan( Dlg, Icons ); OT->setScanWith( OT->driver(i) ); V->addWidget( Scn ); Dlg->setCaption( tr("Scan Neighbourhood" ) ); Dlg->showMaximized(); Dlg->exec(); delete Dlg; return; } } } void OTMain::SLOT_StateChange( OTDriver * D, bool Up ) { for( int i = 0; i < DeviceList_CB->count(); i ++ ) { if( DeviceList_CB->text(i) == D->devname() ) { DeviceList_CB->changeItem( Icons->loadPixmap( (Up) ? "bluezon" : "bluezoff" ), D->devname(), i ); return; } } } void OTMain::SLOT_Pairing( void ) { QDialog * Dlg = new QDialog( this, 0, TRUE ); QVBoxLayout * V = new QVBoxLayout( Dlg ); OTPairing * Pair = new OTPairing( Dlg, Icons ); V->addWidget( Pair ); Dlg->showMaximized(); Dlg->setCaption( tr("Manage pairing" ) ); Dlg->exec(); delete Dlg; } void OTMain::SLOT_Sniffing( void ) { if( SnifWindow == 0 ) { SnifWindow = new QDialog( this, 0, FALSE ); QVBoxLayout * V = new QVBoxLayout( SnifWindow ); OTSniffing * SN = new OTSniffing( SnifWindow ); V->addWidget( SN ); } SnifWindow->showMaximized(); SnifWindow->show(); } |