author | korovkin <korovkin> | 2006-04-01 17:42:42 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-04-01 17:42:42 (UTC) |
commit | 812083469c80a0a07ad1ba41d6795e05f950710b (patch) (unidiff) | |
tree | a6a8736439877f790c9a003f86cde2af74a853a6 | |
parent | 2efba75b536877b4138197af4159849e87b12bde (diff) | |
download | opie-812083469c80a0a07ad1ba41d6795e05f950710b.zip opie-812083469c80a0a07ad1ba41d6795e05f950710b.tar.gz opie-812083469c80a0a07ad1ba41d6795e05f950710b.tar.bz2 |
DUN connection parameters dialog added.
-rw-r--r-- | noncore/net/opietooth/manager/dundialog.cpp | 131 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/dundialog.h | 42 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/manager.pro | 8 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/popuphelper.cpp | 4 |
4 files changed, 179 insertions, 6 deletions
diff --git a/noncore/net/opietooth/manager/dundialog.cpp b/noncore/net/opietooth/manager/dundialog.cpp new file mode 100644 index 0000000..033534c --- a/dev/null +++ b/noncore/net/opietooth/manager/dundialog.cpp | |||
@@ -0,0 +1,131 @@ | |||
1 | |||
2 | #include "dundialog.h" | ||
3 | #include <qpushbutton.h> | ||
4 | #include <qmultilineedit.h> | ||
5 | #include <qlineedit.h> | ||
6 | #include <qlayout.h> | ||
7 | #include <qcheckbox.h> | ||
8 | #include <qlabel.h> | ||
9 | #include <qstring.h> | ||
10 | #include <opie2/oprocess.h> | ||
11 | #include <opie2/odebug.h> | ||
12 | using namespace Opie::Core; | ||
13 | |||
14 | using namespace OpieTooth; | ||
15 | |||
16 | using namespace Opie::Core; | ||
17 | |||
18 | DunDialog::DunDialog( const QString& device, int port, QWidget* parent, | ||
19 | const char* name, bool modal, WFlags fl ) | ||
20 | : QDialog( parent, name, modal, fl ) { | ||
21 | if ( !name ) | ||
22 | setName( "DUNDialog" ); | ||
23 | setCaption( tr( "DUN connection " ) ) ; | ||
24 | |||
25 | m_device = device; | ||
26 | m_port = port; | ||
27 | |||
28 | m_dunConnect = NULL; | ||
29 | layout = new QVBoxLayout( this ); | ||
30 | |||
31 | QLabel* info = new QLabel( this ); | ||
32 | info->setText( tr("Enter an ppp script name:") ); | ||
33 | |||
34 | cmdLine = new QLineEdit( this ); | ||
35 | |||
36 | outPut = new QMultiLineEdit( this ); | ||
37 | QFont outPut_font( outPut->font() ); | ||
38 | outPut_font.setPointSize( 8 ); | ||
39 | outPut->setFont( outPut_font ); | ||
40 | outPut->setWordWrap( QMultiLineEdit::WidgetWidth ); | ||
41 | |||
42 | connectButton = new QPushButton( this ); | ||
43 | connectButton->setText( tr( "Connect" ) ); | ||
44 | |||
45 | doEncryption = new QCheckBox(this, "encrypt"); | ||
46 | doEncryption->setText( tr( "encrypt" ) ); | ||
47 | |||
48 | layout->addWidget(info); | ||
49 | layout->addWidget(cmdLine); | ||
50 | layout->addWidget(doEncryption); | ||
51 | layout->addWidget(outPut); | ||
52 | layout->addWidget(connectButton); | ||
53 | |||
54 | connect( connectButton, SIGNAL( clicked() ), this, SLOT( connectToDevice() ) ); | ||
55 | } | ||
56 | |||
57 | DunDialog::~DunDialog() { | ||
58 | } | ||
59 | |||
60 | void DunDialog::connectToDevice() { | ||
61 | bool doEnc = doEncryption->isChecked(); | ||
62 | if (cmdLine->text() == "") | ||
63 | return; | ||
64 | if (m_dunConnect) { | ||
65 | outPut->append(tr("Work in progress")); | ||
66 | return; | ||
67 | } | ||
68 | m_dunConnect = new OProcess(); | ||
69 | outPut->clear(); | ||
70 | |||
71 | // Fill process command line | ||
72 | *m_dunConnect << tr("dund") | ||
73 | << tr("--connect") << m_device | ||
74 | << tr("--channel") << QString::number(m_port) | ||
75 | << tr("--nodetach"); | ||
76 | if (doEnc) | ||
77 | *m_dunConnect << tr("--encrypt"); | ||
78 | *m_dunConnect << tr("call") | ||
79 | << cmdLine->text(); | ||
80 | if (!m_dunConnect->start(OProcess::NotifyOnExit, | ||
81 | OProcess::All)) { | ||
82 | outPut->append(tr("Couldn't start")); | ||
83 | delete m_dunConnect; | ||
84 | m_dunConnect = NULL; | ||
85 | } | ||
86 | else | ||
87 | { | ||
88 | m_dunConnect->resume(); | ||
89 | outPut->append(tr("Started")); | ||
90 | connect(m_dunConnect, | ||
91 | SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), | ||
92 | this, SLOT(fillOutPut(Opie::Core::OProcess*, char*, int))); | ||
93 | connect(m_dunConnect, | ||
94 | SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), | ||
95 | this, SLOT(fillErr(Opie::Core::OProcess*, char*, int))); | ||
96 | connect(m_dunConnect, | ||
97 | SIGNAL(processExited(Opie::Core::OProcess*)), | ||
98 | this, SLOT(slotProcessExited(Opie::Core::OProcess*))); | ||
99 | } | ||
100 | } | ||
101 | |||
102 | void DunDialog::fillOutPut( OProcess*, char* cha, int len ) { | ||
103 | QCString str(cha, len); | ||
104 | outPut->append(str); | ||
105 | } | ||
106 | |||
107 | void DunDialog::fillErr(OProcess*, char* buf, int len) | ||
108 | { | ||
109 | QCString str(buf, len); | ||
110 | outPut->append(str); | ||
111 | } | ||
112 | |||
113 | void DunDialog::slotProcessExited(OProcess* proc) { | ||
114 | if (m_dunConnect->normalExit()) { | ||
115 | outPut->append( tr("Finished with result ") ); | ||
116 | outPut->append( QString::number(proc->exitStatus()) ); | ||
117 | } | ||
118 | else | ||
119 | outPut->append( tr("Exited abnormally") ); | ||
120 | delete m_dunConnect; | ||
121 | m_dunConnect = NULL; | ||
122 | } | ||
123 | |||
124 | void DunDialog::closeEvent(QCloseEvent* e) | ||
125 | { | ||
126 | if (m_dunConnect && m_dunConnect->isRunning()) | ||
127 | m_dunConnect->kill(); | ||
128 | QDialog::closeEvent(e); | ||
129 | } | ||
130 | |||
131 | //eof | ||
diff --git a/noncore/net/opietooth/manager/dundialog.h b/noncore/net/opietooth/manager/dundialog.h new file mode 100644 index 0000000..746c8a3 --- a/dev/null +++ b/noncore/net/opietooth/manager/dundialog.h | |||
@@ -0,0 +1,42 @@ | |||
1 | #ifndef DUNDIALOG_H | ||
2 | #define DUNDIALOG_H | ||
3 | |||
4 | |||
5 | #include <qdialog.h> | ||
6 | #include <opie2/oprocess.h> | ||
7 | |||
8 | class QVBoxLayout; | ||
9 | class QPushButton; | ||
10 | class QMultiLineEdit; | ||
11 | class QLineEdit; | ||
12 | class QCheckBox; | ||
13 | |||
14 | namespace OpieTooth { | ||
15 | class DunDialog : public QDialog { | ||
16 | |||
17 | Q_OBJECT | ||
18 | |||
19 | public: | ||
20 | DunDialog(const QString& device = 0, int port = 0, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0); | ||
21 | ~DunDialog(); | ||
22 | |||
23 | private slots: | ||
24 | void connectToDevice(); | ||
25 | void fillOutPut( Opie::Core::OProcess* pppDial, char* cha, int len ); | ||
26 | void fillErr(Opie::Core::OProcess*, char*, int); | ||
27 | void slotProcessExited(Opie::Core::OProcess* proc); | ||
28 | void closeEvent(QCloseEvent* e); | ||
29 | protected: | ||
30 | QVBoxLayout* layout; | ||
31 | QLineEdit* cmdLine; | ||
32 | QPushButton* connectButton; | ||
33 | QMultiLineEdit* outPut; | ||
34 | QCheckBox* doEncryption; | ||
35 | |||
36 | private: | ||
37 | QString m_device; //device BT address | ||
38 | int m_port; //device process | ||
39 | Opie::Core::OProcess* m_dunConnect; //DUN process | ||
40 | }; | ||
41 | } | ||
42 | #endif | ||
diff --git a/noncore/net/opietooth/manager/manager.pro b/noncore/net/opietooth/manager/manager.pro index 5e7d395..d042c4c 100644 --- a/noncore/net/opietooth/manager/manager.pro +++ b/noncore/net/opietooth/manager/manager.pro | |||
@@ -1,26 +1,26 @@ | |||
1 | CONFIG = qt warn_on quick-app | 1 | CONFIG = qt warn_on quick-app |
2 | HEADERS = btconnectionitem.h btdeviceitem.h \ | 2 | HEADERS = btconnectionitem.h btdeviceitem.h \ |
3 | btserviceitem.h stdpopups.h \ | 3 | btserviceitem.h stdpopups.h \ |
4 | popuphelper.h bluebase.h \ | 4 | popuphelper.h bluebase.h \ |
5 | scandialog.h btlistitem.h filistitem.h \ | 5 | scandialog.h btlistitem.h filistitem.h \ |
6 | hciconfwrapper.h bticonloader.h \ | 6 | hciconfwrapper.h bticonloader.h \ |
7 | pppdialog.h obexdialog.h obexftpdialog.h \ | 7 | pppdialog.h dundialog.h obexdialog.h obexftpdialog.h \ |
8 | rfcommassigndialogimpl.h rfcommassigndialogitem.h \ | 8 | rfcommassigndialogimpl.h rfcommassigndialogitem.h \ |
9 | devicehandler.h rfcpopup.h obexpopup.h obexftpopup.h \ | 9 | devicehandler.h rfcpopup.h obexpopup.h obexftpopup.h \ |
10 | rfcommhelper.h panpopup.h dunpopup.h rfcommconfhandler.h | 10 | rfcommhelper.h panpopup.h dunpopup.h rfcommconfhandler.h |
11 | 11 | ||
12 | SOURCES = btconnectionitem.cpp btdeviceitem.cpp \ | 12 | SOURCES = btconnectionitem.cpp btdeviceitem.cpp \ |
13 | btserviceitem.cpp filelistitem.cpp stdpopups.cpp \ | 13 | btserviceitem.cpp filelistitem.cpp stdpopups.cpp \ |
14 | popuphelper.cpp main.cpp \ | 14 | popuphelper.cpp main.cpp \ |
15 | bluebase.cpp scandialog.cpp \ | 15 | bluebase.cpp scandialog.cpp \ |
16 | btlistitem.cpp hciconfwrapper.cpp \ | 16 | btlistitem.cpp hciconfwrapper.cpp \ |
17 | bticonloader.cpp pppdialog.cpp \ | 17 | bticonloader.cpp pppdialog.cpp dundialog.cpp \ |
18 | rfcommassigndialogimpl.cpp rfcommassigndialogitem.cpp \ | 18 | rfcommassigndialogimpl.cpp rfcommassigndialogitem.cpp \ |
19 | obexdialog.cpp devicehandler.cpp \ | 19 | obexdialog.cpp devicehandler.cpp \ |
20 | rfcpopup.cpp obexpopup.cpp obexftpopup.cpp obexftpdialog.cpp \ | 20 | rfcpopup.cpp obexpopup.cpp obexftpopup.cpp obexftpdialog.cpp \ |
21 | rfcommhelper.cpp panpopup.cpp dunpopup.cpp rfcommconfhandler.cpp | 21 | rfcommhelper.cpp panpopup.cpp dunpopup.cpp rfcommconfhandler.cpp |
22 | INCLUDEPATH += $(OPIEDIR)/include | 22 | INCLUDEPATH += $(OPIEDIR)/include |
23 | INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib | 23 | INCLUDEPATH += $(OPIEDIR)/noncore/net/opietooth/lib |
24 | DEPENDPATH += $(OPIEDIR)/include | 24 | DEPENDPATH += $(OPIEDIR)/include |
25 | LIBS += -lqpe -lbluetooth -lopietooth1 -lopiecore2 -lopieui2 -lopenobex | 25 | LIBS += -lqpe -lbluetooth -lopietooth1 -lopiecore2 -lopieui2 -lopenobex |
26 | INTERFACES = bluetoothbase.ui devicedialog.ui rfcommassigndialogbase.ui \ | 26 | INTERFACES = bluetoothbase.ui devicedialog.ui rfcommassigndialogbase.ui \ |
diff --git a/noncore/net/opietooth/manager/popuphelper.cpp b/noncore/net/opietooth/manager/popuphelper.cpp index bd2071a..b3d7aa5 100644 --- a/noncore/net/opietooth/manager/popuphelper.cpp +++ b/noncore/net/opietooth/manager/popuphelper.cpp | |||
@@ -22,15 +22,15 @@ QPopupMenu* PopupHelper::find( int id, const Services& ser, BTDeviceItem* item ) | |||
22 | //owarn << "found" << oendl; | 22 | //owarn << "found" << oendl; |
23 | popupFactory fact = it.data(); | 23 | popupFactory fact = it.data(); |
24 | return (*fact)(ser, item); | 24 | return (*fact)(ser, item); |
25 | } | 25 | } |
26 | return 0l; | 26 | return 0l; |
27 | } | 27 | } |
28 | 28 | ||
29 | void PopupHelper::init() { | 29 | void PopupHelper::init() { |
30 | insert( 4355, newRfcComPopup ); | ||
31 | insert( 4354, newDunPopup ); | ||
32 | insert( 4353, newRfcComPopup ); | 30 | insert( 4353, newRfcComPopup ); |
31 | insert( 4354, newDunPopup ); | ||
32 | insert( 4355, newRfcComPopup ); | ||
33 | insert( 4357, newObexPushPopup ); | 33 | insert( 4357, newObexPushPopup ); |
34 | insert( 4358, newObexFtpPopup ); | 34 | insert( 4358, newObexFtpPopup ); |
35 | insert( 4374, newPanPopup ); | 35 | insert( 4374, newPanPopup ); |
36 | } | 36 | } |