author | kergoth <kergoth> | 2003-08-09 17:29:36 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 17:29:36 (UTC) |
commit | a0bab0e281fbaf6f6ebbb1a48e5c06426bfbbb93 (patch) (side-by-side diff) | |
tree | 5ce78e1a5dedd31b7851d53bf9f072bd44edd1b0 /core/obex | |
parent | a7e015198a8c5ad3b6e144a9032b059086253e00 (diff) | |
download | opie-a0bab0e281fbaf6f6ebbb1a48e5c06426bfbbb93.zip opie-a0bab0e281fbaf6f6ebbb1a48e5c06426bfbbb93.tar.gz opie-a0bab0e281fbaf6f6ebbb1a48e5c06426bfbbb93.tar.bz2 |
Merge from BRANCH_1_0
-rw-r--r-- | core/obex/obex.cc | 15 | ||||
-rw-r--r-- | core/obex/obexhandler.cpp | 2 | ||||
-rw-r--r-- | core/obex/obeximpl.cpp | 2 | ||||
-rw-r--r-- | core/obex/obexsend.cpp | 2 | ||||
-rw-r--r-- | core/obex/receiver.cpp | 73 | ||||
-rw-r--r-- | core/obex/receiver.h | 5 |
6 files changed, 65 insertions, 34 deletions
diff --git a/core/obex/obex.cc b/core/obex/obex.cc index 595fed9..2a306de 100644 --- a/core/obex/obex.cc +++ b/core/obex/obex.cc @@ -13,2 +13,4 @@ using namespace OpieObex; +/* TRANSLATOR OpieObex::Obex */ + Obex::Obex( QObject *parent, const char* name ) @@ -111,7 +113,3 @@ void Obex::slotStdOut(OProcess* proc, char* buf, int len){ if ( proc == m_rec ) { // only receive - for (int i = 0; i < len; i++ ) { - printf("%c", buf[i] ); - } - printf("\n"); - QByteArray ar( len ); + QByteArray ar( len ); memcpy( ar.data(), buf, len ); @@ -127,9 +125,2 @@ void Obex::received() { qWarning("ACHTUNG %s", filename.latin1() ); - if (filename.contains( 'ö' ) || filename.contains( 'ä' ) || filename.contains('ü' ) ) { - qWarning("renaming!!!!"); - QFileInfo inf( filename ); - QString newName = "/tmp/opie-obex." + inf.extension(); - ::rename( QFile::encodeName( filename ).data(), newName ); - qWarning("name is %s", QFile::encodeName( filename ).data() ); - } emit receivedFile( filename ); diff --git a/core/obex/obexhandler.cpp b/core/obex/obexhandler.cpp index 6509d12..5aaf63c 100644 --- a/core/obex/obexhandler.cpp +++ b/core/obex/obexhandler.cpp @@ -10,2 +10,4 @@ using namespace OpieObex; +/* TRANSLATOR OpieObex::ObexHandler */ + ObexHandler::ObexHandler() { diff --git a/core/obex/obeximpl.cpp b/core/obex/obeximpl.cpp index 12a078f..5bfc779 100644 --- a/core/obex/obeximpl.cpp +++ b/core/obex/obeximpl.cpp @@ -5,2 +5,4 @@ using namespace OpieObex; +/* TRANSLATOR OpieObex::ObexImpl */ + ObexImpl::ObexImpl() { diff --git a/core/obex/obexsend.cpp b/core/obex/obexsend.cpp index 2931cf7..cf5d958 100644 --- a/core/obex/obexsend.cpp +++ b/core/obex/obexsend.cpp @@ -17,2 +17,4 @@ using namespace OpieObex; +/* TRANSLATOR OpieObex::SendWidget */ + diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index 31c6afe..bf9e30c 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp @@ -3,2 +3,3 @@ #include <sys/mman.h> +#include <stdlib.h> // int system #include <unistd.h> @@ -11,2 +12,3 @@ #include <qhbox.h> +#include <qregexp.h> #include <qtextview.h> @@ -17,2 +19,3 @@ #include <qpe/qcopenvelope_qws.h> +#include <qpe/global.h> @@ -23,2 +26,4 @@ using namespace OpieObex; +/* TRANSLATOR OpieObex::Receiver */ + Receiver::Receiver() { @@ -33,3 +38,4 @@ Receiver::~Receiver() { } -void Receiver::slotReceived( const QString& file ) { +void Receiver::slotReceived( const QString& _file ) { + QString file = _file; int check = checkFile(file); @@ -61,9 +67,33 @@ void Receiver::handleOther( const QString& other ) { } -int Receiver::checkFile( const QString& file ) { +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 ); + QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); + qWarning("Executing: %s", cmd.latin1() ); + (void)::system( cmd.latin1() ); + + cmd = QString("rm %1").arg( Global::shellQuote(file) ); + (void)::system( cmd.latin1() ); +} +int Receiver::checkFile( QString& file ) { qWarning("check file!! %s", file.latin1() ); int ret; + QString ending; + if (file.right(4) == ".vcs" ) { ret = Datebook; + ending = QString::fromLatin1(".vcs"); }else if ( file.right(4) == ".vcf") { ret = AddressBook; + ending = QString::fromLatin1(".vcf"); }else @@ -72,2 +102,13 @@ int Receiver::checkFile( const QString& file ) { + if (ending.isEmpty() ) + return ret; + + /** + * currently the parser is broken in regard of BASE64 encoding + * and M$ likes to send that. So we will executed a small + * tidy up system sed script + * At this point we can also remove umlaute from the filename + */ + tidyUp( file, ending ); + qWarning("check it now %d", ret ); @@ -76,2 +117,4 @@ int Receiver::checkFile( const QString& file ) { +/* TRANSLATOR OpieObex::OtherHandler */ + OtherHandler::OtherHandler() @@ -135,2 +178,6 @@ QString OtherHandler::targetName( const QString& file ) { QFileInfo info( file ); + + /* $HOME needs to be set!!!! */ + Global::createDocDir(); + QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); @@ -151,21 +198,5 @@ void OtherHandler::copy(const QString& src, const QString& file) { qWarning("src %s, dest %s", src.latin1(),file.latin1() ); - int src_fd = ::open( QFile::encodeName( src ), O_RDONLY ); - int to_fd = ::open( QFile::encodeName( file), O_RDWR| O_CREAT| O_TRUNC, - S_IRUSR, S_IWUSR, S_IRGRP, S_IRGRP ); - - struct stat stater; - ::fstat(src_fd, &stater ); - ::lseek(to_fd, stater.st_size-1, SEEK_SET ); - ::write(to_fd, "", 1 ); - - void *src_addr, *dest_addr; - src_addr = ::mmap(0, stater.st_size, PROT_READ, - MAP_FILE | MAP_SHARED, src_fd, 0 ); - dest_addr= ::mmap(0, stater.st_size, PROT_READ | PROT_WRITE, - MAP_FILE | MAP_PRIVATE, to_fd, 0 ); - - ::memcpy(dest_addr , src_addr, stater.st_size ); - ::munmap(src_addr , stater.st_size ); - ::munmap(dest_addr, stater.st_size ); - + QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). + arg( Global::shellQuote( file ) ); + ::system( cmd.latin1() ); // done diff --git a/core/obex/receiver.h b/core/obex/receiver.h index 5b20146..e1d54df 100644 --- a/core/obex/receiver.h +++ b/core/obex/receiver.h @@ -23,5 +23,8 @@ namespace OpieObex { void handleOther(const QString& ); - int checkFile( const QString& file ); + /* will alter the file name */ + int checkFile( QString& file ); bool testDateTodo(const QString& file); bool testAddressbook(const QString& file); + /* called by checkFile */ + void tidyUp( QString& file, const QString& ending ); |