author | zecke <zecke> | 2003-02-16 17:50:15 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-02-16 17:50:15 (UTC) |
commit | 62cc9d89378f281c11599f38c3ebe89886b69568 (patch) (side-by-side diff) | |
tree | 7499e9704f66820e785acc8c772e35b4f804aa80 | |
parent | e9e20c4e64b8b228af928822e3d4a49ed773dc2e (diff) | |
download | opie-62cc9d89378f281c11599f38c3ebe89886b69568.zip opie-62cc9d89378f281c11599f38c3ebe89886b69568.tar.gz opie-62cc9d89378f281c11599f38c3ebe89886b69568.tar.bz2 |
Fix getting files
-rw-r--r-- | core/obex/obex.cc | 8 | ||||
-rw-r--r-- | core/obex/receiver.cpp | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/core/obex/obex.cc b/core/obex/obex.cc index 92cd317..b8ed6e0 100644 --- a/core/obex/obex.cc +++ b/core/obex/obex.cc @@ -1,44 +1,44 @@ #include <qapplication.h> #include <qfile.h> #include <qmessagebox.h> #include <qpe/qcopenvelope_qws.h> #include <opie/oprocess.h> #include "obex.h" using namespace OpieObex; Obex::Obex( QObject *parent, const char* name ) : QObject(parent, name ) { m_rec = 0; m_send=0; m_count = 0; m_receive = false; connect( this, SIGNAL(error(int) ), // for recovering to receive SLOT(slotError() ) ); - connect( this, SIGNAL(sent() ), + connect( this, SIGNAL(sent(bool) ), SLOT(slotError() ) ); }; Obex::~Obex() { delete m_rec; delete m_send; } void Obex::receive() { m_receive = true; m_outp = QString::null; qWarning("Receive" ); m_rec = new OProcess(); *m_rec << "irobex_palm3"; // connect to the necessary slots connect(m_rec, SIGNAL(processExited(OProcess*) ), this, SLOT(slotExited(OProcess*) ) ); connect(m_rec, SIGNAL(receivedStdout(OProcess*, char*, int ) ), this, SLOT(slotStdOut(OProcess*, char*, int) ) ); if(!m_rec->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { qWarning("could not start :("); emit done( false ); delete m_rec; m_rec = 0; @@ -85,58 +85,58 @@ void Obex::sendNow(){ this, SLOT(slotStdOut(OProcess*, char*, int) ) ); // now start it if (!m_send->start(/*OProcess::NotifyOnExit, OProcess::AllOutput*/ ) ) { qWarning("could not send" ); m_count = 25; emit error(-1 ); delete m_send; m_send=0; } // end m_count++; emit currentTry( m_count ); } void Obex::slotExited(OProcess* proc ){ if (proc == m_rec ) { // receive process received(); }else if ( proc == m_send ) { sendEnd(); } } void Obex::slotStdOut(OProcess* proc, char* buf, int len){ if ( proc == m_rec ) { // only receive - QCString cstring( buf, len ); - m_outp.append( cstring.data() ); + QString str = QString::fromUtf8( buf, len ); + m_outp.append( str ); } } void Obex::received() { if (m_rec->normalExit() ) { if ( m_rec->exitStatus() == 0 ) { // we got one QString filename = parseOut(); - qWarning("ACHTUNG"); + qWarning("ACHTUNG %s", filename.latin1() ); emit receivedFile( filename ); } }else{ emit done(false); }; delete m_rec; m_rec = 0; receive(); } void Obex::sendEnd() { if (m_send->normalExit() ) { if ( m_send->exitStatus() == 0 ) { delete m_send; m_send=0; qWarning("done" ); emit sent(true); }else if (m_send->exitStatus() == 255 ) { // it failed maybe the other side wasn't ready // let's try it again delete m_send; m_send = 0; qWarning("try sending again" ); sendNow(); } diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index 50ee6cb..d5a7271 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp @@ -39,94 +39,98 @@ void Receiver::slotReceived( const QString& file ) { 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 ); } int Receiver::checkFile( const QString& file ) { + qWarning("check file!! %s", file.latin1() ); int ret; if (file.right(4) == ".vcs" ) { ret = Datebook; }else if ( file.right(4) == ".vcf") { ret = AddressBook; }else ret = Other; + + qWarning("check it now %d", ret ); return ret; } OtherHandler::OtherHandler() : QVBox() { QHBox* box = new QHBox(this); QLabel* lbl = new QLabel(box); lbl->setText(tr("<qt><b>Received:</b></qt>")); m_na = new QLabel(box); QFrame* frame = new QFrame(this); frame->setFrameShape( QFrame::HLine ); frame->setFrameShadow( QFrame::Sunken ); m_view = new QTextView(this); box = new QHBox(this); QPushButton *but = new QPushButton(box); but->setText(tr("Accept") ); connect(but, SIGNAL(clicked() ), this, SLOT(accept()) ); but = new QPushButton(box); but->setText(tr("Deny") ); connect(but, SIGNAL(clicked() ), this, SLOT(deny() ) ); raise(); showMaximized(); } OtherHandler::~OtherHandler() { } void OtherHandler::handle( const QString& file ) { m_file = file; m_na->setText(file); DocLnk lnk(file); + qWarning(" %s %s", lnk.type().latin1(), lnk.icon().latin1() ); QString str = tr("<p>You received a file of type %1 (<img src=\"%2\"> )What do you want to do?").arg(lnk.type() ).arg(lnk.icon() ); m_view->setText( str ); } /* * hehe evil evil mmap ahead :) * we quickly copy the file and then we'll create a DocLnk for it */ void OtherHandler::accept() { QString na = targetName( m_file ); copy(m_file, na ); DocLnk lnk(na); lnk.writeLink(); QFile::remove(m_file); delete this; } void OtherHandler::deny() { QFile::remove( m_file ); delete this; } QString OtherHandler::targetName( const QString& file ) { QFileInfo info( file ); QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); |