author | korovkin <korovkin> | 2006-03-19 14:58:21 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-03-19 14:58:21 (UTC) |
commit | 3de693f244170cb9424d841aef6a6d7175766fa3 (patch) (side-by-side diff) | |
tree | 03450003b6ea810052b7e046a1a9cb375d01ebba | |
parent | a71b86fe8ca57753e8209786691b9c7a33d1c1c9 (diff) | |
download | opie-3de693f244170cb9424d841aef6a6d7175766fa3.zip opie-3de693f244170cb9424d841aef6a6d7175766fa3.tar.gz opie-3de693f244170cb9424d841aef6a6d7175766fa3.tar.bz2 |
Added connection and disconnection.
-rw-r--r-- | noncore/net/opietooth/manager/rfcpopup.cpp | 44 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/rfcpopup.h | 7 |
2 files changed, 34 insertions, 17 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,51 +1,64 @@ #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() ) ); - - + 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() ) ); @@ -69,24 +82,27 @@ RfcCommPopup::~RfcCommPopup() } 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() ); diff --git a/noncore/net/opietooth/manager/rfcpopup.h b/noncore/net/opietooth/manager/rfcpopup.h index 74b9117..a67e41e 100644 --- a/noncore/net/opietooth/manager/rfcpopup.h +++ b/noncore/net/opietooth/manager/rfcpopup.h @@ -1,38 +1,39 @@ #ifndef RFCPOPUP_H #define RFCPOPUP_H #include <qpopupmenu.h> #include <qaction.h> - +#include <services.h> #include "btdeviceitem.h" namespace OpieTooth { /** * A simple reference implementation for * the popup helper factory. * This class derives from QPopupMenu and uses * plugged QActions to do all the nasty in it's * slots. After the work is done everything must * be deleted. */ class RfcCommPopup : public QPopupMenu { Q_OBJECT public: - RfcCommPopup( OpieTooth::BTDeviceItem* ); + RfcCommPopup(const OpieTooth::Services&, OpieTooth::BTDeviceItem*); ~RfcCommPopup(); - private: QAction* m_con; QAction* m_dis; QAction* m_bind; QAction* m_bar; OpieTooth::BTDeviceItem *m_item; + Services m_service; + int procId; //Connection process number private slots: void slotConnect(); void slotDisconnect(); void slotBind(); void slotBar(); }; }; |