VirtualBox

Changeset 53328 in vbox


Ignore:
Timestamp:
Nov 14, 2014 2:02:43 PM (10 years ago)
Author:
vboxsync
Message:

FE/Qt: 7456: Global properties: Network page: Port-forwarding sub-dialog: Make sure validation takes into account conflicting rules.

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

Legend:

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

    r53291 r53328  
    11171117          tr("The current port forwarding rules are not valid. "
    11181118             "Rule names should be unique."));
     1119    return false;
     1120}
     1121
     1122bool UIMessageCenter::warnAboutRulesConflict(QWidget *pParent /* = 0 */) const
     1123{
     1124    alert(pParent, MessageType_Error,
     1125          tr("The current port forwarding rules are not valid. "
     1126             "Few rules have same host ports and conflicting IP addresses."));
    11191127    return false;
    11201128}
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h

    r53291 r53328  
    232232    bool warnAboutIncorrectPort(QWidget *pParent = 0) const;
    233233    bool warnAboutNameShouldBeUnique(QWidget *pParent = 0) const;
     234    bool warnAboutRulesConflict(QWidget *pParent = 0) const;
    234235    bool confirmCancelingPortForwardingDialog(QWidget *pParent = 0) const;
    235236    void cannotCreateSharedFolder(const CMachine &machine, const QString &strName, const QString &strPath, QWidget *pParent = 0);
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPortForwardingTable.cpp

    r53295 r53328  
    3030# include <QLineEdit>
    3131# include <QSpinBox>
     32# include <QHostAddress>
    3233
    3334/* GUI includes: */
     
    692693    /* Validate table: */
    693694    QSet<QString> usedNames;
     695    QMap<int, QString> rules;
    694696    for (int i = 0; i < m_pModel->rowCount(); ++i)
    695697    {
     
    705707        else
    706708            return msgCenter().warnAboutNameShouldBeUnique(window());
     709
     710        /* Make sure rules are not in conflict: */
     711        const ushort iHostPort = m_pModel->data(m_pModel->index(i, UIPortForwardingModel::UIPortForwardingDataType_HostPort), Qt::EditRole).value<PortData>().value();
     712        const QString strHostAddressNew = m_pModel->data(m_pModel->index(i, UIPortForwardingModel::UIPortForwardingDataType_HostIp), Qt::EditRole).value<IpData>();
     713        if (rules.contains(iHostPort))
     714        {
     715            const QString strHostAddressOld = rules.value(iHostPort);
     716            if (   strHostAddressNew == strHostAddressOld
     717                || strHostAddressNew.isEmpty() || QHostAddress(strHostAddressNew).isNull()
     718                || strHostAddressOld.isEmpty() || QHostAddress(strHostAddressOld).isNull())
     719                return msgCenter().warnAboutRulesConflict(window());
     720        }
     721        else
     722            rules[iHostPort] = strHostAddressNew;
    707723    }
    708724    /* True by default: */
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