VirtualBox

Changeset 106149 in vbox for trunk


Ignore:
Timestamp:
Sep 25, 2024 4:32:45 PM (7 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
164928
Message:

FE/Qt: bugref:10310: VM Settings / Display page / Remote Display tab: Adding new field called Security Method to let user specify this VRDE property; This combo allows to choose among TLS, RDP and NEGOTIATE values.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/converter/UIConverterBackendGlobal.cpp

    r106061 r106149  
    4040#include "UISettingsDefs.h"
    4141#include "UITranslator.h"
     42#include "UIVRDESettingsEditor.h"
    4243#if defined(VBOX_WS_NIX) && !defined(VBOX_GUI_WITH_CUSTOMIZATIONS1)
    4344# include "UIDesktopWidgetWatchdog.h"
     
    29042905    return VMActivityOverviewColumn_Max;
    29052906}
     2907
     2908/* QString <= UIVRDESecurityMethod: */
     2909template<> SHARED_LIBRARY_STUFF QString UIConverter::toString(const UIVRDESecurityMethod &enmSecurityMethod) const
     2910{
     2911    QString strResult;
     2912    switch (enmSecurityMethod)
     2913    {
     2914        case UIVRDESecurityMethod_TLS:       strResult = QApplication::translate("UICommon", "TLS"); break;
     2915        case UIVRDESecurityMethod_RDP:       strResult = QApplication::translate("UICommon", "RDP"); break;
     2916        case UIVRDESecurityMethod_Negotiate: strResult = QApplication::translate("UICommon", "NEGOTIATE"); break;
     2917        default:
     2918        {
     2919            AssertMsgFailed(("No text for security method=%d", enmSecurityMethod));
     2920            break;
     2921        }
     2922    }
     2923    return strResult;
     2924}
     2925
     2926/* QString <= UIVRDESecurityMethod: */
     2927template<> SHARED_LIBRARY_STUFF QString UIConverter::toInternalString(const UIVRDESecurityMethod &enmSecurityMethod) const
     2928{
     2929    QString strResult;
     2930    switch (enmSecurityMethod)
     2931    {
     2932        case UIVRDESecurityMethod_TLS:       strResult = QString(); break;
     2933        case UIVRDESecurityMethod_RDP:       strResult = QString("RDP"); break;
     2934        case UIVRDESecurityMethod_Negotiate: strResult = QString("NEGOTIATE"); break;
     2935        default:
     2936        {
     2937            AssertMsgFailed(("No text for security method=%d", enmSecurityMethod));
     2938            break;
     2939        }
     2940    }
     2941    return strResult;
     2942}
     2943
     2944/* UIVRDESecurityMethod <= QString: */
     2945template<> SHARED_LIBRARY_STUFF UIVRDESecurityMethod UIConverter::fromInternalString<UIVRDESecurityMethod>(const QString &strSecurityMethod) const
     2946{
     2947    if (strSecurityMethod.compare("RDP", Qt::CaseInsensitive) == 0)
     2948        return UIVRDESecurityMethod_RDP;
     2949    if (strSecurityMethod.compare("NEGOTIATE", Qt::CaseInsensitive) == 0)
     2950        return UIVRDESecurityMethod_Negotiate;
     2951    return UIVRDESecurityMethod_TLS;
     2952}
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIVRDESettingsEditor.cpp

    r106061 r106149  
    4141    : UIEditor(pParent)
    4242    , m_fFeatureEnabled(false)
     43    , m_enmSecurityMethod(UIVRDESecurityMethod_Max)
    4344    , m_enmAuthType(KAuthType_Max)
    4445    , m_fMultipleConnectionsAllowed(false)
     
    4748    , m_pLabelPort(0)
    4849    , m_pEditorPort(0)
     50    , m_pLabelSecurityMethod(0)
     51    , m_pComboSecurityMethod(0)
    4952    , m_pLabelAuthMethod(0)
    5053    , m_pComboAuthType(0)
     
    102105}
    103106
     107void UIVRDESettingsEditor::setSecurityMethod(const UIVRDESecurityMethod &enmMethod)
     108{
     109    /* Update cached value and
     110     * combo if value has changed: */
     111    if (m_enmSecurityMethod != enmMethod)
     112    {
     113        m_enmSecurityMethod = enmMethod;
     114        repopulateComboSecurityMethod();
     115    }
     116}
     117
     118UIVRDESecurityMethod UIVRDESettingsEditor::securityMethod() const
     119{
     120    return m_pComboSecurityMethod ? m_pComboSecurityMethod->currentData().value<UIVRDESecurityMethod>() : m_enmSecurityMethod;
     121}
     122
    104123void UIVRDESettingsEditor::setAuthType(const KAuthType &enmType)
    105124{
     
    167186        m_pEditorPort->setToolTip(tr("Holds the VRDP Server port number. You may specify 0 (zero), to select port 3389, the "
    168187                                     "standard port for RDP."));
     188
     189    if (m_pLabelSecurityMethod)
     190        m_pLabelSecurityMethod->setText(tr("&Security Method:"));
     191    if (m_pComboSecurityMethod)
     192    {
     193        for (int iIndex = 0; iIndex < m_pComboSecurityMethod->count(); ++iIndex)
     194        {
     195            const UIVRDESecurityMethod enmType = m_pComboSecurityMethod->itemData(iIndex).value<UIVRDESecurityMethod>();
     196            m_pComboSecurityMethod->setItemText(iIndex, gpConverter->toString(enmType));
     197        }
     198        m_pComboSecurityMethod->setToolTip(tr("Selects the VRDP security method."));
     199    }
    169200
    170201    if (m_pLabelAuthMethod)
     
    264295                }
    265296
     297                /* Prepare 'security method' label: */
     298                m_pLabelSecurityMethod = new QLabel(m_pWidgetSettings);
     299                if (m_pLabelSecurityMethod)
     300                {
     301                    m_pLabelSecurityMethod->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
     302                    pLayoutRemoteDisplaySettings->addWidget(m_pLabelSecurityMethod, 1, 0);
     303                }
     304                /* Prepare 'security method' combo: */
     305                m_pComboSecurityMethod = new QComboBox(m_pWidgetSettings);
     306                if (m_pComboSecurityMethod)
     307                {
     308                    if (m_pLabelSecurityMethod)
     309                        m_pLabelSecurityMethod->setBuddy(m_pComboSecurityMethod);
     310                    m_pComboSecurityMethod->setSizeAdjustPolicy(QComboBox::AdjustToContents);
     311
     312                    pLayoutRemoteDisplaySettings->addWidget(m_pComboSecurityMethod, 1, 1, 1, 2);
     313                }
     314
    266315                /* Prepare 'auth type' label: */
    267316                m_pLabelAuthMethod = new QLabel(m_pWidgetSettings);
     
    269318                {
    270319                    m_pLabelAuthMethod->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    271                     pLayoutRemoteDisplaySettings->addWidget(m_pLabelAuthMethod, 1, 0);
     320                    pLayoutRemoteDisplaySettings->addWidget(m_pLabelAuthMethod, 2, 0);
    272321                }
    273322                /* Prepare 'auth type' combo: */
     
    279328                    m_pComboAuthType->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    280329
    281                     pLayoutRemoteDisplaySettings->addWidget(m_pComboAuthType, 1, 1, 1, 2);
     330                    pLayoutRemoteDisplaySettings->addWidget(m_pComboAuthType, 2, 1, 1, 2);
    282331                }
    283332
     
    287336                {
    288337                    m_pLabelTimeout->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    289                     pLayoutRemoteDisplaySettings->addWidget(m_pLabelTimeout, 2, 0);
     338                    pLayoutRemoteDisplaySettings->addWidget(m_pLabelTimeout, 3, 0);
    290339                }
    291340                /* Prepare 'timeout' editor: */
     
    297346                    m_pEditorTimeout->setValidator(new QIntValidator(this));
    298347
    299                     pLayoutRemoteDisplaySettings->addWidget(m_pEditorTimeout, 2, 1, 1, 2);
     348                    pLayoutRemoteDisplaySettings->addWidget(m_pEditorTimeout, 3, 1, 1, 2);
    300349                }
    301350
     
    305354                {
    306355                    m_pLabelOptions->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    307                     pLayoutRemoteDisplaySettings->addWidget(m_pLabelOptions, 3, 0);
     356                    pLayoutRemoteDisplaySettings->addWidget(m_pLabelOptions, 4, 0);
    308357                }
    309358                /* Prepare 'multiple connections' check-box: */
    310359                m_pCheckboxMultipleConnections = new QCheckBox(m_pWidgetSettings);
    311360                if (m_pCheckboxMultipleConnections)
    312                     pLayoutRemoteDisplaySettings->addWidget(m_pCheckboxMultipleConnections, 3, 1);
     361                    pLayoutRemoteDisplaySettings->addWidget(m_pCheckboxMultipleConnections, 4, 1);
    313362            }
    314363
     
    332381}
    333382
     383void UIVRDESettingsEditor::repopulateComboSecurityMethod()
     384{
     385    if (m_pComboSecurityMethod)
     386    {
     387        /* Clear combo first of all: */
     388        m_pComboSecurityMethod->clear();
     389
     390        QVector<UIVRDESecurityMethod> securityMethods = QVector<UIVRDESecurityMethod>() << UIVRDESecurityMethod_TLS
     391                                                                                        << UIVRDESecurityMethod_RDP
     392                                                                                        << UIVRDESecurityMethod_Negotiate;
     393
     394        /* Take into account currently cached value: */
     395        if (!securityMethods.contains(m_enmSecurityMethod))
     396            securityMethods.prepend(m_enmSecurityMethod);
     397
     398        /* Populate combo finally: */
     399        foreach (const UIVRDESecurityMethod &enmType, securityMethods)
     400            m_pComboSecurityMethod->addItem(gpConverter->toString(enmType), QVariant::fromValue(enmType));
     401
     402        /* Look for proper index to choose: */
     403        const int iIndex = m_pComboSecurityMethod->findData(QVariant::fromValue(m_enmSecurityMethod));
     404        if (iIndex != -1)
     405            m_pComboSecurityMethod->setCurrentIndex(iIndex);
     406    }
     407}
     408
    334409void UIVRDESettingsEditor::repopulateComboAuthType()
    335410{
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/editors/UIVRDESettingsEditor.h

    r106061 r106149  
    4545class QWidget;
    4646
     47/** VRDE Security Methods. */
     48enum UIVRDESecurityMethod
     49{
     50    UIVRDESecurityMethod_TLS,
     51    UIVRDESecurityMethod_RDP,
     52    UIVRDESecurityMethod_Negotiate,
     53    UIVRDESecurityMethod_Max
     54};
     55Q_DECLARE_METATYPE(UIVRDESecurityMethod);
     56
    4757/** UIEditor sub-class used as a VRDE settings editor. */
    4858class SHARED_LIBRARY_STUFF UIVRDESettingsEditor : public UIEditor
     
    7383    QString port() const;
    7484
     85    /** Defines security @a enmMethod. */
     86    void setSecurityMethod(const UIVRDESecurityMethod &enmMethod);
     87    /** Returns security method. */
     88    UIVRDESecurityMethod securityMethod() const;
     89
    7590    /** Defines auth @a enmType. */
    7691    void setAuthType(const KAuthType &enmType);
     
    87102    /** Returns whether multiple connections allowed. */
    88103    bool isMultipleConnectionsAllowed() const;
    89 
    90104
    91105private slots:
     
    106120    void prepareConnections();
    107121
     122    /** Repopulates security method combo-box. */
     123    void repopulateComboSecurityMethod();
    108124    /** Repopulates auth type combo-box. */
    109125    void repopulateComboAuthType();
     
    112128     * @{ */
    113129        /** Holds whether feature is enabled. */
    114         bool       m_fFeatureEnabled;
     130        bool                  m_fFeatureEnabled;
    115131        /** Holds the port. */
    116         QString    m_strPort;
     132        QString               m_strPort;
     133        /** Holds the security method. */
     134        UIVRDESecurityMethod  m_enmSecurityMethod;
    117135        /** Holds the auth type. */
    118         KAuthType  m_enmAuthType;
     136        KAuthType             m_enmAuthType;
    119137        /** Holds the timeout. */
    120         QString    m_strTimeout;
     138        QString               m_strTimeout;
    121139        /** Returns whether multiple connections allowed. */
    122         bool       m_fMultipleConnectionsAllowed;
     140        bool                  m_fMultipleConnectionsAllowed;
    123141    /** @} */
    124142
     
    133151        /** Holds the port editor instance. */
    134152        QLineEdit *m_pEditorPort;
    135         /** Holds the port auth method label instance. */
     153        /** Holds the security method label instance. */
     154        QLabel    *m_pLabelSecurityMethod;
     155        /** Holds the security method combo instance. */
     156        QComboBox *m_pComboSecurityMethod;
     157        /** Holds the auth method label instance. */
    136158        QLabel    *m_pLabelAuthMethod;
    137         /** Holds the port auth method combo instance. */
     159        /** Holds the auth method combo instance. */
    138160        QComboBox *m_pComboAuthType;
    139161        /** Holds the timeout label instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsDisplay.cpp

    r106074 r106149  
    7474        , m_fRemoteDisplayServerEnabled(false)
    7575        , m_strRemoteDisplayPort(QString())
     76        , m_remoteDisplaySecurityMethod(UIVRDESecurityMethod_Max)
    7677        , m_remoteDisplayAuthType(KAuthType_Null)
    7778        , m_uRemoteDisplayTimeout(0)
     
    101102               && (m_fRemoteDisplayServerEnabled == other.m_fRemoteDisplayServerEnabled)
    102103               && (m_strRemoteDisplayPort == other.m_strRemoteDisplayPort)
     104               && (m_remoteDisplaySecurityMethod == other.m_remoteDisplaySecurityMethod)
    103105               && (m_remoteDisplayAuthType == other.m_remoteDisplayAuthType)
    104106               && (m_uRemoteDisplayTimeout == other.m_uRemoteDisplayTimeout)
     
    269271    /** Holds the remote display server port. */
    270272    QString                  m_strRemoteDisplayPort;
     273    /** Holds the remote display server security method. */
     274    UIVRDESecurityMethod     m_remoteDisplaySecurityMethod;
    271275    /** Holds the remote display server auth type. */
    272276    KAuthType                m_remoteDisplayAuthType;
     
    412416        oldDisplayData.m_fRemoteDisplayServerEnabled = comVrdeServer.GetEnabled();
    413417        oldDisplayData.m_strRemoteDisplayPort = comVrdeServer.GetVRDEProperty("TCP/Ports");
     418        oldDisplayData.m_remoteDisplaySecurityMethod =
     419            gpConverter->fromInternalString<UIVRDESecurityMethod>(comVrdeServer.GetVRDEProperty("Security/Method"));
    414420        oldDisplayData.m_remoteDisplayAuthType = comVrdeServer.GetAuthType();
    415421        oldDisplayData.m_uRemoteDisplayTimeout = comVrdeServer.GetAuthTimeout();
     
    494500            m_pEditorVRDESettings->setFeatureEnabled(oldDisplayData.m_fRemoteDisplayServerEnabled);
    495501            m_pEditorVRDESettings->setPort(oldDisplayData.m_strRemoteDisplayPort);
     502            m_pEditorVRDESettings->setSecurityMethod(oldDisplayData.m_remoteDisplaySecurityMethod);
    496503            m_pEditorVRDESettings->setAuthType(oldDisplayData.m_remoteDisplayAuthType);
    497504            m_pEditorVRDESettings->setTimeout(QString::number(oldDisplayData.m_uRemoteDisplayTimeout));
     
    570577        newDisplayData.m_fRemoteDisplayServerEnabled = m_pEditorVRDESettings->isFeatureEnabled();
    571578        newDisplayData.m_strRemoteDisplayPort = m_pEditorVRDESettings->port();
     579        newDisplayData.m_remoteDisplaySecurityMethod = m_pEditorVRDESettings->securityMethod();
    572580        newDisplayData.m_remoteDisplayAuthType = m_pEditorVRDESettings->authType();
    573581        newDisplayData.m_uRemoteDisplayTimeout = m_pEditorVRDESettings->timeout().toULong();
     
    11971205            {
    11981206                comServer.SetVRDEProperty("TCP/Ports", newDisplayData.m_strRemoteDisplayPort);
     1207                fSuccess = comServer.isOk();
     1208            }
     1209            /* Save remote display server security method: */
     1210            if (fSuccess && newDisplayData.m_remoteDisplaySecurityMethod != oldDisplayData.m_remoteDisplaySecurityMethod)
     1211            {
     1212                comServer.SetVRDEProperty("Security/Method", gpConverter->toInternalString(newDisplayData.m_remoteDisplaySecurityMethod));
    11991213                fSuccess = comServer.isOk();
    12001214            }
Note: See TracChangeset for help on using the changeset viewer.

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