summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/obex.cc5
-rw-r--r--core/obex/obexhandler.cpp2
-rw-r--r--core/obex/obexsend.cpp19
3 files changed, 15 insertions, 11 deletions
diff --git a/core/obex/obex.cc b/core/obex/obex.cc
index 83d1faf..92cd317 100644
--- a/core/obex/obex.cc
+++ b/core/obex/obex.cc
@@ -1,14 +1,15 @@
1 1
2#include <qapplication.h> 2#include <qapplication.h>
3#include <qfile.h>
3#include <qmessagebox.h> 4#include <qmessagebox.h>
4#include <qpe/qcopenvelope_qws.h> 5#include <qpe/qcopenvelope_qws.h>
5#include <opie/oprocess.h> 6#include <opie/oprocess.h>
6#include "obex.h" 7#include "obex.h"
7 8
8using namespace OpieObex; 9using namespace OpieObex;
9 10
10Obex::Obex( QObject *parent, const char* name ) 11Obex::Obex( QObject *parent, const char* name )
11 : QObject(parent, name ) 12 : QObject(parent, name )
12{ 13{
13 m_rec = 0; 14 m_rec = 0;
14 m_send=0; 15 m_send=0;
@@ -39,25 +40,25 @@ void Obex::receive() {
39 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 40 if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
40 qWarning("could not start :("); 41 qWarning("could not start :(");
41 emit done( false ); 42 emit done( false );
42 delete m_rec; 43 delete m_rec;
43 m_rec = 0; 44 m_rec = 0;
44 } 45 }
45// emit currentTry(m_count ); 46// emit currentTry(m_count );
46 47
47} 48}
48void Obex::send( const QString& fileName) { // if currently receiving stop it send receive 49void Obex::send( const QString& fileName) { // if currently receiving stop it send receive
49 m_count = 0; 50 m_count = 0;
50 m_file = fileName; 51 m_file = fileName;
51 qWarning("send"); 52 qWarning("send %s", fileName.latin1() );
52 if (m_rec != 0 ) { 53 if (m_rec != 0 ) {
53 qWarning("running"); 54 qWarning("running");
54 if (m_rec->isRunning() ) { 55 if (m_rec->isRunning() ) {
55 emit error(-1 ); 56 emit error(-1 );
56 qWarning("is running"); 57 qWarning("is running");
57 delete m_rec; 58 delete m_rec;
58 m_rec = 0; 59 m_rec = 0;
59 60
60 }else{ 61 }else{
61 qWarning("is not running"); 62 qWarning("is not running");
62 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending 63 emit error( -1 ); // we did not delete yet but it's not running slotExited is pending
63 return; 64 return;
@@ -66,25 +67,25 @@ void Obex::send( const QString& fileName) { // if currently receiving stop it se
66 sendNow(); 67 sendNow();
67} 68}
68void Obex::sendNow(){ 69void Obex::sendNow(){
69 qWarning("sendNow"); 70 qWarning("sendNow");
70 if ( m_count >= 25 ) { // could not send 71 if ( m_count >= 25 ) { // could not send
71 emit error(-1 ); 72 emit error(-1 );
72 emit sent(false); 73 emit sent(false);
73 return; 74 return;
74 } 75 }
75 // OProcess inititialisation 76 // OProcess inititialisation
76 m_send = new OProcess(); 77 m_send = new OProcess();
77 *m_send << "irobex_palm3"; 78 *m_send << "irobex_palm3";
78 *m_send << m_file; 79 *m_send << QFile::encodeName(m_file);
79 80
80 // connect to slots Exited and and StdOut 81 // connect to slots Exited and and StdOut
81 connect(m_send, SIGNAL(processExited(OProcess*) ), 82 connect(m_send, SIGNAL(processExited(OProcess*) ),
82 this, SLOT(slotExited(OProcess*)) ); 83 this, SLOT(slotExited(OProcess*)) );
83 connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )), 84 connect(m_send, SIGNAL(receivedStdout(OProcess*, char*, int )),
84 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 85 this, SLOT(slotStdOut(OProcess*, char*, int) ) );
85 86
86 // now start it 87 // now start it
87 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { 88 if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) {
88 qWarning("could not send" ); 89 qWarning("could not send" );
89 m_count = 25; 90 m_count = 25;
90 emit error(-1 ); 91 emit error(-1 );
diff --git a/core/obex/obexhandler.cpp b/core/obex/obexhandler.cpp
index f71a233..16e1c2f 100644
--- a/core/obex/obexhandler.cpp
+++ b/core/obex/obexhandler.cpp
@@ -47,19 +47,19 @@ void ObexHandler::slotSent() {
47 e << file; 47 e << file;
48 doReceive(m_wasRec ); 48 doReceive(m_wasRec );
49 m_wasRec = false; 49 m_wasRec = false;
50} 50}
51void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { 51void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) {
52 QDataStream stream( data, IO_ReadOnly ); 52 QDataStream stream( data, IO_ReadOnly );
53 if ( msg == "send(QString,QString,QString)" ) { 53 if ( msg == "send(QString,QString,QString)" ) {
54 QString name, desc; 54 QString name, desc;
55 stream >> name; 55 stream >> name;
56 stream >> desc; 56 stream >> desc;
57 m_wasRec = (m_receiver != 0 ); 57 m_wasRec = (m_receiver != 0 );
58 doReceive( false ); 58 doReceive( false );
59 doSend(name, desc); 59 doSend(desc, name);
60 }else if (msg == "receive(int)") { 60 }else if (msg == "receive(int)") {
61 int rec; 61 int rec;
62 stream >> rec; 62 stream >> rec;
63 doReceive(rec); 63 doReceive(rec);
64 } 64 }
65} 65}
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp
index a2e4c16..d5ebd81 100644
--- a/core/obex/obexsend.cpp
+++ b/core/obex/obexsend.cpp
@@ -23,29 +23,29 @@ SendWidget::~SendWidget() {
23} 23}
24void SendWidget::initUI() { 24void SendWidget::initUI() {
25 m_obex = new Obex(this, "obex"); 25 m_obex = new Obex(this, "obex");
26 connect(m_obex, SIGNAL(error(int) ), 26 connect(m_obex, SIGNAL(error(int) ),
27 this, SLOT(slotIrError(int) ) ); 27 this, SLOT(slotIrError(int) ) );
28 connect(m_obex, SIGNAL(sent(bool) ), 28 connect(m_obex, SIGNAL(sent(bool) ),
29 this, SLOT(slotIrSent(bool) ) ); 29 this, SLOT(slotIrSent(bool) ) );
30 connect(m_obex, SIGNAL(currentTry(unsigned int ) ), 30 connect(m_obex, SIGNAL(currentTry(unsigned int ) ),
31 this, SLOT(slotIrTry(unsigned int ) ) ); 31 this, SLOT(slotIrTry(unsigned int ) ) );
32 32
33 QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); 33 QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this );
34 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 34 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
35 this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) ); 35 this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) );
36 36
37 chan = new QCopChannel("QPE/BluetoothBack", this ); 37 chan = new QCopChannel("QPE/BluetoothBack", this );
38 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 38 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
39 this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) ); 39 this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) );
40 40
41 QVBoxLayout* lay = new QVBoxLayout(this); 41 QVBoxLayout* lay = new QVBoxLayout(this);
42 42
43 QHBox* nameBox = new QHBox(this); 43 QHBox* nameBox = new QHBox(this);
44 QLabel* name = new QLabel(nameBox); 44 QLabel* name = new QLabel(nameBox);
45 name->setText( tr("<qt><h1>Sending:</h1></qt>") ); 45 name->setText( tr("<qt><h1>Sending:</h1></qt>") );
46 name->setAlignment( AlignLeft | AlignTop ); 46 name->setAlignment( AlignLeft | AlignTop );
47 m_lblFile = new QLabel(nameBox); 47 m_lblFile = new QLabel(nameBox);
48 lay->addWidget(nameBox, 0); 48 lay->addWidget(nameBox, 0);
49 49
50 QFrame* frame = new QFrame(this); 50 QFrame* frame = new QFrame(this);
51 frame->setFrameShape( QFrame::HLine ); 51 frame->setFrameShape( QFrame::HLine );
@@ -94,80 +94,83 @@ void SendWidget::send( const QString& file, const QString& desc ) {
94 if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { 94 if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) {
95 m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); 95 m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error );
96 m_start++; 96 m_start++;
97 }else 97 }else
98 m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); 98 m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search );
99 99
100 if (m_start != 2 ) { 100 if (m_start != 2 ) {
101 QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); 101 QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()");
102 QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); 102 QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()");
103 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 103 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
104 QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); 104 QCopEnvelope e3("QPE/Bluetooth", "listDevices()");
105 } 105 }
106 QTimer::singleShot(5000, this, SLOT(testIt() ) );
107} 106}
108void SendWidget::slotIrDaDevices( const QStringList& list) { 107void SendWidget::slotIrDaDevices( const QStringList& list) {
108 qWarning("slot it irda devices ");
109 m_irDa = list; 109 m_irDa = list;
110 m_start = 0; 110 m_start = 0;
111 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) 111 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it )
112 m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); 112 m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") );
113 m_devBox->removeDevice( tr("Search for IrDa Devices.") ); 113
114 m_devBox->removeDevice( tr("Searching for IrDa Devices.") );
114 115
115 slotStartIrda(); 116 slotStartIrda();
116} 117}
117void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { 118void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) {
118 m_bt = str; 119 m_bt = str;
119 for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { 120 for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) {
120 m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); 121 m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") );
121 } 122 }
122 m_devBox->removeDevice( tr("Searching for bluetooth Devices.") ); 123 m_devBox->removeDevice( tr("Searching for bluetooth Devices.") );
123} 124}
124void SendWidget::slotSelectedDevice( const QString& name, int dev ) { 125void SendWidget::slotSelectedDevice( const QString& name, int dev ) {
125 qWarning("Start beam? %s %d", name.latin1(), dev ); 126 qWarning("Start beam? %s %d", name.latin1(), dev );
126 if ( name == tr("Search again for IrDa.") ) { 127 if ( name == tr("Search again for IrDa.") ) {
127 for (QStringList::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) 128 for (QStringList::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it )
128 m_devBox->removeDevice( (*it) ); 129 m_devBox->removeDevice( (*it) );
130
129 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 131 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
130 } 132 }
131} 133}
132void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { 134void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) {
133 qWarning("dispatch irda %s", str.data() ); 135 qWarning("dispatch irda %s", str.data() );
134 if ( str == "listDevices(QStringList)" ) { 136 if ( str == "devices(QStringList)" ) {
135 QDataStream stream( ar, IO_ReadOnly ); 137 QDataStream stream( ar, IO_ReadOnly );
136 QStringList list; 138 QStringList list;
137 stream >> list; 139 stream >> list;
138 slotIrDaDevices( list ); 140 slotIrDaDevices( list );
139 } 141 }
140} 142}
141void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) { 143void SendWidget::dispatchBt( const QCString& str, const QByteArray& ar ) {
142 144
143} 145}
144void SendWidget::slotIrError( int ) { 146void SendWidget::slotIrError( int ) {
145 147
146} 148}
147void SendWidget::slotIrSent( bool b) { 149void SendWidget::slotIrSent( bool b) {
150 qWarning("irda sent!!");
148 QString text = b ? tr("Sent") : tr("Failure"); 151 QString text = b ? tr("Sent") : tr("Failure");
149 m_devBox->setStatus( m_irDa[m_start], text ); 152// m_devBox->setStatus( m_irDa[m_start], text );
150 m_start++; 153 m_start++;
151 slotStartIrda(); 154 slotStartIrda();
152} 155}
153void SendWidget::slotIrTry(unsigned int trI) { 156void SendWidget::slotIrTry(unsigned int trI) {
154 m_devBox->setStatus( m_irDa[m_start], tr("Try %1").arg( QString::number( trI ) ) ); 157// m_devBox->setStatus( m_irDa[m_start], tr("Try %1").arg( QString::number( trI ) ) );
155} 158}
156void SendWidget::slotStartIrda() { 159void SendWidget::slotStartIrda() {
157 if (m_start >= m_irDa.count() ) { 160 if (m_start >= m_irDa.count() ) {
158 m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); 161 m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search );
159 return; 162 return;
160 } 163 }
161 m_devBox->setStatus( m_irDa[m_start], tr("Start sending") ); 164// m_devBox->setStatus( m_irDa[m_start], tr("Start sending") );
162 m_obex->send( m_file ); 165 m_obex->send( m_file );
163} 166}
164void SendWidget::slotDone() { 167void SendWidget::slotDone() {
165 QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); 168 QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()");
166 QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); 169 QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()");
167 emit done(); 170 emit done();
168} 171}
169QString SendWidget::file()const { 172QString SendWidget::file()const {
170 return m_file; 173 return m_file;
171} 174}
172DeviceBox::DeviceBox( QWidget* parent ) 175DeviceBox::DeviceBox( QWidget* parent )
173 : QTextBrowser( parent ) { 176 : QTextBrowser( parent ) {