author | korovkin <korovkin> | 2006-04-05 19:29:19 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-04-05 19:29:19 (UTC) |
commit | 6c1c44237a16dc8fed89905ae729e36eb9711c07 (patch) (unidiff) | |
tree | cfcb46f571669c0d8e57ee703c712b09ed8af185 /noncore/net/opietooth/manager/pppdialog.cpp | |
parent | 31ea6e9f697d72a31ce319f7f42254fe90e48a36 (diff) | |
download | opie-6c1c44237a16dc8fed89905ae729e36eb9711c07.zip opie-6c1c44237a16dc8fed89905ae729e36eb9711c07.tar.gz opie-6c1c44237a16dc8fed89905ae729e36eb9711c07.tar.bz2 |
Added combobox with ppp script names from /etc/ppp/peers.
Diffstat (limited to 'noncore/net/opietooth/manager/pppdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/pppdialog.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/noncore/net/opietooth/manager/pppdialog.cpp b/noncore/net/opietooth/manager/pppdialog.cpp index 11091c4..1df22a1 100644 --- a/noncore/net/opietooth/manager/pppdialog.cpp +++ b/noncore/net/opietooth/manager/pppdialog.cpp | |||
@@ -1,95 +1,111 @@ | |||
1 | 1 | /* $Id$ */ | |
2 | /* PPP/rfcomm connection dialog */ | ||
3 | /*************************************************************************** | ||
4 | * * | ||
5 | * This program is free software; you can redistribute it and/or modify * | ||
6 | * it under the terms of the GNU General Public License as published by * | ||
7 | * the Free Software Foundation; either version 2 of the License, or * | ||
8 | * (at your option) any later version. * | ||
9 | * * | ||
10 | ***************************************************************************/ | ||
2 | #include "pppdialog.h" | 11 | #include "pppdialog.h" |
3 | #include "rfcommhelper.h" | 12 | #include "rfcommhelper.h" |
4 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
5 | #include <qmultilineedit.h> | 14 | #include <qmultilineedit.h> |
6 | #include <qlineedit.h> | 15 | #include <qlineedit.h> |
7 | #include <qlayout.h> | 16 | #include <qlayout.h> |
8 | #include <qcombobox.h> | 17 | #include <qcombobox.h> |
9 | #include <qlabel.h> | 18 | #include <qlabel.h> |
19 | #include <qdir.h> | ||
10 | #include <opie2/oprocess.h> | 20 | #include <opie2/oprocess.h> |
11 | #include <opie2/odebug.h> | 21 | #include <opie2/odebug.h> |
12 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
13 | 23 | ||
14 | using namespace OpieTooth; | 24 | using namespace OpieTooth; |
15 | 25 | ||
16 | using namespace Opie::Core; | 26 | using namespace Opie::Core; |
17 | 27 | ||
18 | Connection PPPDialog::conns[NCONNECTS]; | 28 | Connection PPPDialog::conns[NCONNECTS]; |
19 | 29 | ||
20 | PPPDialog::PPPDialog( const QString& device, int port, QWidget* parent, | 30 | PPPDialog::PPPDialog( const QString& device, int port, QWidget* parent, |
21 | const char* name, bool modal, WFlags fl ) | 31 | const char* name, bool modal, WFlags fl ) |
22 | : QDialog( parent, name, modal, fl ) { | 32 | : QDialog( parent, name, modal, fl ) { |
23 | int i; //Just an index variable | 33 | int i; //Just an index variable |
34 | QDir d("/etc/ppp/peers/"); //Dir we search files in | ||
35 | d.setFilter( QDir::Files); | ||
36 | d.setSorting( QDir::Size | QDir::Reversed ); | ||
24 | 37 | ||
25 | if ( !name ) | 38 | if ( !name ) |
26 | setName( "PPPDialog" ); | 39 | setName( "PPPDialog" ); |
27 | setCaption( tr( "ppp connection " ) ) ; | 40 | setCaption( tr( "ppp connection " ) ) ; |
28 | 41 | ||
29 | m_device = device; | 42 | m_device = device; |
30 | m_port = port; | 43 | m_port = port; |
31 | 44 | ||
32 | layout = new QVBoxLayout( this ); | 45 | layout = new QVBoxLayout( this ); |
33 | 46 | ||
34 | QLabel* info = new QLabel( this ); | 47 | QLabel* info = new QLabel( this ); |
35 | info->setText( tr("Enter an ppp script name:") ); | 48 | info->setText( tr("Enter a ppp script name:") ); |
36 | 49 | ||
37 | cmdLine = new QLineEdit( this ); | 50 | cmdLine = new QComboBox( this ); |
51 | cmdLine->setEditable(true); | ||
38 | 52 | ||
39 | outPut = new QMultiLineEdit( this ); | 53 | outPut = new QMultiLineEdit( this ); |
40 | QFont outPut_font( outPut->font() ); | 54 | QFont outPut_font( outPut->font() ); |
41 | outPut_font.setPointSize( 8 ); | 55 | outPut_font.setPointSize( 8 ); |
42 | outPut->setFont( outPut_font ); | 56 | outPut->setFont( outPut_font ); |
43 | outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); | 57 | outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); |
44 | 58 | ||
45 | connectButton = new QPushButton( this ); | 59 | connectButton = new QPushButton( this ); |
46 | connectButton->setText( tr( "Connect" ) ); | 60 | connectButton->setText( tr( "Connect" ) ); |
47 | 61 | ||
48 | serPort = new QComboBox(this); | 62 | serPort = new QComboBox(this); |
49 | for (i = 0; i < NCONNECTS; i++) { | 63 | for (i = 0; i < NCONNECTS; i++) { |
50 | if (!PPPDialog::conns[i].proc.isRunning()) | 64 | if (!PPPDialog::conns[i].proc.isRunning()) |
51 | serPort->insertItem(tr("rfcomm%1").arg(i)); | 65 | serPort->insertItem(tr("rfcomm%1").arg(i)); |
52 | } | 66 | } |
53 | 67 | ||
54 | layout->addWidget(info); | 68 | layout->addWidget(info); |
55 | layout->addWidget(cmdLine); | 69 | layout->addWidget(cmdLine); |
56 | layout->addWidget(serPort); | 70 | layout->addWidget(serPort); |
57 | layout->addWidget(outPut); | 71 | layout->addWidget(outPut); |
58 | layout->addWidget(connectButton); | 72 | layout->addWidget(connectButton); |
59 | 73 | ||
60 | 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()); | ||
61 | } | 77 | } |
62 | 78 | ||
63 | PPPDialog::~PPPDialog() { | 79 | PPPDialog::~PPPDialog() { |
64 | } | 80 | } |
65 | 81 | ||
66 | void PPPDialog::connectToDevice() { | 82 | void PPPDialog::connectToDevice() { |
67 | int portNum = serPort->currentText().right(1).toInt(); | 83 | int portNum = serPort->currentText().right(1).toInt(); |
68 | if (PPPDialog::conns[portNum].proc.isRunning()) { | 84 | if (PPPDialog::conns[portNum].proc.isRunning()) { |
69 | outPut->append(tr("Work in progress")); | 85 | outPut->append(tr("Work in progress")); |
70 | return; | 86 | return; |
71 | } | 87 | } |
72 | outPut->clear(); | 88 | outPut->clear(); |
73 | PPPDialog::conns[portNum].proc.clearArguments(); | 89 | PPPDialog::conns[portNum].proc.clearArguments(); |
74 | // vom popupmenu beziehen | 90 | // vom popupmenu beziehen |
75 | if (cmdLine->text().isEmpty()) {//Connect by rfcomm | 91 | if (cmdLine->currentText().isEmpty()) {//Connect by rfcomm |
76 | PPPDialog::conns[portNum].proc << "rfcomm" << "connect" | 92 | PPPDialog::conns[portNum].proc << "rfcomm" << "connect" |
77 | << QString::number(portNum) << m_device << QString::number(m_port); | 93 | << QString::number(portNum) << m_device << QString::number(m_port); |
78 | } | 94 | } |
79 | else { | 95 | else { |
80 | PPPDialog::conns[portNum].proc << "pppd" | 96 | PPPDialog::conns[portNum].proc << "pppd" |
81 | << tr("/dev/bluetooth/rfcomm/%1").arg(portNum) | 97 | << tr("/dev/bluetooth/rfcomm/%1").arg(portNum) |
82 | << "call" | 98 | << "call" |
83 | << cmdLine->text(); | 99 | << cmdLine->currentText(); |
84 | } | 100 | } |
85 | if (!PPPDialog::conns[portNum].proc.start(OProcess::NotifyOnExit, | 101 | if (!PPPDialog::conns[portNum].proc.start(OProcess::NotifyOnExit, |
86 | OProcess::All)) { | 102 | OProcess::All)) { |
87 | outPut->append(tr("Couldn't start")); | 103 | outPut->append(tr("Couldn't start")); |
88 | } | 104 | } |
89 | else | 105 | else |
90 | { | 106 | { |
91 | PPPDialog::conns[portNum].proc.resume(); | 107 | PPPDialog::conns[portNum].proc.resume(); |
92 | outPut->append(tr("Started")); | 108 | outPut->append(tr("Started")); |
93 | PPPDialog::conns[portNum].btAddr = m_device; | 109 | PPPDialog::conns[portNum].btAddr = m_device; |
94 | PPPDialog::conns[portNum].port = m_port; | 110 | PPPDialog::conns[portNum].port = m_port; |
95 | connect(&PPPDialog::conns[portNum].proc, | 111 | connect(&PPPDialog::conns[portNum].proc, |