Diffstat (limited to 'noncore/net/opietooth/manager/dundialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/dundialog.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/noncore/net/opietooth/manager/dundialog.cpp b/noncore/net/opietooth/manager/dundialog.cpp index c6d8619..872ab00 100644 --- a/noncore/net/opietooth/manager/dundialog.cpp +++ b/noncore/net/opietooth/manager/dundialog.cpp | |||
@@ -7,102 +7,111 @@ | |||
7 | * the Free Software Foundation; either version 2 of the License, or * | 7 | * the Free Software Foundation; either version 2 of the License, or * |
8 | * (at your option) any later version. * | 8 | * (at your option) any later version. * |
9 | * * | 9 | * * |
10 | ***************************************************************************/ | 10 | ***************************************************************************/ |
11 | #include "dundialog.h" | 11 | #include "dundialog.h" |
12 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
13 | #include <qmultilineedit.h> | 13 | #include <qmultilineedit.h> |
14 | #include <qlineedit.h> | 14 | #include <qlineedit.h> |
15 | #include <qlayout.h> | 15 | #include <qlayout.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qstring.h> | 18 | #include <qstring.h> |
19 | #include <qcombobox.h> | ||
20 | #include <qdir.h> | ||
19 | #include <opie2/oprocess.h> | 21 | #include <opie2/oprocess.h> |
20 | #include <opie2/odebug.h> | 22 | #include <opie2/odebug.h> |
21 | using namespace Opie::Core; | 23 | using namespace Opie::Core; |
22 | 24 | ||
23 | using namespace OpieTooth; | 25 | using namespace OpieTooth; |
24 | 26 | ||
25 | using namespace Opie::Core; | 27 | using namespace Opie::Core; |
26 | 28 | ||
27 | DunDialog::DunDialog( const QString& device, int port, QWidget* parent, | 29 | DunDialog::DunDialog( const QString& device, int port, QWidget* parent, |
28 | const char* name, bool modal, WFlags fl ) | 30 | const char* name, bool modal, WFlags fl ) |
29 | : QDialog( parent, name, modal, fl ) { | 31 | : QDialog( parent, name, modal, fl ) { |
32 | QDir d("/etc/ppp/peers/"); //Dir we search files in | ||
33 | d.setFilter( QDir::Files); | ||
34 | d.setSorting( QDir::Size | QDir::Reversed ); | ||
35 | |||
30 | if ( !name ) | 36 | if ( !name ) |
31 | setName( "DUNDialog" ); | 37 | setName( "DUNDialog" ); |
32 | setCaption( tr( "DUN connection " ) ) ; | 38 | setCaption( tr( "DUN connection " ) ) ; |
33 | 39 | ||
34 | m_device = device; | 40 | m_device = device; |
35 | m_port = port; | 41 | m_port = port; |
36 | 42 | ||
37 | m_dunConnect = NULL; | 43 | m_dunConnect = NULL; |
38 | layout = new QVBoxLayout( this ); | 44 | layout = new QVBoxLayout( this ); |
39 | 45 | ||
40 | QLabel* info = new QLabel( this ); | 46 | QLabel* info = new QLabel( this ); |
41 | info->setText( tr("Enter an ppp script name:") ); | 47 | info->setText( tr("Enter an ppp script name:") ); |
42 | 48 | ||
43 | cmdLine = new QLineEdit( this ); | 49 | cmdLine = new QComboBox( this ); |
50 | cmdLine->setEditable(true); | ||
44 | 51 | ||
45 | outPut = new QMultiLineEdit( this ); | 52 | outPut = new QMultiLineEdit( this ); |
46 | QFont outPut_font( outPut->font() ); | 53 | QFont outPut_font( outPut->font() ); |
47 | outPut_font.setPointSize( 8 ); | 54 | outPut_font.setPointSize( 8 ); |
48 | outPut->setFont( outPut_font ); | 55 | outPut->setFont( outPut_font ); |
49 | outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); | 56 | outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); |
50 | 57 | ||
51 | connectButton = new QPushButton( this ); | 58 | connectButton = new QPushButton( this ); |
52 | connectButton->setText( tr( "Connect" ) ); | 59 | connectButton->setText( tr( "Connect" ) ); |
53 | 60 | ||
54 | doEncryption = new QCheckBox(this, "encrypt"); | 61 | doEncryption = new QCheckBox(this, "encrypt"); |
55 | doEncryption->setText( tr( "encrypt" ) ); | 62 | doEncryption->setText( tr( "encrypt" ) ); |
56 | 63 | ||
57 | persist = new QCheckBox(this, "persist"); | 64 | persist = new QCheckBox(this, "persist"); |
58 | persist->setText( tr( "persist" ) ); | 65 | persist->setText( tr( "persist" ) ); |
59 | 66 | ||
60 | layout->addWidget(info); | 67 | layout->addWidget(info); |
61 | layout->addWidget(cmdLine); | 68 | layout->addWidget(cmdLine); |
62 | layout->addWidget(doEncryption); | 69 | layout->addWidget(doEncryption); |
63 | layout->addWidget(persist); | 70 | layout->addWidget(persist); |
64 | layout->addWidget(outPut); | 71 | layout->addWidget(outPut); |
65 | layout->addWidget(connectButton); | 72 | layout->addWidget(connectButton); |
66 | 73 | ||
67 | connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); | 74 | connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); |
75 | //And fill cmdLine with ppp script filenames | ||
76 | cmdLine->insertStringList(d.entryList()); | ||
68 | } | 77 | } |
69 | 78 | ||
70 | DunDialog::~DunDialog() { | 79 | DunDialog::~DunDialog() { |
71 | } | 80 | } |
72 | 81 | ||
73 | void DunDialog::connectToDevice() { | 82 | void DunDialog::connectToDevice() { |
74 | bool doEnc = doEncryption->isChecked(); | 83 | bool doEnc = doEncryption->isChecked(); |
75 | bool doPersist = persist->isChecked(); | 84 | bool doPersist = persist->isChecked(); |
76 | 85 | ||
77 | if (cmdLine->text() == "") | 86 | if (cmdLine->currentText() == "") |
78 | return; | 87 | return; |
79 | if (m_dunConnect) { | 88 | if (m_dunConnect) { |
80 | outPut->append(tr("Work in progress")); | 89 | outPut->append(tr("Work in progress")); |
81 | return; | 90 | return; |
82 | } | 91 | } |
83 | m_dunConnect = new OProcess(); | 92 | m_dunConnect = new OProcess(); |
84 | outPut->clear(); | 93 | outPut->clear(); |
85 | 94 | ||
86 | // Fill process command line | 95 | // Fill process command line |
87 | *m_dunConnect << tr("dund") | 96 | *m_dunConnect << tr("dund") |
88 | << tr("--connect") << m_device | 97 | << tr("--connect") << m_device |
89 | << tr("--channel") << QString::number(m_port) | 98 | << tr("--channel") << QString::number(m_port) |
90 | << tr("--nodetach"); | 99 | << tr("--nodetach"); |
91 | if (doEnc) | 100 | if (doEnc) |
92 | *m_dunConnect << tr("--encrypt"); | 101 | *m_dunConnect << tr("--encrypt"); |
93 | if (doPersist) | 102 | if (doPersist) |
94 | *m_dunConnect << tr("--persist"); | 103 | *m_dunConnect << tr("--persist"); |
95 | *m_dunConnect << tr("call") | 104 | *m_dunConnect << tr("call") |
96 | << cmdLine->text(); | 105 | << cmdLine->currentText(); |
97 | if (!m_dunConnect->start(OProcess::NotifyOnExit, | 106 | if (!m_dunConnect->start(OProcess::NotifyOnExit, |
98 | OProcess::All)) { | 107 | OProcess::All)) { |
99 | outPut->append(tr("Couldn't start")); | 108 | outPut->append(tr("Couldn't start")); |
100 | delete m_dunConnect; | 109 | delete m_dunConnect; |
101 | m_dunConnect = NULL; | 110 | m_dunConnect = NULL; |
102 | } | 111 | } |
103 | else | 112 | else |
104 | { | 113 | { |
105 | m_dunConnect->resume(); | 114 | m_dunConnect->resume(); |
106 | outPut->append(tr("Started")); | 115 | outPut->append(tr("Started")); |
107 | connect(m_dunConnect, | 116 | connect(m_dunConnect, |
108 | SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), | 117 | SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), |