author | zecke <zecke> | 2002-06-12 16:37:52 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-12 16:37:52 (UTC) |
commit | ac707e366de561cabc8074b62025d143200869d7 (patch) (unidiff) | |
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 | 25 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.h | 5 |
5 files changed, 44 insertions, 36 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,9 +1,9 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include "kprocess.h" | 3 | #include <opie/oprocess.h> |
4 | #include "obex.h" | 4 | #include "obex.h" |
5 | 5 | ||
6 | using namespace OpieObex; | 6 | using namespace OpieObex; |
7 | 7 | ||
8 | Obex::Obex( QObject *parent, const char* name ) | 8 | Obex::Obex( QObject *parent, const char* name ) |
9 | : QObject(parent, name ) | 9 | : QObject(parent, name ) |
@@ -14,22 +14,22 @@ Obex::Obex( QObject *parent, const char* name ) | |||
14 | }; | 14 | }; |
15 | Obex::~Obex() { | 15 | Obex::~Obex() { |
16 | delete m_rec; | 16 | delete m_rec; |
17 | delete m_send; | 17 | delete m_send; |
18 | } | 18 | } |
19 | void Obex::receive() { | 19 | void Obex::receive() { |
20 | m_rec = new KProcess(); | 20 | m_rec = new OProcess(); |
21 | *m_rec << "irobex_palm3"; | 21 | *m_rec << "irobex_palm3"; |
22 | // connect to the necessary slots | 22 | // connect to the necessary slots |
23 | connect(m_rec, SIGNAL(processExited(KProcess*) ), | 23 | connect(m_rec, SIGNAL(processExited(OProcess*) ), |
24 | this, SLOT(slotExited(KProcess*) ) ); | 24 | this, SLOT(slotExited(OProcess*) ) ); |
25 | 25 | ||
26 | connect(m_rec, SIGNAL(receivedStdout(KProcess*, char*, int ) ), | 26 | connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
27 | this, SLOT(slotStdOut(KProcess*, char*, int) ) ); | 27 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
28 | 28 | ||
29 | if(!m_rec->start(KProcess::NotifyOnExit, KProcess::AllOutput) ) { | 29 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
30 | qWarning("could not start :("); | 30 | qWarning("could not start :("); |
31 | emit done( false ); | 31 | emit done( false ); |
32 | } | 32 | } |
33 | emit currentTry(m_count ); | 33 | emit currentTry(m_count ); |
34 | 34 | ||
35 | } | 35 | } |
@@ -39,40 +39,40 @@ void Obex::send( const QString& fileName) { | |||
39 | sendNow(); | 39 | sendNow(); |
40 | } | 40 | } |
41 | void Obex::sendNow(){ | 41 | void Obex::sendNow(){ |
42 | if ( m_count >= 15 ) { // could not send | 42 | if ( m_count >= 15 ) { // could not send |
43 | emit error(-1 ); | 43 | emit error(-1 ); |
44 | } | 44 | } |
45 | // KProcess inititialisation | 45 | // OProcess inititialisation |
46 | m_send = new KProcess(); | 46 | m_send = new OProcess(); |
47 | *m_send << "irobex_palm3"; | 47 | *m_send << "irobex_palm3"; |
48 | *m_send << m_file; | 48 | *m_send << m_file; |
49 | 49 | ||
50 | // connect to slots Exited and and StdOut | 50 | // connect to slots Exited and and StdOut |
51 | connect(m_send, SIGNAL(processExited(KProcess*) ), | 51 | connect(m_send, SIGNAL(processExited(OProcess*) ), |
52 | this, SLOT(slotExited(KProcess*)) ); | 52 | this, SLOT(slotExited(OProcess*)) ); |
53 | connect(m_send, SIGNAL(receivedStdout(KProcess*, char*, int )), | 53 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), |
54 | this, SLOT(slotStdOut(KProcess*, char*, int) ) ); | 54 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
55 | // now start it | 55 | // now start it |
56 | if (!m_send->start(/*KProcess::NotifyOnExit, KProcess::AllOutput*/ ) ) { | 56 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { |
57 | m_count = 15; | 57 | m_count = 15; |
58 | emit error(-1 ); | 58 | emit error(-1 ); |
59 | } | 59 | } |
60 | // end | 60 | // end |
61 | m_count++; | 61 | m_count++; |
62 | emit currentTry( m_count ); | 62 | emit currentTry( m_count ); |
63 | } | 63 | } |
64 | 64 | ||
65 | void Obex::slotExited(KProcess* proc ){ | 65 | void Obex::slotExited(OProcess* proc ){ |
66 | if (proc == m_rec ) { // recieve process | 66 | if (proc == m_rec ) { // recieve process |
67 | recieved(); | 67 | recieved(); |
68 | }else if ( proc == m_send ) { | 68 | }else if ( proc == m_send ) { |
69 | sendEnd(); | 69 | sendEnd(); |
70 | } | 70 | } |
71 | } | 71 | } |
72 | void Obex::slotStdOut(KProcess* proc, char* buf, int len){ | 72 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ |
73 | if ( proc == m_rec ) { // only recieve | 73 | if ( proc == m_rec ) { // only recieve |
74 | QCString cstring( buf, len ); | 74 | QCString cstring( buf, len ); |
75 | m_outp.append( cstring.data() ); | 75 | m_outp.append( cstring.data() ); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
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 | |||
@@ -2,13 +2,13 @@ | |||
2 | 2 | ||
3 | #ifndef OpieObex_H | 3 | #ifndef OpieObex_H |
4 | #define OpieObex_H | 4 | #define OpieObex_H |
5 | 5 | ||
6 | #include <qobject.h> | 6 | #include <qobject.h> |
7 | 7 | ||
8 | class KProcess; | 8 | class OProcess; |
9 | class QCopChannel; | 9 | class QCopChannel; |
10 | namespace OpieObex { | 10 | namespace OpieObex { |
11 | class Obex : public QObject { | 11 | class Obex : public QObject { |
12 | Q_OBJECT | 12 | Q_OBJECT |
13 | public: | 13 | public: |
14 | /** | 14 | /** |
@@ -50,26 +50,26 @@ namespace OpieObex { | |||
50 | void done(bool); | 50 | void done(bool); |
51 | 51 | ||
52 | private: | 52 | private: |
53 | uint m_count; | 53 | uint m_count; |
54 | QString m_file; | 54 | QString m_file; |
55 | QString m_outp; | 55 | QString m_outp; |
56 | KProcess *m_send; | 56 | OProcess *m_send; |
57 | KProcess *m_rec; | 57 | OProcess *m_rec; |
58 | 58 | ||
59 | private slots: | 59 | private slots: |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * send over palm obex | 62 | * send over palm obex |
63 | */ | 63 | */ |
64 | 64 | ||
65 | //void send(const QString&); | 65 | //void send(const QString&); |
66 | 66 | ||
67 | // the process exited | 67 | // the process exited |
68 | void slotExited(KProcess* proc) ; | 68 | void slotExited(OProcess* proc) ; |
69 | void slotStdOut(KProcess*, char*, int); | 69 | void slotStdOut(OProcess*, char*, int); |
70 | 70 | ||
71 | private: | 71 | private: |
72 | void sendNow(); | 72 | void sendNow(); |
73 | QString parseOut(); | 73 | QString parseOut(); |
74 | void recieved(); | 74 | void recieved(); |
75 | void sendEnd(); | 75 | void sendEnd(); |
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 @@ | |||
1 | TEMPLATE= lib | 1 | TEMPLATE= lib |
2 | CONFIG += qt warn_on release | 2 | CONFIG += qt warn_on release |
3 | HEADERS= kprocess.h kprocctrl.h obex.h | 3 | HEADERS= obex.h obeximpl.h |
4 | SOURCES= kprocess.cpp kprocctrl.cpp obex.cc | 4 | SOURCES= obex.cc obeximpl.cc |
5 | TARGET = obex | 5 | TARGET = obex |
6 | DESTDIR = ../../plugins/applets | 6 | DESTDIR = ../../plugins/obex |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += ../$(OPIEDIR)/include | 8 | DEPENDPATH += ../$(OPIEDIR)/include |
9 | LIBS += -lqpe | 9 | LIBS += -lqpe -lopie |
10 | VERSION = 0.0.1 | 10 | VERSION = 0.0.1 |
11 | 11 | ||
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 @@ | |||
1 | 1 | ||
2 | #include <qdatastream.h> | ||
3 | #include <qpe/qcom.h> | ||
2 | 4 | ||
3 | #include "obex.h" | 5 | #include "obex.h" |
4 | #include "obeximpl.h" | 6 | #include "obeximpl.h" |
5 | 7 | ||
8 | |||
9 | |||
6 | using namespace OpieObex; | 10 | using namespace OpieObex; |
7 | 11 | ||
8 | ObexImpl::ObexImpl( ) | 12 | ObexImpl::ObexImpl( ) |
9 | : QObject { | 13 | : QObject() { |
10 | // register to a channel | 14 | // register to a channel |
15 | qWarning( "c'tor" ); | ||
11 | m_obex = new Obex(this, "obex"); | 16 | m_obex = new Obex(this, "obex"); |
12 | m_chan = new QCopChannel("QPE/Obex" ); | 17 | m_chan = new QCopChannel("QPE/Obex" ); |
13 | cconnect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 18 | connect(m_chan, SIGNAL(received(const QCString&, const QByteArray& ) ), |
14 | this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); | 19 | this, SLOT(slotMessage(const QCString&, const QByteArray&) ) ); |
15 | } | 20 | } |
16 | ObexImpl::~ObexImpl() { | 21 | ObexImpl::~ObexImpl() { |
17 | delete m_obex; | 22 | delete m_obex; |
18 | delete m_chan; | 23 | delete m_chan; |
19 | } | 24 | } |
20 | QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 25 | QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
21 | *iface = 0; | 26 | *iface = 0; |
22 | if( uuid == IID_QUknown ) | 27 | if( uuid == IID_QUnknown ) |
23 | *iface = this; | 28 | *iface = this; |
24 | else if( uuid == IID_ObexInterface ) | 29 | else if( uuid == IID_ObexInterface ) |
25 | *iface = this; | 30 | *iface = this; |
26 | 31 | ||
32 | qWarning("query" ); | ||
27 | if(*iface ) | 33 | if(*iface ) |
28 | (*iface)->addRef(); | 34 | (*iface)->addRef(); |
29 | return QS_OK; | 35 | return QS_OK; |
30 | 36 | ||
31 | } | 37 | } |
32 | void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { | 38 | void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { |
33 | QDataStrean stream( data, IO_ReadOnly ); | 39 | QDataStream stream( data, IO_ReadOnly ); |
40 | qWarning("Message %s", msg.data() ); | ||
34 | if(msg == "send(QString,QString,QString)" ) { | 41 | if(msg == "send(QString,QString,QString)" ) { |
35 | QString desc; | 42 | QString desc; |
36 | stream >> desc; | 43 | stream >> desc; |
37 | QString filename; | 44 | QString filename; |
38 | stream >> filename; | 45 | stream >> filename; |
39 | m_obex->send(filename ); | 46 | m_obex->send(filename ); |
40 | QCopEnvelope e ("QPE/Obex", "done(QString)" ): | 47 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); |
41 | e << filename; | 48 | e << filename; |
42 | }else if( ) { | 49 | }else if(msg == "receive(bool)" ) { |
43 | 50 | ; | |
44 | } | 51 | } |
45 | } | 52 | } |
46 | 53 | ||
47 | Q_EXPORT_INTERFACE() | 54 | Q_EXPORT_INTERFACE() |
48 | { | 55 | { |
49 | Q_CREATE_INSTANCE( IrdaAppletImpl ) | 56 | Q_CREATE_INSTANCE( ObexImpl ) |
50 | } | 57 | } |
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,20 +1,21 @@ | |||
1 | 1 | ||
2 | #ifndef OpieObexImpl_H | 2 | #ifndef OpieObexImpl_H |
3 | #define OpieObexImpl_H | 3 | #define OpieObexImpl_H |
4 | 4 | ||
5 | #include <qobject.h> | ||
5 | #include "../obexinterface.h" | 6 | #include "../obexinterface.h" |
6 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
7 | 8 | ||
8 | namespace OpieObex { | 9 | namespace OpieObex { |
9 | class Obex; | 10 | class Obex; |
10 | class ObexImpl : public ObexInterface, public QObject { | 11 | class ObexImpl : public QObject, public ObexInterface { |
11 | Q_OBJECT | 12 | Q_OBJECT |
12 | public: | 13 | public: |
13 | ObexImpl(); | 14 | ObexImpl(); |
14 | virtual ObexImpl(); | 15 | virtual ~ObexImpl(); |
15 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 16 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
16 | Q_REFCOUNT // for reference counting (macro ) | 17 | Q_REFCOUNT // for reference counting (macro ) |
17 | private: | 18 | private: |
18 | ulong ref; | 19 | ulong ref; |
19 | Obex* m_obex; // obex lib | 20 | Obex* m_obex; // obex lib |
20 | QCopChannel *m_chan; | 21 | QCopChannel *m_chan; |