Update alternative identification strings

On Windows we should use the NT version number.

For Firefox we use the updated format of version 4.

For Safari and iPhone we pretend to run on native platforms.

If in doubt we fallback to X11/ Linux, not Unknown.
This commit is contained in:
Christian Dywan 2011-05-01 06:53:08 +02:00
parent 96dda85b81
commit ee39b5c87b

View file

@ -1222,7 +1222,7 @@ midori_web_settings_finalize (GObject* object)
G_OBJECT_CLASS (midori_web_settings_parent_class)->finalize (object); G_OBJECT_CLASS (midori_web_settings_parent_class)->finalize (object);
} }
#if defined (G_OS_UNIX) && !HAVE_OSX #if (!HAVE_OSX && defined (G_OS_UNIX)) || defined (G_OS_WIN32)
static gchar* static gchar*
get_sys_name (void) get_sys_name (void)
{ {
@ -1230,11 +1230,15 @@ get_sys_name (void)
if (!sys_name) if (!sys_name)
{ {
#ifdef G_OS_WIN32
sys_name = g_strdup_printf ("NT %d.0", g_win32_get_windows_version ());
#else
struct utsname name; struct utsname name;
if (uname (&name) != -1) if (uname (&name) != -1)
sys_name = g_strdup(name.sysname); sys_name = g_strdup(name.sysname);
else else
sys_name = "Unix"; sys_name = "Linux";
#endif
} }
return sys_name; return sys_name;
} }
@ -1245,28 +1249,24 @@ generate_ident_string (MidoriIdentity identify_as)
{ {
const gchar* platform = const gchar* platform =
#if HAVE_HILDON #if HAVE_HILDON
"Maemo" "Maemo;"
#elif defined (GDK_WINDOWING_X11) #elif defined (G_OS_WIN32)
"X11";
#elif defined(GDK_WINDOWING_WIN32)
"Windows"; "Windows";
#elif defined(GDK_WINDOWING_QUARTZ) #elif defined(GDK_WINDOWING_QUARTZ)
"Macintosh"; "Macintosh;";
#elif defined(GDK_WINDOWING_DIRECTFB) #elif defined(GDK_WINDOWING_DIRECTFB)
"DirectFB"; "DirectFB;";
#else #else
"Unknown"; "X11;";
#endif #endif
const gchar* os = const gchar* os =
#if HAVE_OSX #if HAVE_OSX
"Mac OS X"; "Mac OS X";
#elif defined (G_OS_UNIX) #elif defined (G_OS_UNIX) || defined (G_OS_WIN32)
get_sys_name (); get_sys_name ();
#elif defined (G_OS_WIN32)
"Windows";
#else #else
"Unknown"; "Linux";
#endif #endif
const gchar* appname = "Midori/" const gchar* appname = "Midori/"
@ -1285,24 +1285,21 @@ generate_ident_string (MidoriIdentity identify_as)
switch (identify_as) switch (identify_as)
{ {
case MIDORI_IDENT_MIDORI: case MIDORI_IDENT_MIDORI:
return g_strdup_printf ("Mozilla/5.0 (%s; %s) AppleWebKit/%d.%d+ %s", return g_strdup_printf ("Mozilla/5.0 (%s %s) AppleWebKit/%d.%d+ %s",
platform, os, webcore_major, webcore_minor, appname); platform, os, webcore_major, webcore_minor, appname);
case MIDORI_IDENT_SAFARI: case MIDORI_IDENT_SAFARI:
return g_strdup_printf ("Mozilla/5.0 (%s; U; %s; %s) " return g_strdup_printf ("Mozilla/5.0 (Macintosh; U; Intel Mac OS X; %s) "
"AppleWebKit/%d+ (KHTML, like Gecko) Version/5.0 Safari/%d.%d+ %s", "AppleWebKit/%d+ (KHTML, like Gecko) Version/5.0 Safari/%d.%d+ %s",
platform, os, lang, webcore_major, webcore_major, webcore_minor, appname); lang, webcore_major, webcore_major, webcore_minor, appname);
case MIDORI_IDENT_IPHONE: case MIDORI_IDENT_IPHONE:
return g_strdup_printf ("Mozilla/5.0 (iPhone; U; %s; %s) " return g_strdup_printf ("Mozilla/5.0 (iPhone; U; CPU like Mac OS X; %s) "
"AppleWebKit/532+ (KHTML, like Gecko) Version/3.0 Mobile/1A538b " "AppleWebKit/532+ (KHTML, like Gecko) Version/3.0 Mobile/1A538b Safari/419.3 %s",
"Safari/419.3 %s", lang, appname);
os, lang, appname);
case MIDORI_IDENT_FIREFOX: case MIDORI_IDENT_FIREFOX:
return g_strdup_printf ("Mozilla/5.0 (%s; U; %s; %s; rv:1.9.0.2) " return g_strdup_printf ("Mozilla/5.0 (%s %s; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 %s",
"Gecko/2008092313 Firefox/3.8 %s", platform, os, appname);
platform, os, lang, appname);
case MIDORI_IDENT_EXPLORER: case MIDORI_IDENT_EXPLORER:
return g_strdup_printf ("Mozilla/4.0 (compatible; " return g_strdup_printf ("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; %s) %s",
"MSIE 6.0; Windows NT 5.1; %s) %s",
lang, appname); lang, appname);
default: default:
return g_strdup_printf ("%s", appname); return g_strdup_printf ("%s", appname);