From 6d16b9e672e9a703be9a35d04f306a83d29be58c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Wed, 29 Jun 2011 06:52:18 +0000 Subject: [PATCH] set SWISSSURFER_USERAGENT e.g. to "Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%"; closes #88 --- swisssurfer/src/browser.hxx | 7 +-- swisssurfer/src/main.cxx | 21 +++++++-- swisssurfer/src/swisssurfer_de.ts | 78 ++++++++++++++----------------- swisssurfer/src/swisssurfer_en.ts | 56 +++++++++++++--------- swisssurfer/src/swisssurfer_fr.ts | 78 ++++++++++++++----------------- swisssurfer/src/swisssurfer_it.ts | 78 ++++++++++++++----------------- swisssurfer/src/webpage.hxx | 7 ++- 7 files changed, 166 insertions(+), 159 deletions(-) diff --git a/swisssurfer/src/browser.hxx b/swisssurfer/src/browser.hxx index 9b9c5ba..056c191 100644 --- a/swisssurfer/src/browser.hxx +++ b/swisssurfer/src/browser.hxx @@ -630,8 +630,8 @@ class Browser: public QMainWindow, protected Ui::Browser { } void on_actionAbout_triggered() { - QMessageBox::about(this, tr("About"), - tr("SwissSurfer\n" + QMessageBox::about(this, tr("About"), + tr("%8\n" "Version: %1\n" "Builddate: %2\n" "Libraries:\n" @@ -645,7 +645,8 @@ class Browser: public QMainWindow, protected Ui::Browser { .arg(QString::fromStdString(pcsc::version())) .arg(qVersion()) .arg(QT_VERSION_STR) - .arg(SHLIB_VERSION_NUMBER)); + .arg(SHLIB_VERSION_NUMBER) + .arg(QApplication::applicationName())); } void on_actionSettings_triggered() { diff --git a/swisssurfer/src/main.cxx b/swisssurfer/src/main.cxx index 1041bd2..23e8462 100644 --- a/swisssurfer/src/main.cxx +++ b/swisssurfer/src/main.cxx @@ -250,6 +250,8 @@ int main(int argv, char** argc) try { QTextCodec::setCodecForTr(utf8); QApplication app(argv, argc); app.setWindowIcon(QIcon(":/icons/appicon")); + app.setApplicationName(QObject::trUtf8("SwissSurfer", "application name")); + app.setApplicationVersion(VERSION); QTranslator qtTranslator; if (env.contains("LANGUAGE")) QLocale::setDefault(env["LANGUAGE"]); qtTranslator.load(":/language/qt_" + QLocale::system().name()); @@ -322,13 +324,22 @@ int main(int argv, char** argc) try { " start for mimetype \n" " optional full URL\n" "Environment:\n" - " LANGUAGE \"de\", \"en\", ... (actual: %5)\n" - " PROXY_TYPE \"http\" or \"socks\" or \"\" (actual: %2)\n" - " PROXY_PORT proxy port number (actual: %3)\n" - " PROXY_HOST proxy host name (actual: %4)\n") + " LANGUAGE \"de\", \"en\", ... (actual: %5)\n" + " PROXY_TYPE \"http\" or \"socks\" or \"\" (actual: %2)\n" + " PROXY_PORT proxy port number (actual: %3)\n" + " PROXY_HOST proxy host name (actual: %4)\n" + " SWISSSURFER_USERAGENT fake user agent (actual: %6)\n" + " %Platform% and %Subplatform% are expanded\n" + " to the windowing system and the operation\n" + " system. %Security% expands to U if SSL is\n" + " available, otherwise N. %Locale% is\n" + " replaced with locale name. %WebKitVersion%\n" + " is the version of WebKit the application\n" + " was compiled against. %AppVersion% expands\n" + " to application name/version\n") .arg(QFileInfo(argc[0]).fileName()) .arg(env["PROXY_TYPE"]).arg(env["PROXY_PORT"]).arg(env["PROXY_HOST"]) - .arg(env["LANGUAGE"]) + .arg(env["LANGUAGE"]).arg(env["SWISSSURFER_USERAGENT"]) .toStdString() < - + Info: %1 - + done. - + page load error. - + %1 statusbar for hovered link %1=url @@ -338,7 +338,7 @@ - SwissSurfer + %8 Version: %1 Builddate: %2 Libraries: @@ -346,8 +346,7 @@ Libraries: %4 qt-%5 (%6) openssl-%7 - SwissSurfer %1 (%2) - + SwissSurfer Version: %1 Builddate: %2 Libraries: @@ -358,22 +357,22 @@ openssl-%7 - + %1 - + Save File As ... - + authentication required - + ssl error @@ -681,7 +680,13 @@ openssl-%7 QObject - + + SwissSurfer + application name + + + + Usage: %1 [OPTIONS...] [<url> ...] Options: -h, --help show this help text @@ -699,57 +704,44 @@ Options: start <tool> for mimetype <mime> <url> optional full URL Environment: - LANGUAGE "de", "en", ... (actual: %5) - PROXY_TYPE "http" or "socks" or "" (actual: %2) - PROXY_PORT proxy port number (actual: %3) - PROXY_HOST proxy host name (actual: %4) + LANGUAGE "de", "en", ... (actual: %5) + PROXY_TYPE "http" or "socks" or "" (actual: %2) + PROXY_PORT proxy port number (actual: %3) + PROXY_HOST proxy host name (actual: %4) + SWISSSURFER_USERAGENT fake user agent (actual: %6) + %Platform% and %Subplatform% are expanded + to the windowing system and the operation + system. %Security% expands to U if SSL is + available, otherwise N. %Locale% is + replaced with locale name. %WebKitVersion% + is the version of WebKit the application + was compiled against. %AppVersion% expands + to application name/version - Usage: %1 [OPTIONS...] [<url> ...] -Options: - -h, --help show this help text - -k, --kiosk no url bar - if you sepcify -k and -s, -k must be first - -n, --no-settings don't load or store any settings - --no-login don't ask for smartcard password - -l, --lib <file> path to file libengine_act.so - -s, --settings <file> - load settings from <file> - if you sepcify -k and -s, -k must be first - -c, --cert <file> load local client certificate from <file> - -y, --key <file> load local certificate key from <file> - -m, --mime <mime> <ext> <tool> - start <tool> for mimetype <mime> - <url> optional full URL -Environment: - LANGUAGE "de", "en", ... (actual: %5) - PROXY_TYPE "http" or "socks" or "" (actual: %2) - PROXY_PORT proxy port number (actual: %3) - PROXY_HOST proxy host name (actual: %4) - - + Cannot read PEM certificate from file: %1 - + Read PEM certificates from file: %1 - + Cannot read PEM RSA key from file: %1 - + Read private key from file: %1 - + Too few arguments. Try: %1 --help diff --git a/swisssurfer/src/swisssurfer_en.ts b/swisssurfer/src/swisssurfer_en.ts index a97ac0c..01502fb 100644 --- a/swisssurfer/src/swisssurfer_en.ts +++ b/swisssurfer/src/swisssurfer_en.ts @@ -312,7 +312,7 @@ - SwissSurfer + %8 Version: %1 Builddate: %2 Libraries: @@ -320,8 +320,7 @@ Libraries: %4 qt-%5 (%6) openssl-%7 - SwissSurfer %1 (%2) - + SwissSurfer Version: %1 Builddate: %2 Libraries: @@ -332,43 +331,43 @@ openssl-%7 - + %1 - + Info: %1 - + done. - + page load error. - + %1 statusbar for hovered link %1=url - + Save File As ... - + authentication required - + ssl error @@ -671,7 +670,13 @@ openssl-%7 QObject - + + SwissSurfer + application name + + + + Usage: %1 [OPTIONS...] [<url> ...] Options: -h, --help show this help text @@ -689,35 +694,44 @@ Options: start <tool> for mimetype <mime> <url> optional full URL Environment: - LANGUAGE "de", "en", ... (actual: %5) - PROXY_TYPE "http" or "socks" or "" (actual: %2) - PROXY_PORT proxy port number (actual: %3) - PROXY_HOST proxy host name (actual: %4) + LANGUAGE "de", "en", ... (actual: %5) + PROXY_TYPE "http" or "socks" or "" (actual: %2) + PROXY_PORT proxy port number (actual: %3) + PROXY_HOST proxy host name (actual: %4) + SWISSSURFER_USERAGENT fake user agent (actual: %6) + %Platform% and %Subplatform% are expanded + to the windowing system and the operation + system. %Security% expands to U if SSL is + available, otherwise N. %Locale% is + replaced with locale name. %WebKitVersion% + is the version of WebKit the application + was compiled against. %AppVersion% expands + to application name/version - + Cannot read PEM certificate from file: %1 - + Read PEM certificates from file: %1 - + Cannot read PEM RSA key from file: %1 - + Read private key from file: %1 - + Too few arguments. Try: %1 --help diff --git a/swisssurfer/src/swisssurfer_fr.ts b/swisssurfer/src/swisssurfer_fr.ts index 28ec992..436e261 100644 --- a/swisssurfer/src/swisssurfer_fr.ts +++ b/swisssurfer/src/swisssurfer_fr.ts @@ -280,22 +280,22 @@ - + Info: %1 - + done. - + page load error. - + %1 statusbar for hovered link %1=url @@ -338,7 +338,7 @@ - SwissSurfer + %8 Version: %1 Builddate: %2 Libraries: @@ -346,8 +346,7 @@ Libraries: %4 qt-%5 (%6) openssl-%7 - SwissSurfer %1 (%2) - + SwissSurfer Version: %1 Builddate: %2 Libraries: @@ -358,22 +357,22 @@ openssl-%7 - + %1 - + Save File As ... - + authentication required - + ssl error @@ -681,7 +680,13 @@ openssl-%7 QObject - + + SwissSurfer + application name + + + + Usage: %1 [OPTIONS...] [<url> ...] Options: -h, --help show this help text @@ -699,57 +704,44 @@ Options: start <tool> for mimetype <mime> <url> optional full URL Environment: - LANGUAGE "de", "en", ... (actual: %5) - PROXY_TYPE "http" or "socks" or "" (actual: %2) - PROXY_PORT proxy port number (actual: %3) - PROXY_HOST proxy host name (actual: %4) + LANGUAGE "de", "en", ... (actual: %5) + PROXY_TYPE "http" or "socks" or "" (actual: %2) + PROXY_PORT proxy port number (actual: %3) + PROXY_HOST proxy host name (actual: %4) + SWISSSURFER_USERAGENT fake user agent (actual: %6) + %Platform% and %Subplatform% are expanded + to the windowing system and the operation + system. %Security% expands to U if SSL is + available, otherwise N. %Locale% is + replaced with locale name. %WebKitVersion% + is the version of WebKit the application + was compiled against. %AppVersion% expands + to application name/version - Usage: %1 [OPTIONS...] [<url> ...] -Options: - -h, --help show this help text - -k, --kiosk no url bar - if you sepcify -k and -s, -k must be first - -n, --no-settings don't load or store any settings - --no-login don't ask for smartcard password - -l, --lib <file> path to file libengine_act.so - -s, --settings <file> - load settings from <file> - if you sepcify -k and -s, -k must be first - -c, --cert <file> load local client certificate from <file> - -y, --key <file> load local certificate key from <file> - -m, --mime <mime> <ext> <tool> - start <tool> for mimetype <mime> - <url> optional full URL -Environment: - LANGUAGE "de", "en", ... (actual: %5) - PROXY_TYPE "http" or "socks" or "" (actual: %2) - PROXY_PORT proxy port number (actual: %3) - PROXY_HOST proxy host name (actual: %4) - - + Cannot read PEM certificate from file: %1 - + Read PEM certificates from file: %1 - + Cannot read PEM RSA key from file: %1 - + Read private key from file: %1 - + Too few arguments. Try: %1 --help diff --git a/swisssurfer/src/swisssurfer_it.ts b/swisssurfer/src/swisssurfer_it.ts index 28ec992..436e261 100644 --- a/swisssurfer/src/swisssurfer_it.ts +++ b/swisssurfer/src/swisssurfer_it.ts @@ -280,22 +280,22 @@ - + Info: %1 - + done. - + page load error. - + %1 statusbar for hovered link %1=url @@ -338,7 +338,7 @@ - SwissSurfer + %8 Version: %1 Builddate: %2 Libraries: @@ -346,8 +346,7 @@ Libraries: %4 qt-%5 (%6) openssl-%7 - SwissSurfer %1 (%2) - + SwissSurfer Version: %1 Builddate: %2 Libraries: @@ -358,22 +357,22 @@ openssl-%7 - + %1 - + Save File As ... - + authentication required - + ssl error @@ -681,7 +680,13 @@ openssl-%7 QObject - + + SwissSurfer + application name + + + + Usage: %1 [OPTIONS...] [<url> ...] Options: -h, --help show this help text @@ -699,57 +704,44 @@ Options: start <tool> for mimetype <mime> <url> optional full URL Environment: - LANGUAGE "de", "en", ... (actual: %5) - PROXY_TYPE "http" or "socks" or "" (actual: %2) - PROXY_PORT proxy port number (actual: %3) - PROXY_HOST proxy host name (actual: %4) + LANGUAGE "de", "en", ... (actual: %5) + PROXY_TYPE "http" or "socks" or "" (actual: %2) + PROXY_PORT proxy port number (actual: %3) + PROXY_HOST proxy host name (actual: %4) + SWISSSURFER_USERAGENT fake user agent (actual: %6) + %Platform% and %Subplatform% are expanded + to the windowing system and the operation + system. %Security% expands to U if SSL is + available, otherwise N. %Locale% is + replaced with locale name. %WebKitVersion% + is the version of WebKit the application + was compiled against. %AppVersion% expands + to application name/version - Usage: %1 [OPTIONS...] [<url> ...] -Options: - -h, --help show this help text - -k, --kiosk no url bar - if you sepcify -k and -s, -k must be first - -n, --no-settings don't load or store any settings - --no-login don't ask for smartcard password - -l, --lib <file> path to file libengine_act.so - -s, --settings <file> - load settings from <file> - if you sepcify -k and -s, -k must be first - -c, --cert <file> load local client certificate from <file> - -y, --key <file> load local certificate key from <file> - -m, --mime <mime> <ext> <tool> - start <tool> for mimetype <mime> - <url> optional full URL -Environment: - LANGUAGE "de", "en", ... (actual: %5) - PROXY_TYPE "http" or "socks" or "" (actual: %2) - PROXY_PORT proxy port number (actual: %3) - PROXY_HOST proxy host name (actual: %4) - - + Cannot read PEM certificate from file: %1 - + Read PEM certificates from file: %1 - + Cannot read PEM RSA key from file: %1 - + Read private key from file: %1 - + Too few arguments. Try: %1 --help diff --git a/swisssurfer/src/webpage.hxx b/swisssurfer/src/webpage.hxx index 2f7456b..efa3feb 100644 --- a/swisssurfer/src/webpage.hxx +++ b/swisssurfer/src/webpage.hxx @@ -9,6 +9,7 @@ #define __WEBPAGE_HXX__ #include +#include class Browser; @@ -16,7 +17,11 @@ class WebPage: public QWebPage { public: WebPage(Browser* b, QObject *parent = 0): QWebPage(parent), _browser(b) {} protected: - QWebPage* createWindow(WebWindowType type); + virtual QWebPage* createWindow(WebWindowType type); + virtual QString userAgentForUrl(const QUrl& url) const { + return QProcessEnvironment::systemEnvironment() + .value("SWISSSURFER_USERAGENT", QWebPage::userAgentForUrl(url)); + } private: Browser* _browser; };