Diffstat (limited to 'noncore/net/opietooth/manager/obexdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/obexdialog.cpp | 67 |
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,8 +1,9 @@ | |||
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> |
@@ -16,76 +17,124 @@ 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") ); |
111 | } | ||
112 | else | ||
113 | statLine->setText( tr("Sending") ); | ||
87 | } | 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 | } |