Changeset View
Changeset View
Standalone View
Standalone View
src/kioexec/main.cpp
Show All 13 Lines | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |||
---|---|---|---|---|---|
14 | General Public License for more details. | 14 | General Public License for more details. | ||
15 | 15 | | |||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License | ||
17 | along with this program; see the file COPYING. If not, write to | 17 | along with this program; see the file COPYING. If not, write to | ||
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
19 | Boston, MA 02110-1301, USA. | 19 | Boston, MA 02110-1301, USA. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | // TODO: remove me | | |||
23 | #undef QT_NO_CAST_FROM_ASCII | | |||
24 | | ||||
25 | #include "main.h" | 22 | #include "main.h" | ||
26 | #include "kio_version.h" | 23 | #include "kio_version.h" | ||
27 | #include "kioexecdinterface.h" | 24 | #include "kioexecdinterface.h" | ||
28 | 25 | | |||
29 | #include <QFile> | 26 | #include <QFile> | ||
30 | #include <QDir> | 27 | #include <QDir> | ||
31 | 28 | | |||
32 | #include <job.h> | 29 | #include <job.h> | ||
▲ Show 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | 184 | { | |||
194 | 191 | | |||
195 | KService service(QStringLiteral("dummy"), command, QString()); | 192 | KService service(QStringLiteral("dummy"), command, QString()); | ||
196 | 193 | | |||
197 | QList<QUrl> list; | 194 | QList<QUrl> list; | ||
198 | list.reserve(fileList.size()); | 195 | list.reserve(fileList.size()); | ||
199 | // Store modification times | 196 | // Store modification times | ||
200 | QList<FileInfo>::Iterator it = fileList.begin(); | 197 | QList<FileInfo>::Iterator it = fileList.begin(); | ||
201 | for (; it != fileList.end() ; ++it) { | 198 | for (; it != fileList.end() ; ++it) { | ||
202 | QFileInfo info(QFile::encodeName(it->path)); | 199 | QFileInfo info(it->path); | ||
dfaure: Ouch.
QFileInfo info(it->path)
should be enough. | |||||
In my defence, since that looks a bit too crazy even to me, I was worried about files with names that have encoding issues, e.g. the dreaded �; but looking up just a little at the code I see that fileList was written by the code, so if the encoding did go south, that ship has sailed and already has sunk :) ahmadsamir: In my defence, since that looks a bit too crazy even to me, I was worried about files with… | |||||
In any case, encoding issues are for QString<->QByteArray conversions. Any time we can stick to QString<->QString like here, we're safe :) dfaure: In any case, encoding issues are for QString<->QByteArray conversions. Any time we can stick to… | |||||
203 | it->time = info.lastModified(); | 200 | it->time = info.lastModified(); | ||
204 | QUrl url = QUrl::fromLocalFile(it->path); | 201 | QUrl url = QUrl::fromLocalFile(it->path); | ||
205 | list << url; | 202 | list << url; | ||
206 | } | 203 | } | ||
207 | 204 | | |||
208 | KIO::DesktopExecParser execParser(service, list); | 205 | KIO::DesktopExecParser execParser(service, list); | ||
209 | QStringList params = execParser.resultingArguments(); | 206 | QStringList params = execParser.resultingArguments(); | ||
210 | 207 | | |||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 229 | for (it = fileList.begin(); it != fileList.end(); ++it) { | |||
257 | 254 | | |||
258 | if ((uploadChanges || mTempFiles) && exit_code == 0) { // Wait for a reasonable time so that even if the application forks on startup (like OOo or amarok) | 255 | if ((uploadChanges || mTempFiles) && exit_code == 0) { // Wait for a reasonable time so that even if the application forks on startup (like OOo or amarok) | ||
259 | // it will have time to start up and read the file before it gets deleted. #130709. | 256 | // it will have time to start up and read the file before it gets deleted. #130709. | ||
260 | const int sleepSecs = 180; | 257 | const int sleepSecs = 180; | ||
261 | qDebug() << "sleeping for" << sleepSecs << "seconds before deleting file..."; | 258 | qDebug() << "sleeping for" << sleepSecs << "seconds before deleting file..."; | ||
262 | QThread::currentThread()->sleep(sleepSecs); | 259 | QThread::currentThread()->sleep(sleepSecs); | ||
263 | const QString parentDir = info.path(); | 260 | const QString parentDir = info.path(); | ||
264 | qDebug() << sleepSecs << "seconds have passed, deleting" << info.filePath(); | 261 | qDebug() << sleepSecs << "seconds have passed, deleting" << info.filePath(); | ||
265 | QFile(QFile::encodeName(src)).remove(); | 262 | QFile(src).remove(); | ||
dfaure: Same here | |||||
266 | // NOTE: this is not necessarily a temporary directory. | 263 | // NOTE: this is not necessarily a temporary directory. | ||
267 | if (QDir().rmdir(parentDir)) { | 264 | if (QDir().rmdir(parentDir)) { | ||
268 | qDebug() << "Removed empty parent directory" << parentDir; | 265 | qDebug() << "Removed empty parent directory" << parentDir; | ||
269 | } | 266 | } | ||
270 | } | 267 | } | ||
271 | } | 268 | } | ||
272 | 269 | | |||
273 | mExited = true; | 270 | mExited = true; | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |
Ouch.
should be enough.