-rw-r--r-- | core/obex/obexhandler.cpp | 4 | ||||
-rw-r--r-- | core/obex/obexsend.cpp | 16 | ||||
-rw-r--r-- | core/obex/receiver.cpp | 4 |
3 files changed, 12 insertions, 12 deletions
diff --git a/core/obex/obexhandler.cpp b/core/obex/obexhandler.cpp index 4034560..28f9b5b 100644 --- a/core/obex/obexhandler.cpp +++ b/core/obex/obexhandler.cpp | |||
@@ -1,67 +1,67 @@ | |||
1 | 1 | ||
2 | #include <qpe/qcopenvelope_qws.h> | 2 | #include <qpe/qcopenvelope_qws.h> |
3 | #include <qpe/qpeapplication.h> | 3 | #include <qpe/qpeapplication.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 | ||
9 | using namespace OpieObex; | 9 | using namespace OpieObex; |
10 | 10 | ||
11 | /* TRANSLATOR OpieObex::ObexHandler */ | 11 | /* TRANSLATOR OpieObex::ObexHandler */ |
12 | 12 | ||
13 | ObexHandler::ObexHandler() { | 13 | ObexHandler::ObexHandler() { |
14 | m_wasRec = false; | 14 | m_wasRec = false; |
15 | m_sender = 0l; | 15 | m_sender = 0l; |
16 | m_receiver = 0l; | 16 | m_receiver = 0l; |
17 | QCopChannel* chan = new QCopChannel("QPE/Obex"); | 17 | QCopChannel* chan = new QCopChannel("QPE/Obex"); |
18 | connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ), | 18 | connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ), |
19 | this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) ); | 19 | this, SLOT(irdaMessage(const QCString&,const QByteArray&) ) ); |
20 | } | 20 | } |
21 | ObexHandler::~ObexHandler() { | 21 | ObexHandler::~ObexHandler() { |
22 | delete m_sender; | 22 | delete m_sender; |
23 | delete m_receiver; | 23 | delete m_receiver; |
24 | } | 24 | } |
25 | void ObexHandler::doSend(const QString& str, const QString& desc) { | 25 | void ObexHandler::doSend(const QString& str, const QString& desc) { |
26 | delete m_sender; | 26 | delete m_sender; |
27 | m_sender = new SendWidget; | 27 | m_sender = new SendWidget; |
28 | m_sender->raise(); | 28 | m_sender->raise(); |
29 | QPEApplication::showWidget( m_sender ); | 29 | QPEApplication::showWidget( m_sender ); |
30 | connect(m_sender, SIGNAL(done() ), | 30 | connect(m_sender, SIGNAL(done() ), |
31 | this, SLOT(slotSent() ) ); | 31 | this, SLOT(slotSent() ) ); |
32 | m_sender->send( str, desc ); | 32 | m_sender->send( str, desc ); |
33 | } | 33 | } |
34 | void ObexHandler::doReceive(bool b) { | 34 | void ObexHandler::doReceive(bool b) { |
35 | if (m_receiver && b ) return; // we should enable receiver and it is on | 35 | if (m_receiver && b ) return; // we should enable receiver and it is on |
36 | else if (!m_receiver && !b ) return; // we should disbale receiver and it is off | 36 | else if (!m_receiver && !b ) return; // we should disbale receiver and it is off |
37 | else if (m_receiver && !b ) { | 37 | else if (m_receiver && !b ) { |
38 | delete m_receiver; | 38 | delete m_receiver; |
39 | m_receiver=0; | 39 | m_receiver=0; |
40 | }else if (!m_receiver && b ) { | 40 | }else if (!m_receiver && b ) { |
41 | m_receiver= new Receiver; | 41 | m_receiver= new Receiver; |
42 | } | 42 | } |
43 | } | 43 | } |
44 | void ObexHandler::slotSent() { | 44 | void ObexHandler::slotSent() { |
45 | QString file = m_sender->file(); | 45 | QString file = m_sender->file(); |
46 | delete m_sender; | 46 | delete m_sender; |
47 | m_sender = 0; | 47 | m_sender = 0; |
48 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); | 48 | QCopEnvelope e ("QPE/Obex", "done(QString)" ); |
49 | e << file; | 49 | e << file; |
50 | doReceive(m_wasRec ); | 50 | doReceive(m_wasRec ); |
51 | m_wasRec = false; | 51 | m_wasRec = false; |
52 | } | 52 | } |
53 | void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { | 53 | void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) { |
54 | QDataStream stream( data, IO_ReadOnly ); | 54 | QDataStream stream( data, IO_ReadOnly ); |
55 | if ( msg == "send(QString,QString,QString)" ) { | 55 | if ( msg == "send(QString,QString,QString)" ) { |
56 | QString name, desc; | 56 | QString name, desc; |
57 | stream >> desc; | 57 | stream >> desc; |
58 | stream >> name; | 58 | stream >> name; |
59 | m_wasRec = (m_receiver != 0 ); | 59 | m_wasRec = (m_receiver != 0 ); |
60 | doReceive( false ); | 60 | doReceive( false ); |
61 | doSend(name, desc); | 61 | doSend(name, desc); |
62 | }else if (msg == "receive(int)") { | 62 | }else if (msg == "receive(int)") { |
63 | int rec; | 63 | int rec; |
64 | stream >> rec; | 64 | stream >> rec; |
65 | doReceive(rec); | 65 | doReceive(rec); |
66 | } | 66 | } |
67 | } | 67 | } |
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,110 +1,110 @@ | |||
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 | ||
12 | using namespace OpieObex; | 12 | using namespace OpieObex; |
13 | 13 | ||
14 | /* TRANSLATOR OpieObex::SendWidget */ | 14 | /* TRANSLATOR OpieObex::SendWidget */ |
15 | 15 | ||
16 | 16 | ||
17 | SendWidget::SendWidget( QWidget* parent, const char* name ) | 17 | SendWidget::SendWidget( QWidget* parent, const char* name ) |
18 | : QWidget( parent, name ) { | 18 | : QWidget( parent, name ) { |
19 | initUI(); | 19 | initUI(); |
20 | } | 20 | } |
21 | SendWidget::~SendWidget() { | 21 | SendWidget::~SendWidget() { |
22 | } | 22 | } |
23 | void SendWidget::initUI() { | 23 | void 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 | */ |
81 | void SendWidget::send( const QString& file, const QString& desc ) { | 81 | void 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 | } |
106 | void SendWidget::slotIrDaDevices( const QStringList& list) { | 106 | void 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) ); |
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index 7d9f7ec..ee2668b 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp | |||
@@ -1,76 +1,76 @@ | |||
1 | #include <sys/types.h> | 1 | #include <sys/types.h> |
2 | #include <sys/stat.h> | 2 | #include <sys/stat.h> |
3 | #include <sys/mman.h> | 3 | #include <sys/mman.h> |
4 | #include <stdlib.h> // int system | 4 | #include <stdlib.h> // int system |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | 6 | ||
7 | #include <fcntl.h> | 7 | #include <fcntl.h> |
8 | 8 | ||
9 | #include <qfileinfo.h> | 9 | #include <qfileinfo.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qtextview.h> | 11 | #include <qtextview.h> |
12 | #include <qpushbutton.h> | 12 | #include <qpushbutton.h> |
13 | 13 | ||
14 | #include <qpe/applnk.h> | 14 | #include <qpe/applnk.h> |
15 | #include <qpe/qpeapplication.h> | 15 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/qcopenvelope_qws.h> | 16 | #include <qpe/qcopenvelope_qws.h> |
17 | 17 | ||
18 | #include "obex.h" | 18 | #include "obex.h" |
19 | #include "receiver.h" | 19 | #include "receiver.h" |
20 | 20 | ||
21 | using namespace OpieObex; | 21 | using namespace OpieObex; |
22 | 22 | ||
23 | /* TRANSLATOR OpieObex::Receiver */ | 23 | /* TRANSLATOR OpieObex::Receiver */ |
24 | 24 | ||
25 | Receiver::Receiver() { | 25 | Receiver::Receiver() { |
26 | m_obex = new Obex(this, "Receiver"); | 26 | m_obex = new Obex(this, "Receiver"); |
27 | connect(m_obex, SIGNAL(receivedFile(const QString& ) ), | 27 | connect(m_obex, SIGNAL(receivedFile(const QString&) ), |
28 | this, SLOT(slotReceived(const QString& ) ) ); | 28 | this, SLOT(slotReceived(const QString&) ) ); |
29 | m_obex->receive(); | 29 | m_obex->receive(); |
30 | } | 30 | } |
31 | Receiver::~Receiver() { | 31 | Receiver::~Receiver() { |
32 | m_obex->setReceiveEnabled( false ); | 32 | m_obex->setReceiveEnabled( false ); |
33 | delete m_obex; | 33 | delete m_obex; |
34 | } | 34 | } |
35 | void Receiver::slotReceived( const QString& _file ) { | 35 | void Receiver::slotReceived( const QString& _file ) { |
36 | QString file = _file; | 36 | QString file = _file; |
37 | int check = checkFile(file); | 37 | int check = checkFile(file); |
38 | if ( check == AddressBook ) | 38 | if ( check == AddressBook ) |
39 | handleAddr( file ); | 39 | handleAddr( file ); |
40 | else if ( check == Datebook ) | 40 | else if ( check == Datebook ) |
41 | handleDateTodo( file ); | 41 | handleDateTodo( file ); |
42 | else | 42 | else |
43 | handleOther( file ); | 43 | handleOther( file ); |
44 | } | 44 | } |
45 | void Receiver::handleAddr( const QString& str ) { | 45 | void Receiver::handleAddr( const QString& str ) { |
46 | QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" ); | 46 | QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" ); |
47 | e << str; | 47 | e << str; |
48 | } | 48 | } |
49 | /* we can not say for sure if it's a VEevent ot VTodo */ | 49 | /* we can not say for sure if it's a VEevent ot VTodo */ |
50 | void Receiver::handleDateTodo( const QString& str ) { | 50 | void Receiver::handleDateTodo( const QString& str ) { |
51 | QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)"); | 51 | QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)"); |
52 | e0 << str; | 52 | e0 << str; |
53 | QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" ); | 53 | QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" ); |
54 | e1 << str; | 54 | e1 << str; |
55 | } | 55 | } |
56 | /* | 56 | /* |
57 | * Handle other asks if it should accept the | 57 | * Handle other asks if it should accept the |
58 | * beamed object and creates a DocLnk | 58 | * beamed object and creates a DocLnk |
59 | */ | 59 | */ |
60 | void Receiver::handleOther( const QString& other ) { | 60 | void Receiver::handleOther( const QString& other ) { |
61 | OtherHandler* hand = new OtherHandler(); | 61 | OtherHandler* hand = new OtherHandler(); |
62 | hand->handle( other ); | 62 | hand->handle( other ); |
63 | } | 63 | } |
64 | void Receiver::tidyUp( QString& _file, const QString& ending) { | 64 | void Receiver::tidyUp( QString& _file, const QString& ending) { |
65 | /* libversit fails on BASE64 encoding we try to sed it away */ | 65 | /* libversit fails on BASE64 encoding we try to sed it away */ |
66 | QString file = _file; | 66 | QString file = _file; |
67 | char foo[24]; // big enough | 67 | char foo[24]; // big enough |
68 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); | 68 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); |
69 | 69 | ||
70 | int fd = ::mkstemp(foo); | 70 | int fd = ::mkstemp(foo); |
71 | 71 | ||
72 | if ( fd == -1 ) | 72 | if ( fd == -1 ) |
73 | return; | 73 | return; |
74 | 74 | ||
75 | (void)::strncat( foo, ending.latin1(), 4 ); | 75 | (void)::strncat( foo, ending.latin1(), 4 ); |
76 | _file = QString::fromLatin1( foo ); | 76 | _file = QString::fromLatin1( foo ); |