summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/pppdialog.cpp
blob: 4e585523b21f61f86e1828816b2c9700ec68923f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

#include "pppdialog.h"
#include <qpushbutton.h>
#include <qmultilineedit.h>
#include <qlineedit.h>
#include <qlayout.h>
#include <qlabel.h>
#include <opie/oprocess.h>

using namespace OpieTooth;

PPPDialog::PPPDialog( QWidget* parent,  const char* name, bool modal, WFlags fl, const QString& device )
    : QDialog( parent, name, modal, fl ) {

    if ( !name )
	setName( "PPPDialog" );
    setCaption( tr( "ppp connection " ) ) ;

    m_device = device;

    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" ) );

    layout->addWidget(info);
    layout->addWidget(cmdLine);
    layout->addWidget(outPut);
    layout->addWidget(connectButton);

    connect( connectButton, SIGNAL( clicked() ), this,  SLOT( connectToDevice() ) );

}

PPPDialog::~PPPDialog() {
}

void PPPDialog::connectToDevice() {
    outPut->clear();
    // vom popupmenu beziehen
    QString connectScript = "/etc/ppp/peers/" + cmdLine->text();
    OProcess* pppDial = new OProcess();
    *pppDial << "pppd" << m_device << "call" << connectScript;
    connect( pppDial, SIGNAL(receivedStdout(OProcess*,char*,int) ),
                this, SLOT(fillOutPut(OProcess*,char*,int) ) );
     if (!pppDial->start(OProcess::DontCare, OProcess::AllOutput) ) {
        qWarning("could not start");
        delete pppDial;
    }
}

void PPPDialog::fillOutPut( OProcess* pppDial, char* cha, int len ) {
    QCString str(cha, len );
    outPut->insertLine( str );
    delete pppDial;
}