-rw-r--r-- | core/obex/receiver.cpp | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/core/obex/receiver.cpp b/core/obex/receiver.cpp index d4ae323..7d9a42a 100644 --- a/core/obex/receiver.cpp +++ b/core/obex/receiver.cpp | |||
@@ -67,60 +67,57 @@ void Receiver::handleOther( const QString& other ) { | |||
67 | } | 67 | } |
68 | void Receiver::tidyUp( QString& _file, const QString& ending) { | 68 | void Receiver::tidyUp( QString& _file, const QString& ending) { |
69 | /* libversit fails on BASE64 encoding we try to sed it away */ | 69 | /* libversit fails on BASE64 encoding we try to sed it away */ |
70 | QString file = _file; | 70 | QString file = _file; |
71 | char foo[24]; // big enough | 71 | char foo[24]; // big enough |
72 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); | 72 | (void)::strcpy(foo, "/tmp/opie-XXXXXX"); |
73 | 73 | ||
74 | int fd = ::mkstemp(foo); | 74 | int fd = ::mkstemp(foo); |
75 | 75 | ||
76 | if ( fd == -1 ) | 76 | if ( fd == -1 ) |
77 | return; | 77 | return; |
78 | 78 | ||
79 | (void)::strncat( foo, ending.latin1(), 4 ); | 79 | (void)::strncat( foo, QFile::encodeName(ending), 4 ); |
80 | _file = QString::fromLatin1( foo ); | 80 | _file = QString::fromLocal8Bit( foo ); |
81 | QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); | 81 | QString cmd = QString("sed -e \"s/^\\(X-MICROSOFT-BODYINK\\)\\;/\\1:/;\" < %2 > %2 ").arg( Global::shellQuote(file)).arg( Global::shellQuote(_file) ); |
82 | owarn << "Executing: " << cmd << "" << oendl; | 82 | (void)::system( QFile::encodeName(cmd) ); |
83 | (void)::system( cmd.latin1() ); | ||
84 | 83 | ||
85 | cmd = QString("rm %1").arg( Global::shellQuote(file) ); | 84 | cmd = QString("rm %1").arg( Global::shellQuote(file) ); |
86 | (void)::system( cmd.latin1() ); | 85 | (void)::system( QFile::encodeName(cmd) ); |
87 | } | 86 | } |
88 | int Receiver::checkFile( QString& file ) { | 87 | int Receiver::checkFile( QString& file ) { |
89 | owarn << "check file!! " << file << "" << oendl; | ||
90 | int ret; | 88 | int ret; |
91 | QString ending; | 89 | QString ending; |
92 | 90 | ||
93 | if (file.right(4) == ".vcs" ) { | 91 | if (file.right(4) == ".vcs" ) { |
94 | ret = Datebook; | 92 | ret = Datebook; |
95 | ending = QString::fromLatin1(".vcs"); | 93 | ending = QString::fromLatin1(".vcs"); |
96 | }else if ( file.right(4) == ".vcf") { | 94 | }else if ( file.right(4) == ".vcf") { |
97 | ret = AddressBook; | 95 | ret = AddressBook; |
98 | ending = QString::fromLatin1(".vcf"); | 96 | ending = QString::fromLatin1(".vcf"); |
99 | }else | 97 | }else |
100 | ret = Other; | 98 | ret = Other; |
101 | 99 | ||
102 | 100 | ||
103 | if (ending.isEmpty() ) | 101 | if (ending.isEmpty() ) |
104 | return ret; | 102 | return ret; |
105 | 103 | ||
106 | /** | 104 | /** |
107 | * currently the parser is broken in regard of BASE64 encoding | 105 | * currently the parser is broken in regard of BASE64 encoding |
108 | * and M$ likes to send that. So we will executed a small | 106 | * and M$ likes to send that. So we will executed a small |
109 | * tidy up system sed script | 107 | * tidy up system sed script |
110 | * At this point we can also remove umlaute from the filename | 108 | * At this point we can also remove umlaute from the filename |
111 | */ | 109 | */ |
112 | tidyUp( file, ending ); | 110 | tidyUp( file, ending ); |
113 | 111 | ||
114 | owarn << "check it now " << ret << "" << oendl; | ||
115 | return ret; | 112 | return ret; |
116 | } | 113 | } |
117 | 114 | ||
118 | /* TRANSLATOR OpieObex::OtherHandler */ | 115 | /* TRANSLATOR OpieObex::OtherHandler */ |
119 | 116 | ||
120 | OtherHandler::OtherHandler() | 117 | OtherHandler::OtherHandler() |
121 | : QVBox() | 118 | : QVBox() |
122 | { | 119 | { |
123 | QHBox* box = new QHBox(this); | 120 | QHBox* box = new QHBox(this); |
124 | QLabel* lbl = new QLabel(box); | 121 | QLabel* lbl = new QLabel(box); |
125 | lbl->setText(tr("<qt><b>Received:</b></qt>")); | 122 | lbl->setText(tr("<qt><b>Received:</b></qt>")); |
126 | m_na = new QLabel(box); | 123 | m_na = new QLabel(box); |
@@ -143,25 +140,24 @@ OtherHandler::OtherHandler() | |||
143 | this, SLOT(deny() ) ); | 140 | this, SLOT(deny() ) ); |
144 | 141 | ||
145 | raise(); | 142 | raise(); |
146 | showMaximized(); | 143 | showMaximized(); |
147 | } | 144 | } |
148 | OtherHandler::~OtherHandler() { | 145 | OtherHandler::~OtherHandler() { |
149 | 146 | ||
150 | } | 147 | } |
151 | void OtherHandler::handle( const QString& file ) { | 148 | void OtherHandler::handle( const QString& file ) { |
152 | m_file = file; | 149 | m_file = file; |
153 | m_na->setText(file); | 150 | m_na->setText(file); |
154 | DocLnk lnk(file); | 151 | DocLnk lnk(file); |
155 | owarn << " " << lnk.type() << " " << lnk.icon() << "" << oendl; | ||
156 | 152 | ||
157 | 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() ); | 153 | 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() ); |
158 | m_view->setText( str ); | 154 | m_view->setText( str ); |
159 | } | 155 | } |
160 | 156 | ||
161 | /* | 157 | /* |
162 | * hehe evil evil mmap ahead :) | 158 | * hehe evil evil mmap ahead :) |
163 | * we quickly copy the file and then we'll create a DocLnk for it | 159 | * we quickly copy the file and then we'll create a DocLnk for it |
164 | */ | 160 | */ |
165 | void OtherHandler::accept() { | 161 | void OtherHandler::accept() { |
166 | QString na = targetName( m_file ); | 162 | QString na = targetName( m_file ); |
167 | copy(m_file, na ); | 163 | copy(m_file, na ); |
@@ -186,23 +182,17 @@ QString OtherHandler::targetName( const QString& file ) { | |||
186 | int trie = 0; | 182 | int trie = 0; |
187 | while (QFile::exists(newFile + "."+info.extension() ) ) { | 183 | while (QFile::exists(newFile + "."+info.extension() ) ) { |
188 | newFile = newFileBase + "_"+QString::number(trie) ; | 184 | newFile = newFileBase + "_"+QString::number(trie) ; |
189 | trie++; | 185 | trie++; |
190 | } | 186 | } |
191 | newFile += "." + info.extension(); | 187 | newFile += "." + info.extension(); |
192 | 188 | ||
193 | return newFile; | 189 | return newFile; |
194 | } | 190 | } |
195 | 191 | ||
196 | /* fast cpy */ | 192 | /* fast cpy */ |
197 | void OtherHandler::copy(const QString& src, const QString& file) { | 193 | void OtherHandler::copy(const QString& src, const QString& file) { |
198 | owarn << "src " << src << ", dest " << file << "" << oendl; | ||
199 | FileManager *fm; | 194 | FileManager *fm; |
200 | if(!fm->copyFile(src,file)) { | 195 | if(!fm->copyFile(src,file)) { |
201 | owarn << "Copy failed" << oendl; | 196 | owarn << "Copy failed" << oendl; |
202 | } | 197 | } |
203 | |||
204 | // QString cmd = QString("mv %1 %2").arg( Global::shellQuote( src )). | ||
205 | // arg( Global::shellQuote( file ) ); | ||
206 | // ::system( cmd.latin1() ); | ||
207 | // done | ||
208 | } | 198 | } |