Diffstat (limited to 'noncore/net/opietooth/manager/pppdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/pppdialog.cpp | 78 |
1 files changed, 64 insertions, 14 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 | |||
@@ -2,2 +2,3 @@ | |||
2 | #include "pppdialog.h" | 2 | #include "pppdialog.h" |
3 | #include "rfcommhelper.h" | ||
3 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
@@ -14,3 +15,7 @@ using namespace OpieTooth; | |||
14 | using namespace Opie::Core; | 15 | using namespace Opie::Core; |
15 | PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device ) | 16 | |
17 | Connection PPPDialog::conns[NCONNECTS]; | ||
18 | |||
19 | PPPDialog::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 ) { |
@@ -18,3 +23,3 @@ PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, | |||
18 | if ( !name ) | 23 | if ( !name ) |
19 | setName( "PPPDialog" ); | 24 | setName( "PPPDialog" ); |
20 | setCaption( tr( "ppp connection " ) ) ; | 25 | setCaption( tr( "ppp connection " ) ) ; |
@@ -22,2 +27,3 @@ PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, | |||
22 | m_device = device; | 27 | m_device = device; |
28 | m_port = port; | ||
23 | 29 | ||
@@ -46,2 +52,11 @@ PPPDialog::PPPDialog( QWidget* parent, const char* name, bool modal, WFlags fl, | |||
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 | } |
@@ -52,12 +67,27 @@ PPPDialog::~PPPDialog() { | |||
52 | void PPPDialog::connectToDevice() { | 67 | void 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 |
55 | QString connectScript = "/etc/ppp/peers/" + cmdLine->text(); | 75 | if (cmdLine->text().isEmpty()) {//Connect by rfcomm |
56 | OProcess* pppDial = new OProcess(); | 76 | PPPDialog::conns[0].proc << "rfcomm" << "connect" |
57 | *pppDial << "pppd" << m_device << "call" << connectScript; | 77 | << "0" << m_device << QString::number(m_port); |
58 | connect( pppDial, SIGNAL(receivedStdout(Opie::Core::OProcess*,char*,int) ), | 78 | } |
59 | this, SLOT(fillOutPut(Opie::Core::OProcess*,char*,int) ) ); | 79 | else { |
60 | if (!pppDial->start(OProcess::DontCare, OProcess::AllOutput) ) { | 80 | QString connectScript = "/etc/ppp/peers/" + cmdLine->text(); |
61 | owarn << "could not start" << oendl; | 81 | PPPDialog::conns[0].proc << "pppd" |
62 | delete pppDial; | 82 | << m_device << "call" << connectScript; |
83 | } | ||
84 | if (!PPPDialog::conns[0].proc.start(OProcess::NotifyOnExit, OProcess::All)) { | ||
85 | outPut->append(tr("Couldn't start")); | ||
86 | } | ||
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 | } |
@@ -65,7 +95,27 @@ void PPPDialog::connectToDevice() { | |||
65 | 95 | ||
66 | void PPPDialog::fillOutPut( OProcess* pppDial, char* cha, int len ) { | 96 | void 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; | ||
70 | } | 99 | } |
71 | 100 | ||
101 | void PPPDialog::fillErr(OProcess*, char* buf, int len) | ||
102 | { | ||
103 | QCString str(buf, len); | ||
104 | outPut->append(str); | ||
105 | } | ||
106 | |||
107 | void 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 | |||
116 | void PPPDialog::closeEvent(QCloseEvent* e) | ||
117 | { | ||
118 | if(PPPDialog::conns[0].proc.isRunning()) | ||
119 | PPPDialog::conns[0].proc.kill(); | ||
120 | QDialog::closeEvent(e); | ||
121 | } | ||