Diffstat (limited to 'noncore/net/opietooth/manager/rfcpopup.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/rfcpopup.cpp | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/noncore/net/opietooth/manager/rfcpopup.cpp b/noncore/net/opietooth/manager/rfcpopup.cpp index 54f1eb7..7711f0a 100644 --- a/noncore/net/opietooth/manager/rfcpopup.cpp +++ b/noncore/net/opietooth/manager/rfcpopup.cpp @@ -1,105 +1,121 @@ #include "pppdialog.h" #include "rfcpopup.h" #include "rfcommassigndialogimpl.h" /* OPIE */ #include <qpe/qpeapplication.h> #include <opie2/odebug.h> +#include <opie2/oprocess.h> + using namespace Opie::Core; /* QT */ #include <qtimer.h> using namespace OpieTooth; /* * c'tor init the QAction */ -RfcCommPopup::RfcCommPopup( OpieTooth::BTDeviceItem* item ) - : QPopupMenu() +RfcCommPopup::RfcCommPopup(const OpieTooth::Services& service, + OpieTooth::BTDeviceItem* item) + : QPopupMenu(), m_service(service) { owarn << "RfcCommPopup c'tor" << oendl; QAction* a; + int port = service.protocolDescriptorList().last().port(); + QString mac = item->mac(); + unsigned int i; - + procId = -1; m_item = item; - /* connect action */ - a = new QAction( ); // so it's get deleted - a->setText("Connect"); - a->addTo( this ); - connect( a, SIGNAL( activated() ), - this, SLOT( slotConnect() ) ); - - - /* disconnect action */ - a = new QAction( ); - a->setText("Disconnect"); - a->addTo( this ); - connect( a, SIGNAL( activated() ) , - this, SLOT( slotDisconnect() ) ); - + for (i = 0; i < sizeof(PPPDialog::conns) / sizeof(Connection); i++) { + if (PPPDialog::conns[i].port == port && + PPPDialog::conns[i].btAddr == mac && + PPPDialog::conns[i].proc.isRunning()) { + /* disconnect action */ + a = new QAction( ); + a->setText("Disconnect"); + a->addTo( this ); + connect( a, SIGNAL( activated() ) , + this, SLOT( slotDisconnect() ) ); + procId = i; + break; + } + } + if (procId == -1) { + /* connect action */ + a = new QAction( ); // so it's get deleted + a->setText("Connect"); + a->addTo( this ); + connect( a, SIGNAL( activated() ), + this, SLOT( slotConnect() ) ); + } /* foo action */ a = new QAction( ); a->setText("Bind table"); a->addTo( this ); connect( a, SIGNAL( activated() ), this, SLOT( slotBind() ) ); /* bar action */ a = new QAction( ); a->setText( "Bar" ); a->addTo( this ); connect( a, SIGNAL( activated() ), this, SLOT( slotBar() ) ); }; RfcCommPopup::~RfcCommPopup() { /* delete m_con; delete m_dis; delete m_foo; delete m_bar; */ } void RfcCommPopup::slotConnect() { owarn << "connect" << oendl; - PPPDialog pppDialog; + PPPDialog pppDialog(m_item->mac(), + m_service.protocolDescriptorList().last().port()); QPEApplication::execDialog( &pppDialog ); } void RfcCommPopup::slotDisconnect() { - owarn << "slot disconnected" << oendl; + owarn << "slot disconnected " << procId << oendl; + if (procId >= 0) + PPPDialog::conns[procId].proc.kill(); } void RfcCommPopup::slotBind() { RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); rfcommAssign.newDevice( m_item->mac() ); if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) { rfcommAssign.saveConfig(); } } void RfcCommPopup::slotBar() { owarn << "slotBar" << oendl; }; |