summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-03-19 14:56:24 (UTC)
committer korovkin <korovkin>2006-03-19 14:56:24 (UTC)
commitbf4d4b814d514762748fe602aeef6c43da102c3a (patch) (unidiff)
tree611d82e4f062430dedd161242986fefa138e719c
parent4c59235642953b2b1d2a07b47313540e85fa5f6a (diff)
downloadopie-bf4d4b814d514762748fe602aeef6c43da102c3a.zip
opie-bf4d4b814d514762748fe602aeef6c43da102c3a.tar.gz
opie-bf4d4b814d514762748fe602aeef6c43da102c3a.tar.bz2
Fixed the way OBEX push uses ussp-push utility.
Diffstat (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
@@ -1,4 +1,5 @@
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>
@@ -20,9 +21,9 @@ using namespace Opie::Core;
20using namespace Opie::Ui; 21using 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 ) {
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
@@ -30,8 +31,15 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
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
@@ -46,14 +54,27 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
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
57ObexDialog::~ObexDialog() { 74ObexDialog::~ObexDialog() {
75 if (obexSend->isRunning())
76 obexSend->kill();
77 delete obexSend;
78 obexSend = NULL;
58} 79}
59 80
@@ -67,5 +88,5 @@ void ObexDialog::browse() {
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
@@ -74,18 +95,46 @@ void ObexDialog::sendData() {
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
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
@@ -5,4 +5,6 @@
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
8class QVBoxLayout; 10class QVBoxLayout;
@@ -11,5 +13,5 @@ class QMultiLineEdit;
11class QLineEdit; 13class QLineEdit;
12 14
13 15namespace Opie {namespace Core {class OProcess;}}
14namespace OpieTooth { 16namespace OpieTooth {
15 17
@@ -19,5 +21,5 @@ namespace OpieTooth {
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
@@ -26,5 +28,8 @@ 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;
@@ -32,7 +37,11 @@ private slots:
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}