[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdenox/konq-embed/dropin/kio
From: Eva Brucherseifer <eva () kde ! org>
Date: 2006-05-09 12:49:52
Message-ID: 1147178992.925215.27685.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 538976 by eva:
read user agent setting from config file and parse it correctly
M +59 -8 kprotocolmanager.cpp
M +3 -2 kprotocolmanager.h
--- trunk/kdenox/konq-embed/dropin/kio/kprotocolmanager.cpp #538975:538976
@@ -30,7 +30,9 @@
#include <qglobal.h>
#include <stdlib.h>
+#include <sys/utsname.h>
+
#ifdef _QT_QPE_
#include <qtopia/config.h>
#include <qtopia/global.h>
@@ -50,26 +52,75 @@
#ifdef Q_WS_QWS
#define DEFAULT_USERAGENT_STRING \
- QString::fromLatin1("Mozilla/5.0 (compatible; Konqueror/%1.%2%3) KHTML/%4.%5.%6 \
(like Gecko); QtEmbedded/%2x%3") \
- .arg( KDE_VERSION_STRING ) \
- .arg( qApp->desktop()->width() ) \
- .arg( qApp->desktop()->height() )
+ QString::fromLatin1("Mozilla/5.0 (compatible; Konqueror/%1) KHTML/%2 (like \
Gecko); QtEmbedded/%3x%4") \ + .arg( KDE_VERSION_STRING ).arg( KDE_VERSION_STRING \
).arg( qApp->desktop()->width() ).arg( qApp->desktop()->height() ) #else
#define DEFAULT_USERAGENT_STRING \
- QString::fromLatin1("Mozilla/5.0 (compatible; Konqueror/%1.%2%3; X11) \
KHTML/%4.%5.%6 (like Gecko)").arg( KDE_VERSION_STRING ) + \
QString::fromLatin1("Mozilla/5.0 (compatible; Konqueror/%1; X11) KHTML/%2 (like \
Gecko)").arg( KDE_VERSION_STRING ).arg( KDE_VERSION_STRING ) #endif
+//from KDE sources:
+//#define CFG_DEFAULT_UAGENT(X) \
+//QString("Mozilla/5.0 (compatible; Konqueror/%1.%2%3) KHTML/%4.%5.%6 (like Gecko)") \
\ +// .arg(KDE_VERSION_MAJOR).arg(KDE_VERSION_MINOR).arg(X).arg(KDE_VERSION_MAJOR).arg(KDE_VERSION_MINOR).arg(KDE_VERSION_RELEASE)
+
+#define QFL(x) QString::fromLatin1(x)
+
+QString KProtocolManager::parseUADescription(const QString& uastring)
+{
+ QString tmp(uastring);
+ kdDebug() << "*************** PARSE USER AGENT STRING (" << uastring << ")" << \
endl; +
+ struct utsname utsn;
+ uname( &utsn );
+
+ tmp.replace( QFL("appSysName"), QString(utsn.sysname) );
+ tmp.replace( QFL("appSysRelease"), QString(utsn.release) );
+ tmp.replace( QFL("appMachineType"), QString(utsn.machine) );
+
+ QStringList languageList = KGlobal::locale()->languageList();
+ if ( languageList.count() )
+ {
+ QStringList::Iterator it = languageList.find( QString::fromLatin1("C") );
+ if( it != languageList.end() )
+ {
+ if( languageList.contains( QString::fromLatin1("en") ) > 0 )
+ languageList.remove( it );
+ else
+ (*it) = QString::fromLatin1("en");
+ }
+ }
+
+ tmp.replace( QFL("appLanguage"), QString("%1").arg(languageList.join(", ")) );
+ tmp.replace( QFL("appPlatform"), QFL("X11") );
+
+ return tmp;
+}
+
+
+
QString KProtocolManager::userAgentForHost( const QString &/*host*/ )
{
QString agent = QString::fromLatin1( getenv( "HTTP_USER_AGENT" ) );
+ if ( !agent.isEmpty() )
+ return agent;
- if ( agent.isEmpty() )
- agent = DEFAULT_USERAGENT_STRING;
+ KConfig *config = KGlobal::config();
+ config->setGroup("General");
+ agent = config->readEntry( "UserAgentString" );
+ if ( !agent.isEmpty() )
+ return parseUADescription(agent);
- return agent;
+ return DEFAULT_USERAGENT_STRING;
}
+QString KProtocolManager::defaultUserAgent( const QString & )
+{
+ return userAgentForHost();
+}
+
+
bool KProtocolManager::useProxy()
{
return !httpProxy().isEmpty();
--- trunk/kdenox/konq-embed/dropin/kio/kprotocolmanager.h #538975:538976
@@ -9,9 +9,9 @@
{
public:
- static QString userAgentForHost( const QString &host );
+ static QString userAgentForHost( const QString &host = QString::null );
- static QString defaultUserAgent( const QString & ) { return userAgentForHost( \
QString::null ); } + static QString defaultUserAgent( const QString & );
static bool useProxy();
@@ -55,6 +55,7 @@
private:
static int configValue( const char *envVarName, int defaultVal );
+ static QString parseUADescription(const QString& uastring);
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic