From 30a098530260176ac20d75ba6cb7abfb3d998c13 Mon Sep 17 00:00:00 2001 From: zecke Date: Sun, 16 Feb 2003 15:49:02 +0000 Subject: disable snd in IrDaApplet it hangs on my machine.. Remove the hacky OBEX Implementation Add a more cleaned up more appealing (not yet working) version which will even be able to do OBEX over Bluetooth in the future -It handles receive better let's you choose what to do with custom files and created a DocLnk -Send lets you beam to multiple devices this needs the IrDa Applet to be present --- (limited to 'core/applets/obex') diff --git a/core/applets/obex/config.in b/core/applets/obex/config.in deleted file mode 100644 index 4d1f43d..0000000 --- a/core/applets/obex/config.in +++ b/dev/null @@ -1,4 +0,0 @@ - config OBEX - boolean "Obex library (library needed for beaming in Opie)" - default "y" - depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE diff --git a/core/applets/obex/libopieobex.control b/core/applets/obex/libopieobex.control deleted file mode 100644 index 3fd0f77..0000000 --- a/core/applets/obex/libopieobex.control +++ b/dev/null @@ -1,8 +0,0 @@ -Files: plugins/obex/libopieobex.so* -Priority: optional -Section: opie/system -Maintainer: Holger Freyther -Architecture: arm -Version: $QPE_VERSION-$SUB_VERSION.1 -Depends: opie-base, openobex | libopenobex1 -Description: Irda obex lib diff --git a/core/applets/obex/obex.cc b/core/applets/obex/obex.cc deleted file mode 100644 index 43041f5..0000000 --- a/core/applets/obex/obex.cc +++ b/dev/null @@ -1,194 +0,0 @@ - -#include -#include -#include -#include -#include "obex.h" - -using namespace OpieObex; - -Obex::Obex( QObject *parent, const char* name ) - : QObject(parent, name ) -{ - m_rec = 0; - m_send=0; - m_count = 0; - m_receive = false; - connect( this, SIGNAL(error(int) ), // for recovering to receive - SLOT(slotError() ) ); - connect( this, SIGNAL(sent() ), - SLOT(slotError() ) ); -}; -Obex::~Obex() { - delete m_rec; - delete m_send; -} -void Obex::receive() { - m_receive = true; - m_outp = QString::null; - qWarning("Receive" ); - m_rec = new OProcess(); - *m_rec << "irobex_palm3"; - // connect to the necessary slots - connect(m_rec, SIGNAL(processExited(OProcess*) ), - this, SLOT(slotExited(OProcess*) ) ); - - connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), - this, SLOT(slotStdOut(OProcess*, char*, int) ) ); - - if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { - qWarning("could not start :("); - emit done( false ); - delete m_rec; - m_rec = 0; - } -// emit currentTry(m_count ); - -} -void Obex::send( const QString& fileName) { // if currently receiving stop it send receive - m_count = 0; - m_file = fileName; - qWarning("send"); - if (m_rec != 0 ) { - qWarning("running"); - if (m_rec->isRunning() ) { - emit error(-1 ); - qWarning("is running"); - delete m_rec; - m_rec = 0; - - }else{ - qWarning("is not running"); - emit error( -1 ); // we did not delete yet but it's not running slotExited is pending - return; - } - } - sendNow(); -} -void Obex::sendNow(){ - qWarning("sendNow"); - if ( m_count >= 25 ) { // could not send - emit error(-1 ); - return; - } - // OProcess inititialisation - m_send = new OProcess(); - *m_send << "irobex_palm3"; - *m_send << m_file; - - // connect to slots Exited and and StdOut - connect(m_send, SIGNAL(processExited(OProcess*) ), - this, SLOT(slotExited(OProcess*)) ); - connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), - this, SLOT(slotStdOut(OProcess*, char*, int) ) ); - - // now start it - if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { - qWarning("could not send" ); - m_count = 25; - emit error(-1 ); - delete m_send; - m_send=0; - } - // end - m_count++; - emit currentTry( m_count ); -} - -void Obex::slotExited(OProcess* proc ){ - if (proc == m_rec ) { // receive process - received(); - }else if ( proc == m_send ) { - sendEnd(); - } -} -void Obex::slotStdOut(OProcess* proc, char* buf, int len){ - if ( proc == m_rec ) { // only receive - QCString cstring( buf, len ); - m_outp.append( cstring.data() ); - } -} - -void Obex::received() { - if (m_rec->normalExit() ) { - if ( m_rec->exitStatus() == 0 ) { // we got one - QString filename = parseOut(); - qWarning("ACHTUNG"); - emit receivedFile( filename ); - } - }else{ - emit done(false); - }; - delete m_rec; - m_rec = 0; - receive(); -} - -void Obex::sendEnd() { - if (m_send->normalExit() ) { - if ( m_send->exitStatus() == 0 ) { - delete m_send; - m_send=0; - qWarning("done" ); - emit sent(); - }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready - // let's try it again - delete m_send; - m_send = 0; - qWarning("try sending again" ); - sendNow(); - } - }else { - emit error( -1 ); - delete m_send; - m_send = 0; - } -} -QString Obex::parseOut( ){ - QString path; - QStringList list = QStringList::split("\n", m_outp); - QStringList::Iterator it; - for (it = list.begin(); it != list.end(); ++it ) { - if ( (*it).startsWith("Wrote" ) ) { - int pos = (*it).findRev('(' ); - if ( pos > 0 ) { - qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; - qWarning("%d %d", (*it).length(), (*it).length()-pos ); - - path = (*it).remove( pos, (*it).length() - pos ); - qWarning("%s", path.latin1() ); - path = path.mid(6 ); - path = path.stripWhiteSpace(); - qWarning("path %s", path.latin1() ); - } - } - } - return path; -} -/** - * when sent is done slotError is called we will start receive again - */ -void Obex::slotError() { - qWarning("slotError"); - if ( m_receive ) - receive(); -}; -void Obex::setReceiveEnabled( bool receive ) { - if ( !receive ) { // - m_receive = false; - shutDownReceive(); - } -} - -void Obex::shutDownReceive() { - if (m_rec != 0 ) { - qWarning("running"); - if (m_rec->isRunning() ) { - emit error(-1 ); - qWarning("is running"); - delete m_rec; - m_rec = 0; - } - } - -} diff --git a/core/applets/obex/obex.h b/core/applets/obex/obex.h deleted file mode 100644 index 781fca2..0000000 --- a/core/applets/obex/obex.h +++ b/dev/null @@ -1,85 +0,0 @@ - - -#ifndef OpieObex_H -#define OpieObex_H - -#include - -class OProcess; -class QCopChannel; -namespace OpieObex { - class Obex : public QObject { - Q_OBJECT - public: - /** - * Obex c'tor look - */ - Obex( QObject *parent, const char* name); - /** - * d'tor - */ - ~Obex(); - - /** - * Starting listening to irda after enabled by the applet - * a signal gets emitted when recieved a file - */ - void receive(); - void send( const QString& ); - void setReceiveEnabled( bool = false ); - signals: - - /** - * a signal - * @param path The path to the recieved file - */ - void receivedFile( const QString& path); - /** - * error signal if the program couldn't be started or the - * the connection timed out - */ - void error( int ); - /** - * The current try to receive data - */ - void currentTry(unsigned int); - /** - * signal sent The file got beamed to the remote location - */ - void sent(); - // private slots - void done(bool); - - private: - uint m_count; - QString m_file; - QString m_outp; - OProcess *m_send; - OProcess *m_rec; - bool m_receive : 1; - void shutDownReceive(); - -private slots: - - /** - * send over palm obex - */ - - //void send(const QString&); - - // the process exited - void slotExited(OProcess* proc) ; - void slotStdOut(OProcess*, char*, int); - void slotError(); - - private: - void sendNow(); - QString parseOut(); - void received(); - void sendEnd(); - - }; -}; - - -#endif diff --git a/core/applets/obex/obex.pro b/core/applets/obex/obex.pro deleted file mode 100644 index d7cc338..0000000 --- a/core/applets/obex/obex.pro +++ b/dev/null @@ -1,32 +0,0 @@ -TEMPLATE = lib -CONFIG += qt warn_on release -HEADERS = obex.h obeximpl.h -SOURCES = obex.cc obeximpl.cc -TARGET = opieobex -DESTDIR = $(OPIEDIR)/plugins/obex -INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/core/launcher -DEPENDPATH += ../$(OPIEDIR)/include -INTERFACES = obexinc.ui obexdlg.ui -LIBS += -lqpe -lopie -VERSION = 0.0.1 - -TRANSLATIONS = ../../../i18n/de/libopieobex.ts \ - ../../../i18n/da/libopieobex.ts \ - ../../../i18n/xx/libopieobex.ts \ - ../../../i18n/en/libopieobex.ts \ - ../../../i18n/es/libopieobex.ts \ - ../../../i18n/fr/libopieobex.ts \ - ../../../i18n/hu/libopieobex.ts \ - ../../../i18n/ja/libopieobex.ts \ - ../../../i18n/ko/libopieobex.ts \ - ../../../i18n/no/libopieobex.ts \ - ../../../i18n/pl/libopieobex.ts \ - ../../../i18n/pt/libopieobex.ts \ - ../../../i18n/pt_BR/libopieobex.ts \ - ../../../i18n/sl/libopieobex.ts \ - ../../../i18n/zh_CN/libopieobex.ts \ - ../../../i18n/zh_TW/libopieobex.ts - - - -include ( $(OPIEDIR)/include.pro ) diff --git a/core/applets/obex/obexdlg.ui b/core/applets/obex/obexdlg.ui deleted file mode 100644 index b367ffd..0000000 --- a/core/applets/obex/obexdlg.ui +++ b/dev/null @@ -1,279 +0,0 @@ - -ObexDlg -me - - QWidget - - name - Form1 - - - geometry - - 0 - 0 - 204 - 246 - - - - caption - OBEX Sending - - - QLayoutWidget - - name - Layout5 - - - geometry - - 0 - 60 - 200 - 70 - - - - - margin - 0 - - - spacing - 6 - - - QLabel - - name - TextLabel1 - - - text - Sending: - - - - - name - Spacer6 - - - orientation - Vertical - - - sizeType - Fixed - - - sizeHint - - 20 - 20 - - - - - QLabel - - name - lblPath - - - text - filename - - - textFormat - RichText - - - alignment - AlignTop|AlignLeft - - - hAlign - - - vAlign - - - - - - - name - Spacer7 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - name - Spacer8 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QLayoutWidget - - name - Layout6 - - - geometry - - 20 - 170 - 170 - 34 - - - - - margin - 0 - - - spacing - 6 - - - - name - Spacer9 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QPushButton - - name - PushButton2 - - - text - &Cancel - - - - - name - Spacer10 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - - - name - Spacer11 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - name - Spacer18 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - - PushButton2 - clicked() - Form1 - slotCancel() - - slotCancel() - - diff --git a/core/applets/obex/obeximpl.cc b/core/applets/obex/obeximpl.cc deleted file mode 100644 index 88f2d44..0000000 --- a/core/applets/obex/obeximpl.cc +++ b/dev/null @@ -1,150 +0,0 @@ - -#include -#include - - -#include -#include - -#include - -#include "obex.h" -#include "obeximpl.h" - - - -using namespace OpieObex; - -ObexImpl::ObexImpl( ) - : QObject() { - // register to a channel - qWarning( "c'tor" ); - m_obex = new Obex(this, "obex"); - m_sendgui = new ObexDlg(); - m_recvgui = new ObexInc(); - m_chan = new QCopChannel("QPE/Obex" ); - connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), - this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); - connect(m_obex, SIGNAL(receivedFile(const QString& ) ), - this, SLOT(slotReceivedFile(const QString& ) ) ); - connect((QObject*) m_recvgui->InsertButton, SIGNAL(clicked()), - m_recvgui, SLOT( accept() )); - connect((QObject*) m_recvgui->RejectButton, SIGNAL(clicked()), - m_recvgui, SLOT( reject() )); -} - -ObexImpl::~ObexImpl() { - delete m_obex; - delete m_chan; - delete m_sendgui; - delete m_recvgui; -} - -QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { - *iface = 0; - if( uuid == IID_QUnknown ) - *iface = this; - else if( uuid == IID_ObexInterface ) - *iface = this; - - qWarning("query" ); - if(*iface ) - (*iface)->addRef(); - return QS_OK; -} - -void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { - QDataStream stream( data, IO_ReadOnly ); - qWarning("Message %s", msg.data() ); - if(msg == "send(QString,QString,QString)" ) { - QString desc; - stream >> desc; - stream >> m_name; - m_sendgui->raise(); // should be on top - m_sendgui->showMaximized(); - m_sendgui->lblPath->setText(m_name); - connect( (QObject*)m_sendgui->PushButton2, SIGNAL(clicked()), - this, SLOT(slotCancelSend())); - m_obex->send(m_name ); - connect( (QObject*)m_obex, SIGNAL( sent() ), this, - SLOT( slotSent() ) ); - connect( (QObject*)m_obex, SIGNAL( error(int) ), this, - SLOT( slotSent() ) ); - }else if(msg == "receive(int)" ) { // open a GUI - //m_recvgui->showMaximized(); - int receiveD = 0; - stream >> receiveD; - if ( receiveD == 1) - m_obex->receive(); - else - m_obex->setReceiveEnabled( false ); - - } else if (msg =="done(QString)") { - QString text; - stream >> text; - m_sendgui->lblPath->setText(tr("Done transfering " + text)); - - } -} - -void ObexImpl::slotCancelSend() { - // cancel sync process too - //m_obex->cancel(); // not ready yet - m_sendgui->hide(); -} - -void ObexImpl::slotDone(bool) { - QCopEnvelope e ("QPE/Obex", "done(QString)" ); //but this into a slot - e << m_name; -} - -void ObexImpl::slotSent() { - m_sendgui->lblPath->setText("Done!"); - m_sendgui->hide(); -} - -void ObexImpl::slotError( int errorCode) { - - QString errorString = ""; - if (errorCode == -1) { - errorString = "test"; - } - qDebug("Error: " + errorString); - m_sendgui->hide(); -} - -// Received a file via beam -// check for mime type and then either -// add to App via setDocument -void ObexImpl::slotReceivedFile( const QString &fileName ) { - qWarning("filename %s", fileName.latin1() ); - DocLnk lnk( fileName ); - QString exec = lnk.exec(); - qWarning("executing %s", exec.latin1() ); - if ( exec.isEmpty() || exec == "" ) { - qWarning("empty"); - if ( fileName.right(4) == ".vcf" ) - exec = "addressbook"; - else if ( fileName.right(4) == ".vcs" ) { - exec = "datebook"; - } - } // now prompt and then add it - - m_recvgui->PixmapLabel->setPixmap( lnk.pixmap() ); - m_recvgui->AppLabel->setText( "" + exec + "" ); - m_recvgui->FileLabel->setText( lnk.name() ); - // m_recvgui->showMaximized(); - // if( m_recvgui->exec() == 0 ) { - QCString str= "QPE/Application/"; - str += exec.latin1(); - qWarning("channel %s", str.data() ); - QCopEnvelope e(str , "setDocument(QString)" ); - e << fileName; - //} -} - - - -Q_EXPORT_INTERFACE() { - Q_CREATE_INSTANCE( ObexImpl ) -} diff --git a/core/applets/obex/obeximpl.h b/core/applets/obex/obeximpl.h deleted file mode 100644 index 78d5b25..0000000 --- a/core/applets/obex/obeximpl.h +++ b/dev/null @@ -1,38 +0,0 @@ - -#ifndef OpieObexImpl_H -#define OpieObexImpl_H - -#include -#include -#include "obexdlg.h" -#include "obexinc.h" -#include - -namespace OpieObex { - class Obex; - class ObexImpl : public QObject, public ObexInterface { - Q_OBJECT - public: - ObexImpl(); - virtual ~ObexImpl(); - QRESULT queryInterface( const QUuid&, QUnknownInterface** ); - Q_REFCOUNT // for reference counting (macro ) - private: - ulong ref; - Obex* m_obex; // obex lib - QCopChannel *m_chan; - ObexDlg *m_sendgui; - ObexInc *m_recvgui; - QString m_name; - private slots: - void slotCancelSend(); - void slotMessage( const QCString&, const QByteArray& ); - void slotError(int ); - // void slotCurrentTry( unsigned int ); */ - void slotDone(bool); - void slotReceivedFile(const QString & ); - void slotSent(); - - }; -}; -#endif diff --git a/core/applets/obex/obexinc.ui b/core/applets/obex/obexinc.ui deleted file mode 100644 index 4cc8056..0000000 --- a/core/applets/obex/obexinc.ui +++ b/dev/null @@ -1,230 +0,0 @@ - -ObexInc - - QDialog - - name - ObexInc - - - geometry - - 0 - 0 - 208 - 248 - - - - caption - OBEX Receiving - - - QLayoutWidget - - name - Layout5 - - - geometry - - 90 - 100 - 79 - 68 - - - - - margin - 0 - - - spacing - 6 - - - QLabel - - name - AppLabel - - - text - TextLabel1 - - - - QLabel - - name - FileLabel - - - text - Filename - - - alignment - AlignTop|AlignLeft - - - vAlign - - - - - - QLabel - - name - TextLabel1 - - - geometry - - 30 - 30 - 161 - 41 - - - - text - A file was beamed -to you. - - - - QLabel - - name - PixmapLabel - - - geometry - - 30 - 100 - 40 - 40 - - - - scaledContents - true - - - - QLayoutWidget - - name - Layout4 - - - geometry - - 0 - 210 - 246 - 33 - - - - - margin - 0 - - - spacing - 6 - - - - name - Spacer9 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QPushButton - - name - InsertButton - - - text - Insert - - - - - name - Spacer11 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QPushButton - - name - RejectButton - - - text - Reject - - - - - name - Spacer10 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - - diff --git a/core/applets/obex/processwrapper.cc b/core/applets/obex/processwrapper.cc deleted file mode 100755 index ebc7794..0000000 --- a/core/applets/obex/processwrapper.cc +++ b/dev/null @@ -1,114 +0,0 @@ -// -m_rec == KProcess -m_count = int // the number of tries to recieve -m_send == KProcess -m_file == QString filename to send -m_outp == the output of the process - -// - - -void receive() { - m_rec = new KProcess(); - *m_rec << "irobex_palm3"; - // connect to the necessary slots - connect(m_rec, SIGNAL(processExited(KProcess*) ), - this, SLOT(slotExited(KProcess*) ) ); - - connect(m_rec, SIGNAL(receivedStdout(KProcess*, char*, int ) ), - this, SLOT(slotStdOut(KProcess*, char*, int) ) ); - - if(!m_rec->start(KProcess::NotifyOnExit, KProcess::AllOutput) ) { - qWarning("could not start :("); - emit done( false ); - } - emit try(m_count ) -} -void send(const QString &fileName) { - m_count = 0; - m_file = fileName; - sendNow(); -} -void sendNow() { - if ( m_count >= 15 ) { // could not send - emit error(-1 ); - } - // KProcess inititialisation - m_send = new KProcess(); - m_send << "irobex_palm3"; - m_send << m_file; - - // connect to slots Exited and and StdOut - connect(m_send, SIGNAL(processExited(KProcess*) ), - this, SLOT(slotExited(KProcess*)) ); - connect(m_send, SIGNAL(receivedStdout(KProcess*, char*, int ) ) - this, SLOT(slotStdOut(KProcess*, char*, int) ) ); - // now start it - if (!m_send->start(/*KProcess::NotifyOnExit, KProcess::AllOutput*/ ) ) { - m_count = 15; - emit error(-1 ); - } - // end - m_count++; - emit try( m_count ); -} - -void recieved() { - if (m_rec->normalExit() ) { - if ( m_rec->exitStatus() == 0 ) { // we got one - QString filename = parseOut(); - emit recievedFile( filename ); - } - }else{ - emit error(-1); - }; - delete m_rec; -} - - -void slotExited(KProcess* proc) { - if (proc == m_rec ) { // recieve process - recieved(); - }else if ( proc == m_send ) { - send(); - } -} - - -void send() { - if (m_send->normalExit() ) { - if ( m_send->exitStatus() == 0 ) { - delete m_send; - m_send=0; - emit sent(); - }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready - // let's try it again - delete m_send; - m_send = 0; - sendNow(); - } - }else { - emit error( -1 ); - delete m_send; - m_send = 0; - } - -} -void parseOut() { - QStringList list = QStringList::split("\n", m_outp); - QStringList::Iterator it; - for (it = list.begin(); it != list.end(); ++it ) { - if ( (*it).startsWith("Wrote" ) ) { - QStringList pathes = QStringList::split(' ', (*it) ); - QString path = pathes[1]; - } - } -} - -void slotStdOut(KProcess* proc, char* buf, int len) { - if ( proc == m_rec ) { // only recieve - QCString cstring( buf, len ); - m_outp.append( cstring.data() ); - } - -} -- cgit v0.9.0.2