summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-04-09 17:14:19 (UTC)
committer korovkin <korovkin>2006-04-09 17:14:19 (UTC)
commitfb5daa581aee96edca0206f2f68d25c370692adb (patch) (unidiff)
tree04ddf2ff040a195d5ad6ae310a988457c7cc52a0
parent6c1c44237a16dc8fed89905ae729e36eb9711c07 (diff)
downloadopie-fb5daa581aee96edca0206f2f68d25c370692adb.zip
opie-fb5daa581aee96edca0206f2f68d25c370692adb.tar.gz
opie-fb5daa581aee96edca0206f2f68d25c370692adb.tar.bz2
Added empty string in the beginning of the list of ppp scripts.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/pppdialog.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/pppdialog.cpp b/noncore/net/opietooth/manager/pppdialog.cpp
index 1df22a1..4ab3738 100644
--- a/noncore/net/opietooth/manager/pppdialog.cpp
+++ b/noncore/net/opietooth/manager/pppdialog.cpp
@@ -12,128 +12,129 @@
12#include "rfcommhelper.h" 12#include "rfcommhelper.h"
13#include <qpushbutton.h> 13#include <qpushbutton.h>
14#include <qmultilineedit.h> 14#include <qmultilineedit.h>
15#include <qlineedit.h> 15#include <qlineedit.h>
16#include <qlayout.h> 16#include <qlayout.h>
17#include <qcombobox.h> 17#include <qcombobox.h>
18#include <qlabel.h> 18#include <qlabel.h>
19#include <qdir.h> 19#include <qdir.h>
20#include <opie2/oprocess.h> 20#include <opie2/oprocess.h>
21#include <opie2/odebug.h> 21#include <opie2/odebug.h>
22using namespace Opie::Core; 22using namespace Opie::Core;
23 23
24using namespace OpieTooth; 24using namespace OpieTooth;
25 25
26using namespace Opie::Core; 26using namespace Opie::Core;
27 27
28Connection PPPDialog::conns[NCONNECTS]; 28Connection PPPDialog::conns[NCONNECTS];
29 29
30PPPDialog::PPPDialog( const QString& device, int port, QWidget* parent, 30PPPDialog::PPPDialog( const QString& device, int port, QWidget* parent,
31 const char* name, bool modal, WFlags fl ) 31 const char* name, bool modal, WFlags fl )
32 : QDialog( parent, name, modal, fl ) { 32 : QDialog( parent, name, modal, fl ) {
33 int i; //Just an index variable 33 int i; //Just an index variable
34 QDir d("/etc/ppp/peers/"); //Dir we search files in 34 QDir d("/etc/ppp/peers/"); //Dir we search files in
35 d.setFilter( QDir::Files); 35 d.setFilter( QDir::Files);
36 d.setSorting( QDir::Size | QDir::Reversed ); 36 d.setSorting( QDir::Size | QDir::Reversed );
37 37
38 if ( !name ) 38 if ( !name )
39 setName( "PPPDialog" ); 39 setName( "PPPDialog" );
40 setCaption( tr( "ppp connection " ) ) ; 40 setCaption( tr( "ppp connection " ) ) ;
41 41
42 m_device = device; 42 m_device = device;
43 m_port = port; 43 m_port = port;
44 44
45 layout = new QVBoxLayout( this ); 45 layout = new QVBoxLayout( this );
46 46
47 QLabel* info = new QLabel( this ); 47 QLabel* info = new QLabel( this );
48 info->setText( tr("Enter a ppp script name:") ); 48 info->setText( tr("Enter a ppp script name:") );
49 49
50 cmdLine = new QComboBox( this ); 50 cmdLine = new QComboBox( this );
51 cmdLine->setEditable(true); 51 cmdLine->setEditable(true);
52 52
53 outPut = new QMultiLineEdit( this ); 53 outPut = new QMultiLineEdit( this );
54 QFont outPut_font( outPut->font() ); 54 QFont outPut_font( outPut->font() );
55 outPut_font.setPointSize( 8 ); 55 outPut_font.setPointSize( 8 );
56 outPut->setFont( outPut_font ); 56 outPut->setFont( outPut_font );
57 outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); 57 outPut->setWordWrap( QMultiLineEdit::WidgetWidth );
58 58
59 connectButton = new QPushButton( this ); 59 connectButton = new QPushButton( this );
60 connectButton->setText( tr( "Connect" ) ); 60 connectButton->setText( tr( "Connect" ) );
61 61
62 serPort = new QComboBox(this); 62 serPort = new QComboBox(this);
63 for (i = 0; i < NCONNECTS; i++) { 63 for (i = 0; i < NCONNECTS; i++) {
64 if (!PPPDialog::conns[i].proc.isRunning()) 64 if (!PPPDialog::conns[i].proc.isRunning())
65 serPort->insertItem(tr("rfcomm%1").arg(i)); 65 serPort->insertItem(tr("rfcomm%1").arg(i));
66 } 66 }
67 67
68 layout->addWidget(info); 68 layout->addWidget(info);
69 layout->addWidget(cmdLine); 69 layout->addWidget(cmdLine);
70 layout->addWidget(serPort); 70 layout->addWidget(serPort);
71 layout->addWidget(outPut); 71 layout->addWidget(outPut);
72 layout->addWidget(connectButton); 72 layout->addWidget(connectButton);
73 73
74 connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); 74 connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) );
75 //And fill cmdLine with ppp script filenames 75 //And fill cmdLine with ppp script filenames
76 cmdLine->insertItem("");
76 cmdLine->insertStringList(d.entryList()); 77 cmdLine->insertStringList(d.entryList());
77} 78}
78 79
79PPPDialog::~PPPDialog() { 80PPPDialog::~PPPDialog() {
80} 81}
81 82
82void PPPDialog::connectToDevice() { 83void PPPDialog::connectToDevice() {
83 int portNum = serPort->currentText().right(1).toInt(); 84 int portNum = serPort->currentText().right(1).toInt();
84 if (PPPDialog::conns[portNum].proc.isRunning()) { 85 if (PPPDialog::conns[portNum].proc.isRunning()) {
85 outPut->append(tr("Work in progress")); 86 outPut->append(tr("Work in progress"));
86 return; 87 return;
87 } 88 }
88 outPut->clear(); 89 outPut->clear();
89 PPPDialog::conns[portNum].proc.clearArguments(); 90 PPPDialog::conns[portNum].proc.clearArguments();
90 // vom popupmenu beziehen 91 // vom popupmenu beziehen
91 if (cmdLine->currentText().isEmpty()) {//Connect by rfcomm 92 if (cmdLine->currentText().isEmpty()) {//Connect by rfcomm
92 PPPDialog::conns[portNum].proc << "rfcomm" << "connect" 93 PPPDialog::conns[portNum].proc << "rfcomm" << "connect"
93 << QString::number(portNum) << m_device << QString::number(m_port); 94 << QString::number(portNum) << m_device << QString::number(m_port);
94 } 95 }
95 else { 96 else {
96 PPPDialog::conns[portNum].proc << "pppd" 97 PPPDialog::conns[portNum].proc << "pppd"
97 << tr("/dev/bluetooth/rfcomm/%1").arg(portNum) 98 << tr("/dev/bluetooth/rfcomm/%1").arg(portNum)
98 << "call" 99 << "call"
99 << cmdLine->currentText(); 100 << cmdLine->currentText();
100 } 101 }
101 if (!PPPDialog::conns[portNum].proc.start(OProcess::NotifyOnExit, 102 if (!PPPDialog::conns[portNum].proc.start(OProcess::NotifyOnExit,
102 OProcess::All)) { 103 OProcess::All)) {
103 outPut->append(tr("Couldn't start")); 104 outPut->append(tr("Couldn't start"));
104 } 105 }
105 else 106 else
106 { 107 {
107 PPPDialog::conns[portNum].proc.resume(); 108 PPPDialog::conns[portNum].proc.resume();
108 outPut->append(tr("Started")); 109 outPut->append(tr("Started"));
109 PPPDialog::conns[portNum].btAddr = m_device; 110 PPPDialog::conns[portNum].btAddr = m_device;
110 PPPDialog::conns[portNum].port = m_port; 111 PPPDialog::conns[portNum].port = m_port;
111 connect(&PPPDialog::conns[portNum].proc, 112 connect(&PPPDialog::conns[portNum].proc,
112 SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), 113 SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)),
113 this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int))); 114 this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int)));
114 connect( &PPPDialog::conns[portNum].proc, 115 connect( &PPPDialog::conns[portNum].proc,
115 SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), 116 SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)),
116 this, SLOT(fillErr(Opie::Core::OProcess*, char*, int))); 117 this, SLOT(fillErr(Opie::Core::OProcess*, char*, int)));
117 connect( &PPPDialog::conns[portNum].proc, 118 connect( &PPPDialog::conns[portNum].proc,
118 SIGNAL(processExited(Opie::Core::OProcess*)), 119 SIGNAL(processExited(Opie::Core::OProcess*)),
119 this, SLOT(slotProcessExited(Opie::Core::OProcess*))); 120 this, SLOT(slotProcessExited(Opie::Core::OProcess*)));
120 } 121 }
121} 122}
122 123
123void PPPDialog::fillOutPut( OProcess*, char* cha, int len ) { 124void PPPDialog::fillOutPut( OProcess*, char* cha, int len ) {
124 QCString str(cha, len); 125 QCString str(cha, len);
125 outPut->append(str); 126 outPut->append(str);
126} 127}
127 128
128void PPPDialog::fillErr(OProcess*, char* buf, int len) 129void PPPDialog::fillErr(OProcess*, char* buf, int len)
129{ 130{
130 QCString str(buf, len); 131 QCString str(buf, len);
131 outPut->append(str); 132 outPut->append(str);
132} 133}
133 134
134void PPPDialog::slotProcessExited(OProcess* proc) { 135void PPPDialog::slotProcessExited(OProcess* proc) {
135 if (proc->normalExit()) { 136 if (proc->normalExit()) {
136 outPut->append( tr("Finished with result ") ); 137 outPut->append( tr("Finished with result ") );
137 outPut->append( QString::number(proc->exitStatus()) ); 138 outPut->append( QString::number(proc->exitStatus()) );
138 } 139 }
139 else 140 else