VirtualBox

Changeset 41613 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jun 7, 2012 2:07:55 PM (13 years ago)
Author:
vboxsync
Message:

FE/Qt: VBoxGlobal stuff: Move some local stuff out of VBoxGlobal.

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r41610 r41613  
    5757#include "QIMessageBox.h"
    5858#include "QIDialogButtonBox.h"
    59 #include "QIProcess.h"
    6059#include "UIIconPool.h"
    6160#include "UIActionPoolSelector.h"
     
    18771876
    18781877    return QString (sTableTpl). arg (report);
    1879 }
    1880 
    1881 QString VBoxGlobal::platformInfo()
    1882 {
    1883     QString platform;
    1884 
    1885 #if defined (Q_OS_WIN)
    1886     platform = "win";
    1887 #elif defined (Q_OS_LINUX)
    1888     platform = "linux";
    1889 #elif defined (Q_OS_MACX)
    1890     platform = "macosx";
    1891 #elif defined (Q_OS_OS2)
    1892     platform = "os2";
    1893 #elif defined (Q_OS_FREEBSD)
    1894     platform = "freebsd";
    1895 #elif defined (Q_OS_SOLARIS)
    1896     platform = "solaris";
    1897 #else
    1898     platform = "unknown";
    1899 #endif
    1900 
    1901     /* The format is <system>.<bitness> */
    1902     platform += QString (".%1").arg (ARCH_BITS);
    1903 
    1904     /* Add more system information */
    1905 #if defined (Q_OS_WIN)
    1906     OSVERSIONINFO versionInfo;
    1907     ZeroMemory (&versionInfo, sizeof (OSVERSIONINFO));
    1908     versionInfo.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
    1909     GetVersionEx (&versionInfo);
    1910     int major = versionInfo.dwMajorVersion;
    1911     int minor = versionInfo.dwMinorVersion;
    1912     int build = versionInfo.dwBuildNumber;
    1913     QString sp = QString::fromUtf16 ((ushort*)versionInfo.szCSDVersion);
    1914 
    1915     QString distrib;
    1916     if (major == 6)
    1917         distrib = QString ("Windows Vista %1");
    1918     else if (major == 5)
    1919     {
    1920         if (minor == 2)
    1921             distrib = QString ("Windows Server 2003 %1");
    1922         else if (minor == 1)
    1923             distrib = QString ("Windows XP %1");
    1924         else if (minor == 0)
    1925             distrib = QString ("Windows 2000 %1");
    1926         else
    1927             distrib = QString ("Unknown %1");
    1928     }
    1929     else if (major == 4)
    1930     {
    1931         if (minor == 90)
    1932             distrib = QString ("Windows Me %1");
    1933         else if (minor == 10)
    1934             distrib = QString ("Windows 98 %1");
    1935         else if (minor == 0)
    1936             distrib = QString ("Windows 95 %1");
    1937         else
    1938             distrib = QString ("Unknown %1");
    1939     }
    1940     else /** @todo Windows Server 2008 == vista? Probably not... */
    1941         distrib = QString ("Unknown %1");
    1942     distrib = distrib.arg (sp);
    1943     QString version = QString ("%1.%2").arg (major).arg (minor);
    1944     QString kernel = QString ("%1").arg (build);
    1945     platform += QString (" [Distribution: %1 | Version: %2 | Build: %3]")
    1946         .arg (distrib).arg (version).arg (kernel);
    1947 #elif defined (Q_OS_LINUX)
    1948     /* Get script path: */
    1949     char szAppPrivPath[RTPATH_MAX];
    1950     int rc = RTPathAppPrivateNoArch(szAppPrivPath, sizeof(szAppPrivPath)); NOREF(rc);
    1951     AssertRC(rc);
    1952     /* Run script: */
    1953     QByteArray result = QIProcess::singleShot(QString(szAppPrivPath) + "/VBoxSysInfo.sh");
    1954     if (!result.isNull())
    1955         platform += QString(" [%1]").arg(QString(result).trimmed());
    1956 #else
    1957     /* Use RTSystemQueryOSInfo. */
    1958     char szTmp[256];
    1959     QStringList components;
    1960     int vrc = RTSystemQueryOSInfo (RTSYSOSINFO_PRODUCT, szTmp, sizeof (szTmp));
    1961     if ((RT_SUCCESS (vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
    1962         components << QString ("Product: %1").arg (szTmp);
    1963     vrc = RTSystemQueryOSInfo (RTSYSOSINFO_RELEASE, szTmp, sizeof (szTmp));
    1964     if ((RT_SUCCESS (vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
    1965         components << QString ("Release: %1").arg (szTmp);
    1966     vrc = RTSystemQueryOSInfo (RTSYSOSINFO_VERSION, szTmp, sizeof (szTmp));
    1967     if ((RT_SUCCESS (vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
    1968         components << QString ("Version: %1").arg (szTmp);
    1969     vrc = RTSystemQueryOSInfo (RTSYSOSINFO_SERVICE_PACK, szTmp, sizeof (szTmp));
    1970     if ((RT_SUCCESS (vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
    1971         components << QString ("SP: %1").arg (szTmp);
    1972     if (!components.isEmpty())
    1973         platform += QString (" [%1]").arg (components.join (" | "));
    1974 #endif
    1975 
    1976     return platform;
    19771878}
    19781879
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r41610 r41613  
    256256    QString detailsReport (const CMachine &aMachine, bool aWithLinks);
    257257
    258     QString platformInfo();
    259 
    260258    /* VirtualBox helpers */
    261259
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp

    r41587 r41613  
    3636#include "UIGlobalSettingsExtension.h"
    3737#include "VBoxDefs.h"
     38#include "QIProcess.h"
    3839
    3940/* COM includes: */
    4041#include "CExtPack.h"
    4142#include "CExtPackManager.h"
     43
     44/* Other VBox includes: */
     45#include <iprt/path.h>
    4246
    4347/* Forward declarations: */
     
    189193        url.addQueryItem("count", QString::number(cCount));
    190194        url.addQueryItem("branch", VBoxUpdateData(vboxGlobal().virtualBox().GetExtraData(VBoxDefs::GUI_UpdateDate)).branchName());
    191         QString strUserAgent(QString("VirtualBox %1 <%2>").arg(vboxGlobal().virtualBox().GetVersion()).arg(vboxGlobal().platformInfo()));
     195        QString strUserAgent(QString("VirtualBox %1 <%2>").arg(vboxGlobal().virtualBox().GetVersion()).arg(platformInfo()));
    192196
    193197        /* Send GET request: */
     
    237241        /* Notify about step completion: */
    238242        emit sigStepComplete();
     243    }
     244
     245    /* Platform information getter: */
     246    static QString platformInfo()
     247    {
     248        /* Prepare platform report: */
     249        QString strPlatform;
     250
     251#if defined (Q_OS_WIN)
     252        strPlatform = "win";
     253#elif defined (Q_OS_LINUX)
     254        strPlatform = "linux";
     255#elif defined (Q_OS_MACX)
     256        strPlatform = "macosx";
     257#elif defined (Q_OS_OS2)
     258        strPlatform = "os2";
     259#elif defined (Q_OS_FREEBSD)
     260        strPlatform = "freebsd";
     261#elif defined (Q_OS_SOLARIS)
     262        strPlatform = "solaris";
     263#else
     264        strPlatform = "unknown";
     265#endif
     266
     267        /* The format is <system>.<bitness>: */
     268        strPlatform += QString(".%1").arg(ARCH_BITS);
     269
     270        /* Add more system information: */
     271#if defined (Q_OS_WIN)
     272        OSVERSIONINFO versionInfo;
     273        ZeroMemory(&versionInfo, sizeof(OSVERSIONINFO));
     274        versionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
     275        GetVersionEx(&versionInfo);
     276        int iMajor = versionInfo.dwMajorVersion;
     277        int iMinor = versionInfo.dwMinorVersion;
     278        int iBuild = versionInfo.dwBuildNumber;
     279        QString strVersionInfo = QString::fromUtf16((ushort*)versionInfo.szCSDVersion);
     280
     281        QString strDistributiveInfo;
     282        if (iMajor == 6)
     283            strDistributiveInfo = QString("Windows Vista %1");
     284        else if (iMajor == 5)
     285        {
     286            if (iMinor == 2)
     287                strDistributiveInfo = QString("Windows Server 2003 %1");
     288            else if (iMinor == 1)
     289                strDistributiveInfo = QString("Windows XP %1");
     290            else if (iMinor == 0)
     291                strDistributiveInfo = QString("Windows 2000 %1");
     292            else
     293                strDistributiveInfo = QString("Unknown %1");
     294        }
     295        else if (iMajor == 4)
     296        {
     297            if (iMinor == 90)
     298                strDistributiveInfo = QString("Windows Me %1");
     299            else if (iMinor == 10)
     300                strDistributiveInfo = QString("Windows 98 %1");
     301            else if (iMinor == 0)
     302                strDistributiveInfo = QString("Windows 95 %1");
     303            else
     304                strDistributiveInfo = QString("Unknown %1");
     305        }
     306        else strDistributiveInfo = QString("Unknown %1");
     307        // TODO: Windows Server 2008 == Vista? */
     308        strDistributiveInfo = strDistributiveInfo.arg(strVersionInfo);
     309        QString strVersion = QString("%1.%2").arg(iMajor).arg(iMinor);
     310        QString strKernel = QString("%1").arg(iBuild);
     311        strPlatform += QString(" [Distribution: %1 | Version: %2 | Build: %3]")
     312            .arg(strDistributiveInfo).arg(strVersion).arg(strKernel);
     313#elif defined (Q_OS_LINUX)
     314        /* Get script path: */
     315        char szAppPrivPath[RTPATH_MAX];
     316        int rc = RTPathAppPrivateNoArch(szAppPrivPath, sizeof(szAppPrivPath)); NOREF(rc);
     317        AssertRC(rc);
     318        /* Run script: */
     319        QByteArray result = QIProcess::singleShot(QString(szAppPrivPath) + "/VBoxSysInfo.sh");
     320        if (!result.isNull())
     321            strPlatform += QString(" [%1]").arg(QString(result).trimmed());
     322#else
     323        /* Use RTSystemQueryOSInfo: */
     324        char szTmp[256];
     325        QStringList components;
     326        int vrc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szTmp, sizeof(szTmp));
     327        if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
     328            components << QString("Product: %1").arg(szTmp);
     329        vrc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szTmp, sizeof(szTmp));
     330        if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
     331            components << QString("Release: %1").arg(szTmp);
     332        vrc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szTmp, sizeof(szTmp));
     333        if ((RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
     334            components << QString("Version: %1").arg(szTmp);
     335        vrc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szTmp, sizeof(szTmp));
     336        if ((RT_SUCCESS (vrc) || vrc == VERR_BUFFER_OVERFLOW) && szTmp[0] != '\0')
     337            components << QString("SP: %1").arg(szTmp);
     338        if (!components.isEmpty())
     339            strPlatform += QString(" [%1]").arg(components.join(" | "));
     340#endif
     341
     342        return strPlatform;
    239343    }
    240344
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette