summaryrefslogtreecommitdiff
authorzecke <zecke>2003-02-16 17:12:10 (UTC)
committer zecke <zecke>2003-02-16 17:12:10 (UTC)
commite9e20c4e64b8b228af928822e3d4a49ed773dc2e (patch) (unidiff)
tree17cdd250d08093d4c1564b7e61015d764da7e590
parent7280d00082163307ecc09d8f4b98397dda460dd5 (diff)
downloadopie-e9e20c4e64b8b228af928822e3d4a49ed773dc2e.zip
opie-e9e20c4e64b8b228af928822e3d4a49ed773dc2e.tar.gz
opie-e9e20c4e64b8b228af928822e3d4a49ed773dc2e.tar.bz2
Debug output
disabled some features inside the QTextView.. fixed two typos and the order of filename + description it's sending now again
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,195 +1,196 @@
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;
15 m_count = 0; 16 m_count = 0;
16 m_receive = false; 17 m_receive = false;
17 connect( this, SIGNAL(error(int) ), // for recovering to receive 18 connect( this, SIGNAL(error(int) ), // for recovering to receive
18 SLOT(slotError() ) ); 19 SLOT(slotError() ) );
19 connect( this, SIGNAL(sent() ), 20 connect( this, SIGNAL(sent() ),
20 SLOT(slotError() ) ); 21 SLOT(slotError() ) );
21}; 22};
22Obex::~Obex() { 23Obex::~Obex() {
23 delete m_rec; 24 delete m_rec;
24 delete m_send; 25 delete m_send;
25} 26}
26void Obex::receive() { 27void Obex::receive() {
27 m_receive = true; 28 m_receive = true;
28 m_outp = QString::null; 29 m_outp = QString::null;
29 qWarning("Receive" ); 30 qWarning("Receive" );
30 m_rec = new OProcess(); 31 m_rec = new OProcess();
31 *m_rec << "irobex_palm3"; 32 *m_rec << "irobex_palm3";
32 // connect to the necessary slots 33 // connect to the necessary slots
33 connect(m_rec, SIGNAL(processExited(OProcess*) ), 34 connect(m_rec, SIGNAL(processExited(OProcess*) ),
34 this, SLOT(slotExited(OProcess*) ) ); 35 this, SLOT(slotExited(OProcess*) ) );
35 36
36 connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 37 connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
37 this, SLOT(slotStdOut(OProcess*, char*, int) ) ); 38 this, SLOT(slotStdOut(OProcess*, char*, int) ) );
38 39
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;
64 } 65 }
65 } 66 }
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 );
91 delete m_send; 92 delete m_send;
92 m_send=0; 93 m_send=0;
93 } 94 }
94 // end 95 // end
95 m_count++; 96 m_count++;
96 emit currentTry( m_count ); 97 emit currentTry( m_count );
97} 98}
98 99
99void Obex::slotExited(OProcess* proc ){ 100void Obex::slotExited(OProcess* proc ){
100 if (proc == m_rec ) { // receive process 101 if (proc == m_rec ) { // receive process
101 received(); 102 received();
102 }else if ( proc == m_send ) { 103 }else if ( proc == m_send ) {
103 sendEnd(); 104 sendEnd();
104 } 105 }
105} 106}
106void Obex::slotStdOut(OProcess* proc, char* buf, int len){ 107void Obex::slotStdOut(OProcess* proc, char* buf, int len){
107 if ( proc == m_rec ) { // only receive 108 if ( proc == m_rec ) { // only receive
108 QCString cstring( buf, len ); 109 QCString cstring( buf, len );
109 m_outp.append( cstring.data() ); 110 m_outp.append( cstring.data() );
110 } 111 }
111} 112}
112 113
113void Obex::received() { 114void Obex::received() {
114 if (m_rec->normalExit() ) { 115 if (m_rec->normalExit() ) {
115 if ( m_rec->exitStatus() == 0 ) { // we got one 116 if ( m_rec->exitStatus() == 0 ) { // we got one
116 QString filename = parseOut(); 117 QString filename = parseOut();
117 qWarning("ACHTUNG"); 118 qWarning("ACHTUNG");
118 emit receivedFile( filename ); 119 emit receivedFile( filename );
119 } 120 }
120 }else{ 121 }else{
121 emit done(false); 122 emit done(false);
122 }; 123 };
123 delete m_rec; 124 delete m_rec;
124 m_rec = 0; 125 m_rec = 0;
125 receive(); 126 receive();
126} 127}
127 128
128void Obex::sendEnd() { 129void Obex::sendEnd() {
129 if (m_send->normalExit() ) { 130 if (m_send->normalExit() ) {
130 if ( m_send->exitStatus() == 0 ) { 131 if ( m_send->exitStatus() == 0 ) {
131 delete m_send; 132 delete m_send;
132 m_send=0; 133 m_send=0;
133 qWarning("done" ); 134 qWarning("done" );
134 emit sent(true); 135 emit sent(true);
135 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready 136 }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready
136 // let's try it again 137 // let's try it again
137 delete m_send; 138 delete m_send;
138 m_send = 0; 139 m_send = 0;
139 qWarning("try sending again" ); 140 qWarning("try sending again" );
140 sendNow(); 141 sendNow();
141 } 142 }
142 }else { 143 }else {
143 emit error( -1 ); 144 emit error( -1 );
144 delete m_send; 145 delete m_send;
145 m_send = 0; 146 m_send = 0;
146 } 147 }
147} 148}
148QString Obex::parseOut( ){ 149QString Obex::parseOut( ){
149 QString path; 150 QString path;
150 QStringList list = QStringList::split("\n", m_outp); 151 QStringList list = QStringList::split("\n", m_outp);
151 QStringList::Iterator it; 152 QStringList::Iterator it;
152 for (it = list.begin(); it != list.end(); ++it ) { 153 for (it = list.begin(); it != list.end(); ++it ) {
153 if ( (*it).startsWith("Wrote" ) ) { 154 if ( (*it).startsWith("Wrote" ) ) {
154 int pos = (*it).findRev('(' ); 155 int pos = (*it).findRev('(' );
155 if ( pos > 0 ) { 156 if ( pos > 0 ) {
156 qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ; 157 qWarning( "%d %s", pos, (*it).mid(6 ).latin1() ) ;
157 qWarning("%d %d", (*it).length(), (*it).length()-pos ); 158 qWarning("%d %d", (*it).length(), (*it).length()-pos );
158 159
159 path = (*it).remove( pos, (*it).length() - pos ); 160 path = (*it).remove( pos, (*it).length() - pos );
160 qWarning("%s", path.latin1() ); 161 qWarning("%s", path.latin1() );
161 path = path.mid(6 ); 162 path = path.mid(6 );
162 path = path.stripWhiteSpace(); 163 path = path.stripWhiteSpace();
163 qWarning("path %s", path.latin1() ); 164 qWarning("path %s", path.latin1() );
164 } 165 }
165 } 166 }
166 } 167 }
167 return path; 168 return path;
168} 169}
169/** 170/**
170 * when sent is done slotError is called we will start receive again 171 * when sent is done slotError is called we will start receive again
171 */ 172 */
172void Obex::slotError() { 173void Obex::slotError() {
173 qWarning("slotError"); 174 qWarning("slotError");
174 if ( m_receive ) 175 if ( m_receive )
175 receive(); 176 receive();
176}; 177};
177void Obex::setReceiveEnabled( bool receive ) { 178void Obex::setReceiveEnabled( bool receive ) {
178 if ( !receive ) { // 179 if ( !receive ) { //
179 m_receive = false; 180 m_receive = false;
180 shutDownReceive(); 181 shutDownReceive();
181 } 182 }
182} 183}
183 184
184void Obex::shutDownReceive() { 185void Obex::shutDownReceive() {
185 if (m_rec != 0 ) { 186 if (m_rec != 0 ) {
186 qWarning("running"); 187 qWarning("running");
187 if (m_rec->isRunning() ) { 188 if (m_rec->isRunning() ) {
188 emit error(-1 ); 189 emit error(-1 );
189 qWarning("is running"); 190 qWarning("is running");
190 delete m_rec; 191 delete m_rec;
191 m_rec = 0; 192 m_rec = 0;
192 } 193 }
193 } 194 }
194 195
195} 196}
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
@@ -1,65 +1,65 @@
1#include <qcopchannel_qws.h> 1#include <qcopchannel_qws.h>
2 2
3#include <qpe/qcopenvelope_qws.h> 3#include <qpe/qcopenvelope_qws.h>
4 4
5#include "obexsend.h" 5#include "obexsend.h"
6#include "receiver.h" 6#include "receiver.h"
7#include "obexhandler.h" 7#include "obexhandler.h"
8 8
9using namespace OpieObex; 9using namespace OpieObex;
10 10
11ObexHandler::ObexHandler() { 11ObexHandler::ObexHandler() {
12 m_wasRec = false; 12 m_wasRec = false;
13 m_sender = 0l; 13 m_sender = 0l;
14 m_receiver = 0l; 14 m_receiver = 0l;
15 QCopChannel* chan = new QCopChannel("QPE/Obex"); 15 QCopChannel* chan = new QCopChannel("QPE/Obex");
16 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 16 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
17 this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) ); 17 this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) );
18} 18}
19ObexHandler::~ObexHandler() { 19ObexHandler::~ObexHandler() {
20 delete m_sender; 20 delete m_sender;
21 delete m_receiver; 21 delete m_receiver;
22} 22}
23void ObexHandler::doSend(const QString& str, const QString& desc) { 23void ObexHandler::doSend(const QString& str, const QString& desc) {
24 delete m_sender; 24 delete m_sender;
25 m_sender = new SendWidget; 25 m_sender = new SendWidget;
26 m_sender->raise(); 26 m_sender->raise();
27 m_sender->showMaximized(); 27 m_sender->showMaximized();
28 connect(m_sender, SIGNAL(done() ), 28 connect(m_sender, SIGNAL(done() ),
29 this, SLOT(slotSent() ) ); 29 this, SLOT(slotSent() ) );
30 m_sender->send( str, desc ); 30 m_sender->send( str, desc );
31} 31}
32void ObexHandler::doReceive(bool b) { 32void ObexHandler::doReceive(bool b) {
33 if (m_receiver && b ) return; // we should enable receiver and it is on 33 if (m_receiver && b ) return; // we should enable receiver and it is on
34 else if (!m_receiver && !b ) return; // we should disbale receiver and it is off 34 else if (!m_receiver && !b ) return; // we should disbale receiver and it is off
35 else if (m_receiver && !b ) { 35 else if (m_receiver && !b ) {
36 delete m_receiver; 36 delete m_receiver;
37 m_receiver=0; 37 m_receiver=0;
38 }else if (!m_receiver && b ) { 38 }else if (!m_receiver && b ) {
39 m_receiver= new Receiver; 39 m_receiver= new Receiver;
40 } 40 }
41} 41}
42void ObexHandler::slotSent() { 42void ObexHandler::slotSent() {
43 QString file = m_sender->file(); 43 QString file = m_sender->file();
44 delete m_sender; 44 delete m_sender;
45 m_sender = 0; 45 m_sender = 0;
46 QCopEnvelope e ("QPE/Obex", "done(QString)" ); 46 QCopEnvelope e ("QPE/Obex", "done(QString)" );
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
@@ -1,251 +1,254 @@
1#include <qpushbutton.h> 1#include <qpushbutton.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qhbox.h> 3#include <qhbox.h>
4#include <qlayout.h> 4#include <qlayout.h>
5#include <qtimer.h> 5#include <qtimer.h>
6 6
7#include <qcopchannel_qws.h> 7#include <qcopchannel_qws.h>
8 8
9#include <qpe/resource.h> 9#include <qpe/resource.h>
10#include <qpe/qcopenvelope_qws.h> 10#include <qpe/qcopenvelope_qws.h>
11 11
12#include "obex.h" 12#include "obex.h"
13#include "obexsend.h" 13#include "obexsend.h"
14 14
15using namespace OpieObex; 15using namespace OpieObex;
16 16
17 17
18SendWidget::SendWidget( QWidget* parent, const char* name ) 18SendWidget::SendWidget( QWidget* parent, const char* name )
19 : QWidget( parent, name ) { 19 : QWidget( parent, name ) {
20 initUI(); 20 initUI();
21} 21}
22SendWidget::~SendWidget() { 22SendWidget::~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 );
52 frame->setFrameShadow( QFrame::Sunken ); 52 frame->setFrameShadow( QFrame::Sunken );
53 lay->addWidget(frame, 10); 53 lay->addWidget(frame, 10);
54 54
55 QLabel* devices = new QLabel(this); 55 QLabel* devices = new QLabel(this);
56 devices->setText("<qt><b>Devices:</b></qt>"); 56 devices->setText("<qt><b>Devices:</b></qt>");
57 devices->setAlignment( AlignLeft | AlignTop ); 57 devices->setAlignment( AlignLeft | AlignTop );
58 lay->addWidget( devices,10 ); 58 lay->addWidget( devices,10 );
59 59
60 m_devBox = new DeviceBox(this); 60 m_devBox = new DeviceBox(this);
61 lay->addWidget( m_devBox, 50 ); 61 lay->addWidget( m_devBox, 50 );
62 connect(m_devBox, SIGNAL(selectedDevice(const QString&, int ) ), 62 connect(m_devBox, SIGNAL(selectedDevice(const QString&, int ) ),
63 this, SLOT(slotSelectedDevice(const QString&, int) ) ); 63 this, SLOT(slotSelectedDevice(const QString&, int) ) );
64 64
65 QPushButton *but = new QPushButton(this); 65 QPushButton *but = new QPushButton(this);
66 but->setText(tr("Done") ); 66 but->setText(tr("Done") );
67 connect(but, SIGNAL(clicked() ), 67 connect(but, SIGNAL(clicked() ),
68 this, SLOT(slotDone() ) ); 68 this, SLOT(slotDone() ) );
69 69
70 lay->addWidget( but ); 70 lay->addWidget( but );
71 m_lay = lay; 71 m_lay = lay;
72 72
73 // QT does not like if you add items to an layout which already exits.... 73 // QT does not like if you add items to an layout which already exits....
74 // and was layouted invalidate() does not help too 74 // and was layouted invalidate() does not help too
75 // so we use RichText.... 75 // so we use RichText....
76} 76}
77 77
78/* 78/*
79 * in send we'll first set everything up 79 * in send we'll first set everything up
80 * and then wait for a list of devices. 80 * and then wait for a list of devices.
81 */ 81 */
82void SendWidget::send( const QString& file, const QString& desc ) { 82void SendWidget::send( const QString& file, const QString& desc ) {
83 m_file = file; 83 m_file = file;
84 m_irDa.clear(); 84 m_irDa.clear();
85 m_start = 0; 85 m_start = 0;
86 m_lblFile->setText(desc.isEmpty() ? file : desc ); 86 m_lblFile->setText(desc.isEmpty() ? file : desc );
87 87
88 if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { 88 if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) {
89 m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); 89 m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error );
90 m_start++; 90 m_start++;
91 }else 91 }else
92 m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); 92 m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search );
93 93
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 ) {
174 177
175} 178}
176DeviceBox::~DeviceBox() { 179DeviceBox::~DeviceBox() {
177 180
178} 181}
179void DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { 182void DeviceBox::addDevice( const QString& name, int dev, const QString& status ) {
180 QString tex; 183 QString tex;
181 DeviceItem item( name, status, dev ); 184 DeviceItem item( name, status, dev );
182 m_dev.insert( name, item ); 185 m_dev.insert( name, item );
183 tex = item.toString(); 186 tex = item.toString();
184 m_devices.prepend(tex); 187 m_devices.prepend(tex);
185 setText( text()+ "<br>"+tex ); 188 setText( text()+ "<br>"+tex );
186} 189}
187void DeviceBox::removeDevice( const QString& name ) { 190void DeviceBox::removeDevice( const QString& name ) {
188 if (!m_dev.contains(name) ) return; 191 if (!m_dev.contains(name) ) return;
189 m_devices.remove( m_dev[name].toString() ); 192 m_devices.remove( m_dev[name].toString() );
190 193
191 m_dev.remove(name); 194 m_dev.remove(name);
192 setText( m_devices.join("<br>") ); 195 setText( m_devices.join("<br>") );
193 196
194} 197}
195void DeviceBox::setStatus( const QString& name, const QString& status ) { 198void DeviceBox::setStatus( const QString& name, const QString& status ) {
196 if ( !m_dev.contains(name) ) return; 199 if ( !m_dev.contains(name) ) return;
197 DeviceItem dev = m_dev[name]; 200 DeviceItem dev = m_dev[name];
198 QString ole = dev.toString(); 201 QString ole = dev.toString();
199 dev.setStatus( status ); 202 dev.setStatus( status );
200 int index = m_devices.findIndex( ole ); 203 int index = m_devices.findIndex( ole );
201 m_devices[index] = dev.toString(); 204 m_devices[index] = dev.toString();
202 setText( m_devices.join("<br>") ); 205 setText( m_devices.join("<br>") );
203} 206}
204void DeviceBox::setSource( const QString& str ) { 207void DeviceBox::setSource( const QString& str ) {
205 qWarning("SetSource:%s", str.latin1() ); 208 qWarning("SetSource:%s", str.latin1() );
206 emit selectedDevice( str, m_dev[str].device() ); 209 emit selectedDevice( str, m_dev[str].device() );
207} 210}
208 211
209 212
210DeviceItem::DeviceItem( const QString& name, 213DeviceItem::DeviceItem( const QString& name,
211 const QString& status, int dev) 214 const QString& status, int dev)
212{ 215{
213 m_name = name; 216 m_name = name;
214 m_status = status; 217 m_status = status;
215 m_dev = dev; 218 m_dev = dev;
216} 219}
217QString DeviceItem::name()const { 220QString DeviceItem::name()const {
218 return m_name; 221 return m_name;
219} 222}
220QString DeviceItem::status()const { 223QString DeviceItem::status()const {
221 return m_status; 224 return m_status;
222} 225}
223int DeviceItem::device()const { 226int DeviceItem::device()const {
224 return m_dev; 227 return m_dev;
225} 228}
226QString DeviceItem::pixmap()const{ 229QString DeviceItem::pixmap()const{
227 QString str; 230 QString str;
228 switch(m_dev) { 231 switch(m_dev) {
229 case DeviceBox::IrDa: 232 case DeviceBox::IrDa:
230 str ="obex/irda"; 233 str ="obex/irda";
231 break; 234 break;
232 case DeviceBox::BT: 235 case DeviceBox::BT:
233 str ="obex/bt"; 236 str ="obex/bt";
234 break; 237 break;
235 case DeviceBox::Search: 238 case DeviceBox::Search:
236 str = "obex/search"; 239 str = "obex/search";
237 break; 240 break;
238 case DeviceBox::Error: 241 case DeviceBox::Error:
239 str = "editdelete"; 242 str = "editdelete";
240 break; 243 break;
241 }; 244 };
242 return str; 245 return str;
243} 246}
244DeviceItem::~DeviceItem() { 247DeviceItem::~DeviceItem() {
245} 248}
246void DeviceItem::setStatus(const QString& status ) { 249void DeviceItem::setStatus(const QString& status ) {
247 m_status = status; 250 m_status = status;
248} 251}
249QString DeviceItem::toString()const { 252QString DeviceItem::toString()const {
250 return "<p><a href=\""+m_name +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ; 253 return "<p><a href=\""+m_name +"\" ><img src=\""+pixmap()+"\" >"+m_name+" "+m_status+" </a></p>" ;
251} 254}