VirtualBox

Changeset 4572 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 6, 2007 1:47:22 PM (17 years ago)
Author:
vboxsync
Message:

2292: Remove license display from .deb:
License Viewer implemented:

  1. If the GUI/LicenseAgreed flag is not presented in the user's VirtualBox.xml configuration file extra-data (or this flag's value is not equal to LicenseX-Y.html file version X-Y) then license file LicenseX-Y.html will be displayed to the user.
  2. If the file in LicenseX-Y.html format (for example, License1-3.html) is not presented in RTPathAppDocs() directory then the error-box will be displayed and application will exit (this will force the user to respect the license in case of license file is not found due to user simple removed this file).
  3. If the user read the license (at least scrolls the license-view to the end) and agreed it then the license viewer will be closed and will never bother the user until another license file with higher license version appears in RTPathAppDocs() directory (for example, License1-4.html).

NOTE: Feature temporary disabled due to License1-3.html file is not defaultly generated to RTPathAppDocs() directory yet.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk

    r4500 r4572  
    8282# Sources containing local definitions of classes that use the Q_OBJECT macro
    8383VirtualBox_QT_MOCSRCS = src/VBoxSelectorWnd.cpp
     84ifeq ($(BUILD_TARGET),linux)
     85VirtualBox_QT_MOCSRCS += src/VBoxGlobal.cpp
     86endif
    8487ifdef VBOX_WITH_XPCOM
    8588VirtualBox_QT_MOCSRCS += src/COMDefs.cpp
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxDefs.h

    r4202 r4572  
    160160    static const char* GUI_SuppressMessages;
    161161    static const char* GUI_PermanentSharedFoldersAtRuntime;
     162#ifdef Q_WS_X11
     163    static const char* GUI_LicenseKey;
     164#endif
    162165};
    163166
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r4354 r4572  
    363363
    364364    /* VirtualBox helpers */
     365
     366#ifdef Q_WS_X11
     367    bool showVirtualBoxLicense();
     368#endif
    365369
    366370    CSession openSession (const QUuid &id);
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxProblemReporter.h

    r4331 r4572  
    8585    // problem handlers
    8686
     87#ifdef Q_WS_X11
     88    void cannotFindLicenseFiles (const QString &aPath);
     89    void cannotOpenLicenseFile (QWidget *aParent, const QString &aPath);
     90#endif
     91
    8792    void cannotOpenURL (const QString &aURL);
    8893
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxDefs.cpp

    r4071 r4572  
    2929const char* VBoxDefs::GUI_SuppressMessages = "GUI/SuppressMessages";
    3030const char* VBoxDefs::GUI_PermanentSharedFoldersAtRuntime = "GUI/PermanentSharedFoldersAtRuntime";
     31#ifdef Q_WS_X11
     32const char* VBoxDefs::GUI_LicenseKey = "GUI/LicenseAgreed";
     33#endif
    3134
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r4459 r4572  
    3333#include <qimage.h>
    3434#include <qlabel.h>
     35
     36#ifdef Q_WS_X11
     37#include <qtextbrowser.h>
     38#include <qpushbutton.h>
     39#include <qlayout.h>
     40#endif
    3541
    3642#include <qfileinfo.h>
     
    491497#endif /* Q_WS_WIN */
    492498
     499#ifdef Q_WS_X11
     500/**
     501 *  This class is used to show a user license under linux.
     502 */
     503class VBoxLicenseViewer : public QDialog
     504{
     505    Q_OBJECT
     506
     507public:
     508
     509    VBoxLicenseViewer (const QString &aFilePath)
     510        : QDialog (0, "VBoxLicenseViewerObject")
     511        , mFilePath (aFilePath)
     512        , mLicenseText (0), mAgreeButton (0), mDisagreeButton (0)
     513    {
     514        setCaption ("VirtualBox License");
     515        setIcon (QPixmap::fromMimeSource ("ico40x01.png"));
     516
     517        mLicenseText = new QTextBrowser (this);
     518        mAgreeButton = new QPushButton (tr ("I &Agree"), this);
     519        mDisagreeButton = new QPushButton (tr ("I &Disagree"), this);
     520
     521        mLicenseText->setTextFormat (Qt::RichText);
     522        mAgreeButton->setEnabled (false);
     523        mDisagreeButton->setEnabled (false);
     524
     525        connect (mLicenseText->verticalScrollBar(), SIGNAL (valueChanged (int)),
     526                 SLOT (onScrollBarMoving (int)));
     527        connect (mAgreeButton, SIGNAL (clicked()), SLOT (accept()));
     528        connect (mDisagreeButton, SIGNAL (clicked()), SLOT (reject()));
     529
     530        QVBoxLayout *mainLayout = new QVBoxLayout (this, 10, 10);
     531        mainLayout->addWidget (mLicenseText);
     532
     533        QHBoxLayout *buttonLayout = new QHBoxLayout (mainLayout, 10);
     534        buttonLayout->addItem (new QSpacerItem (0, 0, QSizePolicy::Expanding,
     535                                                      QSizePolicy::Preferred));
     536        buttonLayout->addWidget (mAgreeButton);
     537        buttonLayout->addWidget (mDisagreeButton);
     538
     539        resize (600, 450);
     540    }
     541
     542public slots:
     543
     544    int exec()
     545    {
     546        /* read & show the license file */
     547        QFile file (mFilePath);
     548        if (file.open (IO_ReadOnly))
     549        {
     550            mLicenseText->setText (file.readAll());
     551            return QDialog::exec();
     552        }
     553        else
     554        {
     555            vboxProblem().cannotOpenLicenseFile (this, mFilePath);
     556            return QDialog::Rejected;
     557        }
     558    }
     559
     560private slots:
     561
     562    void onScrollBarMoving (int aValue)
     563    {
     564        if (aValue == mLicenseText->verticalScrollBar()->maxValue())
     565        {
     566            mAgreeButton->setEnabled (true);
     567            mDisagreeButton->setEnabled (true);
     568        }
     569    }
     570
     571private:
     572
     573    QString       mFilePath;
     574    QTextBrowser *mLicenseText;
     575    QPushButton  *mAgreeButton;
     576    QPushButton  *mDisagreeButton;
     577};
     578#endif
     579
     580
    493581// VBoxGlobal
    494582////////////////////////////////////////////////////////////////////////////////
     
    831919    const ulong IOBase;
    832920}
    833 kKnownPorts[] = 
     921kKnownPorts[] =
    834922{
    835923    { "COM1", 4, 0x3F8 },
     
    841929};
    842930
    843 /** 
     931/**
    844932 *  Returns the list of the standard COM port names (i.e. "COMx").
    845933 */
     
    853941}
    854942
    855 /** 
     943/**
    856944 *  Returns the name of the standard COM port corresponding to the given
    857945 *  parameters, or "User-defined" (which is also returned when both
     
    868956}
    869957
    870 /** 
     958/**
    871959 *  Returns port parameters corresponding to the given standard COM name.
    872960 *  Returns @c true on success, or @c false if the given port name is not one
     
    13851473                            .arg (vboxGlobal().toString (mode))
    13861474                            .arg (QDir::convertSeparators (port.GetPath()));
    1387                     else 
     1475                    else
    13881476                        data += toString (mode);
    13891477
     
    14911579    return QString (sTableTpl). arg (detailsReport);
    14921580}
     1581
     1582#ifdef Q_WS_X11
     1583bool VBoxGlobal::showVirtualBoxLicense()
     1584{
     1585    /* get the apps doc path */
     1586    int size = 256;
     1587    char *buffer = (char*) malloc (size);
     1588    RTPathAppDocs (buffer, size);
     1589    QString path (buffer);
     1590    free (buffer);
     1591    QDir docDir (path);
     1592    docDir.setFilter (QDir::Files);
     1593    docDir.setNameFilter ("License*-*.html");
     1594
     1595    /* get the license files list and search for the latest license */
     1596    QStringList filesList = docDir.entryList();
     1597    double maxVersionNumber = 0;
     1598    for (uint index = 0; index < filesList.count(); ++ index)
     1599    {
     1600        QRegExp regExp ("License([\\d]+-[\\d]+).html");
     1601        regExp.search (filesList [index]);
     1602        QString version = regExp.cap (1);
     1603        version = version.replace ("-", ".");
     1604        if (maxVersionNumber < version.toDouble())
     1605            maxVersionNumber = version.toDouble();
     1606    }
     1607    if (!maxVersionNumber)
     1608    {
     1609        vboxProblem().cannotFindLicenseFiles (path);
     1610        return false;
     1611    }
     1612
     1613    /* compose the latest license file full path */
     1614    QString latestVersion = QString::number (maxVersionNumber);
     1615    latestVersion = latestVersion.replace (".", "-");
     1616    QString latestFilePath = docDir.absFilePath (
     1617        QString ("License%1.html").arg (latestVersion));
     1618
     1619    /* check for the agreed license version */
     1620    QString licenseAgreed = virtualBox().GetExtraData (VBoxDefs::GUI_LicenseKey);
     1621    if (licenseAgreed == latestVersion)
     1622        return true;
     1623
     1624    VBoxLicenseViewer licenseDialog (latestFilePath);
     1625    bool result = licenseDialog.exec() == QDialog::Accepted;
     1626    if (result)
     1627        virtualBox().SetExtraData (VBoxDefs::GUI_LicenseKey, latestVersion);
     1628    return result;
     1629}
     1630#endif
    14931631
    14941632/**
     
    37213859}
    37223860
     3861#ifdef Q_WS_X11
     3862#include "VBoxGlobal.moc"
     3863#endif
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxProblemReporter.cpp

    r4482 r4572  
    450450/////////////////////////////////////////////////////////////////////////////
    451451
     452#ifdef Q_WS_X11
     453void VBoxProblemReporter::cannotFindLicenseFiles (const QString &aPath)
     454{
     455    message
     456        (0, VBoxProblemReporter::Error,
     457         tr ("Failed to find any license file in "
     458             "<nobr><b>%1</b></nobr> path.")
     459             .arg (aPath));
     460}
     461
     462void VBoxProblemReporter::cannotOpenLicenseFile (QWidget *aParent,
     463                                                 const QString &aPath)
     464{
     465    message
     466        (aParent, VBoxProblemReporter::Error,
     467         tr ("Failed to open license file <nobr><b>%1</b></nobr>. "
     468             "Check the file presence and read-permissions.")
     469             .arg (aPath));
     470}
     471#endif
     472
    452473void VBoxProblemReporter::cannotOpenURL (const QString &aURL)
    453474{
     
    16011622}
    16021623
    1603 /** 
     1624/**
    16041625 *  Returns @c true if the user has selected to power off the machine.
    16051626 */
  • trunk/src/VBox/Frontends/VirtualBox/src/main.cpp

    r4071 r4572  
    190190    if (vboxGlobal().isValid())
    191191    {
     192#ifdef Q_WS_X11
     193        /* show the user license file */
     194        //if (!vboxGlobal().showVirtualBoxLicense())
     195        //    return rc;
     196#endif
     197
    192198        VBoxGlobalSettings settings = vboxGlobal().settings();
    193199        /* Process known keys */
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