author | korovkin <korovkin> | 2006-03-19 14:57:44 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-03-19 14:57:44 (UTC) |
commit | a71b86fe8ca57753e8209786691b9c7a33d1c1c9 (patch) (unidiff) | |
tree | 7463f566a86c5bdff0e4e1380300edc327ebcada /noncore/net/opietooth | |
parent | bf4d4b814d514762748fe602aeef6c43da102c3a (diff) | |
download | opie-a71b86fe8ca57753e8209786691b9c7a33d1c1c9.zip opie-a71b86fe8ca57753e8209786691b9c7a33d1c1c9.tar.gz opie-a71b86fe8ca57753e8209786691b9c7a33d1c1c9.tar.bz2 |
PPP dialog calls rfcomm connect 0 <device MAC address> <port> if ppp script name
is empty.
-rw-r--r-- | noncore/net/opietooth/manager/pppdialog.cpp | 72 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/pppdialog.h | 16 |
2 files changed, 75 insertions, 13 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 ) { |
@@ -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 |
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 | } |
@@ -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; | 99 | } |
100 | |||
101 | void PPPDialog::fillErr(OProcess*, char* buf, int len) | ||
102 | { | ||
103 | QCString str(buf, len); | ||
104 | outPut->append(str); | ||
70 | } | 105 | } |
71 | 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 | } | ||
diff --git a/noncore/net/opietooth/manager/pppdialog.h b/noncore/net/opietooth/manager/pppdialog.h index 05894e2..565fe1e 100644 --- a/noncore/net/opietooth/manager/pppdialog.h +++ b/noncore/net/opietooth/manager/pppdialog.h | |||
@@ -11,5 +11,10 @@ class QMultiLineEdit; | |||
11 | class QLineEdit; | 11 | class QLineEdit; |
12 | 12 | #define NCONNECTS 10 //Maximal | |
13 | 13 | ||
14 | namespace OpieTooth { | 14 | namespace OpieTooth { |
15 | typedef struct { | ||
16 | Opie::Core::OProcess proc; //Connection process | ||
17 | QString btAddr; //MAC address | ||
18 | int port; //port | ||
19 | } Connection; | ||
15 | 20 | ||
@@ -20,3 +25,3 @@ namespace OpieTooth { | |||
20 | public: | 25 | public: |
21 | PPPDialog( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0, const QString& device = 0); | 26 | PPPDialog(const QString& device = 0, int port = 0, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0); |
22 | ~PPPDialog(); | 27 | ~PPPDialog(); |
@@ -26,2 +31,8 @@ namespace OpieTooth { | |||
26 | void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len ); | 31 | void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len ); |
32 | void fillErr(Opie::Core::OProcess*, char*, int); | ||
33 | void slotProcessExited(Opie::Core::OProcess* proc); | ||
34 | void closeEvent(QCloseEvent* e); | ||
35 | public: | ||
36 | //Array of connections indexed by rfcomm device number | ||
37 | static Connection conns[NCONNECTS]; | ||
27 | protected: | 38 | protected: |
@@ -34,2 +45,3 @@ namespace OpieTooth { | |||
34 | QString m_device; | 45 | QString m_device; |
46 | int m_port; | ||
35 | }; | 47 | }; |