summaryrefslogtreecommitdiff
path: root/core/obex
Side-by-side diff
Diffstat (limited to 'core/obex') (more/less context) (ignore whitespace changes)
-rw-r--r--core/obex/obexhandler.cpp4
-rw-r--r--core/obex/obexsend.cpp16
-rw-r--r--core/obex/receiver.cpp4
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 @@
#include <qpe/qcopenvelope_qws.h>
#include <qpe/qpeapplication.h>
#include "obexsend.h"
#include "receiver.h"
#include "obexhandler.h"
using namespace OpieObex;
/* TRANSLATOR OpieObex::ObexHandler */
ObexHandler::ObexHandler() {
m_wasRec = false;
m_sender = 0l;
m_receiver = 0l;
QCopChannel* chan = new QCopChannel("QPE/Obex");
- connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
- this, SLOT(irdaMessage(const QCString&, const QByteArray& ) ) );
+ connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
+ this, SLOT(irdaMessage(const QCString&,const QByteArray&) ) );
}
ObexHandler::~ObexHandler() {
delete m_sender;
delete m_receiver;
}
void ObexHandler::doSend(const QString& str, const QString& desc) {
delete m_sender;
m_sender = new SendWidget;
m_sender->raise();
QPEApplication::showWidget( m_sender );
connect(m_sender, SIGNAL(done() ),
this, SLOT(slotSent() ) );
m_sender->send( str, desc );
}
void ObexHandler::doReceive(bool b) {
if (m_receiver && b ) return; // we should enable receiver and it is on
else if (!m_receiver && !b ) return; // we should disbale receiver and it is off
else if (m_receiver && !b ) {
delete m_receiver;
m_receiver=0;
}else if (!m_receiver && b ) {
m_receiver= new Receiver;
}
}
void ObexHandler::slotSent() {
QString file = m_sender->file();
delete m_sender;
m_sender = 0;
QCopEnvelope e ("QPE/Obex", "done(QString)" );
e << file;
doReceive(m_wasRec );
m_wasRec = false;
}
void ObexHandler::irdaMessage( const QCString& msg, const QByteArray& data) {
QDataStream stream( data, IO_ReadOnly );
if ( msg == "send(QString,QString,QString)" ) {
QString name, desc;
stream >> desc;
stream >> name;
m_wasRec = (m_receiver != 0 );
doReceive( false );
doSend(name, desc);
}else if (msg == "receive(int)") {
int rec;
stream >> rec;
doReceive(rec);
}
}
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 @@
#include <qpushbutton.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qtimer.h>
#include <qpe/qcopenvelope_qws.h>
#include "obex.h"
#include "obexsend.h"
using namespace OpieObex;
/* TRANSLATOR OpieObex::SendWidget */
SendWidget::SendWidget( QWidget* parent, const char* name )
: QWidget( parent, name ) {
initUI();
}
SendWidget::~SendWidget() {
}
void SendWidget::initUI() {
m_obex = new Obex(this, "obex");
connect(m_obex, SIGNAL(error(int) ),
this, SLOT(slotIrError(int) ) );
connect(m_obex, SIGNAL(sent(bool) ),
this, SLOT(slotIrSent(bool) ) );
- connect(m_obex, SIGNAL(currentTry(unsigned int ) ),
- this, SLOT(slotIrTry(unsigned int ) ) );
+ connect(m_obex, SIGNAL(currentTry(unsigned int) ),
+ this, SLOT(slotIrTry(unsigned int) ) );
QCopChannel* chan = new QCopChannel("QPE/IrDaAppletBack", this );
- connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
- this, SLOT(dispatchIrda(const QCString&, const QByteArray& ) ) );
+ connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
+ this, SLOT(dispatchIrda(const QCString&,const QByteArray&) ) );
chan = new QCopChannel("QPE/BluetoothBack", this );
- connect(chan, SIGNAL(received(const QCString&, const QByteArray& ) ),
- this, SLOT(dispatchBt(const QCString&, const QByteArray& ) ) );
+ connect(chan, SIGNAL(received(const QCString&,const QByteArray&) ),
+ this, SLOT(dispatchBt(const QCString&,const QByteArray&) ) );
QVBoxLayout* lay = new QVBoxLayout(this);
QHBox* nameBox = new QHBox(this);
QLabel* name = new QLabel(nameBox);
name->setText( tr("<qt><h1>Sending:</h1></qt>") );
name->setAlignment( AlignLeft | AlignTop );
m_lblFile = new QLabel(nameBox);
lay->addWidget(nameBox, 0);
QFrame* frame = new QFrame(this);
frame->setFrameShape( QFrame::HLine );
frame->setFrameShadow( QFrame::Sunken );
lay->addWidget(frame, 10);
QLabel* devices = new QLabel(this);
devices->setText("<qt><b>Devices:</b></qt>");
devices->setAlignment( AlignLeft | AlignTop );
lay->addWidget( devices,10 );
m_devBox = new DeviceBox(this);
lay->addWidget( m_devBox, 50 );
- connect(m_devBox, SIGNAL(selectedDevice(int, int ) ),
- this, SLOT(slotSelectedDevice(int, int) ) );
+ connect(m_devBox, SIGNAL(selectedDevice(int,int) ),
+ this, SLOT(slotSelectedDevice(int,int) ) );
QPushButton *but = new QPushButton(this);
but->setText(tr("Done") );
connect(but, SIGNAL(clicked() ),
this, SLOT(slotDone() ) );
lay->addWidget( but );
m_lay = lay;
// QT does not like if you add items to an layout which already exits....
// and was layouted invalidate() does not help too
// so we use RichText....
}
/*
* in send we'll first set everything up
* and then wait for a list of devices.
*/
void SendWidget::send( const QString& file, const QString& desc ) {
m_file = file;
m_irDa.clear();
m_start = 0;
m_lblFile->setText(desc.isEmpty() ? file : desc );
if ( !QCopChannel::isRegistered("QPE/IrDaApplet") ) {
m_irDeSearch = m_devBox->addDevice( tr("IrDa is not enabled!"), DeviceBox::Error );
m_start++;
}else
m_irDeSearch = m_devBox->addDevice( tr("Searching for IrDa Devices."), DeviceBox::Search );
if ( !QCopChannel::isRegistered("QPE/Bluetooth") ) {
m_btDeSearch = m_devBox->addDevice( tr("Bluetooth is not available"), DeviceBox::Error );
m_start++;
}else
m_btDeSearch = m_devBox->addDevice( tr("Searching for bluetooth Devices."), DeviceBox::Search );
if (m_start != 2 ) {
QCopEnvelope e0("QPE/IrDaApplet", "enableIrda()");
QCopEnvelope e1("QPE/Bluetooth", "enableBluetooth()");
QCopEnvelope e2("QPE/IrDaApplet", "listDevices()");
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) );
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 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdlib.h> // int system
#include <unistd.h>
#include <fcntl.h>
#include <qfileinfo.h>
#include <qlabel.h>
#include <qtextview.h>
#include <qpushbutton.h>
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include "obex.h"
#include "receiver.h"
using namespace OpieObex;
/* TRANSLATOR OpieObex::Receiver */
Receiver::Receiver() {
m_obex = new Obex(this, "Receiver");
- connect(m_obex, SIGNAL(receivedFile(const QString& ) ),
- this, SLOT(slotReceived(const QString& ) ) );
+ connect(m_obex, SIGNAL(receivedFile(const QString&) ),
+ this, SLOT(slotReceived(const QString&) ) );
m_obex->receive();
}
Receiver::~Receiver() {
m_obex->setReceiveEnabled( false );
delete m_obex;
}
void Receiver::slotReceived( const QString& _file ) {
QString file = _file;
int check = checkFile(file);
if ( check == AddressBook )
handleAddr( file );
else if ( check == Datebook )
handleDateTodo( file );
else
handleOther( file );
}
void Receiver::handleAddr( const QString& str ) {
QCopEnvelope e("QPE/Application/addressbook", "setDocument(QString)" );
e << str;
}
/* we can not say for sure if it's a VEevent ot VTodo */
void Receiver::handleDateTodo( const QString& str ) {
QCopEnvelope e0("QPE/Application/todolist", "setDocument(QString)");
e0 << str;
QCopEnvelope e1("QPE/Application/datebook", "setDocument(QString)" );
e1 << str;
}
/*
* Handle other asks if it should accept the
* beamed object and creates a DocLnk
*/
void Receiver::handleOther( const QString& other ) {
OtherHandler* hand = new OtherHandler();
hand->handle( other );
}
void Receiver::tidyUp( QString& _file, const QString& ending) {
/* libversit fails on BASE64 encoding we try to sed it away */
QString file = _file;
char foo[24]; // big enough
(void)::strcpy(foo, "/tmp/opie-XXXXXX");
int fd = ::mkstemp(foo);
if ( fd == -1 )
return;
(void)::strncat( foo, ending.latin1(), 4 );
_file = QString::fromLatin1( foo );