author | korovkin <korovkin> | 2006-04-03 04:16:39 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-04-03 04:16:39 (UTC) |
commit | 70c7420d074505c75a5482e3e71be2e403df7b62 (patch) (unidiff) | |
tree | 795f5fee86d62f6304ad129fa543622362ed4f1f | |
parent | 430017b047c885ba4dfd9f4074f4e4ab130d5709 (diff) | |
download | opie-70c7420d074505c75a5482e3e71be2e403df7b62.zip opie-70c7420d074505c75a5482e3e71be2e403df7b62.tar.gz opie-70c7420d074505c75a5482e3e71be2e403df7b62.tar.bz2 |
Added dialog boxes for PAN connection.
-rw-r--r-- | noncore/net/opietooth/manager/pandialog.cpp | 125 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/pandialog.h | 40 |
2 files changed, 165 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/pandialog.cpp b/noncore/net/opietooth/manager/pandialog.cpp new file mode 100644 index 0000000..ca6f491 --- a/dev/null +++ b/noncore/net/opietooth/manager/pandialog.cpp | |||
@@ -0,0 +1,125 @@ | |||
1 | |||
2 | #include "pandialog.h" | ||
3 | #include <qpushbutton.h> | ||
4 | #include <qlayout.h> | ||
5 | #include <qcheckbox.h> | ||
6 | #include <qlabel.h> | ||
7 | #include <qstring.h> | ||
8 | #include <qmultilineedit.h> | ||
9 | #include <opie2/oprocess.h> | ||
10 | #include <opie2/odebug.h> | ||
11 | using namespace Opie::Core; | ||
12 | |||
13 | using namespace OpieTooth; | ||
14 | |||
15 | using namespace Opie::Core; | ||
16 | |||
17 | PanDialog::PanDialog( const QString& device, QWidget* parent, | ||
18 | const char* name, bool modal, WFlags fl ) | ||
19 | : QDialog( parent, name, modal, fl ) { | ||
20 | m_panConnect = NULL; | ||
21 | |||
22 | if ( !name ) | ||
23 | setName( "PANDialog" ); | ||
24 | setCaption( tr( "PAN connection " ) ) ; | ||
25 | |||
26 | m_device = device; | ||
27 | |||
28 | layout = new QVBoxLayout( this ); | ||
29 | |||
30 | outPut = new QMultiLineEdit( this ); | ||
31 | QFont outPut_font( outPut->font() ); | ||
32 | outPut_font.setPointSize( 8 ); | ||
33 | outPut->setFont( outPut_font ); | ||
34 | outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); | ||
35 | |||
36 | connectButton = new QPushButton( this ); | ||
37 | connectButton->setText( tr( "Connect" ) ); | ||
38 | |||
39 | doEncryption = new QCheckBox(this, "encrypt"); | ||
40 | doEncryption->setText( tr( "encrypt" ) ); | ||
41 | doSecure = new QCheckBox(this, "secure connection"); | ||
42 | doSecure->setText( tr( "secure connection" ) ); | ||
43 | |||
44 | layout->addWidget(doEncryption); | ||
45 | layout->addWidget(doSecure); | ||
46 | layout->addWidget(outPut); | ||
47 | layout->addWidget(connectButton); | ||
48 | |||
49 | connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); | ||
50 | } | ||
51 | |||
52 | PanDialog::~PanDialog() { | ||
53 | } | ||
54 | |||
55 | void PanDialog::connectToDevice() { | ||
56 | bool doEnc = doEncryption->isChecked(); | ||
57 | bool doSec = doSecure->isChecked(); | ||
58 | |||
59 | if (m_panConnect) { | ||
60 | outPut->append(tr("Work in progress")); | ||
61 | return; | ||
62 | } | ||
63 | m_panConnect = new OProcess(); | ||
64 | outPut->clear(); | ||
65 | |||
66 | // Fill process command line | ||
67 | *m_panConnect << tr("pand") | ||
68 | << tr("--connect") << m_device | ||
69 | << tr("--nodetach"); | ||
70 | if (doEnc) | ||
71 | *m_panConnect << tr("--encrypt"); | ||
72 | if (doSec) | ||
73 | *m_panConnect << tr("--secure"); | ||
74 | if (!m_panConnect->start(OProcess::NotifyOnExit, | ||
75 | OProcess::All)) { | ||
76 | outPut->append(tr("Couldn't start")); | ||
77 | delete m_panConnect; | ||
78 | m_panConnect = NULL; | ||
79 | } | ||
80 | else | ||
81 | { | ||
82 | m_panConnect->resume(); | ||
83 | outPut->append(tr("Started")); | ||
84 | connect(m_panConnect, | ||
85 | SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), | ||
86 | this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int))); | ||
87 | connect(m_panConnect, | ||
88 | SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), | ||
89 | this, SLOT(fillErr(Opie::Core::OProcess*, char*, int))); | ||
90 | connect(m_panConnect, | ||
91 | SIGNAL(processExited(Opie::Core::OProcess*)), | ||
92 | this, SLOT(slotProcessExited(Opie::Core::OProcess*))); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | void PanDialog::fillOutPut( OProcess*, char* cha, int len ) { | ||
97 | QCString str(cha, len); | ||
98 | outPut->append(str); | ||
99 | } | ||
100 | |||
101 | void PanDialog::fillErr(OProcess*, char* buf, int len) | ||
102 | { | ||
103 | QCString str(buf, len); | ||
104 | outPut->append(str); | ||
105 | } | ||
106 | |||
107 | void PanDialog::slotProcessExited(OProcess* proc) { | ||
108 | if (m_panConnect->normalExit()) { | ||
109 | outPut->append( tr("Finished with result ") ); | ||
110 | outPut->append( QString::number(proc->exitStatus()) ); | ||
111 | } | ||
112 | else | ||
113 | outPut->append( tr("Exited abnormally") ); | ||
114 | delete m_panConnect; | ||
115 | m_panConnect = NULL; | ||
116 | } | ||
117 | |||
118 | void PanDialog::closeEvent(QCloseEvent* e) | ||
119 | { | ||
120 | if (m_panConnect && m_panConnect->isRunning()) | ||
121 | m_panConnect->kill(); | ||
122 | QDialog::closeEvent(e); | ||
123 | } | ||
124 | |||
125 | //eof | ||
diff --git a/noncore/net/opietooth/manager/pandialog.h b/noncore/net/opietooth/manager/pandialog.h new file mode 100644 index 0000000..02363d2 --- a/dev/null +++ b/noncore/net/opietooth/manager/pandialog.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef PANDIALOG_H | ||
2 | #define DUNDIALOG_H | ||
3 | |||
4 | |||
5 | #include <qdialog.h> | ||
6 | #include <opie2/oprocess.h> | ||
7 | |||
8 | class QVBoxLayout; | ||
9 | class QMultiLineEdit; | ||
10 | class QPushButton; | ||
11 | class QCheckBox; | ||
12 | |||
13 | namespace OpieTooth { | ||
14 | class PanDialog : public QDialog { | ||
15 | |||
16 | Q_OBJECT | ||
17 | |||
18 | public: | ||
19 | PanDialog(const QString& device = 0, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0); | ||
20 | ~PanDialog(); | ||
21 | |||
22 | private slots: | ||
23 | void connectToDevice(); | ||
24 | void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len ); | ||
25 | void fillErr(Opie::Core::OProcess*, char*, int); | ||
26 | void slotProcessExited(Opie::Core::OProcess* proc); | ||
27 | void closeEvent(QCloseEvent* e); | ||
28 | protected: | ||
29 | QVBoxLayout* layout; | ||
30 | QPushButton* connectButton; | ||
31 | QMultiLineEdit* outPut; | ||
32 | QCheckBox* doEncryption; | ||
33 | QCheckBox* doSecure; | ||
34 | Opie::Core::OProcess* m_panConnect; | ||
35 | |||
36 | private: | ||
37 | QString m_device; //device BT address | ||
38 | }; | ||
39 | } | ||
40 | #endif | ||