author | korovkin <korovkin> | 2006-05-10 13:32:46 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-05-10 13:32:46 (UTC) |
commit | 5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f (patch) (side-by-side diff) | |
tree | e9ea63a2fe15982e98886af727649dc6a513faac /noncore/net/opietooth/manager | |
parent | 620d55ae3b94fa8d2fa696b6626893e4520c3a02 (diff) | |
download | opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.zip opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.tar.gz opie-5521b2c0508cf6e6a390bd4796e8c9f2c7a6d05f.tar.bz2 |
OBEX push functionality moved to libbluetooth1.
Made some reformatting in device.cc
In bluezapplet.cpp /etc/init.d/bluetooth is started synchronously if it's called from QCopMessage.
-rw-r--r-- | noncore/net/opietooth/manager/obexdialog.cpp | 62 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexdialog.h | 15 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexftpdialog.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/obexpopup.cpp | 8 |
4 files changed, 35 insertions, 52 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 @@ -11,35 +11,37 @@ #include <qpe/resource.h> #include <opie2/oprocess.h> #include <opie2/ofiledialog.h> #include <opie2/odebug.h> using namespace Opie::Core; using namespace OpieTooth; using namespace Opie::Core; using namespace Opie::Ui; using namespace Opie::Core; -ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name, bool modal, WFlags fl) +ObexDialog::ObexDialog(const QString& device, int port, + QWidget* parent, const char* name, bool modal, WFlags fl) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "ObexDialog" ); setCaption( tr( "beam files " ) ) ; m_device = device; + m_port = port; layout = new QVBoxLayout( this ); - obexSend = new OProcess(); + obexSend = new ObexPush(); info = new QLabel( this ); info->setText( tr("Which file should be beamed?") ); statLine = new QLabel(this); statLine->setText( tr("Ready") ); status = new QMultiLineEdit(this); status->setReadOnly(true); cmdLine = new QLineEdit( this ); @@ -53,88 +55,68 @@ ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name sendButton->setText( tr( "Send" ) ); layout->addWidget(info); layout->addWidget(status); layout->addWidget(cmdLine); layout->addWidget(browserButton); layout->addWidget(chNameLine); layout->addWidget(sendButton); layout->addWidget(statLine); connect( sendButton, SIGNAL( clicked() ), this, SLOT( sendData() ) ); - connect(obexSend, SIGNAL(processExited(Opie::Core::OProcess*)), - this, SLOT(slotProcessExited(Opie::Core::OProcess*))); - connect(obexSend, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)), - this, SLOT(slotPushOut(Opie::Core::OProcess*, char*, int))); - connect(obexSend, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)), - this, SLOT(slotPushErr(Opie::Core::OProcess*, char*, int))); + connect(obexSend, SIGNAL(sendComplete(int)), + this, SLOT(slotPushComplete(int))); + connect(obexSend, SIGNAL(sendError(int)), + this, SLOT(slotPushError(int))); + connect(obexSend, SIGNAL(status(QCString&)), + this, SLOT(slotPushStatus(QCString&))); } ObexDialog::~ObexDialog() { - if (obexSend->isRunning()) - obexSend->kill(); delete obexSend; obexSend = NULL; } void ObexDialog::browse() { MimeTypes types; QStringList all; all << "*/*"; types.insert("All Files", all ); QString str = OFileDialog::getOpenFileName( 1,"/","", types, 0 ); cmdLine->setText( str ); statLine->setText( tr("Ready") ); } void ObexDialog::sendData() { + int result; //function call result QString fileURL = cmdLine->text(); - QString file = QFileInfo( fileURL ).fileName(); QString modifiedName = chNameLine->text(); - QString execName = "ussp-push"; - - if (obexSend->isRunning()) + result = obexSend->send(m_device, m_port, fileURL, modifiedName); + if (result > 0) return; - obexSend->clearArguments(); - // vom popupmenu beziehen - if ( !modifiedName.isEmpty() ) { - *obexSend << execName << "--timeo 30" << m_device << fileURL << modifiedName; - } else { - *obexSend << execName << "--timeo 30" << m_device << fileURL << file; - } - obexSend->setUseShell(true); - if (!obexSend->start(OProcess::NotifyOnExit, OProcess::All) ) { + else if (result < 0) statLine->setText( tr("Error: couln't start process") ); - } else statLine->setText( tr("Sending") ); } -void ObexDialog::slotPushOut(OProcess*, char* buf, int len) { - QCString str(buf, len); +void ObexDialog::slotPushStatus(QCString& str) { status->append(str); } -void ObexDialog::slotPushErr(OProcess*, char* buf, int len) { - QCString str(buf, len); - status->append(str); -} - -void ObexDialog::slotProcessExited(OProcess*) { - if (obexSend == NULL) - return; - if (obexSend->normalExit()) { +void ObexDialog::slotPushComplete(int result) { status->append( tr("Finished with result ") ); - status->append( QString::number(obexSend->exitStatus()) ); + status->append( QString::number(result) ); status->append( tr("\n") ); - odebug << obexSend->exitStatus() << oendl; - statLine->setText( tr("Finished: ") + tr(strerror(obexSend->exitStatus())) ); + odebug << result << oendl; + statLine->setText( tr("Finished: ") + tr(strerror(result)) ); } - else { + +void ObexDialog::slotPushError(int) { status->append( tr("Exited abnormally\n") ); statLine->setText( tr("Exited abnormally") ); } -} +//eof diff --git a/noncore/net/opietooth/manager/obexdialog.h b/noncore/net/opietooth/manager/obexdialog.h index 44a26f3..063b7f1 100644 --- a/noncore/net/opietooth/manager/obexdialog.h +++ b/noncore/net/opietooth/manager/obexdialog.h @@ -1,48 +1,51 @@ #ifndef OBEXDIALOG_H #define OBEXDIALOG_H #include <qdialog.h> -#include <opie2/oprocess.h> #include <qlabel.h> #include <qmultilineedit.h> +#include "obexpush.h" class QVBoxLayout; class QPushButton; class QMultiLineEdit; class QLineEdit; namespace Opie {namespace Core {class OProcess;}} namespace OpieTooth { class ObexDialog : public QDialog { Q_OBJECT public: - ObexDialog( const QString& device = 0, QWidget* parent = 0, const char* name = 0, bool modal = TRUE, WFlags fl = 0); + ObexDialog( const QString& device = 0, int port = 0, + QWidget* parent = 0, const char* name = 0, + bool modal = TRUE, WFlags fl = 0); ~ObexDialog(); private slots: void browse(); void sendData(); - void slotPushOut(Opie::Core::OProcess*, char*, int); - void slotPushErr(Opie::Core::OProcess*, char*, int); - void slotProcessExited(Opie::Core::OProcess* proc); + void slotPushStatus(QCString&); + void slotPushComplete(int); + void slotPushError(int); protected: QVBoxLayout* layout; QLineEdit* cmdLine; QLineEdit* chNameLine; QPushButton* sendButton; QLabel* info; QMultiLineEdit* status; QLabel* statLine; private: // Device that is used QString m_device; - Opie::Core::OProcess *obexSend; + int m_port; //Port used + ObexPush* obexSend; }; } #endif diff --git a/noncore/net/opietooth/manager/obexftpdialog.cpp b/noncore/net/opietooth/manager/obexftpdialog.cpp index efb3ff2..2a578ac 100644 --- a/noncore/net/opietooth/manager/obexftpdialog.cpp +++ b/noncore/net/opietooth/manager/obexftpdialog.cpp @@ -234,25 +234,25 @@ void ObexFtpDialog::slotCd(QListViewItem* item) idx = curdir.findRev('/'); if (idx >= 0) curdir.remove(idx, curdir.length() - idx); else curdir = ""; } else { if (curdir != "" && curdir.right(1) != "/") curdir += "/"; curdir += file->text(0); } odebug << "Browse " << curdir << oendl; - if (obexftp_setpath(client, curdir, 0) < 0) + if (obexftp_setpath(client, QFile::encodeName(curdir), 0) < 0) log(tr("CD failed: ") + tr(strerror(errno))); doBrowse(); } } /* * Copy file from a remote device to the local device */ void ObexFtpDialog::getFile() { FileListItem* file = (FileListItem*)fileList->selectedItem(); int result; diff --git a/noncore/net/opietooth/manager/obexpopup.cpp b/noncore/net/opietooth/manager/obexpopup.cpp index d1d1b4a..759a452 100644 --- a/noncore/net/opietooth/manager/obexpopup.cpp +++ b/noncore/net/opietooth/manager/obexpopup.cpp @@ -9,41 +9,39 @@ using namespace Opie::Core; /* QT */ #include <qtimer.h> using namespace OpieTooth; /* * c'tor init the QAction */ ObexPopup::ObexPopup(const OpieTooth::Services& service, OpieTooth::BTDeviceItem* item) : QPopupMenu(), m_service(service) { - owarn << "ObexPopup c'tor" << oendl; + odebug << "ObexPopup c'tor" << oendl; m_item = item; /* connect action */ m_push = new QAction( ); // so it's get deleted m_push->setText("Push file"); m_push->addTo( this ); connect(m_push, SIGNAL(activated()), SLOT(slotPush())); } ObexPopup::~ObexPopup() { delete m_push; } void ObexPopup::slotPush() { QString device = m_item->mac(); int port = m_service.protocolDescriptorList().last().port(); - device += "@"; - device += QString::number(port); - owarn << "push something to " << device << oendl; - ObexDialog obexDialog(device); + odebug << "push something to " << device << " " << port << oendl; + ObexDialog obexDialog(device, port); QPEApplication::execDialog( &obexDialog ); } |