summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/obex/obex.cc32
-rw-r--r--core/applets/obex/obex.h10
-rw-r--r--core/applets/obex/obex.pro8
-rw-r--r--core/applets/obex/obeximpl.cc25
-rw-r--r--core/applets/obex/obeximpl.h5
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,119 +1,119 @@
1 1
2 2
3#include "kprocess.h" 3#include <opie/oprocess.h>
4#include "obex.h" 4#include "obex.h"
5 5
6using namespace OpieObex; 6using namespace OpieObex;
7 7
8Obex::Obex( QObject *parent, const char* name ) 8Obex::Obex( QObject *parent, const char* name )
9 : QObject(parent, name ) 9 : QObject(parent, name )
10{ 10{
11 m_rec = 0; 11 m_rec = 0;
12 m_send=0; 12 m_send=0;
13 m_count = 0; 13 m_count = 0;
14}; 14};
15Obex::~Obex() { 15Obex::~Obex() {
16 delete m_rec; 16 delete m_rec;
17 delete m_send; 17 delete m_send;
18} 18}
19void Obex::receive() { 19void 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}
36void Obex::send( const QString& fileName) { 36void Obex::send( const QString& fileName) {
37 m_count = 0; 37 m_count = 0;
38 m_file = fileName; 38 m_file = fileName;
39 sendNow(); 39 sendNow();
40} 40}
41void Obex::sendNow(){ 41void 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
65void Obex::slotExited(KProcess* proc ){ 65void 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}
72void Obex::slotStdOut(KProcess* proc, char* buf, int len){ 72void 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
79void Obex::recieved() { 79void Obex::recieved() {
80 if (m_rec->normalExit() ) { 80 if (m_rec->normalExit() ) {
81 if ( m_rec->exitStatus() == 0 ) { // we got one 81 if ( m_rec->exitStatus() == 0 ) { // we got one
82 QString filename = parseOut(); 82 QString filename = parseOut();
83 emit receivedFile( filename ); 83 emit receivedFile( filename );
84 } 84 }
85 }else{ 85 }else{
86 emit error(-1); 86 emit error(-1);
87 }; 87 };
88 delete m_rec; 88 delete m_rec;
89} 89}
90void Obex::sendEnd() { 90void Obex::sendEnd() {
91 if (m_send->normalExit() ) { 91 if (m_send->normalExit() ) {
92 if ( m_send->exitStatus() == 0 ) { 92 if ( m_send->exitStatus() == 0 ) {
93 delete m_send; 93 delete m_send;
94 m_send=0; 94 m_send=0;
95 emit sent(); 95 emit sent();
96 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready 96 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready
97 // let's try it again 97 // let's try it again
98 delete m_send; 98 delete m_send;
99 m_send = 0; 99 m_send = 0;
100 sendNow(); 100 sendNow();
101 } 101 }
102 }else { 102 }else {
103 emit error( -1 ); 103 emit error( -1 );
104 delete m_send; 104 delete m_send;
105 m_send = 0; 105 m_send = 0;
106 } 106 }
107} 107}
108QString Obex::parseOut( ){ 108QString Obex::parseOut( ){
109 QString path; 109 QString path;
110 QStringList list = QStringList::split("\n", m_outp); 110 QStringList list = QStringList::split("\n", m_outp);
111 QStringList::Iterator it; 111 QStringList::Iterator it;
112 for (it = list.begin(); it != list.end(); ++it ) { 112 for (it = list.begin(); it != list.end(); ++it ) {
113 if ( (*it).startsWith("Wrote" ) ) { 113 if ( (*it).startsWith("Wrote" ) ) {
114 QStringList pathes = QStringList::split(' ', (*it) ); 114 QStringList pathes = QStringList::split(' ', (*it) );
115 path = pathes[1]; 115 path = pathes[1];
116 } 116 }
117 } 117 }
118 return path; 118 return path;
119} 119}
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 @@
1 1
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
8class KProcess; 8class OProcess;
9class QCopChannel; 9class QCopChannel;
10namespace OpieObex { 10namespace OpieObex {
11 class Obex : public QObject { 11 class Obex : public QObject {
12 Q_OBJECT 12 Q_OBJECT
13 public: 13 public:
14 /** 14 /**
15 * Obex c'tor look 15 * Obex c'tor look
16 */ 16 */
17 Obex( QObject *parent, const char* name); 17 Obex( QObject *parent, const char* name);
18 /** 18 /**
19 * d'tor 19 * d'tor
20 */ 20 */
21 ~Obex(); 21 ~Obex();
22 22
23 /** 23 /**
24 * Starting listening to irda after enabled by the applet 24 * Starting listening to irda after enabled by the applet
25 * a signal gets emitted when recieved a file 25 * a signal gets emitted when recieved a file
26 */ 26 */
27 void receive(); 27 void receive();
28 void send( const QString& ); 28 void send( const QString& );
29 signals: 29 signals:
30 30
31 /** 31 /**
32 * a signal 32 * a signal
33 * @param path The path to the recieved file 33 * @param path The path to the recieved file
34 */ 34 */
35 void receivedFile( const QString& path); 35 void receivedFile( const QString& path);
36 /** 36 /**
37 * error signal if the program couldn't be started or the 37 * error signal if the program couldn't be started or the
38 * the connection timed out 38 * the connection timed out
39 */ 39 */
40 void error( int ); 40 void error( int );
41 /** 41 /**
42 * The current try to receive data 42 * The current try to receive data
43 */ 43 */
44 void currentTry(unsigned int); 44 void currentTry(unsigned int);
45 /** 45 /**
46 * signal sent The file got beamed to the remote location 46 * signal sent The file got beamed to the remote location
47 */ 47 */
48 void sent(); 48 void sent();
49 // private slots 49 // private slots
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();
76 76
77 }; 77 };
78}; 78};
79 79
80 80
81#endif 81#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 @@
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
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += ../$(OPIEDIR)/include 8DEPENDPATH += ../$(OPIEDIR)/include
9LIBS += -lqpe 9LIBS += -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
6using namespace OpieObex; 10using namespace OpieObex;
7 11
8ObexImpl::ObexImpl( ) 12ObexImpl::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}
16ObexImpl::~ObexImpl() { 21ObexImpl::~ObexImpl() {
17 delete m_obex; 22 delete m_obex;
18 delete m_chan; 23 delete m_chan;
19} 24}
20QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 25QRESULT 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}
32void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { 38void 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
47Q_EXPORT_INTERFACE() 54Q_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,25 +1,26 @@
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
8namespace OpieObex { 9namespace 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;
21 private slots: 22 private slots:
22 void slotMessage( const QCString&, const QByteArray& ); 23 void slotMessage( const QCString&, const QByteArray& );
23 }; 24 };
24}; 25};
25#endif 26#endif