summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.cpp12
-rw-r--r--noncore/net/opietooth/applet/bluezapplet.h2
-rw-r--r--noncore/net/opietooth/lib/device.cc108
-rw-r--r--noncore/net/opietooth/lib/lib.pro7
-rw-r--r--noncore/net/opietooth/lib/obexpush.cpp108
-rw-r--r--noncore/net/opietooth/lib/obexpush.h77
-rw-r--r--noncore/net/opietooth/manager/obexdialog.cpp68
-rw-r--r--noncore/net/opietooth/manager/obexdialog.h15
-rw-r--r--noncore/net/opietooth/manager/obexftpdialog.cpp2
-rw-r--r--noncore/net/opietooth/manager/obexpopup.cpp8
10 files changed, 289 insertions, 118 deletions
diff --git a/noncore/net/opietooth/applet/bluezapplet.cpp b/noncore/net/opietooth/applet/bluezapplet.cpp
index 90b0c6d..6351d4e 100644
--- a/noncore/net/opietooth/applet/bluezapplet.cpp
+++ b/noncore/net/opietooth/applet/bluezapplet.cpp
@@ -118,3 +118,3 @@ namespace OpieTooth {
- int BluezApplet::setBluezStatus(int c) {
+ int BluezApplet::setBluezStatus(int c, bool sync) {
@@ -140,4 +140,8 @@ namespace OpieTooth {
}
- QCopEnvelope e("QPE/System", "execute(QString)");
- e << QString("/etc/init.d/bluetooth start");
+ if (sync) {
+ ::system("/etc/init.d/bluetooth start >/dev/null 2>/dev/null");
+ } else {
+ QCopEnvelope e("QPE/System", "execute(QString)");
+ e << QString("/etc/init.d/bluetooth start");
+ }
} else {
@@ -171,3 +175,3 @@ namespace OpieTooth {
if (!m_wasOn) {
- setBluezStatus(1);
+ setBluezStatus(1, true);
sleep(2);
diff --git a/noncore/net/opietooth/applet/bluezapplet.h b/noncore/net/opietooth/applet/bluezapplet.h
index 90bee3b..1937934 100644
--- a/noncore/net/opietooth/applet/bluezapplet.h
+++ b/noncore/net/opietooth/applet/bluezapplet.h
@@ -57,3 +57,3 @@ public slots:
bool checkBluezStatus();
- int setBluezStatus(int);
+ int setBluezStatus(int, bool sync = false);
int checkBluezDiscoveryStatus();
diff --git a/noncore/net/opietooth/lib/device.cc b/noncore/net/opietooth/lib/device.cc
index 40acbd2..2f04d46 100644
--- a/noncore/net/opietooth/lib/device.cc
+++ b/noncore/net/opietooth/lib/device.cc
@@ -18,29 +18,27 @@ using Opie::Core::OProcess;
namespace {
- int parsePid( const QCString& par )
- {
- int id=0;
- QString string( par );
- QStringList list = QStringList::split( '\n', string );
+ int parsePid( const QCString& par )
+ {
+ int id = 0;
+ QString string( par );
+ QStringList list = QStringList::split( '\n', string );
- for( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
- {
- owarn << "parsePID: " << (*it).latin1() << oendl;
+ for( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
+ owarn << "parsePID: " << (*it).latin1() << oendl;
- // FIXME mbhaynie: Surely there is a better way to skip
- // verbosity (E.g. the TI device configuration
- // script). Apparently the PID is always on a line by
- // itself, or is at least the first word of a line. Does
- // QString have somethine like startsWithRegex("[0-9]+")?
- if( (*it).startsWith("#") ) continue;
- if( (*it).startsWith("TI") ) continue;
- if( (*it).startsWith("Loading") ) continue;
- if( (*it).startsWith("BTS") ) continue;
- if( !(*it).startsWith("CSR") )
- {
- id = (*it).toInt();
- break;
- }
- }
- return id;
+ // FIXME mbhaynie: Surely there is a better way to skip
+ // verbosity (E.g. the TI device configuration
+ // script). Apparently the PID is always on a line by
+ // itself, or is at least the first word of a line. Does
+ // QString have somethine like startsWithRegex("[0-9]+")?
+ if( (*it).startsWith("#") ) continue;
+ if( (*it).startsWith("TI") ) continue;
+ if( (*it).startsWith("Loading") ) continue;
+ if( (*it).startsWith("BTS") ) continue;
+ if( !(*it).startsWith("CSR") ) {
+ id = (*it).toInt();
+ break;
+ }
}
+ return id;
+ }
}
@@ -77,9 +75,5 @@ void Device::attach(){
if ( ODevice::inst()->modelString() == "HX4700" )
- {
- *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas";
- }
+ *m_process << "-S" << "/etc/bluetooth/TIInit_3.2.26.bts" << "/dev/ttyS1" << "texas";
else
- {
- *m_process << m_device << m_mode << m_speed;
- }
+ *m_process << m_device << m_mode << m_speed;
connect(m_process, SIGNAL( processExited(Opie::Core::OProcess*) ),
@@ -95,3 +89,3 @@ void Device::attach(){
}
- };
+ }
}
@@ -99,3 +93,5 @@ void Device::detach(){
delete m_hci;
+ m_hci = 0;
delete m_process;
+ m_process = 0;
// kill the pid we got
@@ -104,3 +100,3 @@ void Device::detach(){
owarn << "killing" << oendl;
- kill(pid, 9);
+ ::kill(pid, 9);
}
@@ -123,23 +119,23 @@ void Device::slotExited( OProcess* proc)
if( ret == 0 ){ // attached
- owarn << "attached" << oendl;
- owarn << "Output: " << m_output.data() << oendl;
- pid = parsePid( m_output );
- owarn << "Pid = " << pid << oendl;
- // now hciconfig hci0 up ( determine hciX FIXME)
- // and call hciconfig hci0 up
- // FIXME hardcoded to hci0 now :(
- m_hci = new OProcess( );
- *m_hci << "hciconfig";
- *m_hci << "hci0 up";
- connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
+ owarn << "attached" << oendl;
+ owarn << "Output: " << m_output.data() << oendl;
+ pid = parsePid( m_output );
+ owarn << "Pid = " << pid << oendl;
+ // now hciconfig hci0 up ( determine hciX FIXME)
+ // and call hciconfig hci0 up
+ // FIXME hardcoded to hci0 now :(
+ m_hci = new OProcess( );
+ *m_hci << "hciconfig";
+ *m_hci << "hci0 up";
+ connect(m_hci, SIGNAL( processExited(Opie::Core::OProcess*) ),
this, SLOT( slotExited(Opie::Core::OProcess* ) ) );
- if(!m_hci->start() ){
- owarn << "could not start" << oendl;
- m_attached = false;
- emit device("hci0", false );
- }
+ if(!m_hci->start() ){
+ owarn << "could not start" << oendl;
+ m_attached = false;
+ emit device("hci0", false );
+ }
}else{
owarn << "crass" << oendl;
- m_attached = false;
- emit device("hci0", false );
+ m_attached = false;
+ emit device("hci0", false );
@@ -155,9 +151,9 @@ void Device::slotExited( OProcess* proc)
if( ret == 0 ){
- owarn << "attached really really attached" << oendl;
- m_attached = true;
- emit device("hci0", true );
+ owarn << "attached really really attached" << oendl;
+ m_attached = true;
+ emit device("hci0", true );
}else{
- owarn << "failed" << oendl;
- emit device("hci0", false );
- m_attached = false;
+ owarn << "failed" << oendl;
+ emit device("hci0", false );
+ m_attached = false;
}
diff --git a/noncore/net/opietooth/lib/lib.pro b/noncore/net/opietooth/lib/lib.pro
index 781bf15..e11af9a 100644
--- a/noncore/net/opietooth/lib/lib.pro
+++ b/noncore/net/opietooth/lib/lib.pro
@@ -3,5 +3,8 @@ CONFIG += qte warn_on
HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h \
- startpanconnection.h startdunconnection.h bt-serial.h forwarder.h
+ startpanconnection.h startdunconnection.h obexpush.h \
+ bt-serial.h forwarder.h
SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc \
- startpanconnection.cpp startdunconnection.cpp bt-serial.c forwarder.cc
+ startpanconnection.cpp startdunconnection.cpp obexpush.cpp \
+ bt-serial.c forwarder.cc
+
TARGET = opietooth1
diff --git a/noncore/net/opietooth/lib/obexpush.cpp b/noncore/net/opietooth/lib/obexpush.cpp
new file mode 100644
index 0000000..e0a4bee
--- a/dev/null
+++ b/noncore/net/opietooth/lib/obexpush.cpp
@@ -0,0 +1,108 @@
+/* $Id$ */
+/* OBEX push functions implementation */
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#include "obexpush.h"
+
+#include <qfileinfo.h>
+#include <qfile.h>
+
+#include <opie2/odebug.h>
+#include <opie2/odebug.h>
+
+using namespace Opie::Core;
+using namespace OpieTooth;
+
+ObexPush::ObexPush()
+{
+ pushProc = new OProcess();
+ connect(pushProc, SIGNAL(processExited(Opie::Core::OProcess*)),
+ this, SLOT(slotPushExited(Opie::Core::OProcess*)));
+ connect(pushProc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int)),
+ this, SLOT(slotPushOut(Opie::Core::OProcess*, char*, int)));
+ connect(pushProc, SIGNAL(receivedStderr(Opie::Core::OProcess*, char*, int)),
+ this, SLOT(slotPushErr(Opie::Core::OProcess*, char*, int)));
+
+}
+
+ObexPush::~ObexPush()
+{
+ if (pushProc->isRunning())
+ pushProc->kill();
+ delete pushProc;
+ pushProc = NULL;
+}
+
+/**
+ * Function that sends a file
+ * @param mac destination device MAC address
+ * @param port service port number
+ * @param src source file name
+ * @param dst destination file name
+ * @return 0 on success, -1 on error, 1 if sending process is running
+ */
+int ObexPush::send(QString& mac, int port, QString& src, QString& dst)
+{
+ QString dev = mac;
+ QString execName = "ussp-push";
+ if (pushProc->isRunning())
+ return 1;
+ pushProc->clearArguments();
+ dev += "@";
+ dev += QString::number(port);
+ if (!dst.isEmpty())
+ *pushProc << execName << "--timeo 30" << dev
+ << QFile::encodeName(src) << QFile::encodeName(dst);
+ else
+ *pushProc << execName << "--timeo 30" << dev
+ << QFile::encodeName(src)
+ << QFile::encodeName(QFileInfo(src).fileName());
+ odebug << execName << " " << dev << " " << src << " "
+ << ((!dst.isEmpty())? dst: QFileInfo(src).fileName()) << oendl;
+ pushProc->setUseShell(true);
+ if (!pushProc->start(OProcess::NotifyOnExit, OProcess::All))
+ return -1;
+ else
+ return 0;
+}
+
+void ObexPush::slotPushExited(Opie::Core::OProcess* proc)
+{
+ if (pushProc != proc)
+ return;
+ odebug << "Process exited" << oendl;
+ if (pushProc->normalExit())
+ emit sendComplete(pushProc->exitStatus());
+ else
+ emit sendError(-1);
+}
+
+/**
+ * Function makes a notification from slotPushOut and slotPushErr
+ */
+void ObexPush::notifyInfo(Opie::Core::OProcess* proc, char* buf, int len)
+{
+ if (proc != pushProc)
+ return;
+ QCString str(buf, len);
+ odebug << str << oendl;
+ emit status(str);
+}
+
+void ObexPush::slotPushOut(Opie::Core::OProcess* proc, char* buf, int len)
+{
+ notifyInfo(proc, buf, len);
+}
+
+void ObexPush::slotPushErr(Opie::Core::OProcess* proc, char* buf, int len)
+{
+ notifyInfo(proc, buf, len);
+}
+
+//eof
diff --git a/noncore/net/opietooth/lib/obexpush.h b/noncore/net/opietooth/lib/obexpush.h
new file mode 100644
index 0000000..8147643
--- a/dev/null
+++ b/noncore/net/opietooth/lib/obexpush.h
@@ -0,0 +1,77 @@
+/* $Id$ */
+/* OBEX push functions declarations */
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+#ifndef _OBEXPUSH_H_
+#define _OBEXPUSH_H_
+#include <qobject.h>
+#include <qstring.h>
+#include "services.h"
+#include <opie2/oprocess.h>
+namespace OpieTooth {
+ class ObexPush : public QObject {
+ Q_OBJECT
+ public:
+ /**
+ * Constructor which creates an object
+ */
+ ObexPush();
+
+ /**
+ * Public destructor
+ */
+ ~ObexPush();
+
+ /**
+ * Function that sends a file
+ * @param mac destination device MAC address
+ * @param port service port number
+ * @param src source file name
+ * @param dst destination file name
+ * @return 0 on success, -1 on error, 1 if sending process is running
+ */
+ int send(QString& mac, int port, QString& src, QString& dst);
+
+ /**
+ * @return true if it's sending and false otherwise
+ */
+ bool isSending() { return pushProc->isRunning(); }
+ signals:
+ /**
+ * Informs that the sending process has completed
+ * @param status the finish status
+ */
+ void sendComplete(int);
+
+ /**
+ * Informs that the sending process has finished with error
+ * @param status the finish status
+ */
+ void sendError(int);
+
+ /**
+ * Informs that we have a string status update
+ * @param str status string
+ */
+ void status(QCString&);
+ protected slots:
+ void slotPushOut(Opie::Core::OProcess*, char*, int);
+ void slotPushErr(Opie::Core::OProcess*, char*, int);
+ void slotPushExited(Opie::Core::OProcess* proc);
+ protected:
+ /**
+ * Function makes a notification from slotPushOut and slotPushErr
+ */
+ void notifyInfo(Opie::Core::OProcess*, char*, int);
+ protected:
+ Opie::Core::OProcess* pushProc; //The push process
+ };
+};
+#endif
+//eof
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
@@ -22,3 +22,4 @@ 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 ) {
@@ -30,5 +31,6 @@ ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name
m_device = device;
+ m_port = port;
layout = new QVBoxLayout( this );
- obexSend = new OProcess();
+ obexSend = new ObexPush();
@@ -64,8 +66,8 @@ ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name
- 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&)));
@@ -74,4 +76,2 @@ ObexDialog::ObexDialog(const QString& device, QWidget* parent, const char* name
ObexDialog::~ObexDialog() {
- if (obexSend->isRunning())
- obexSend->kill();
delete obexSend;
@@ -93,20 +93,10 @@ void ObexDialog::browse() {
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
@@ -115,4 +105,3 @@ void ObexDialog::sendData() {
-void ObexDialog::slotPushOut(OProcess*, char* buf, int len) {
- QCString str(buf, len);
+void ObexDialog::slotPushStatus(QCString& str) {
status->append(str);
@@ -120,21 +109,14 @@ void ObexDialog::slotPushOut(OProcess*, char* buf, int len) {
-void ObexDialog::slotPushErr(OProcess*, char* buf, int len) {
- QCString str(buf, len);
- status->append(str);
+void ObexDialog::slotPushComplete(int result) {
+ status->append( tr("Finished with result ") );
+ status->append( QString::number(result) );
+ status->append( tr("\n") );
+ odebug << result << oendl;
+ statLine->setText( tr("Finished: ") + tr(strerror(result)) );
}
-void ObexDialog::slotProcessExited(OProcess*) {
- if (obexSend == NULL)
- return;
- if (obexSend->normalExit()) {
- status->append( tr("Finished with result ") );
- status->append( QString::number(obexSend->exitStatus()) );
- status->append( tr("\n") );
- odebug << obexSend->exitStatus() << oendl;
- statLine->setText( tr("Finished: ") + tr(strerror(obexSend->exitStatus())) );
- }
- else {
- status->append( tr("Exited abnormally\n") );
- statLine->setText( tr("Exited abnormally") );
- }
+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
@@ -5,5 +5,5 @@
#include <qdialog.h>
-#include <opie2/oprocess.h>
#include <qlabel.h>
#include <qmultilineedit.h>
+#include "obexpush.h"
@@ -22,3 +22,5 @@ namespace OpieTooth {
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();
@@ -29,5 +31,5 @@ private slots:
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);
@@ -44,3 +46,4 @@ private slots:
QString m_device;
- Opie::Core::OProcess *obexSend;
+ int m_port; //Port used
+ ObexPush* obexSend;
};
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
@@ -245,3 +245,3 @@ void ObexFtpDialog::slotCd(QListViewItem* item)
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)));
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
@@ -20,3 +20,3 @@ ObexPopup::ObexPopup(const OpieTooth::Services& service, OpieTooth::BTDeviceIte
{
- owarn << "ObexPopup c'tor" << oendl;
+ odebug << "ObexPopup c'tor" << oendl;
@@ -41,6 +41,4 @@ void ObexPopup::slotPush()
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 );