-rw-r--r-- | noncore/net/opietooth/manager/obexdialog.cpp | 69 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexdialog.h | 15 |
2 files changed, 71 insertions, 13 deletions
diff --git a/noncore/net/opietooth/manager/obexdialog.cpp b/noncore/net/opietooth/manager/obexdialog.cpp index 951d87a..d3fdd14 100644 --- a/noncore/net/opietooth/manager/obexdialog.cpp +++ b/noncore/net/opietooth/manager/obexdialog.cpp | |||
@@ -1,91 +1,140 @@ | |||
1 | 1 | ||
2 | #include "obexdialog.h" | 2 | #include "obexdialog.h" |
3 | #include <errno.h> | ||
3 | #include <qpushbutton.h> | 4 | #include <qpushbutton.h> |
4 | #include <qmultilineedit.h> | 5 | #include <qmultilineedit.h> |
5 | #include <qlineedit.h> | 6 | #include <qlineedit.h> |
6 | #include <qlayout.h> | 7 | #include <qlayout.h> |
7 | #include <qlabel.h> | 8 | #include <qlabel.h> |
8 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
9 | 10 | ||
10 | #include <qpe/resource.h> | 11 | #include <qpe/resource.h> |
11 | 12 | ||
12 | #include <opie2/oprocess.h> | 13 | #include <opie2/oprocess.h> |
13 | #include <opie2/ofiledialog.h> | 14 | #include <opie2/ofiledialog.h> |
14 | #include <opie2/odebug.h> | 15 | #include <opie2/odebug.h> |
15 | using namespace Opie::Core; | 16 | using namespace Opie::Core; |
16 | 17 | ||
17 | using namespace OpieTooth; | 18 | using namespace OpieTooth; |
18 | 19 | ||
19 | using namespace Opie::Core; | 20 | using namespace Opie::Core; |
20 | using namespace Opie::Ui; | 21 | using namespace Opie::Ui; |
21 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
22 | ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device ) | 23 | ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name, bool modal, WFlags fl) |
23 | : QDialog( parent, name, modal, fl ) { | 24 | : QDialog( parent, name, modal, fl ) { |
24 | 25 | ||
25 | if ( !name ) | 26 | if ( !name ) |
26 | setName( "ObexDialog" ); | 27 | setName( "ObexDialog" ); |
27 | setCaption( tr( "beam files " ) ) ; | 28 | setCaption( tr( "beam files " ) ) ; |
28 | 29 | ||
29 | m_device = device; | 30 | m_device = device; |
30 | 31 | ||
31 | layout = new QVBoxLayout( this ); | 32 | layout = new QVBoxLayout( this ); |
33 | obexSend = new OProcess(); | ||
32 | 34 | ||
33 | QLabel* info = new QLabel( this ); | 35 | info = new QLabel( this ); |
34 | info->setText( tr("Which file should be beamed?") ); | 36 | info->setText( tr("Which file should be beamed?") ); |
35 | 37 | ||
38 | statLine = new QLabel(this); | ||
39 | statLine->setText( tr("Ready") ); | ||
40 | |||
41 | status = new QMultiLineEdit(this); | ||
42 | status->setReadOnly(true); | ||
43 | |||
36 | cmdLine = new QLineEdit( this ); | 44 | cmdLine = new QLineEdit( this ); |
37 | 45 | ||
38 | QPushButton *browserButton; | 46 | QPushButton *browserButton; |
39 | browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); | 47 | browserButton = new QPushButton( Resource::loadIconSet("fileopen"),"",this,"BrowseButton"); |
40 | connect( browserButton, SIGNAL(released() ), this , SLOT(browse() ) ); | 48 | connect( browserButton, SIGNAL(released() ), this , SLOT(browse() ) ); |
41 | 49 | ||
42 | chNameLine = new QLineEdit( this ); | 50 | chNameLine = new QLineEdit( this ); |
43 | 51 | ||
44 | sendButton = new QPushButton( this ); | 52 | sendButton = new QPushButton( this ); |
45 | sendButton->setText( tr( "Send" ) ); | 53 | sendButton->setText( tr( "Send" ) ); |
46 | 54 | ||
47 | layout->addWidget(info); | 55 | layout->addWidget(info); |
56 | layout->addWidget(status); | ||
48 | layout->addWidget(cmdLine); | 57 | layout->addWidget(cmdLine); |
49 | layout->addWidget(browserButton); | 58 | layout->addWidget(browserButton); |
50 | layout->addWidget(chNameLine); | 59 | layout->addWidget(chNameLine); |
51 | layout->addWidget(sendButton); | 60 | layout->addWidget(sendButton); |
61 | layout->addWidget(statLine); | ||
52 | 62 | ||
53 | connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) ); | 63 | connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) ); |
54 | 64 | ||
65 | connect(obexSend, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
66 | this, SLOT(slotProcessExited(Opie::Core::OProcess*))); | ||
67 | connect(obexSend, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), | ||
68 | this, SLOT(slotPushOut(Opie::Core::OProcess*, char*, int))); | ||
69 | connect(obexSend, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), | ||
70 | this, SLOT(slotPushErr(Opie::Core::OProcess*, char*, int))); | ||
71 | |||
55 | } | 72 | } |
56 | 73 | ||
57 | ObexDialog::~ObexDialog() { | 74 | ObexDialog::~ObexDialog() { |
75 | if (obexSend->isRunning()) | ||
76 | obexSend->kill(); | ||
77 | delete obexSend; | ||
78 | obexSend = NULL; | ||
58 | } | 79 | } |
59 | 80 | ||
60 | void ObexDialog::browse() { | 81 | void ObexDialog::browse() { |
61 | 82 | ||
62 | MimeTypes types; | 83 | MimeTypes types; |
63 | QStringList all; | 84 | QStringList all; |
64 | all << "*/*"; | 85 | all << "*/*"; |
65 | types.insert("All Files", all ); | 86 | types.insert("All Files", all ); |
66 | 87 | ||
67 | QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); | 88 | QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); |
68 | cmdLine->setText( str ); | 89 | cmdLine->setText( str ); |
69 | 90 | statLine->setText( tr("Ready") ); | |
70 | } | 91 | } |
71 | 92 | ||
72 | void ObexDialog::sendData() { | 93 | void ObexDialog::sendData() { |
73 | QString fileURL = cmdLine->text(); | 94 | QString fileURL = cmdLine->text(); |
74 | QString file = QFileInfo( fileURL ).fileName(); | 95 | QString file = QFileInfo( fileURL ).fileName(); |
75 | QString modifiedName = chNameLine->text(); | 96 | QString modifiedName = chNameLine->text(); |
97 | QString execName = "ussp-push"; | ||
76 | 98 | ||
99 | if (obexSend->isRunning()) | ||
100 | return; | ||
101 | obexSend->clearArguments(); | ||
77 | // vom popupmenu beziehen | 102 | // vom popupmenu beziehen |
78 | OProcess* obexSend = new OProcess(); | ||
79 | if ( !modifiedName.isEmpty() ) { | 103 | if ( !modifiedName.isEmpty() ) { |
80 | *obexSend << "ussp-push" << m_device << fileURL << modifiedName; | 104 | *obexSend << execName << "--timeo 30" << m_device << fileURL << modifiedName; |
81 | } else { | 105 | } else { |
82 | *obexSend << "ussp-push" << m_device << fileURL << file; | 106 | *obexSend << execName << "--timeo 30" << m_device << fileURL << file; |
83 | } | 107 | } |
84 | if (!obexSend->start(OProcess::DontCare, OProcess::AllOutput) ) { | 108 | obexSend->setUseShell(true); |
85 | owarn << "could not start" << oendl; | 109 | if (!obexSend->start(OProcess::NotifyOnExit, OProcess::All) ) { |
86 | delete obexSend; | 110 | statLine->setText( tr("Error: couln't start process") ); |
87 | } | 111 | } |
112 | else | ||
113 | statLine->setText( tr("Sending") ); | ||
114 | } | ||
88 | 115 | ||
116 | void ObexDialog::slotPushOut(OProcess*, char* buf, int len) { | ||
117 | QCString str(buf, len); | ||
118 | status->append(str); | ||
119 | } | ||
89 | 120 | ||
121 | void ObexDialog::slotPushErr(OProcess*, char* buf, int len) { | ||
122 | QCString str(buf, len); | ||
123 | status->append(str); | ||
124 | } | ||
90 | 125 | ||
126 | void ObexDialog::slotProcessExited(OProcess*) { | ||
127 | if (obexSend == NULL) | ||
128 | return; | ||
129 | if (obexSend->normalExit()) { | ||
130 | status->append( tr("Finished with result ") ); | ||
131 | status->append( QString::number(obexSend->exitStatus()) ); | ||
132 | status->append( tr("\n") ); | ||
133 | odebug << obexSend->exitStatus() << oendl; | ||
134 | statLine->setText( tr("Finished: ") + tr(strerror(obexSend->exitStatus())) ); | ||
135 | } | ||
136 | else { | ||
137 | status->append( tr("Exited abnormally\n") ); | ||
138 | statLine->setText( tr("Exited abnormally") ); | ||
139 | } | ||
91 | } | 140 | } |
diff --git a/noncore/net/opietooth/manager/obexdialog.h b/noncore/net/opietooth/manager/obexdialog.h index d5b5682..44a26f3 100644 --- a/noncore/net/opietooth/manager/obexdialog.h +++ b/noncore/net/opietooth/manager/obexdialog.h | |||
@@ -1,39 +1,48 @@ | |||
1 | #ifndef OBEXDIALOG_H | 1 | #ifndef OBEXDIALOG_H |
2 | #define OBEXDIALOG_H | 2 | #define OBEXDIALOG_H |
3 | 3 | ||
4 | 4 | ||
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include <opie2/oprocess.h> | 6 | #include <opie2/oprocess.h> |
7 | #include <qlabel.h> | ||
8 | #include <qmultilineedit.h> | ||
7 | 9 | ||
8 | class QVBoxLayout; | 10 | class QVBoxLayout; |
9 | class QPushButton; | 11 | class QPushButton; |
10 | class QMultiLineEdit; | 12 | class QMultiLineEdit; |
11 | class QLineEdit; | 13 | class QLineEdit; |
12 | 14 | ||
13 | 15 | namespace Opie {namespace Core {class OProcess;}} | |
14 | namespace OpieTooth { | 16 | namespace OpieTooth { |
15 | 17 | ||
16 | class ObexDialog : public QDialog { | 18 | class ObexDialog : public QDialog { |
17 | 19 | ||
18 | Q_OBJECT | 20 | Q_OBJECT |
19 | 21 | ||
20 | public: | 22 | public: |
21 | ObexDialog( QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0, const QString& device = 0); | 23 | ObexDialog( const QString& device = 0, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0); |
22 | ~ObexDialog(); | 24 | ~ObexDialog(); |
23 | 25 | ||
24 | 26 | ||
25 | private slots: | 27 | private slots: |
26 | void browse(); | 28 | void browse(); |
27 | void sendData(); | 29 | void sendData(); |
28 | 30 | void slotPushOut(Opie::Core::OProcess*, char*, int); | |
31 | void slotPushErr(Opie::Core::OProcess*, char*, int); | ||
32 | void slotProcessExited(Opie::Core::OProcess* proc); | ||
33 | |||
29 | protected: | 34 | protected: |
30 | QVBoxLayout* layout; | 35 | QVBoxLayout* layout; |
31 | QLineEdit* cmdLine; | 36 | QLineEdit* cmdLine; |
32 | QLineEdit* chNameLine; | 37 | QLineEdit* chNameLine; |
33 | QPushButton* sendButton; | 38 | QPushButton* sendButton; |
39 | QLabel* info; | ||
40 | QMultiLineEdit* status; | ||
41 | QLabel* statLine; | ||
34 | private: | 42 | private: |
35 | // Device that is used | 43 | // Device that is used |
36 | QString m_device; | 44 | QString m_device; |
45 | Opie::Core::OProcess *obexSend; | ||
37 | }; | 46 | }; |
38 | } | 47 | } |
39 | #endif | 48 | #endif |