summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/pppdialog.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/manager/pppdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/pppdialog.cpp72
1 files changed, 61 insertions, 11 deletions
diff --git a/noncore/net/opietooth/manager/pppdialog.cpp b/noncore/net/opietooth/manager/pppdialog.cpp
index ef007f5..b8d800a 100644
--- a/noncore/net/opietooth/manager/pppdialog.cpp
+++ b/noncore/net/opietooth/manager/pppdialog.cpp
@@ -1,5 +1,6 @@
1 1
2#include "pppdialog.h" 2#include "pppdialog.h"
3#include "rfcommhelper.h"
3#include <qpushbutton.h> 4#include <qpushbutton.h>
4#include <qmultilineedit.h> 5#include <qmultilineedit.h>
5#include <qlineedit.h> 6#include <qlineedit.h>
@@ -12,7 +13,11 @@ using namespace Opie::Core;
12using namespace OpieTooth; 13using namespace OpieTooth;
13 14
14using namespace Opie::Core; 15using namespace Opie::Core;
15PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device ) 16
17Connection PPPDialog::conns[NCONNECTS];
18
19PPPDialog::PPPDialog( const QString& device, int port, QWidget* parent,
20 const char* name, bool modal, WFlags fl )
16 : QDialog( parent, name, modal, fl ) { 21 : QDialog( parent, name, modal, fl ) {
17 22
18 if ( !name ) 23 if ( !name )
@@ -20,6 +25,7 @@ PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl,
20 setCaption( tr( "ppp connection " ) ) ; 25 setCaption( tr( "ppp connection " ) ) ;
21 26
22 m_device = device; 27 m_device = device;
28 m_port = port;
23 29
24 layout = new QVBoxLayout( this ); 30 layout = new QVBoxLayout( this );
25 31
@@ -44,28 +50,72 @@ PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl,
44 50
45 connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); 51 connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) );
46 52
53 connect(&PPPDialog::conns[0].proc,
54 SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)),
55 this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int)));
56 connect( &PPPDialog::conns[0].proc,
57 SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)),
58 this, SLOT(fillErr(Opie::Core::OProcess*, char*, int)));
59 connect( &PPPDialog::conns[0].proc,
60 SIGNAL(processExited(Opie::Core::OProcess*)),
61 this, SLOT(slotProcessExited(Opie::Core::OProcess*)));
47} 62}
48 63
49PPPDialog::~PPPDialog() { 64PPPDialog::~PPPDialog() {
50} 65}
51 66
52void PPPDialog::connectToDevice() { 67void PPPDialog::connectToDevice() {
68 if (PPPDialog::conns[0].proc.isRunning()) {
69 outPut->append(tr("Work in progress"));
70 return;
71 }
53 outPut->clear(); 72 outPut->clear();
73 PPPDialog::conns[0].proc.clearArguments();
54 // vom popupmenu beziehen 74 // vom popupmenu beziehen
75 if (cmdLine->text().isEmpty()) {//Connect by rfcomm
76 PPPDialog::conns[0].proc << "rfcomm" << "connect"
77 << "0" << m_device << QString::number(m_port);
78 }
79 else {
55 QString connectScript = "/etc/ppp/peers/" + cmdLine->text(); 80 QString connectScript = "/etc/ppp/peers/" + cmdLine->text();
56 OProcess* pppDial = new OProcess(); 81 PPPDialog::conns[0].proc << "pppd"
57 *pppDial << "pppd" << m_device << "call" << connectScript; 82 << m_device << "call" << connectScript;
58 connect( pppDial, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int) ), 83 }
59 this, SLOT(fillOutPut(Opie::Core::OProcess*,char*,int) ) ); 84 if (!PPPDialog::conns[0].proc.start(OProcess::NotifyOnExit, OProcess::All)) {
60 if (!pppDial->start(OProcess::DontCare, OProcess::AllOutput) ) { 85 outPut->append(tr("Couldn't start"));
61 owarn << "could not start" << oendl; 86 }
62 delete pppDial; 87 else
88 {
89 PPPDialog::conns[0].proc.resume();
90 outPut->append(tr("Started"));
91 PPPDialog::conns[0].btAddr = m_device;
92 PPPDialog::conns[0].port = m_port;
63 } 93 }
64} 94}
65 95
66void PPPDialog::fillOutPut( OProcess* pppDial, char* cha, int len ) { 96void PPPDialog::fillOutPut( OProcess*, char* cha, int len ) {
67 QCString str(cha, len ); 97 QCString str(cha, len );
68 outPut->insertLine( str ); 98 outPut->append(str);
69 delete pppDial; 99}
100
101void PPPDialog::fillErr(OProcess*, char* buf, int len)
102{
103 QCString str(buf, len);
104 outPut->append(str);
70} 105}
71 106
107void PPPDialog::slotProcessExited(OProcess* proc) {
108 if (proc->normalExit()) {
109 outPut->append( tr("Finished with result ") );
110 outPut->append( QString::number(proc->exitStatus()) );
111 }
112 else
113 outPut->append( tr("Exited abnormally") );
114}
115
116void PPPDialog::closeEvent(QCloseEvent* e)
117{
118 if(PPPDialog::conns[0].proc.isRunning())
119 PPPDialog::conns[0].proc.kill();
120 QDialog::closeEvent(e);
121}