-rw-r--r-- | core/obex/obexsend.cpp | 4 | ||||
-rw-r--r-- | core/obex/obexsend.h | 3 |
2 files changed, 7 insertions, 0 deletions
diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index 0da57ca..1b19c6b 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp @@ -105,128 +105,132 @@ void SendWidget::send( const QString& file, const QString& desc ) { QCopEnvelope e3("QPE/Bluetooth", "listDevices()"); } } void SendWidget::slotIrDaDevices( const QStringList& list) { qWarning("slot it irda devices "); for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it ) { int id = m_devBox->addDevice( (*it), DeviceBox::IrDa, tr("Scheduling for beam.") ); m_irDa.insert( id, (*it) ); } m_devBox->removeDevice( m_irDeSearch ); m_irDaIt = m_irDa.begin(); slotStartIrda(); } void SendWidget::slotBTDevices( const QMap<QString, QString>& str ) { for(QMap<QString, QString>::ConstIterator it = str.begin(); it != str.end(); ++it ) { int id = m_devBox->addDevice( it.key(), DeviceBox::BT, tr("Click to beam") ); m_bt.insert( id, Pair( it.key(), it.data() ) ); } m_devBox->removeDevice( m_btDeSearch ); } void SendWidget::slotSelectedDevice( int name, int dev ) { qWarning("Start beam? %d %d", name, dev ); if ( name == m_irDeSearch ) { for (QMap<int, QString>::Iterator it= m_irDa.begin(); it != m_irDa.end(); ++it ) m_devBox->removeDevice( it.key() ); QCopEnvelope e2("QPE/IrDaApplet", "listDevices()"); } } void SendWidget::dispatchIrda( const QCString& str, const QByteArray& ar ) { qWarning("dispatch irda %s", str.data() ); if ( str == "devices(QStringList)" ) { QDataStream stream( ar, IO_ReadOnly ); QStringList list; stream >> list; slotIrDaDevices( list ); } } void SendWidget::dispatchBt( const QCString&, const QByteArray& ) { } void SendWidget::slotIrError( int ) { } void SendWidget::slotIrSent( bool b) { qWarning("irda sent!!"); QString text = b ? tr("Sent") : tr("Failure"); m_devBox->setStatus( m_irDaIt.key(), text ); ++m_irDaIt; slotStartIrda(); } void SendWidget::slotIrTry(unsigned int trI) { m_devBox->setStatus( m_irDaIt.key(), tr("Try %1").arg( QString::number( trI ) ) ); } void SendWidget::slotStartIrda() { if (m_irDaIt == m_irDa.end() ) { m_irDeSearch = m_devBox->addDevice(tr("Search again for IrDa."), DeviceBox::Search ); return; } m_devBox->setStatus( m_irDaIt.key(), tr("Start sending") ); m_obex->send( m_file ); } +void SendWidget::closeEvent( QCloseEvent* e) { + e->accept(); // make sure + QTimer::singleShot(0, this, SLOT(slotDone() ) ); +} void SendWidget::slotDone() { QCopEnvelope e0("QPE/IrDaApplet", "disableIrda()"); QCopEnvelope e1("QPE/Bluetooth", "disableBluetooth()"); emit done(); } QString SendWidget::file()const { return m_file; } DeviceBox::DeviceBox( QWidget* parent ) : QTextBrowser( parent ) { } DeviceBox::~DeviceBox() { } int DeviceBox::addDevice( const QString& name, int dev, const QString& status ) { /* return a id for a range of devices */ int id = idFor ( dev ); DeviceItem item( name, status, dev,id ); m_dev.insert( id, item ); setText( allText() ); return id; } void DeviceBox::removeDevice( int id ) { if (!m_dev.contains(id) ) return; m_dev.remove( id ); setText( allText() ); } void DeviceBox::setStatus( int id, const QString& status ) { if ( !m_dev.contains(id) ) return; m_dev[id].setStatus(status ); setText( allText() ); } void DeviceBox::setSource( const QString& str ) { qWarning("SetSource:%d", str.toInt() ); int id = str.toInt(); emit selectedDevice( id, m_dev[id].device() ); } int DeviceBox::idFor ( int id ) { static int irId = 1501; static int irBT = 1001; static int irSr = 501; static int irEr = 0; int ret = -1; switch(id ) { case IrDa: ret = irId; irId++; break; case BT: ret = irBT; irBT++; break; case Search: ret = irSr; irSr++; break; case Error: ret = irEr; irEr++; break; diff --git a/core/obex/obexsend.h b/core/obex/obexsend.h index 02100f7..bf901cb 100644 --- a/core/obex/obexsend.h +++ b/core/obex/obexsend.h @@ -1,105 +1,108 @@ #ifndef OPIE_OBEX_SEND_WIDGET_H #define OPIE_OBEX_SEND_WIDGET_H #include <qstring.h> #include <qstringlist.h> #include <qwidget.h> #include <qvbox.h> #include <qmap.h> #include <qtextbrowser.h> class QLabel; class QVBoxLayout; /** * This is the new sending widget for Obex * It will attemp to smart and be able to send * it to multiple devices. * It'll support BT + IrDa */ namespace OpieObex { class DeviceBox; class Obex; struct Pair { Pair(const QString& first = QString::null, const QString& second = QString::null) : m_first(first), m_second(second ) { } QString first()const{ return m_first; } QString second()const { return m_second; } private: QString m_first; QString m_second; }; class SendWidget : public QWidget{ Q_OBJECT public: SendWidget( QWidget* parent = 0, const char* name = 0); ~SendWidget(); QString file()const; + protected: + void closeEvent( QCloseEvent* ); + public slots: void send( const QString& file, const QString& desc ); signals: void done(); private slots: // QCOP slots /* IrDa Names*/ void slotIrDaDevices( const QStringList& ); /* Bt Names + BD-Addr */ void slotBTDevices( const QMap<QString, QString>& ); void slotSelectedDevice( int id, int dev ); void dispatchIrda( const QCString& str, const QByteArray& ar ); void dispatchBt( const QCString& str, const QByteArray& ar ); void slotIrError( int ); void slotIrSent(bool); void slotIrTry(unsigned int ); void slotStartIrda(); void slotDone(); private: void initUI(); QLabel* m_lblFile; DeviceBox* m_devBox; QVBoxLayout* m_lay; int m_start; QMap<int, QString> m_irDa; QMap<int, QString>::Iterator m_irDaIt; QMap<int, Pair > m_bt; QString m_file; Obex* m_obex; int m_irDeSearch; // search of irda and bt devices int m_btDeSearch; }; class DeviceItem { public: DeviceItem( const QString& name = QString::null, const QString& status = QString::null, int dev = 3, int id = -1); ~DeviceItem(); void setStatus( const QString& text ); QString name()const; QString status()const; QString pixmap()const; int device()const; int id()const; QString toString()const; private: QString m_name; QString m_status; int m_dev; int m_id; }; /* * The text field which contains the information about sending... * */ class DeviceBox : public QTextBrowser { Q_OBJECT public: enum Device { IrDa, BT, Search, Error }; DeviceBox( QWidget* parent ); ~DeviceBox(); |