summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/TODO.txt2
-rw-r--r--noncore/net/opietooth/manager/dundialog.cpp8
-rw-r--r--noncore/net/opietooth/manager/dundialog.h1
-rw-r--r--noncore/net/opietooth/manager/dunpopup.cpp3
4 files changed, 13 insertions, 1 deletions
diff --git a/noncore/net/opietooth/manager/TODO.txt b/noncore/net/opietooth/manager/TODO.txt
index 1914d8b..ed512cd 100644
--- a/noncore/net/opietooth/manager/TODO.txt
+++ b/noncore/net/opietooth/manager/TODO.txt
@@ -1,4 +1,4 @@
11. Try and run and correct authentification and encoding. 11. Improve hcid.conf parsing algorithm.
22. Collect requirements from others. 22. Collect requirements from others.
3 3
4//eof 4//eof
diff --git a/noncore/net/opietooth/manager/dundialog.cpp b/noncore/net/opietooth/manager/dundialog.cpp
index 7aac271..c6d8619 100644
--- a/noncore/net/opietooth/manager/dundialog.cpp
+++ b/noncore/net/opietooth/manager/dundialog.cpp
@@ -9,126 +9,134 @@
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 <opie2/oprocess.h> 19#include <opie2/oprocess.h>
20#include <opie2/odebug.h> 20#include <opie2/odebug.h>
21using namespace Opie::Core; 21using namespace Opie::Core;
22 22
23using namespace OpieTooth; 23using namespace OpieTooth;
24 24
25using namespace Opie::Core; 25using namespace Opie::Core;
26 26
27DunDialog::DunDialog( const QString& device, int port, QWidget* parent, 27DunDialog::DunDialog( const QString& device, int port, QWidget* parent,
28 const char* name, bool modal, WFlags fl ) 28 const char* name, bool modal, WFlags fl )
29 : QDialog( parent, name, modal, fl ) { 29 : QDialog( parent, name, modal, fl ) {
30 if ( !name ) 30 if ( !name )
31 setName( "DUNDialog" ); 31 setName( "DUNDialog" );
32 setCaption( tr( "DUN connection " ) ) ; 32 setCaption( tr( "DUN connection " ) ) ;
33 33
34 m_device = device; 34 m_device = device;
35 m_port = port; 35 m_port = port;
36 36
37 m_dunConnect = NULL; 37 m_dunConnect = NULL;
38 layout = new QVBoxLayout( this ); 38 layout = new QVBoxLayout( this );
39 39
40 QLabel* info = new QLabel( this ); 40 QLabel* info = new QLabel( this );
41 info->setText( tr("Enter an ppp script name:") ); 41 info->setText( tr("Enter an ppp script name:") );
42 42
43 cmdLine = new QLineEdit( this ); 43 cmdLine = new QLineEdit( this );
44 44
45 outPut = new QMultiLineEdit( this ); 45 outPut = new QMultiLineEdit( this );
46 QFont outPut_font( outPut->font() ); 46 QFont outPut_font( outPut->font() );
47 outPut_font.setPointSize( 8 ); 47 outPut_font.setPointSize( 8 );
48 outPut->setFont( outPut_font ); 48 outPut->setFont( outPut_font );
49 outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); 49 outPut->setWordWrap( QMultiLineEdit::WidgetWidth );
50 50
51 connectButton = new QPushButton( this ); 51 connectButton = new QPushButton( this );
52 connectButton->setText( tr( "Connect" ) ); 52 connectButton->setText( tr( "Connect" ) );
53 53
54 doEncryption = new QCheckBox(this, "encrypt"); 54 doEncryption = new QCheckBox(this, "encrypt");
55 doEncryption->setText( tr( "encrypt" ) ); 55 doEncryption->setText( tr( "encrypt" ) );
56 56
57 persist = new QCheckBox(this, "persist");
58 persist->setText( tr( "persist" ) );
59
57 layout->addWidget(info); 60 layout->addWidget(info);
58 layout->addWidget(cmdLine); 61 layout->addWidget(cmdLine);
59 layout->addWidget(doEncryption); 62 layout->addWidget(doEncryption);
63 layout->addWidget(persist);
60 layout->addWidget(outPut); 64 layout->addWidget(outPut);
61 layout->addWidget(connectButton); 65 layout->addWidget(connectButton);
62 66
63 connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); 67 connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) );
64} 68}
65 69
66DunDialog::~DunDialog() { 70DunDialog::~DunDialog() {
67} 71}
68 72
69void DunDialog::connectToDevice() { 73void DunDialog::connectToDevice() {
70 bool doEnc = doEncryption->isChecked(); 74 bool doEnc = doEncryption->isChecked();
75 bool doPersist = persist->isChecked();
76
71 if (cmdLine->text() == "") 77 if (cmdLine->text() == "")
72 return; 78 return;
73 if (m_dunConnect) { 79 if (m_dunConnect) {
74 outPut->append(tr("Work in progress")); 80 outPut->append(tr("Work in progress"));
75 return; 81 return;
76 } 82 }
77 m_dunConnect = new OProcess(); 83 m_dunConnect = new OProcess();
78 outPut->clear(); 84 outPut->clear();
79 85
80 // Fill process command line 86 // Fill process command line
81 *m_dunConnect << tr("dund") 87 *m_dunConnect << tr("dund")
82 << tr("--connect") << m_device 88 << tr("--connect") << m_device
83 << tr("--channel") << QString::number(m_port) 89 << tr("--channel") << QString::number(m_port)
84 << tr("--nodetach"); 90 << tr("--nodetach");
85 if (doEnc) 91 if (doEnc)
86 *m_dunConnect << tr("--encrypt"); 92 *m_dunConnect << tr("--encrypt");
93 if (doPersist)
94 *m_dunConnect << tr("--persist");
87 *m_dunConnect << tr("call") 95 *m_dunConnect << tr("call")
88 << cmdLine->text(); 96 << cmdLine->text();
89 if (!m_dunConnect->start(OProcess::NotifyOnExit, 97 if (!m_dunConnect->start(OProcess::NotifyOnExit,
90 OProcess::All)) { 98 OProcess::All)) {
91 outPut->append(tr("Couldn't start")); 99 outPut->append(tr("Couldn't start"));
92 delete m_dunConnect; 100 delete m_dunConnect;
93 m_dunConnect = NULL; 101 m_dunConnect = NULL;
94 } 102 }
95 else 103 else
96 { 104 {
97 m_dunConnect->resume(); 105 m_dunConnect->resume();
98 outPut->append(tr("Started")); 106 outPut->append(tr("Started"));
99 connect(m_dunConnect, 107 connect(m_dunConnect,
100 SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), 108 SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)),
101 this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int))); 109 this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int)));
102 connect(m_dunConnect, 110 connect(m_dunConnect,
103 SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), 111 SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)),
104 this, SLOT(fillErr(Opie::Core::OProcess*, char*, int))); 112 this, SLOT(fillErr(Opie::Core::OProcess*, char*, int)));
105 connect(m_dunConnect, 113 connect(m_dunConnect,
106 SIGNAL(processExited(Opie::Core::OProcess*)), 114 SIGNAL(processExited(Opie::Core::OProcess*)),
107 this, SLOT(slotProcessExited(Opie::Core::OProcess*))); 115 this, SLOT(slotProcessExited(Opie::Core::OProcess*)));
108 } 116 }
109} 117}
110 118
111void DunDialog::fillOutPut( OProcess*, char* cha, int len ) { 119void DunDialog::fillOutPut( OProcess*, char* cha, int len ) {
112 QCString str(cha, len); 120 QCString str(cha, len);
113 outPut->append(str); 121 outPut->append(str);
114} 122}
115 123
116void DunDialog::fillErr(OProcess*, char* buf, int len) 124void DunDialog::fillErr(OProcess*, char* buf, int len)
117{ 125{
118 QCString str(buf, len); 126 QCString str(buf, len);
119 outPut->append(str); 127 outPut->append(str);
120} 128}
121 129
122void DunDialog::slotProcessExited(OProcess* proc) { 130void DunDialog::slotProcessExited(OProcess* proc) {
123 if (m_dunConnect->normalExit()) { 131 if (m_dunConnect->normalExit()) {
124 outPut->append( tr("Finished with result ") ); 132 outPut->append( tr("Finished with result ") );
125 outPut->append( QString::number(proc->exitStatus()) ); 133 outPut->append( QString::number(proc->exitStatus()) );
126 } 134 }
127 else 135 else
128 outPut->append( tr("Exited abnormally") ); 136 outPut->append( tr("Exited abnormally") );
129 delete m_dunConnect; 137 delete m_dunConnect;
130 m_dunConnect = NULL; 138 m_dunConnect = NULL;
131} 139}
132 140
133void DunDialog::closeEvent(QCloseEvent* e) 141void DunDialog::closeEvent(QCloseEvent* e)
134{ 142{
diff --git a/noncore/net/opietooth/manager/dundialog.h b/noncore/net/opietooth/manager/dundialog.h
index 9e219cd..a0d16ad 100644
--- a/noncore/net/opietooth/manager/dundialog.h
+++ b/noncore/net/opietooth/manager/dundialog.h
@@ -1,52 +1,53 @@
1/* $Id$ */ 1/* $Id$ */
2/* DUN connection dialog */ 2/* DUN connection dialog */
3/*************************************************************************** 3/***************************************************************************
4 * * 4 * *
5 * This program is free software; you can redistribute it and/or modify * 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 * 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 * 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#ifndef DUNDIALOG_H 11#ifndef DUNDIALOG_H
12#define DUNDIALOG_H 12#define DUNDIALOG_H
13 13
14 14
15#include <qdialog.h> 15#include <qdialog.h>
16#include <opie2/oprocess.h> 16#include <opie2/oprocess.h>
17 17
18class QVBoxLayout; 18class QVBoxLayout;
19class QPushButton; 19class QPushButton;
20class QMultiLineEdit; 20class QMultiLineEdit;
21class QLineEdit; 21class QLineEdit;
22class QCheckBox; 22class QCheckBox;
23 23
24namespace OpieTooth { 24namespace OpieTooth {
25 class DunDialog : public QDialog { 25 class DunDialog : public QDialog {
26 26
27 Q_OBJECT 27 Q_OBJECT
28 28
29 public: 29 public:
30 DunDialog(const QString& device = 0, int port = 0, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0); 30 DunDialog(const QString& device = 0, int port = 0, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0);
31 ~DunDialog(); 31 ~DunDialog();
32 32
33 private slots: 33 private slots:
34 void connectToDevice(); 34 void connectToDevice();
35 void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len ); 35 void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len );
36 void fillErr(Opie::Core::OProcess*, char*, int); 36 void fillErr(Opie::Core::OProcess*, char*, int);
37 void slotProcessExited(Opie::Core::OProcess* proc); 37 void slotProcessExited(Opie::Core::OProcess* proc);
38 void closeEvent(QCloseEvent* e); 38 void closeEvent(QCloseEvent* e);
39 protected: 39 protected:
40 QVBoxLayout* layout; 40 QVBoxLayout* layout;
41 QLineEdit* cmdLine; 41 QLineEdit* cmdLine;
42 QPushButton* connectButton; 42 QPushButton* connectButton;
43 QMultiLineEdit* outPut; 43 QMultiLineEdit* outPut;
44 QCheckBox* doEncryption; 44 QCheckBox* doEncryption;
45 QCheckBox* persist;
45 46
46 private: 47 private:
47 QString m_device; //device BT address 48 QString m_device; //device BT address
48 int m_port; //device process 49 int m_port; //device process
49 Opie::Core::OProcess* m_dunConnect; //DUN process 50 Opie::Core::OProcess* m_dunConnect; //DUN process
50 }; 51 };
51} 52}
52#endif 53#endif
diff --git a/noncore/net/opietooth/manager/dunpopup.cpp b/noncore/net/opietooth/manager/dunpopup.cpp
index c304b2d..6844988 100644
--- a/noncore/net/opietooth/manager/dunpopup.cpp
+++ b/noncore/net/opietooth/manager/dunpopup.cpp
@@ -17,64 +17,67 @@ using namespace Opie::Core;
17 17
18#include "dunpopup.h" 18#include "dunpopup.h"
19#include "dundialog.h" 19#include "dundialog.h"
20 20
21using namespace OpieTooth; 21using namespace OpieTooth;
22 22
23/* 23/*
24 * c'tor init the QAction 24 * c'tor init the QAction
25 */ 25 */
26DunPopup::DunPopup( const Services& service, 26DunPopup::DunPopup( const Services& service,
27 BTDeviceItem* item ) : QPopupMenu(), m_service(service) { 27 BTDeviceItem* item ) : QPopupMenu(), m_service(service) {
28 28
29 owarn << "DunPopup c'tor" << oendl; 29 owarn << "DunPopup c'tor" << oendl;
30 30
31 m_item = item; 31 m_item = item;
32 QAction *a, *b, *c; 32 QAction *a, *b, *c;
33 33
34 a = new QAction(); // so it's get deleted 34 a = new QAction(); // so it's get deleted
35 a->setText( tr("connect") ); 35 a->setText( tr("connect") );
36 a->addTo( this ); 36 a->addTo( this );
37 connect( a, SIGNAL( activated() ), this, SLOT( slotConnect() ) ); 37 connect( a, SIGNAL( activated() ), this, SLOT( slotConnect() ) );
38 38
39 b = new QAction(); 39 b = new QAction();
40 b->setText( tr( "connect+conf" ) ); 40 b->setText( tr( "connect+conf" ) );
41 b->addTo( this ); 41 b->addTo( this );
42 connect( b, SIGNAL( activated() ), this, SLOT( slotConnectAndConfig() ) ); 42 connect( b, SIGNAL( activated() ), this, SLOT( slotConnectAndConfig() ) );
43 43
44 c = new QAction(); 44 c = new QAction();
45 c->setText( tr( "disconnect" ) ); 45 c->setText( tr( "disconnect" ) );
46 c->addTo( this ); 46 c->addTo( this );
47 connect( c, SIGNAL( activated() ), this, SLOT( slotDisconnect() ) ); 47 connect( c, SIGNAL( activated() ), this, SLOT( slotDisconnect() ) );
48 48
49}; 49};
50 50
51DunPopup::~DunPopup() { 51DunPopup::~DunPopup() {
52 52
53} 53}
54 54
55void DunPopup::slotConnect() { 55void DunPopup::slotConnect() {
56 odebug << "connect" << oendl; 56 odebug << "connect" << oendl;
57 DunDialog dundlg(m_item->mac(), 57 DunDialog dundlg(m_item->mac(),
58 m_service.protocolDescriptorList().last().port()); 58 m_service.protocolDescriptorList().last().port());
59 QPEApplication::execDialog( &dundlg ); 59 QPEApplication::execDialog( &dundlg );
60} 60}
61 61
62void DunPopup::slotDisconnect() { 62void DunPopup::slotDisconnect() {
63 OProcess dunDis; 63 OProcess dunDis;
64 OProcess pppDis; 64 OProcess pppDis;
65 OProcess dunKill;
65 dunDis << tr("dund") << tr("--kill") << m_item->mac(); 66 dunDis << tr("dund") << tr("--kill") << m_item->mac();
66 dunDis.start(OProcess::DontCare, OProcess::NoCommunication); 67 dunDis.start(OProcess::DontCare, OProcess::NoCommunication);
68 dunKill << tr("killall") << tr("-q") << tr("dund");
69 dunKill.start(OProcess::DontCare, OProcess::NoCommunication);
67 pppDis << tr("killall") << tr("-q") << tr("pppd"); 70 pppDis << tr("killall") << tr("-q") << tr("pppd");
68 pppDis.start(OProcess::DontCare, OProcess::NoCommunication); 71 pppDis.start(OProcess::DontCare, OProcess::NoCommunication);
69 sleep(1); 72 sleep(1);
70 QMessageBox::information(this, tr("DUN Disconnect"), tr("DUN Disconnected")); 73 QMessageBox::information(this, tr("DUN Disconnect"), tr("DUN Disconnected"));
71} 74}
72 75
73 76
74void DunPopup::slotConnectAndConfig() { 77void DunPopup::slotConnectAndConfig() {
75 slotConnect(); 78 slotConnect();
76 79
77 // more intelligence here later like passing the device ( bnepX ) 80 // more intelligence here later like passing the device ( bnepX )
78 QCopEnvelope e( "QPE/System", "execute(QString)" ); 81 QCopEnvelope e( "QPE/System", "execute(QString)" );
79 e << QString( "networksettings" ); 82 e << QString( "networksettings" );
80} 83}