From 7e6cdea4f25f5d4362774069d026074a28a87477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Tue, 24 May 2011 05:53:28 +0000 Subject: [PATCH] closes #51, closes #47 --- swisssurfer/src/browser.hxx | 57 +++++++++++++++++++------------ swisssurfer/src/swisssurfer_de.ts | 40 +++++++++++----------- swisssurfer/src/swisssurfer_en.ts | 40 +++++++++++----------- swisssurfer/src/swisssurfer_fr.ts | 40 +++++++++++----------- swisssurfer/src/swisssurfer_it.ts | 40 +++++++++++----------- 5 files changed, 115 insertions(+), 102 deletions(-) diff --git a/swisssurfer/src/browser.hxx b/swisssurfer/src/browser.hxx index aa8180d..dd302e8 100644 --- a/swisssurfer/src/browser.hxx +++ b/swisssurfer/src/browser.hxx @@ -73,7 +73,6 @@ class Browser: public QMainWindow, protected Ui::Browser { _zoom->setSingleStep(1); _zoom->setPageStep(10); _zoom->setTickPosition(QSlider::TicksBothSides); - //_zoom->setTickInterval(10); assert(connect(_zoom, SIGNAL(valueChanged(int)), SLOT(zoom(int)))); _toolbar->addWidget(_url = new QComboBox(_toolbar)); on_actionNewTab_triggered(); @@ -84,12 +83,6 @@ class Browser: public QMainWindow, protected Ui::Browser { _url->addItems(urls); assert(connect(_url, SIGNAL(currentIndexChanged(const QString&)), SLOT(load(QString)))); - // assert(connect(&_networkManager, - // SIGNAL(extendedContextInitialization(ssl_ctx_st*, - // QSslSocket*)), - // &_scAuth, - // SLOT(extendedContextInitialization(ssl_ctx_st*, - // QSslSocket*)))); assert(connect(&_networkManager, SIGNAL(created(QNetworkReply*)), &_downloadManager, SLOT(add(QNetworkReply*)))); @@ -123,15 +116,15 @@ class Browser: public QMainWindow, protected Ui::Browser { ~Browser() { LOG; - if (_settings.flag("CloseApps")) - for (DownloadProcesses::iterator it(_downloadProcesses.begin()); - it!=_downloadProcesses.end(); ++it) { - LOG<<"delete:"<second->fileName(); - delete it->second; - it->second = 0; - it->first->terminate(); - delete it->first; - } + for (DownloadProcesses::iterator it(_downloadProcesses.begin()); + it!=_downloadProcesses.end(); ++it) { + LOG<<"delete:"<second->fileName(); + it->second->setAutoRemove(_settings.flag("CloseApps")); + delete it->second; + it->second = 0; + if (_settings.flag("CloseApps")) it->first->terminate(); + delete it->first; + } } //! Whitelisting @@ -1017,22 +1010,43 @@ class Browser: public QMainWindow, protected Ui::Browser { .toString(); LOG<<"Content-Type:"<header(QNetworkRequest::ContentTypeHeader) .toString(); + LOG<<"Content-Disposition:"<rawHeader("Content-Disposition"); LOG<<"Status:"<<_downloadManager.networkError(reply->error()); LOG<<"URL:"<url().toString(); LOG<<"File:"<url().toLocalFile(); LOG<<"Path:"<url().path(); + QString filename + (QString::fromUtf8(reply->rawHeader("Content-Disposition"))); + if (filename.contains + (QRegExp("^\\s*attachment\\s*;\\s*filename\\s*=\\s*\"[^\"]+\""))) { + LOG<<"From Content-Disposition"; + filename = filename.replace + (QRegExp("^\\s*attachment\\s*;\\s*filename\\s*=\\s*\"([^\"]+)\".*"), + "\\1"); + } else { + LOG<<"From path"; + filename = + QFileInfo(!reply->url().toLocalFile().isEmpty() + ?reply->url().toLocalFile() + :reply->url().path()).fileName(); + } + LOG<<"Filename:"<header(QNetworkRequest::ContentTypeHeader).toString() .split(';')[0])); if (it!=_settings.mimetypes().end()) { + filename.replace(QRegExp("^(.*)\\."+it.value().toStringList() + .at(0)+"$"), + "\\1"); // remove extension QTemporaryFile *file = new QTemporaryFile(QDir::tempPath()+QDir::separator() - +"swisssurferXXXXXX" + +filename+"_XXXXXX." +it.value().toStringList().at(0), this); file->open(); file->write(reply->readAll()); file->close(); + LOG<<"Stored as:"<fileName(); QProcess* process(new QProcess); _downloadProcesses[process] = file; assert(connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), @@ -1045,9 +1059,7 @@ class Browser: public QMainWindow, protected Ui::Browser { } else { QString saveFile (QFileDialog::getSaveFileName(this, tr("Save File As ..."), - !reply->url().toLocalFile().isEmpty() - ?reply->url().toLocalFile() - :reply->url().path())); + filename)); if (!saveFile.isEmpty()) { QFile file(saveFile); file.open(QIODevice::WriteOnly); @@ -1059,8 +1071,9 @@ class Browser: public QMainWindow, protected Ui::Browser { void processFinished() { LOG; - if (_settings.flag("CloseApps")) - delete _downloadProcesses[qobject_cast(sender())]; + _downloadProcesses[qobject_cast(sender())]->setAutoRemove + (_settings.flag("CloseApps")); + delete _downloadProcesses[qobject_cast(sender())]; _downloadProcesses.erase(qobject_cast(sender())); } diff --git a/swisssurfer/src/swisssurfer_de.ts b/swisssurfer/src/swisssurfer_de.ts index 34293af..9cf34ae 100644 --- a/swisssurfer/src/swisssurfer_de.ts +++ b/swisssurfer/src/swisssurfer_de.ts @@ -226,88 +226,88 @@ - + Checking: %1 Opening: %1 - + Reading: %1 Reading: %1% - + Zoom: %1% - + Illegal URL: %1 - + Print Document - + %1 - %2 Back to %1 - %2 statusbar actionBack_hovered %1=url %2=title - + Info: %1 - + done. - + page load error. - + %1 statusbar for hovered link %1=url - + Forbidden: %1 - + Access Denied - + <p>Access denied due to security considerations.</p><p>You are not allowed to connect to %1. - + %1 - %2 statusbar actionForward_hovered %1=url %2=title - + About - + SwissSurfer %1 (%2) %3 @@ -321,22 +321,22 @@ Compiled: qt-%5 - + %1 - + Save File As ... - + authentication required - + ssl error diff --git a/swisssurfer/src/swisssurfer_en.ts b/swisssurfer/src/swisssurfer_en.ts index 34293af..9cf34ae 100644 --- a/swisssurfer/src/swisssurfer_en.ts +++ b/swisssurfer/src/swisssurfer_en.ts @@ -226,88 +226,88 @@ - + Checking: %1 Opening: %1 - + Reading: %1 Reading: %1% - + Zoom: %1% - + Illegal URL: %1 - + Print Document - + %1 - %2 Back to %1 - %2 statusbar actionBack_hovered %1=url %2=title - + Info: %1 - + done. - + page load error. - + %1 statusbar for hovered link %1=url - + Forbidden: %1 - + Access Denied - + <p>Access denied due to security considerations.</p><p>You are not allowed to connect to %1. - + %1 - %2 statusbar actionForward_hovered %1=url %2=title - + About - + SwissSurfer %1 (%2) %3 @@ -321,22 +321,22 @@ Compiled: qt-%5 - + %1 - + Save File As ... - + authentication required - + ssl error diff --git a/swisssurfer/src/swisssurfer_fr.ts b/swisssurfer/src/swisssurfer_fr.ts index 34293af..9cf34ae 100644 --- a/swisssurfer/src/swisssurfer_fr.ts +++ b/swisssurfer/src/swisssurfer_fr.ts @@ -226,88 +226,88 @@ - + Checking: %1 Opening: %1 - + Reading: %1 Reading: %1% - + Zoom: %1% - + Illegal URL: %1 - + Print Document - + %1 - %2 Back to %1 - %2 statusbar actionBack_hovered %1=url %2=title - + Info: %1 - + done. - + page load error. - + %1 statusbar for hovered link %1=url - + Forbidden: %1 - + Access Denied - + <p>Access denied due to security considerations.</p><p>You are not allowed to connect to %1. - + %1 - %2 statusbar actionForward_hovered %1=url %2=title - + About - + SwissSurfer %1 (%2) %3 @@ -321,22 +321,22 @@ Compiled: qt-%5 - + %1 - + Save File As ... - + authentication required - + ssl error diff --git a/swisssurfer/src/swisssurfer_it.ts b/swisssurfer/src/swisssurfer_it.ts index 34293af..9cf34ae 100644 --- a/swisssurfer/src/swisssurfer_it.ts +++ b/swisssurfer/src/swisssurfer_it.ts @@ -226,88 +226,88 @@ - + Checking: %1 Opening: %1 - + Reading: %1 Reading: %1% - + Zoom: %1% - + Illegal URL: %1 - + Print Document - + %1 - %2 Back to %1 - %2 statusbar actionBack_hovered %1=url %2=title - + Info: %1 - + done. - + page load error. - + %1 statusbar for hovered link %1=url - + Forbidden: %1 - + Access Denied - + <p>Access denied due to security considerations.</p><p>You are not allowed to connect to %1. - + %1 - %2 statusbar actionForward_hovered %1=url %2=title - + About - + SwissSurfer %1 (%2) %3 @@ -321,22 +321,22 @@ Compiled: qt-%5 - + %1 - + Save File As ... - + authentication required - + ssl error