summaryrefslogtreecommitdiff
path: root/core/obex/obexsend.cpp
Unidiff
Diffstat (limited to 'core/obex/obexsend.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/obexsend.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp
index 6b8d467..cd8d58e 100644
--- a/core/obex/obexsend.cpp
+++ b/core/obex/obexsend.cpp
@@ -1,158 +1,158 @@
1#include <qpushbutton.h> 1#include <qpushbutton.h>
2#include <qlabel.h> 2#include <qlabel.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qtimer.h> 4#include <qtimer.h>
5 5
6 6
7#include <qpe/qcopenvelope_qws.h> 7#include <qpe/qcopenvelope_qws.h>
8 8
9#include "obex.h" 9#include "obex.h"
10#include "obexsend.h" 10#include "obexsend.h"
11 11
12using namespace OpieObex; 12using namespace OpieObex;
13 13
14/* TRANSLATOR OpieObex::SendWidget */ 14/* TRANSLATOR OpieObex::SendWidget */
15 15
16 16
17SendWidget::SendWidget( QWidget* parent, const char* name ) 17SendWidget::SendWidget( QWidget* parent, const char* name )
18 : QWidget( parent, name ) { 18 : QWidget( parent, name ) {
19 initUI(); 19 initUI();
20} 20}
21SendWidget::~SendWidget() { 21SendWidget::~SendWidget() {
22} 22}
23void SendWidget::initUI() { 23void SendWidget::initUI() {
24 m_obex = new Obex(this, "obex"); 24 m_obex = new Obex(this, "obex");
25 connect(m_obex, SIGNAL(error(int) ), 25 connect(m_obex, SIGNAL(error(int) ),
26 this, SLOT(slotIrError(int) ) ); 26 this, SLOT(slotIrError(int) ) );
27 connect(m_obex, SIGNAL(sent(bool) ), 27 connect(m_obex, SIGNAL(sent(bool) ),
28 this, SLOT(slotIrSent(bool) ) ); 28 this, SLOT(slotIrSent(bool) ) );
29 connect(m_obex, SIGNAL(currentTry(unsigned int ) ), 29 connect(m_obex, SIGNAL(currentTry(unsigned int) ),
30 this, SLOT(slotIrTry(unsigned int ) ) ); 30 this, SLOT(slotIrTry(unsigned int) ) );
31 31
32 QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this ); 32 QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this );
33 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 33 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
34 this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) ); 34 this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) );
35 35
36 chan = new QCopChannel("QPE/BluetoothBack", this ); 36 chan = new QCopChannel("QPE/BluetoothBack", this );
37 connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), 37 connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
38 this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) ); 38 this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) );
39 39
40 QVBoxLayout* lay = new QVBoxLayout(this); 40 QVBoxLayout* lay = new QVBoxLayout(this);
41 41
42 QHBox* nameBox = new QHBox(this); 42 QHBox* nameBox = new QHBox(this);
43 QLabel* name = new QLabel(nameBox); 43 QLabel* name = new QLabel(nameBox);
44 name->setText( tr("<qt><h1>Sending:</h1></qt>") ); 44 name->setText( tr("<qt><h1>Sending:</h1></qt>") );
45 name->setAlignment( AlignLeft | AlignTop ); 45 name->setAlignment( AlignLeft | AlignTop );
46 m_lblFile = new QLabel(nameBox); 46 m_lblFile = new QLabel(nameBox);
47 lay->addWidget(nameBox, 0); 47 lay->addWidget(nameBox, 0);
48 48
49 QFrame* frame = new QFrame(this); 49 QFrame* frame = new QFrame(this);
50 frame->setFrameShape( QFrame::HLine ); 50 frame->setFrameShape( QFrame::HLine );
51 frame->setFrameShadow( QFrame::Sunken ); 51 frame->setFrameShadow( QFrame::Sunken );
52 lay->addWidget(frame, 10); 52 lay->addWidget(frame, 10);
53 53
54 QLabel* devices = new QLabel(this); 54 QLabel* devices = new QLabel(this);
55 devices->setText("<qt><b>Devices:</b></qt>"); 55 devices->setText("<qt><b>Devices:</b></qt>");
56 devices->setAlignment( AlignLeft | AlignTop ); 56 devices->setAlignment( AlignLeft | AlignTop );
57 lay->addWidget( devices,10 ); 57 lay->addWidget( devices,10 );
58 58
59 m_devBox = new DeviceBox(this); 59 m_devBox = new DeviceBox(this);
60 lay->addWidget( m_devBox, 50 ); 60 lay->addWidget( m_devBox, 50 );
61 connect(m_devBox, SIGNAL(selectedDevice(int, int ) ), 61 connect(m_devBox, SIGNAL(selectedDevice(int,int) ),
62 this, SLOT(slotSelectedDevice(int, int) ) ); 62 this, SLOT(slotSelectedDevice(int,int) ) );
63 63
64 QPushButton *but = new QPushButton(this); 64 QPushButton *but = new QPushButton(this);
65 but->setText(tr("Done") ); 65 but->setText(tr("Done") );
66 connect(but, SIGNAL(clicked() ), 66 connect(but, SIGNAL(clicked() ),
67 this, SLOT(slotDone() ) ); 67 this, SLOT(slotDone() ) );
68 68
69 lay->addWidget( but ); 69 lay->addWidget( but );
70 m_lay = lay; 70 m_lay = lay;
71 71
72 // QT does not like if you add items to an layout which already exits.... 72 // QT does not like if you add items to an layout which already exits....
73 // and was layouted invalidate() does not help too 73 // and was layouted invalidate() does not help too
74 // so we use RichText.... 74 // so we use RichText....
75} 75}
76 76
77/* 77/*
78 * in send we'll first set everything up 78 * in send we'll first set everything up
79 * and then wait for a list of devices. 79 * and then wait for a list of devices.
80 */ 80 */
81void SendWidget::send( const QString& file, const QString& desc ) { 81void SendWidget::send( const QString& file, const QString& desc ) {
82 m_file = file; 82 m_file = file;
83 m_irDa.clear(); 83 m_irDa.clear();
84 m_start = 0; 84 m_start = 0;
85 m_lblFile->setText(desc.isEmpty() ? file : desc ); 85 m_lblFile->setText(desc.isEmpty() ? file : desc );
86 86
87 if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) { 87 if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) {
88 m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error ); 88 m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error );
89 m_start++; 89 m_start++;
90 }else 90 }else
91 m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search ); 91 m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search );
92 92
93 if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) { 93 if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) {
94 m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error ); 94 m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error );
95 m_start++; 95 m_start++;
96 }else 96 }else
97 m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search ); 97 m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search );
98 98
99 if (m_start != 2 ) { 99 if (m_start != 2 ) {
100 QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()"); 100 QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()");
101 QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()"); 101 QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()");
102 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 102 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
103 QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); 103 QCopEnvelope e3("QPE/Bluetooth", "listDevices()");
104 } 104 }
105} 105}
106void SendWidget::slotIrDaDevices( const QStringList& list) { 106void SendWidget::slotIrDaDevices( const QStringList& list) {
107 qWarning("slot it irda devices "); 107 qWarning("slot it irda devices ");
108 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { 108 for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) {
109 int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); 109 int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") );
110 m_irDa.insert( id, (*it) ); 110 m_irDa.insert( id, (*it) );
111 } 111 }
112 m_devBox->removeDevice( m_irDeSearch ); 112 m_devBox->removeDevice( m_irDeSearch );
113 m_irDaIt = m_irDa.begin(); 113 m_irDaIt = m_irDa.begin();
114 114
115 slotStartIrda(); 115 slotStartIrda();
116} 116}
117 117
118void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { 118void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) {
119 for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { 119 for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) {
120 int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); 120 int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") );
121 m_bt.insert( id, Pair( it.key(), it.data() ) ); 121 m_bt.insert( id, Pair( it.key(), it.data() ) );
122 } 122 }
123 m_devBox->removeDevice( m_btDeSearch ); 123 m_devBox->removeDevice( m_btDeSearch );
124} 124}
125void SendWidget::slotSelectedDevice( int name, int dev ) { 125void SendWidget::slotSelectedDevice( int name, int dev ) {
126 qWarning("Start beam? %d %d", name, dev ); 126 qWarning("Start beam? %d %d", name, dev );
127 if ( name == m_irDeSearch ) { 127 if ( name == m_irDeSearch ) {
128 for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) 128 for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it )
129 m_devBox->removeDevice( it.key() ); 129 m_devBox->removeDevice( it.key() );
130 130
131 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); 131 QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
132 } 132 }
133} 133}
134void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { 134void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) {
135 qWarning("dispatch irda %s", str.data() ); 135 qWarning("dispatch irda %s", str.data() );
136 if ( str == "devices(QStringList)" ) { 136 if ( str == "devices(QStringList)" ) {
137 QDataStream stream( ar, IO_ReadOnly ); 137 QDataStream stream( ar, IO_ReadOnly );
138 QStringList list; 138 QStringList list;
139 stream >> list; 139 stream >> list;
140 slotIrDaDevices( list ); 140 slotIrDaDevices( list );
141 } 141 }
142} 142}
143void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { 143void SendWidget::dispatchBt( const QCString&, const QByteArray& ) {
144 144
145} 145}
146void SendWidget::slotIrError( int ) { 146void SendWidget::slotIrError( int ) {
147 147
148} 148}
149void SendWidget::slotIrSent( bool b) { 149void SendWidget::slotIrSent( bool b) {
150 qWarning("irda sent!!"); 150 qWarning("irda sent!!");
151 QString text = b ? tr("Sent") : tr("Failure"); 151 QString text = b ? tr("Sent") : tr("Failure");
152 m_devBox->setStatus( m_irDaIt.key(), text ); 152 m_devBox->setStatus( m_irDaIt.key(), text );
153 ++m_irDaIt; 153 ++m_irDaIt;
154 slotStartIrda(); 154 slotStartIrda();
155} 155}
156void SendWidget::slotIrTry(unsigned int trI) { 156void SendWidget::slotIrTry(unsigned int trI) {
157 m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); 157 m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) );
158} 158}