summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-28 04:02:22 (UTC)
committer llornkcor <llornkcor>2004-07-28 04:02:22 (UTC)
commite98e9106df225b9e19a45a6f0e44193b1d018461 (patch) (unidiff)
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) (ignore 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,41 +1,42 @@
1#include "obex.h" 1#include "obex.h"
2#include "receiver.h" 2#include "receiver.h"
3using namespace OpieObex; 3using namespace OpieObex;
4 4
5/* OPIE */ 5/* OPIE */
6#include <opie2/odebug.h> 6#include <opie2/odebug.h>
7#include <qpe/applnk.h> 7#include <qpe/applnk.h>
8#include <qpe/qpeapplication.h> 8#include <qpe/qpeapplication.h>
9#include <qpe/qcopenvelope_qws.h> 9#include <qpe/qcopenvelope_qws.h>
10#include <qpe/filemanager.h>
10using namespace Opie::Core; 11using namespace Opie::Core;
11 12
12/* QT */ 13/* QT */
13#include <qfileinfo.h> 14#include <qfileinfo.h>
14#include <qlabel.h> 15#include <qlabel.h>
15#include <qtextview.h> 16#include <qtextview.h>
16#include <qpushbutton.h> 17#include <qpushbutton.h>
17 18
18/* STD */ 19/* STD */
19#include <sys/types.h> 20#include <sys/types.h>
20#include <sys/stat.h> 21#include <sys/stat.h>
21#include <sys/mman.h> 22#include <sys/mman.h>
22#include <stdlib.h> // int system 23#include <stdlib.h> // int system
23#include <unistd.h> 24#include <unistd.h>
24#include <fcntl.h> 25#include <fcntl.h>
25 26
26/* TRANSLATOR OpieObex::Receiver */ 27/* TRANSLATOR OpieObex::Receiver */
27 28
28Receiver::Receiver() { 29Receiver::Receiver() {
29 m_obex = new Obex(this, "Receiver"); 30 m_obex = new Obex(this, "Receiver");
30 connect(m_obex, SIGNAL(receivedFile(const QString&) ), 31 connect(m_obex, SIGNAL(receivedFile(const QString&) ),
31 this, SLOT(slotReceived(const QString&) ) ); 32 this, SLOT(slotReceived(const QString&) ) );
32 m_obex->receive(); 33 m_obex->receive();
33} 34}
34Receiver::~Receiver() { 35Receiver::~Receiver() {
35 m_obex->setReceiveEnabled( false ); 36 m_obex->setReceiveEnabled( false );
36 delete m_obex; 37 delete m_obex;
37} 38}
38void Receiver::slotReceived( const QString& _file ) { 39void Receiver::slotReceived( const QString& _file ) {
39 QString file = _file; 40 QString file = _file;
40 int check = checkFile(file); 41 int check = checkFile(file);
41 if ( check == AddressBook ) 42 if ( check == AddressBook )
@@ -166,37 +167,42 @@ void OtherHandler::accept() {
166 copy(m_file, na ); 167 copy(m_file, na );
167 DocLnk lnk(na); 168 DocLnk lnk(na);
168 lnk.writeLink(); 169 lnk.writeLink();
169 QFile::remove(m_file); 170 QFile::remove(m_file);
170 delete this; 171 delete this;
171} 172}
172void OtherHandler::deny() { 173void OtherHandler::deny() {
173 QFile::remove( m_file ); 174 QFile::remove( m_file );
174 delete this; 175 delete this;
175} 176}
176QString OtherHandler::targetName( const QString& file ) { 177QString OtherHandler::targetName( const QString& file ) {
177 QFileInfo info( file ); 178 QFileInfo info( file );
178 179
179 /* $HOME needs to be set!!!! */ 180 /* $HOME needs to be set!!!! */
180 Global::createDocDir(); 181 Global::createDocDir();
181 182
182 QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName(); 183 QString newFile = QPEApplication::documentDir()+ "/"+ info.baseName();
183 QString newFileBase = newFile; 184 QString newFileBase = newFile;
184 185
185 int trie = 0; 186 int trie = 0;
186 while (QFile::exists(newFile + "."+info.extension() ) ) { 187 while (QFile::exists(newFile + "."+info.extension() ) ) {
187 newFile = newFileBase + "_"+QString::number(trie) ; 188 newFile = newFileBase + "_"+QString::number(trie) ;
188 trie++; 189 trie++;
189 } 190 }
190 newFile += "." + info.extension(); 191 newFile += "." + info.extension();
191 192
192 return newFile; 193 return newFile;
193} 194}
194 195
195/* fast cpy */ 196/* fast cpy */
196void OtherHandler::copy(const QString& src, const QString& file) { 197void OtherHandler::copy(const QString& src, const QString& file) {
197 owarn << "src " << src << ", dest " << file << "" << oendl; 198 owarn << "src " << src << ", dest " << file << "" << oendl;
198 QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). 199 FileManager *fm;
199 arg( Global::shellQuote( file ) ); 200 if(!fm->copyFile(src,file)) {
200 ::system( cmd.latin1() ); 201 owarn << "Copy failed" << oendl;
202 }
203
204// QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )).
205// arg( Global::shellQuote( file ) );
206// ::system( cmd.latin1() );
201 // done 207 // done
202} 208}