Diffstat (limited to 'noncore/net/opietooth/manager/obexdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/obexdialog.cpp | 68 |
1 files changed, 25 insertions, 43 deletions
diff --git a/noncore/net/opietooth/manager/obexdialog.cpp b/noncore/net/opietooth/manager/obexdialog.cpp index 8d7b593..4b795b7 100644 --- a/noncore/net/opietooth/manager/obexdialog.cpp +++ b/noncore/net/opietooth/manager/obexdialog.cpp | |||
@@ -21,5 +21,6 @@ using namespace Opie::Core; | |||
21 | using namespace Opie::Ui; | 21 | using namespace Opie::Ui; |
22 | using namespace Opie::Core; | 22 | using namespace Opie::Core; |
23 | ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name, bool modal, WFlags fl) | 23 | ObexDialog::ObexDialog(const QString& device, int port, |
24 | QWidget* parent, const char* name, bool modal, WFlags fl) | ||
24 | : QDialog( parent, name, modal, fl ) { | 25 | : QDialog( parent, name, modal, fl ) { |
25 | 26 | ||
@@ -29,7 +30,8 @@ ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name | |||
29 | 30 | ||
30 | m_device = device; | 31 | m_device = device; |
32 | m_port = port; | ||
31 | 33 | ||
32 | layout = new QVBoxLayout( this ); | 34 | layout = new QVBoxLayout( this ); |
33 | obexSend = new OProcess(); | 35 | obexSend = new ObexPush(); |
34 | 36 | ||
35 | info = new QLabel( this ); | 37 | info = new QLabel( this ); |
@@ -63,16 +65,14 @@ ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name | |||
63 | connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) ); | 65 | connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) ); |
64 | 66 | ||
65 | connect(obexSend, SIGNAL(processExited(Opie::Core::OProcess*)), | 67 | connect(obexSend, SIGNAL(sendComplete(int)), |
66 | this, SLOT(slotProcessExited(Opie::Core::OProcess*))); | 68 | this, SLOT(slotPushComplete(int))); |
67 | connect(obexSend, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), | 69 | connect(obexSend, SIGNAL(sendError(int)), |
68 | this, SLOT(slotPushOut(Opie::Core::OProcess*, char*, int))); | 70 | this, SLOT(slotPushError(int))); |
69 | connect(obexSend, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), | 71 | connect(obexSend, SIGNAL(status(QCString&)), |
70 | this, SLOT(slotPushErr(Opie::Core::OProcess*, char*, int))); | 72 | this, SLOT(slotPushStatus(QCString&))); |
71 | 73 | ||
72 | } | 74 | } |
73 | 75 | ||
74 | ObexDialog::~ObexDialog() { | 76 | ObexDialog::~ObexDialog() { |
75 | if (obexSend->isRunning()) | ||
76 | obexSend->kill(); | ||
77 | delete obexSend; | 77 | delete obexSend; |
78 | obexSend = NULL; | 78 | obexSend = NULL; |
@@ -92,49 +92,31 @@ void ObexDialog::browse() { | |||
92 | 92 | ||
93 | void ObexDialog::sendData() { | 93 | void ObexDialog::sendData() { |
94 | int result; //function call result | ||
94 | QString fileURL = cmdLine->text(); | 95 | QString fileURL = cmdLine->text(); |
95 | QString file = QFileInfo( fileURL ).fileName(); | ||
96 | QString modifiedName = chNameLine->text(); | 96 | QString modifiedName = chNameLine->text(); |
97 | QString execName = "ussp-push"; | 97 | result = obexSend->send(m_device, m_port, fileURL, modifiedName); |
98 | 98 | if (result > 0) | |
99 | if (obexSend->isRunning()) | ||
100 | return; | 99 | return; |
101 | obexSend->clearArguments(); | 100 | else if (result < 0) |
102 | // vom popupmenu beziehen | ||
103 | if ( !modifiedName.isEmpty() ) { | ||
104 | *obexSend << execName << "--timeo 30" << m_device << fileURL << modifiedName; | ||
105 | } else { | ||
106 | *obexSend << execName << "--timeo 30" << m_device << fileURL << file; | ||
107 | } | ||
108 | obexSend->setUseShell(true); | ||
109 | if (!obexSend->start(OProcess::NotifyOnExit, OProcess::All) ) { | ||
110 | statLine->setText( tr("Error: couln't start process") ); | 101 | statLine->setText( tr("Error: couln't start process") ); |
111 | } | ||
112 | else | 102 | else |
113 | statLine->setText( tr("Sending") ); | 103 | statLine->setText( tr("Sending") ); |
114 | } | 104 | } |
115 | 105 | ||
116 | void ObexDialog::slotPushOut(OProcess*, char* buf, int len) { | 106 | void ObexDialog::slotPushStatus(QCString& str) { |
117 | QCString str(buf, len); | ||
118 | status->append(str); | 107 | status->append(str); |
119 | } | 108 | } |
120 | 109 | ||
121 | void ObexDialog::slotPushErr(OProcess*, char* buf, int len) { | 110 | void ObexDialog::slotPushComplete(int result) { |
122 | QCString str(buf, len); | 111 | status->append( tr("Finished with result ") ); |
123 | status->append(str); | 112 | status->append( QString::number(result) ); |
113 | status->append( tr("\n") ); | ||
114 | odebug << result << oendl; | ||
115 | statLine->setText( tr("Finished: ") + tr(strerror(result)) ); | ||
124 | } | 116 | } |
125 | 117 | ||
126 | void ObexDialog::slotProcessExited(OProcess*) { | 118 | void ObexDialog::slotPushError(int) { |
127 | if (obexSend == NULL) | 119 | status->append( tr("Exited abnormally\n") ); |
128 | return; | 120 | statLine->setText( tr("Exited abnormally") ); |
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 | } | ||
140 | } | 121 | } |
122 | //eof | ||