Diffstat (limited to 'noncore/net/opietooth/manager/panpopup.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/panpopup.cpp | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/noncore/net/opietooth/manager/panpopup.cpp b/noncore/net/opietooth/manager/panpopup.cpp index d3d1347..61e632b 100644 --- a/noncore/net/opietooth/manager/panpopup.cpp +++ b/noncore/net/opietooth/manager/panpopup.cpp | |||
@@ -5,66 +5,58 @@ | |||
5 | #include "panpopup.h" | 5 | #include "panpopup.h" |
6 | 6 | ||
7 | using namespace OpieTooth; | 7 | using namespace OpieTooth; |
8 | 8 | ||
9 | /* | 9 | /* |
10 | * c'tor init the QAction | 10 | * c'tor init the QAction |
11 | */ | 11 | */ |
12 | PanPopup::PanPopup( OpieTooth::BTDeviceItem* item ) : QPopupMenu() { | 12 | PanPopup::PanPopup( OpieTooth::BTDeviceItem* item ) : QPopupMenu() { |
13 | 13 | ||
14 | qWarning("PanPopup c'tor"); | 14 | qWarning("PanPopup c'tor"); |
15 | 15 | ||
16 | m_item = item; | 16 | m_item = item; |
17 | m_panconnect = 0l; | 17 | QAction *a, *b, *c; |
18 | QAction *a, *b; | ||
19 | 18 | ||
19 | m_panconnection = 0l; | ||
20 | /* connect action */ | 20 | /* connect action */ |
21 | |||
22 | |||
21 | a = new QAction( ); // so it's get deleted | 23 | a = new QAction( ); // so it's get deleted |
22 | a->setText( "connect" ); | 24 | a->setText( tr("connect") ); |
23 | a->addTo( this ); | 25 | a->addTo( this ); |
24 | connect( a, SIGNAL( activated() ), this, SLOT( slotConnect() ) ); | 26 | connect( a, SIGNAL( activated() ), this, SLOT( slotConnect() ) ); |
25 | 27 | ||
28 | |||
26 | b = new QAction(); | 29 | b = new QAction(); |
27 | b->setText( "connect+conf" ); | 30 | b->setText( tr( "connect+conf" ) ); |
28 | b->addTo( this ); | 31 | b->addTo( this ); |
29 | connect( b, SIGNAL( activated() ), this, SLOT( slotConnectAndConfig() ) ); | 32 | connect( b, SIGNAL( activated() ), this, SLOT( slotConnectAndConfig() ) ); |
33 | |||
34 | c = new QAction(); | ||
35 | c->setText( tr( "disconnect" ) ); | ||
36 | c->addTo( this ); | ||
37 | connect( c, SIGNAL( activated() ), this, SLOT( slotDisconnect() ) ); | ||
38 | |||
30 | }; | 39 | }; |
31 | 40 | ||
32 | PanPopup::~PanPopup() { | 41 | PanPopup::~PanPopup() { |
33 | delete m_panconnect; | 42 | |
34 | } | 43 | } |
35 | 44 | ||
36 | void PanPopup::slotConnect() { | 45 | void PanPopup::slotConnect() { |
37 | 46 | m_panconnection = new StartPanConnection( m_item->mac() ); | |
38 | 47 | m_panconnection->start(); | |
39 | // SHOULD move to lib | ||
40 | // before pand must be in "pand --listen --role panu" mode ( client ) | ||
41 | |||
42 | m_panconnect = new OProcess(); | ||
43 | *m_panconnect << "pand" << "--connect" << m_item->mac(); | ||
44 | |||
45 | connect( m_panconnect, SIGNAL( processExited( OProcess* ) ) , | ||
46 | this, SLOT( slotConnectExited( OProcess* ) ) ); | ||
47 | connect( m_panconnect, SIGNAL( receivedStdout( OProcess*, char*, int ) ), | ||
48 | this, SLOT( slotConnectOut( OProcess*, char*, int ) ) ); | ||
49 | if (!m_panconnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { | ||
50 | qWarning( "could not start" ); | ||
51 | delete m_panconnect; | ||
52 | } | ||
53 | } | 48 | } |
54 | 49 | ||
55 | void PanPopup::slotExited( OProcess* proc ) { | 50 | void PanPopup::slotDisconnect() { |
56 | delete m_panconnect; | 51 | m_panconnection->stop(); |
57 | } | 52 | } |
58 | 53 | ||
59 | void PanPopup::slotStdOut(OProcess* proc, char* chars, int len) | ||
60 | {} | ||
61 | |||
62 | 54 | ||
63 | void PanPopup::slotConnectAndConfig() { | 55 | void PanPopup::slotConnectAndConfig() { |
64 | slotConnect(); | 56 | slotConnect(); |
65 | 57 | ||
66 | // more intelligence here later like passing the device ( bnepX ) | 58 | // more intelligence here later like passing the device ( bnepX ) |
67 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 59 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
68 | e << QString( "networksetup" ); | 60 | e << QString( "networksetup" ); |
69 | 61 | ||
70 | } | 62 | } |