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/manager/rfcpopup.cpp | |
parent | a71b86fe8ca57753e8209786691b9c7a33d1c1c9 (diff) | |
download | opie-3de693f244170cb9424d841aef6a6d7175766fa3.zip opie-3de693f244170cb9424d841aef6a6d7175766fa3.tar.gz opie-3de693f244170cb9424d841aef6a6d7175766fa3.tar.bz2 |
Added connection and disconnection.
Diffstat (limited to 'noncore/net/opietooth/manager/rfcpopup.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/rfcpopup.cpp | 44 |
1 files changed, 30 insertions, 14 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 | |||
@@ -6,6 +6,8 @@ | |||
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 */ |
@@ -16,31 +18,42 @@ using namespace OpieTooth; | |||
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() ), | ||
34 | this, SLOT( slotConnect() ) ); | ||
35 | |||
36 | |||
37 | /* disconnect action */ | 39 | /* disconnect action */ |
38 | a = new QAction( ); | 40 | a = new QAction( ); |
39 | a->setText("Disconnect"); | 41 | a->setText("Disconnect"); |
40 | a->addTo( this ); | 42 | a->addTo( this ); |
41 | connect( a, SIGNAL( activated() ) , | 43 | connect( a, SIGNAL( activated() ) , |
42 | this, SLOT( slotDisconnect() ) ); | 44 | this, SLOT( slotDisconnect() ) ); |
43 | 45 | procId = i; | |
46 | break; | ||
47 | } | ||
48 | } | ||
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( ); |
@@ -74,14 +87,17 @@ void RfcCommPopup::slotConnect() | |||
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 | ||