summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth
Unidiff
Diffstat (limited to 'noncore/net/opietooth') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/obexdialog.cpp69
-rw-r--r--noncore/net/opietooth/manager/obexdialog.h15
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
@@ -2,2 +2,3 @@
2#include "obexdialog.h" 2#include "obexdialog.h"
3#include <errno.h>
3#include <qpushbutton.h> 4#include <qpushbutton.h>
@@ -21,3 +22,3 @@ using namespace Opie::Ui;
21using namespace Opie::Core; 22using namespace Opie::Core;
22ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags fl, const QString& device ) 23ObexDialog::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 ) {
@@ -25,3 +26,3 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
25 if ( !name ) 26 if ( !name )
26 setName( "ObexDialog" ); 27 setName( "ObexDialog" );
27 setCaption( tr( "beam files " ) ) ; 28 setCaption( tr( "beam files " ) ) ;
@@ -31,6 +32,13 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
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 );
@@ -47,2 +55,3 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
47 layout->addWidget(info); 55 layout->addWidget(info);
56 layout->addWidget(status);
48 layout->addWidget(cmdLine); 57 layout->addWidget(cmdLine);
@@ -51,2 +60,3 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
51 layout->addWidget(sendButton); 60 layout->addWidget(sendButton);
61 layout->addWidget(statLine);
52 62
@@ -54,2 +64,9 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
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}
@@ -57,2 +74,6 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
57ObexDialog::~ObexDialog() { 74ObexDialog::~ObexDialog() {
75 if (obexSend->isRunning())
76 obexSend->kill();
77 delete obexSend;
78 obexSend = NULL;
58} 79}
@@ -68,3 +89,3 @@ void ObexDialog::browse() {
68 cmdLine->setText( str ); 89 cmdLine->setText( str );
69 90 statLine->setText( tr("Ready") );
70} 91}
@@ -75,17 +96,45 @@ void ObexDialog::sendData() {
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
116void ObexDialog::slotPushOut(OProcess*, char* buf, int len) {
117 QCString str(buf, len);
118 status->append(str);
119}
89 120
121void ObexDialog::slotPushErr(OProcess*, char* buf, int len) {
122 QCString str(buf, len);
123 status->append(str);
124}
90 125
126void 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
@@ -6,2 +6,4 @@
6#include <opie2/oprocess.h> 6#include <opie2/oprocess.h>
7#include <qlabel.h>
8#include <qmultilineedit.h>
7 9
@@ -12,3 +14,3 @@ class QLineEdit;
12 14
13 15namespace Opie {namespace Core {class OProcess;}}
14namespace OpieTooth { 16namespace OpieTooth {
@@ -20,3 +22,3 @@ namespace OpieTooth {
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();
@@ -27,3 +29,6 @@ private slots:
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:
@@ -33,2 +38,5 @@ private slots:
33 QPushButton* sendButton; 38 QPushButton* sendButton;
39 QLabel* info;
40 QMultiLineEdit* status;
41 QLabel* statLine;
34 private: 42 private:
@@ -36,2 +44,3 @@ private slots:
36 QString m_device; 44 QString m_device;
45 Opie::Core::OProcess *obexSend;
37 }; 46 };