summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-28 04:02:22 (UTC)
committer llornkcor <llornkcor>2004-07-28 04:02:22 (UTC)
commite98e9106df225b9e19a45a6f0e44193b1d018461 (patch) (side-by-side diff)
tree2f2238d1f9549dd4fb645551abf88480a11d2dc3
parent347acd6001e00d0e57c4917f9a741ab887caf4cd (diff)
downloadopie-e98e9106df225b9e19a45a6f0e44193b1d018461.zip
opie-e98e9106df225b9e19a45a6f0e44193b1d018461.tar.gz
opie-e98e9106df225b9e19a45a6f0e44193b1d018461.tar.bz2
use copyfile method that doesnt squish filenames into latin1, so copying files with extended characters doesn't fail after ir receive
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/obex/receiver.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp
index 8885256..d4ae323 100644
--- a/core/obex/receiver.cpp
+++ b/core/obex/receiver.cpp
@@ -1,57 +1,58 @@
#include "obex.h"
#include "receiver.h"
using namespace OpieObex;
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/applnk.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
+#include <qpe/filemanager.h>
using namespace Opie::Core;
/* QT */
#include <qfileinfo.h>
#include <qlabel.h>
#include <qtextview.h>
#include <qpushbutton.h>
/* STD */
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdlib.h> // int system
#include <unistd.h>
#include <fcntl.h>
/* TRANSLATOR OpieObex::Receiver */
Receiver::Receiver() {
m_obex = new Obex(this, "Receiver");
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;
@@ -150,53 +151,58 @@ OtherHandler::~OtherHandler() {
void OtherHandler::handle( const QString& file ) {
m_file = file;
m_na->setText(file);
DocLnk lnk(file);
owarn << " " << lnk.type() << " " << lnk.icon() << "" << oendl;
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 );
/* $HOME needs to be set!!!! */
Global::createDocDir();
QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName();
QString newFileBase = newFile;
int trie = 0;
while (QFile::exists(newFile + "."+info.extension() ) ) {
newFile = newFileBase + "_"+QString::number(trie) ;
trie++;
}
newFile += "." + info.extension();
return newFile;
}
/* fast cpy */
void OtherHandler::copy(const QString& src, const QString& file) {
owarn << "src " << src << ", dest " << file << "" << oendl;
- QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )).
- arg( Global::shellQuote( file ) );
- ::system( cmd.latin1() );
+ FileManager *fm;
+ if(!fm->copyFile(src,file)) {
+ owarn << "Copy failed" << oendl;
+ }
+
+// QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )).
+// arg( Global::shellQuote( file ) );
+// ::system( cmd.latin1() );
// done
}