author | korovkin <korovkin> | 2006-03-19 14:58:21 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-03-19 14:58:21 (UTC) |
commit | 3de693f244170cb9424d841aef6a6d7175766fa3 (patch) (unidiff) | |
tree | 03450003b6ea810052b7e046a1a9cb375d01ebba /noncore/net/opietooth | |
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 | 56 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/rfcpopup.h | 9 |
2 files changed, 41 insertions, 24 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,55 +1,68 @@ | |||
1 | 1 | ||
2 | #include "pppdialog.h" | 2 | #include "pppdialog.h" |
3 | #include "rfcpopup.h" | 3 | #include "rfcpopup.h" |
4 | #include "rfcommassigndialogimpl.h" | 4 | #include "rfcommassigndialogimpl.h" |
5 | 5 | ||
6 | /* OPIE */ | 6 | /* OPIE */ |
7 | #include <qpe/qpeapplication.h> | 7 | #include <qpe/qpeapplication.h> |
8 | #include <opie2/odebug.h> | 8 | #include <opie2/odebug.h> |
9 | #include <opie2/oprocess.h> | ||
10 | |||
9 | using namespace Opie::Core; | 11 | using namespace Opie::Core; |
10 | 12 | ||
11 | /* QT */ | 13 | /* QT */ |
12 | #include <qtimer.h> | 14 | #include <qtimer.h> |
13 | 15 | ||
14 | using namespace OpieTooth; | 16 | using namespace OpieTooth; |
15 | 17 | ||
16 | /* | 18 | /* |
17 | * c'tor init the QAction | 19 | * c'tor init the QAction |
18 | */ | 20 | */ |
19 | RfcCommPopup::RfcCommPopup( OpieTooth::BTDeviceItem* item ) | 21 | RfcCommPopup::RfcCommPopup(const OpieTooth::Services& service, |
20 | : QPopupMenu() | 22 | OpieTooth::BTDeviceItem* item) |
23 | : QPopupMenu(), m_service(service) | ||
21 | { | 24 | { |
22 | owarn << "RfcCommPopup c'tor" << oendl; | 25 | owarn << "RfcCommPopup c'tor" << oendl; |
23 | 26 | ||
24 | QAction* a; | 27 | QAction* a; |
28 | int port = service.protocolDescriptorList().last().port(); | ||
29 | QString mac = item->mac(); | ||
30 | unsigned int i; | ||
25 | 31 | ||
26 | 32 | procId = -1; | |
27 | m_item = item; | 33 | m_item = item; |
28 | 34 | ||
29 | /* connect action */ | 35 | for (i = 0; i < sizeof(PPPDialog::conns) / sizeof(Connection); i++) { |
30 | a = new QAction( ); // so it's get deleted | 36 | if (PPPDialog::conns[i].port == port && |
31 | a->setText("Connect"); | 37 | PPPDialog::conns[i].btAddr == mac && |
32 | a->addTo( this ); | 38 | PPPDialog::conns[i].proc.isRunning()) { |
33 | connect( a, SIGNAL( activated() ), | 39 | /* disconnect action */ |
34 | this, SLOT( slotConnect() ) ); | 40 | a = new QAction( ); |
35 | 41 | a->setText("Disconnect"); | |
36 | 42 | a->addTo( this ); | |
37 | /* disconnect action */ | 43 | connect( a, SIGNAL( activated() ) , |
38 | a = new QAction( ); | 44 | this, SLOT( slotDisconnect() ) ); |
39 | a->setText("Disconnect"); | 45 | procId = i; |
40 | a->addTo( this ); | 46 | break; |
41 | connect( a, SIGNAL( activated() ) , | 47 | } |
42 | this, SLOT( slotDisconnect() ) ); | 48 | } |
43 | 49 | if (procId == -1) { | |
50 | /* connect action */ | ||
51 | a = new QAction( ); // so it's get deleted | ||
52 | a->setText("Connect"); | ||
53 | a->addTo( this ); | ||
54 | connect( a, SIGNAL( activated() ), | ||
55 | this, SLOT( slotConnect() ) ); | ||
56 | } | ||
44 | 57 | ||
45 | /* foo action */ | 58 | /* foo action */ |
46 | a = new QAction( ); | 59 | a = new QAction( ); |
47 | a->setText("Bind table"); | 60 | a->setText("Bind table"); |
48 | a->addTo( this ); | 61 | a->addTo( this ); |
49 | connect( a, SIGNAL( activated() ), | 62 | connect( a, SIGNAL( activated() ), |
50 | this, SLOT( slotBind() ) ); | 63 | this, SLOT( slotBind() ) ); |
51 | 64 | ||
52 | 65 | ||
53 | /* bar action */ | 66 | /* bar action */ |
54 | a = new QAction( ); | 67 | a = new QAction( ); |
55 | a->setText( "Bar" ); | 68 | a->setText( "Bar" ); |
@@ -65,32 +78,35 @@ RfcCommPopup::~RfcCommPopup() | |||
65 | /* delete m_con; | 78 | /* delete m_con; |
66 | delete m_dis; | 79 | delete m_dis; |
67 | delete m_foo; | 80 | delete m_foo; |
68 | delete m_bar; */ | 81 | delete m_bar; */ |
69 | } | 82 | } |
70 | 83 | ||
71 | 84 | ||
72 | void RfcCommPopup::slotConnect() | 85 | void RfcCommPopup::slotConnect() |
73 | { | 86 | { |
74 | 87 | ||
75 | owarn << "connect" << oendl; | 88 | owarn << "connect" << oendl; |
76 | 89 | ||
77 | PPPDialog pppDialog; | 90 | PPPDialog pppDialog(m_item->mac(), |
91 | m_service.protocolDescriptorList().last().port()); | ||
78 | QPEApplication::execDialog( &pppDialog ); | 92 | QPEApplication::execDialog( &pppDialog ); |
79 | } | 93 | } |
80 | 94 | ||
81 | 95 | ||
82 | void RfcCommPopup::slotDisconnect() | 96 | void RfcCommPopup::slotDisconnect() |
83 | { | 97 | { |
84 | owarn << "slot disconnected" << oendl; | 98 | owarn << "slot disconnected " << procId << oendl; |
99 | if (procId >= 0) | ||
100 | PPPDialog::conns[procId].proc.kill(); | ||
85 | } | 101 | } |
86 | 102 | ||
87 | 103 | ||
88 | void RfcCommPopup::slotBind() | 104 | void RfcCommPopup::slotBind() |
89 | { | 105 | { |
90 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); | 106 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); |
91 | 107 | ||
92 | rfcommAssign.newDevice( m_item->mac() ); | 108 | rfcommAssign.newDevice( m_item->mac() ); |
93 | 109 | ||
94 | if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) | 110 | if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) |
95 | { | 111 | { |
96 | rfcommAssign.saveConfig(); | 112 | rfcommAssign.saveConfig(); |
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,39 +1,40 @@ | |||
1 | #ifndef RFCPOPUP_H | 1 | #ifndef RFCPOPUP_H |
2 | #define RFCPOPUP_H | 2 | #define RFCPOPUP_H |
3 | 3 | ||
4 | #include <qpopupmenu.h> | 4 | #include <qpopupmenu.h> |
5 | #include <qaction.h> | 5 | #include <qaction.h> |
6 | 6 | #include <services.h> | |
7 | #include "btdeviceitem.h" | 7 | #include "btdeviceitem.h" |
8 | 8 | ||
9 | namespace OpieTooth { | 9 | namespace OpieTooth { |
10 | /** | 10 | /** |
11 | * A simple reference implementation for | 11 | * A simple reference implementation for |
12 | * the popup helper factory. | 12 | * the popup helper factory. |
13 | * This class derives from QPopupMenu and uses | 13 | * This class derives from QPopupMenu and uses |
14 | * plugged QActions to do all the nasty in it's | 14 | * plugged QActions to do all the nasty in it's |
15 | * slots. After the work is done everything must | 15 | * slots. After the work is done everything must |
16 | * be deleted. | 16 | * be deleted. |
17 | */ | 17 | */ |
18 | class RfcCommPopup : public QPopupMenu { | 18 | class RfcCommPopup : public QPopupMenu { |
19 | Q_OBJECT | 19 | Q_OBJECT |
20 | public: | 20 | public: |
21 | RfcCommPopup( OpieTooth::BTDeviceItem* ); | 21 | RfcCommPopup(const OpieTooth::Services&, OpieTooth::BTDeviceItem*); |
22 | ~RfcCommPopup(); | 22 | ~RfcCommPopup(); |
23 | 23 | ||
24 | |||
25 | private: | 24 | private: |
26 | QAction* m_con; | 25 | QAction* m_con; |
27 | QAction* m_dis; | 26 | QAction* m_dis; |
28 | QAction* m_bind; | 27 | QAction* m_bind; |
29 | QAction* m_bar; | 28 | QAction* m_bar; |
30 | OpieTooth::BTDeviceItem *m_item; | 29 | OpieTooth::BTDeviceItem *m_item; |
30 | Services m_service; | ||
31 | int procId; //Connection process number | ||
31 | private slots: | 32 | private slots: |
32 | void slotConnect(); | 33 | void slotConnect(); |
33 | void slotDisconnect(); | 34 | void slotDisconnect(); |
34 | void slotBind(); | 35 | void slotBind(); |
35 | void slotBar(); | 36 | void slotBar(); |
36 | }; | 37 | }; |
37 | }; | 38 | }; |
38 | 39 | ||
39 | #endif | 40 | #endif |