author | zecke <zecke> | 2002-06-12 16:37:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-12 16:37:52 (UTC) |
commit | ac707e366de561cabc8074b62025d143200869d7 (patch) (side-by-side diff) | |
tree | ad30bac3657fde6e664e7784eb34873989e94699 | |
parent | 9b87f7a2f2de6b5c1bad4f35f76fc7a0fd1ad021 (diff) | |
download | opie-ac707e366de561cabc8074b62025d143200869d7.zip opie-ac707e366de561cabc8074b62025d143200869d7.tar.gz opie-ac707e366de561cabc8074b62025d143200869d7.tar.bz2 |
OBEX time
-rw-r--r-- | core/applets/obex/obex.cc | 32 | ||||
-rw-r--r-- | core/applets/obex/obex.h | 10 | ||||
-rw-r--r-- | core/applets/obex/obex.pro | 8 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.cc | 23 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.h | 5 |
5 files changed, 43 insertions, 35 deletions
diff --git a/core/applets/obex/obex.cc b/core/applets/obex/obex.cc index f2ceff8..582ebbc 100644 --- a/core/applets/obex/obex.cc +++ b/core/applets/obex/obex.cc @@ -1,119 +1,119 @@ -#include "kprocess.h" +#include <opie/oprocess.h> #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; }; Obex::~Obex() { delete m_rec; delete m_send; } void Obex::receive() { - m_rec = new KProcess(); + m_rec = new OProcess(); *m_rec << "irobex_palm3"; // connect to the necessary slots - connect(m_rec, SIGNAL(processExited(KProcess*) ), - this, SLOT(slotExited(KProcess*) ) ); + connect(m_rec, SIGNAL(processExited(OProcess*) ), + this, SLOT(slotExited(OProcess*) ) ); - connect(m_rec, SIGNAL(receivedStdout(KProcess*, char*, int ) ), - this, SLOT(slotStdOut(KProcess*, char*, int) ) ); + connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), + this, SLOT(slotStdOut(OProcess*, char*, int) ) ); - if(!m_rec->start(KProcess::NotifyOnExit, KProcess::AllOutput) ) { + if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { qWarning("could not start :("); emit done( false ); } emit currentTry(m_count ); } void Obex::send( const QString& fileName) { m_count = 0; m_file = fileName; sendNow(); } void Obex::sendNow(){ if ( m_count >= 15 ) { // could not send emit error(-1 ); } - // KProcess inititialisation - m_send = new KProcess(); + // 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(KProcess*) ), - this, SLOT(slotExited(KProcess*)) ); - connect(m_send, SIGNAL(receivedStdout(KProcess*, char*, int )), - this, SLOT(slotStdOut(KProcess*, char*, int) ) ); + 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(/*KProcess::NotifyOnExit, KProcess::AllOutput*/ ) ) { + if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { m_count = 15; emit error(-1 ); } // end m_count++; emit currentTry( m_count ); } -void Obex::slotExited(KProcess* proc ){ +void Obex::slotExited(OProcess* proc ){ if (proc == m_rec ) { // recieve process recieved(); }else if ( proc == m_send ) { sendEnd(); } } -void Obex::slotStdOut(KProcess* proc, char* buf, int len){ +void Obex::slotStdOut(OProcess* proc, char* buf, int len){ if ( proc == m_rec ) { // only recieve QCString cstring( buf, len ); m_outp.append( cstring.data() ); } } void Obex::recieved() { if (m_rec->normalExit() ) { if ( m_rec->exitStatus() == 0 ) { // we got one QString filename = parseOut(); emit receivedFile( filename ); } }else{ emit error(-1); }; delete m_rec; } void Obex::sendEnd() { 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; } } 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" ) ) { QStringList pathes = QStringList::split(' ', (*it) ); path = pathes[1]; } } return path; } diff --git a/core/applets/obex/obex.h b/core/applets/obex/obex.h index 17b8141..4e78015 100644 --- a/core/applets/obex/obex.h +++ b/core/applets/obex/obex.h @@ -1,81 +1,81 @@ #ifndef OpieObex_H #define OpieObex_H #include <qobject.h> -class KProcess; +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& ); 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; - KProcess *m_send; - KProcess *m_rec; + OProcess *m_send; + OProcess *m_rec; private slots: /** * send over palm obex */ //void send(const QString&); // the process exited - void slotExited(KProcess* proc) ; - void slotStdOut(KProcess*, char*, int); + void slotExited(OProcess* proc) ; + void slotStdOut(OProcess*, char*, int); private: void sendNow(); QString parseOut(); void recieved(); void sendEnd(); }; }; #endif diff --git a/core/applets/obex/obex.pro b/core/applets/obex/obex.pro index ce07ac9..72ad78f 100644 --- a/core/applets/obex/obex.pro +++ b/core/applets/obex/obex.pro @@ -1,11 +1,11 @@ TEMPLATE = lib CONFIG += qt warn_on release -HEADERS = kprocess.h kprocctrl.h obex.h -SOURCES = kprocess.cpp kprocctrl.cpp obex.cc +HEADERS = obex.h obeximpl.h +SOURCES = obex.cc obeximpl.cc TARGET = obex -DESTDIR = ../../plugins/applets +DESTDIR = ../../plugins/obex INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += ../$(OPIEDIR)/include -LIBS += -lqpe +LIBS += -lqpe -lopie VERSION = 0.0.1 diff --git a/core/applets/obex/obeximpl.cc b/core/applets/obex/obeximpl.cc index a3004ab..fa2a30a 100644 --- a/core/applets/obex/obeximpl.cc +++ b/core/applets/obex/obeximpl.cc @@ -1,50 +1,57 @@ +#include <qdatastream.h> +#include <qpe/qcom.h> #include "obex.h" #include "obeximpl.h" + + using namespace OpieObex; ObexImpl::ObexImpl( ) - : QObject { + : QObject() { // register to a channel + qWarning( "c'tor" ); m_obex = new Obex(this, "obex"); m_chan = new QCopChannel("QPE/Obex" ); - cconnect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), + connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); } ObexImpl::~ObexImpl() { delete m_obex; delete m_chan; } QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { *iface = 0; - if( uuid == IID_QUknown ) + 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 ) { - QDataStrean stream( data, IO_ReadOnly ); + QDataStream stream( data, IO_ReadOnly ); + qWarning("Message %s", msg.data() ); if(msg == "send(QString,QString,QString)" ) { QString desc; stream >> desc; QString filename; stream >> filename; m_obex->send(filename ); - QCopEnvelope e ("QPE/Obex", "done(QString)" ): + QCopEnvelope e ("QPE/Obex", "done(QString)" ); e << filename; - }else if( ) { - + }else if(msg == "receive(bool)" ) { + ; } } Q_EXPORT_INTERFACE() { - Q_CREATE_INSTANCE( IrdaAppletImpl ) + Q_CREATE_INSTANCE( ObexImpl ) } diff --git a/core/applets/obex/obeximpl.h b/core/applets/obex/obeximpl.h index 996627b..d5159e1 100644 --- a/core/applets/obex/obeximpl.h +++ b/core/applets/obex/obeximpl.h @@ -1,25 +1,26 @@ #ifndef OpieObexImpl_H #define OpieObexImpl_H +#include <qobject.h> #include "../obexinterface.h" #include <qpe/qcopenvelope_qws.h> namespace OpieObex { class Obex; - class ObexImpl : public ObexInterface, public QObject { + class ObexImpl : public QObject, public ObexInterface { Q_OBJECT public: ObexImpl(); - virtual 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; private slots: void slotMessage( const QCString&, const QByteArray& ); }; }; #endif |