author | zecke <zecke> | 2002-06-12 17:08:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-12 17:08:42 (UTC) |
commit | d57ced2b9c8f3ac79bae54bef7d5026d24e2bb98 (patch) (unidiff) | |
tree | 2db69c92fb707834b798f815f812cbf30b9f09b1 | |
parent | ac707e366de561cabc8074b62025d143200869d7 (diff) | |
download | opie-d57ced2b9c8f3ac79bae54bef7d5026d24e2bb98.zip opie-d57ced2b9c8f3ac79bae54bef7d5026d24e2bb98.tar.gz opie-d57ced2b9c8f3ac79bae54bef7d5026d24e2bb98.tar.bz2 |
Send Receive working now it's time for a gui
-rw-r--r-- | core/applets/obex/obex.cc | 11 | ||||
-rw-r--r-- | core/applets/obex/obeximpl.cc | 3 |
2 files changed, 11 insertions, 3 deletions
diff --git a/core/applets/obex/obex.cc b/core/applets/obex/obex.cc index 582ebbc..f35d57a 100644 --- a/core/applets/obex/obex.cc +++ b/core/applets/obex/obex.cc | |||
@@ -1,73 +1,77 @@ | |||
1 | 1 | ||
2 | #include <qapplication.h> | ||
2 | 3 | ||
3 | #include <opie/oprocess.h> | 4 | #include <opie/oprocess.h> |
4 | #include "obex.h" | 5 | #include "obex.h" |
5 | 6 | ||
6 | using namespace OpieObex; | 7 | using namespace OpieObex; |
7 | 8 | ||
8 | Obex::Obex( QObject *parent, const char* name ) | 9 | Obex::Obex( QObject *parent, const char* name ) |
9 | : QObject(parent, name ) | 10 | : QObject(parent, name ) |
10 | { | 11 | { |
11 | m_rec = 0; | 12 | m_rec = 0; |
12 | m_send=0; | 13 | m_send=0; |
13 | m_count = 0; | 14 | m_count = 0; |
14 | }; | 15 | }; |
15 | Obex::~Obex() { | 16 | Obex::~Obex() { |
16 | delete m_rec; | 17 | delete m_rec; |
17 | delete m_send; | 18 | delete m_send; |
18 | } | 19 | } |
19 | void Obex::receive() { | 20 | void Obex::receive() { |
21 | qWarning("Receive" ); | ||
20 | m_rec = new OProcess(); | 22 | m_rec = new OProcess(); |
21 | *m_rec << "irobex_palm3"; | 23 | *m_rec << "irobex_palm3"; |
22 | // connect to the necessary slots | 24 | // connect to the necessary slots |
23 | connect(m_rec, SIGNAL(processExited(OProcess*) ), | 25 | connect(m_rec, SIGNAL(processExited(OProcess*) ), |
24 | this, SLOT(slotExited(OProcess*) ) ); | 26 | this, SLOT(slotExited(OProcess*) ) ); |
25 | 27 | ||
26 | connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 28 | connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
27 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 29 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
28 | 30 | ||
29 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 31 | if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
30 | qWarning("could not start :("); | 32 | qWarning("could not start :("); |
31 | emit done( false ); | 33 | emit done( false ); |
32 | } | 34 | } |
33 | emit currentTry(m_count ); | 35 | emit currentTry(m_count ); |
34 | 36 | ||
35 | } | 37 | } |
36 | void Obex::send( const QString& fileName) { | 38 | void Obex::send( const QString& fileName) { |
37 | m_count = 0; | 39 | m_count = 0; |
38 | m_file = fileName; | 40 | m_file = fileName; |
39 | sendNow(); | 41 | sendNow(); |
40 | } | 42 | } |
41 | void Obex::sendNow(){ | 43 | void Obex::sendNow(){ |
42 | if ( m_count >= 15 ) { // could not send | 44 | if ( m_count >= 25 ) { // could not send |
43 | emit error(-1 ); | 45 | emit error(-1 ); |
46 | return; | ||
44 | } | 47 | } |
45 | // OProcess inititialisation | 48 | // OProcess inititialisation |
46 | m_send = new OProcess(); | 49 | m_send = new OProcess(); |
47 | *m_send << "irobex_palm3"; | 50 | *m_send << "irobex_palm3"; |
48 | *m_send << m_file; | 51 | *m_send << m_file; |
49 | 52 | ||
50 | // connect to slots Exited and and StdOut | 53 | // connect to slots Exited and and StdOut |
51 | connect(m_send, SIGNAL(processExited(OProcess*) ), | 54 | connect(m_send, SIGNAL(processExited(OProcess*) ), |
52 | this, SLOT(slotExited(OProcess*)) ); | 55 | this, SLOT(slotExited(OProcess*)) ); |
53 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), | 56 | connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), |
54 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); | 57 | this, SLOT(slotStdOut(OProcess*, char*, int) ) ); |
55 | // now start it | 58 | // now start it |
56 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { | 59 | if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { |
57 | m_count = 15; | 60 | qWarning("could not send" ); |
61 | m_count = 25; | ||
58 | emit error(-1 ); | 62 | emit error(-1 ); |
59 | } | 63 | } |
60 | // end | 64 | // end |
61 | m_count++; | 65 | m_count++; |
62 | emit currentTry( m_count ); | 66 | emit currentTry( m_count ); |
63 | } | 67 | } |
64 | 68 | ||
65 | void Obex::slotExited(OProcess* proc ){ | 69 | void Obex::slotExited(OProcess* proc ){ |
66 | if (proc == m_rec ) { // recieve process | 70 | if (proc == m_rec ) { // recieve process |
67 | recieved(); | 71 | recieved(); |
68 | }else if ( proc == m_send ) { | 72 | }else if ( proc == m_send ) { |
69 | sendEnd(); | 73 | sendEnd(); |
70 | } | 74 | } |
71 | } | 75 | } |
72 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ | 76 | void Obex::slotStdOut(OProcess* proc, char* buf, int len){ |
73 | if ( proc == m_rec ) { // only recieve | 77 | if ( proc == m_rec ) { // only recieve |
@@ -79,41 +83,44 @@ void Obex::slotStdOut(OProcess* proc, char* buf, int len){ | |||
79 | void Obex::recieved() { | 83 | void Obex::recieved() { |
80 | if (m_rec->normalExit() ) { | 84 | if (m_rec->normalExit() ) { |
81 | if ( m_rec->exitStatus() == 0 ) { // we got one | 85 | if ( m_rec->exitStatus() == 0 ) { // we got one |
82 | QString filename = parseOut(); | 86 | QString filename = parseOut(); |
83 | emit receivedFile( filename ); | 87 | emit receivedFile( filename ); |
84 | } | 88 | } |
85 | }else{ | 89 | }else{ |
86 | emit error(-1); | 90 | emit error(-1); |
87 | }; | 91 | }; |
88 | delete m_rec; | 92 | delete m_rec; |
89 | } | 93 | } |
90 | void Obex::sendEnd() { | 94 | void Obex::sendEnd() { |
91 | if (m_send->normalExit() ) { | 95 | if (m_send->normalExit() ) { |
92 | if ( m_send->exitStatus() == 0 ) { | 96 | if ( m_send->exitStatus() == 0 ) { |
93 | delete m_send; | 97 | delete m_send; |
94 | m_send=0; | 98 | m_send=0; |
99 | qWarning("done" ); | ||
95 | emit sent(); | 100 | emit sent(); |
96 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready | 101 | }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready |
97 | // let's try it again | 102 | // let's try it again |
98 | delete m_send; | 103 | delete m_send; |
99 | m_send = 0; | 104 | m_send = 0; |
105 | qWarning("try sending again" ); | ||
100 | sendNow(); | 106 | sendNow(); |
101 | } | 107 | } |
102 | }else { | 108 | }else { |
103 | emit error( -1 ); | 109 | emit error( -1 ); |
104 | delete m_send; | 110 | delete m_send; |
105 | m_send = 0; | 111 | m_send = 0; |
106 | } | 112 | } |
107 | } | 113 | } |
108 | QString Obex::parseOut( ){ | 114 | QString Obex::parseOut( ){ |
109 | QString path; | 115 | QString path; |
110 | QStringList list = QStringList::split("\n", m_outp); | 116 | QStringList list = QStringList::split("\n", m_outp); |
111 | QStringList::Iterator it; | 117 | QStringList::Iterator it; |
112 | for (it = list.begin(); it != list.end(); ++it ) { | 118 | for (it = list.begin(); it != list.end(); ++it ) { |
113 | if ( (*it).startsWith("Wrote" ) ) { | 119 | if ( (*it).startsWith("Wrote" ) ) { |
114 | QStringList pathes = QStringList::split(' ', (*it) ); | 120 | QStringList pathes = QStringList::split(' ', (*it) ); |
115 | path = pathes[1]; | 121 | path = pathes[1]; |
122 | qWarning("path %s", path.latin1() ); | ||
116 | } | 123 | } |
117 | } | 124 | } |
118 | return path; | 125 | return path; |
119 | } | 126 | } |
diff --git a/core/applets/obex/obeximpl.cc b/core/applets/obex/obeximpl.cc index fa2a30a..82ff1a1 100644 --- a/core/applets/obex/obeximpl.cc +++ b/core/applets/obex/obeximpl.cc | |||
@@ -33,25 +33,26 @@ QRESULT ObexImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | |||
33 | if(*iface ) | 33 | if(*iface ) |
34 | (*iface)->addRef(); | 34 | (*iface)->addRef(); |
35 | return QS_OK; | 35 | return QS_OK; |
36 | 36 | ||
37 | } | 37 | } |
38 | void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { | 38 | void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) { |
39 | QDataStream stream( data, IO_ReadOnly ); | 39 | QDataStream stream( data, IO_ReadOnly ); |
40 | qWarning("Message %s", msg.data() ); | 40 | qWarning("Message %s", msg.data() ); |
41 | if(msg == "send(QString,QString,QString)" ) { | 41 | if(msg == "send(QString,QString,QString)" ) { |
42 | QString desc; | 42 | QString desc; |
43 | stream >> desc; | 43 | stream >> desc; |
44 | QString filename; | 44 | QString filename; |
45 | stream >> filename; | 45 | stream >> filename; |
46 | m_obex->send(filename ); | 46 | m_obex->send(filename ); |
47 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); | 47 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); |
48 | e << filename; | 48 | e << filename; |
49 | }else if(msg == "receive(bool)" ) { | 49 | }else if(msg == "receive(bool)" ) { // open a GUI |
50 | m_obex->receive(); | ||
50 | ; | 51 | ; |
51 | } | 52 | } |
52 | } | 53 | } |
53 | 54 | ||
54 | Q_EXPORT_INTERFACE() | 55 | Q_EXPORT_INTERFACE() |
55 | { | 56 | { |
56 | Q_CREATE_INSTANCE( ObexImpl ) | 57 | Q_CREATE_INSTANCE( ObexImpl ) |
57 | } | 58 | } |