]> git.saurik.com Git - wxWidgets.git/commitdiff
better (more precise) values for wxGetOsDescription() (patch 1047539)
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 10 Nov 2004 22:08:37 +0000 (22:08 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 10 Nov 2004 22:08:37 +0000 (22:08 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30432 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

configure.in
docs/changes.txt
src/msw/utils.cpp
src/unix/baseunix.cpp
src/unix/utilsunx.cpp

index 5cb9a44fc7379d4f73e8ed820b4d220019bf8739..3629b854f28746d958b58b11217517362499db48 100644 (file)
@@ -5745,7 +5745,7 @@ if test "$wxUSE_WIZARDDLG" = "yes"; then
 fi
 
 dnl ---------------------------------------------------------------------------
-dnl get the string with OS info - used by wxGetOsDescription()
+dnl get the string with OS info - used by wxGetOsDescription() on MacOS X
 dnl ---------------------------------------------------------------------------
 
 if test "$cross_compiling" = "yes"; then
index 3c296e31240f85869f7d71f2450e25bc3e1e36fe..ef2582f98faa17b2288f2e067f35c82855a10aaf 100644 (file)
@@ -230,6 +230,7 @@ All:
   behavior between Unicode and non-unicode builds
 - BLOB example added to samples\db (thanks to Casey ODonnell)
 - use wxStream::GetLength() instead of deprecated GetSize()
+- wxGetOsDescription() is now more precise (Olly Betts)
 
 All (GUI):
 
index e7506b0908e67b76913445c83b42868f424726c2..736a8c90af397e0879e2b74f6567fed0bb5e1d16 100644 (file)
@@ -937,8 +937,39 @@ wxString wxGetOsDescription()
                 break;
 
             case VER_PLATFORM_WIN32_WINDOWS:
-                str.Printf(_("Windows 9%c"),
-                           info.dwMinorVersion == 0 ? _T('5') : _T('8'));
+                switch (info.dwMinorVersion)
+                {
+                    case 0:
+                        if ( info.szCSDVersion[1] == 'B' ||
+                             info.szCSDVersion[1] == 'C' )
+                        {
+                            str = _("Windows 95 OSR2");
+                        }
+                        else
+                        {
+                            str = _("Windows 95");
+                        }
+                        break;
+                    case 10:
+                        if ( info.szCSDVersion[1] == 'B' ||
+                             info.szCSDVersion[1] == 'C' )
+                        {
+                            str = _("Windows 98 SE");
+                        }
+                        else
+                        {
+                            str = _("Windows 98");
+                        }
+                        break;
+                    case 90:
+                        str = _("Windows ME");
+                        break;
+                    default:
+                        str.Printf(_("Windows 9x (%d.%d)"),
+                                   info.dwMajorVersion,
+                                   info.dwMinorVersion);
+                        break;
+                }
                 if ( !wxIsEmpty(info.szCSDVersion) )
                 {
                     str << _T(" (") << info.szCSDVersion << _T(')');
@@ -946,10 +977,31 @@ wxString wxGetOsDescription()
                 break;
 
             case VER_PLATFORM_WIN32_NT:
-                str.Printf(_T("Windows NT %lu.%lu (build %lu"),
+                if ( info.dwMajorVersion == 5 )
+                {
+                    switch ( info.dwMinorVersion )
+                    {
+                        case 0:
+                            str.Printf(_("Windows 2000 (build %lu"),
+                                       info.dwBuildNumber);
+                            break;
+                        case 1:
+                            str.Printf(_("Windows XP (build %lu"),
+                                       info.dwBuildNumber);
+                            break;
+                        case 2:
+                            str.Printf(_("Windows Server 2003 (build %lu"),
+                                       info.dwBuildNumber);
+                            break;
+                    }
+                }
+                if ( wxIsEmpty(str) )
+                {
+                    str.Printf(_("Windows NT %lu.%lu (build %lu"),
                            info.dwMajorVersion,
                            info.dwMinorVersion,
                            info.dwBuildNumber);
+                }
                 if ( !wxIsEmpty(info.szCSDVersion) )
                 {
                     str << _T(", ") << info.szCSDVersion;
index 0b03067e58be7a6ce950af1cc77e6937d9ca2acb..d77d5891bd9ff4f4dde7851ccdfbe2783cde8f0b 100644 (file)
@@ -92,11 +92,24 @@ wxToolkitInfo& wxConsoleAppTraits::GetToolkitInfo()
 {
     static wxToolkitInfo info;
     int major, minor;
-    char name[256];
 
-    if ( sscanf(WXWIN_OS_DESCRIPTION, "%255s %d.%d", name, &major, &minor) != 3 )
+    FILE *f = popen("uname -r", "r");
+    if (f)
     {
-        // unreckognized uname string format
+        char buf[32];
+        size_t c = fread(buf, 1, sizeof(buf) - 1, f);
+        pclose(f);
+        buf[c] = '\0';
+        if ( sscanf(buf, "%d.%d", &major, &minor) != 2 )
+        {
+            // unrecognized uname string format
+            major =
+            minor = -1;
+        }
+    }
+    else
+    {
+        // failed to run uname
         major =
         minor = -1;
     }
index 6169570d98c6a47701e4dc55a329c4bf56373e57..4386411aa4bbdce254b18782f80725e11dc3d638 100644 (file)
@@ -837,11 +837,20 @@ bool wxGetUserName(wxChar *buf, int sz)
 
 wxString wxGetOsDescription()
 {
-#ifndef WXWIN_OS_DESCRIPTION
-    #error WXWIN_OS_DESCRIPTION should be defined in config.h by configure
-#else
-    return wxString::FromAscii( WXWIN_OS_DESCRIPTION );
-#endif
+    FILE *f = popen("uname -s -r -m", "r");
+    if (f)
+    {
+        char buf[256];
+        size_t c = fread(buf, 1, sizeof(buf) - 1, f);
+        pclose(f);
+        // Trim newline from output.
+        if (c && buf[c - 1] == '\n')
+            --c;
+        buf[c] = '\0';
+        return wxString::FromAscii( buf );
+    }
+    wxFAIL_MSG( _T("uname failed") );
+    return _T("");
 }
 
 #endif // !__WXMAC__