summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-03-30 20:11:13 (UTC)
committer korovkin <korovkin>2006-03-30 20:11:13 (UTC)
commit2efba75b536877b4138197af4159849e87b12bde (patch) (side-by-side diff)
tree933e2093350d0475e135389231dd681db3ff6289
parent8d8474e48d134c6ee64311d47f22753adcd63d10 (diff)
downloadopie-2efba75b536877b4138197af4159849e87b12bde.zip
opie-2efba75b536877b4138197af4159849e87b12bde.tar.gz
opie-2efba75b536877b4138197af4159849e87b12bde.tar.bz2
Added connections to several /dev/bluetooth/rfcomm/* ports.
Fixed typo in pppd command line.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/pppdialog.cpp64
-rw-r--r--noncore/net/opietooth/manager/pppdialog.h2
2 files changed, 42 insertions, 24 deletions
diff --git a/noncore/net/opietooth/manager/pppdialog.cpp b/noncore/net/opietooth/manager/pppdialog.cpp
index b8d800a..11091c4 100644
--- a/noncore/net/opietooth/manager/pppdialog.cpp
+++ b/noncore/net/opietooth/manager/pppdialog.cpp
@@ -1,104 +1,115 @@
#include "pppdialog.h"
#include "rfcommhelper.h"
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qlineedit.h>
#include <qlayout.h>
+#include <qcombobox.h>
#include <qlabel.h>
#include <opie2/oprocess.h>
#include <opie2/odebug.h>
using namespace Opie::Core;
using namespace OpieTooth;
using namespace Opie::Core;
Connection PPPDialog::conns[NCONNECTS];
PPPDialog::PPPDialog( const QString& device, int port, QWidget* parent,
const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl ) {
+ int i; //Just an index variable
if ( !name )
setName( "PPPDialog" );
setCaption( tr( "ppp connection " ) ) ;
m_device = device;
m_port = port;
layout = new QVBoxLayout( this );
QLabel* info = new QLabel( this );
info->setText( tr("Enter an ppp script name:") );
cmdLine = new QLineEdit( this );
outPut = new QMultiLineEdit( this );
QFont outPut_font( outPut->font() );
outPut_font.setPointSize( 8 );
outPut->setFont( outPut_font );
outPut->setWordWrap( QMultiLineEdit::WidgetWidth );
connectButton = new QPushButton( this );
connectButton->setText( tr( "Connect" ) );
-
+
+ serPort = new QComboBox(this);
+ for (i = 0; i < NCONNECTS; i++) {
+ if (!PPPDialog::conns[i].proc.isRunning())
+ serPort->insertItem(tr("rfcomm%1").arg(i));
+ }
+
layout->addWidget(info);
layout->addWidget(cmdLine);
+ layout->addWidget(serPort);
layout->addWidget(outPut);
layout->addWidget(connectButton);
connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) );
-
- connect(&PPPDialog::conns[0].proc,
- SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)),
- this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int)));
- connect( &PPPDialog::conns[0].proc,
- SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)),
- this, SLOT(fillErr(Opie::Core::OProcess*, char*, int)));
- connect( &PPPDialog::conns[0].proc,
- SIGNAL(processExited(Opie::Core::OProcess*)),
- this, SLOT(slotProcessExited(Opie::Core::OProcess*)));
}
PPPDialog::~PPPDialog() {
}
void PPPDialog::connectToDevice() {
- if (PPPDialog::conns[0].proc.isRunning()) {
+ int portNum = serPort->currentText().right(1).toInt();
+ if (PPPDialog::conns[portNum].proc.isRunning()) {
outPut->append(tr("Work in progress"));
return;
}
outPut->clear();
- PPPDialog::conns[0].proc.clearArguments();
+ PPPDialog::conns[portNum].proc.clearArguments();
// vom popupmenu beziehen
if (cmdLine->text().isEmpty()) {//Connect by rfcomm
- PPPDialog::conns[0].proc << "rfcomm" << "connect"
- << "0" << m_device << QString::number(m_port);
+ PPPDialog::conns[portNum].proc << "rfcomm" << "connect"
+ << QString::number(portNum) << m_device << QString::number(m_port);
}
else {
- QString connectScript = "/etc/ppp/peers/" + cmdLine->text();
- PPPDialog::conns[0].proc << "pppd"
- << m_device << "call" << connectScript;
+ PPPDialog::conns[portNum].proc << "pppd"
+ << tr("/dev/bluetooth/rfcomm/%1").arg(portNum)
+ << "call"
+ << cmdLine->text();
}
- if (!PPPDialog::conns[0].proc.start(OProcess::NotifyOnExit, OProcess::All)) {
+ if (!PPPDialog::conns[portNum].proc.start(OProcess::NotifyOnExit,
+ OProcess::All)) {
outPut->append(tr("Couldn't start"));
}
else
{
- PPPDialog::conns[0].proc.resume();
+ PPPDialog::conns[portNum].proc.resume();
outPut->append(tr("Started"));
- PPPDialog::conns[0].btAddr = m_device;
- PPPDialog::conns[0].port = m_port;
+ PPPDialog::conns[portNum].btAddr = m_device;
+ PPPDialog::conns[portNum].port = m_port;
+ connect(&PPPDialog::conns[portNum].proc,
+ SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)),
+ this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int)));
+ connect( &PPPDialog::conns[portNum].proc,
+ SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)),
+ this, SLOT(fillErr(Opie::Core::OProcess*, char*, int)));
+ connect( &PPPDialog::conns[portNum].proc,
+ SIGNAL(processExited(Opie::Core::OProcess*)),
+ this, SLOT(slotProcessExited(Opie::Core::OProcess*)));
}
}
void PPPDialog::fillOutPut( OProcess*, char* cha, int len ) {
QCString str(cha, len);
outPut->append(str);
}
void PPPDialog::fillErr(OProcess*, char* buf, int len)
{
QCString str(buf, len);
outPut->append(str);
@@ -106,16 +117,21 @@ void PPPDialog::fillErr(OProcess*, char* buf, int len)
void PPPDialog::slotProcessExited(OProcess* proc) {
if (proc->normalExit()) {
outPut->append( tr("Finished with result ") );
outPut->append( QString::number(proc->exitStatus()) );
}
else
outPut->append( tr("Exited abnormally") );
}
void PPPDialog::closeEvent(QCloseEvent* e)
{
- if(PPPDialog::conns[0].proc.isRunning())
- PPPDialog::conns[0].proc.kill();
+ int i; //index variable
+ for (i = 0; i < NCONNECTS; i++) {
+ if(PPPDialog::conns[i].proc.isRunning())
+ PPPDialog::conns[i].proc.kill();
+ }
QDialog::closeEvent(e);
}
+
+//eof
diff --git a/noncore/net/opietooth/manager/pppdialog.h b/noncore/net/opietooth/manager/pppdialog.h
index 565fe1e..e0ffc7f 100644
--- a/noncore/net/opietooth/manager/pppdialog.h
+++ b/noncore/net/opietooth/manager/pppdialog.h
@@ -1,23 +1,24 @@
#ifndef PPPDIALOG_H
#define PPPDIALOG_H
#include <qdialog.h>
#include <opie2/oprocess.h>
class QVBoxLayout;
class QPushButton;
class QMultiLineEdit;
class QLineEdit;
+class QComboBox;
#define NCONNECTS 10 //Maximal
namespace OpieTooth {
typedef struct {
Opie::Core::OProcess proc; //Connection process
QString btAddr; //MAC address
int port; //port
} Connection;
class PPPDialog : public QDialog {
Q_OBJECT
@@ -31,19 +32,20 @@ namespace OpieTooth {
void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len );
void fillErr(Opie::Core::OProcess*, char*, int);
void slotProcessExited(Opie::Core::OProcess* proc);
void closeEvent(QCloseEvent* e);
public:
//Array of connections indexed by rfcomm device number
static Connection conns[NCONNECTS];
protected:
QVBoxLayout* layout;
QLineEdit* cmdLine;
QPushButton* connectButton;
QMultiLineEdit* outPut;
+ QComboBox* serPort;
private:
QString m_device;
int m_port;
};
}
#endif