summaryrefslogtreecommitdiff
path: root/core/applets/obex
authorzecke <zecke>2002-06-12 17:08:42 (UTC)
committer zecke <zecke>2002-06-12 17:08:42 (UTC)
commitd57ced2b9c8f3ac79bae54bef7d5026d24e2bb98 (patch) (unidiff)
tree2db69c92fb707834b798f815f812cbf30b9f09b1 /core/applets/obex
parentac707e366de561cabc8074b62025d143200869d7 (diff)
downloadopie-d57ced2b9c8f3ac79bae54bef7d5026d24e2bb98.zip
opie-d57ced2b9c8f3ac79bae54bef7d5026d24e2bb98.tar.gz
opie-d57ced2b9c8f3ac79bae54bef7d5026d24e2bb98.tar.bz2
Send Receive working now it's time for a gui
Diffstat (limited to 'core/applets/obex') (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/obex/obex.cc11
-rw-r--r--core/applets/obex/obeximpl.cc3
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,7 +1,8 @@
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
6using namespace OpieObex; 7using namespace OpieObex;
7 8
@@ -14,12 +15,13 @@ Obex::Obex( QObject *parent, const char* name )
14}; 15};
15Obex::~Obex() { 16Obex::~Obex() {
16 delete m_rec; 17 delete m_rec;
17 delete m_send; 18 delete m_send;
18} 19}
19void Obex::receive() { 20void 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
@@ -36,14 +38,15 @@ void Obex::receive() {
36void Obex::send( const QString& fileName) { 38void 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}
41void Obex::sendNow(){ 43void 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
@@ -51,13 +54,14 @@ void Obex::sendNow(){
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}
@@ -89,17 +93,19 @@ void Obex::recieved() {
89} 93}
90void Obex::sendEnd() { 94void 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;
@@ -110,10 +116,11 @@ QString Obex::parseOut( ){
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
@@ -43,13 +43,14 @@ void ObexImpl::slotMessage( const QCString& msg, const QByteArray&data ) {
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
54Q_EXPORT_INTERFACE() 55Q_EXPORT_INTERFACE()
55{ 56{