summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/obexdialog.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/manager/obexdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/obexdialog.cpp67
1 files changed, 58 insertions, 9 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,5 +1,6 @@
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>
@@ -19,7 +20,7 @@ using namespace OpieTooth;
19using namespace Opie::Core; 20using 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 )
@@ -29,10 +30,17 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
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;
@@ -45,16 +53,29 @@ ObexDialog::ObexDialog( QWidget* parent, const char* name, bool modal, WFlags f
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
57ObexDialog::~ObexDialog() { 74ObexDialog::~ObexDialog() {
75 if (obexSend->isRunning())
76 obexSend->kill();
77 delete obexSend;
78 obexSend = NULL;
58} 79}
59 80
60void ObexDialog::browse() { 81void ObexDialog::browse() {
@@ -66,26 +87,54 @@ void ObexDialog::browse() {
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
72void ObexDialog::sendData() { 93void 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") );
111 }
112 else
113 statLine->setText( tr("Sending") );
87 } 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}