VirtualBox

Changeset 31533 in vbox for trunk


Ignore:
Timestamp:
Aug 10, 2010 1:08:56 PM (14 years ago)
Author:
vboxsync
Message:

FE/Qt: 1900: Create GUI support for NAT forwarding: Initial commit.

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

Legend:

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

    r30868 r31533  
    276276        src/extensions/QITabWidget.h \
    277277        src/extensions/QIToolButton.h \
     278        src/extensions/QITableView.h \
    278279        src/extensions/QITreeView.h \
    279280        src/extensions/QITreeWidget.h \
     
    296297        src/settings/vm/VBoxVMSettingsAudio.h \
    297298        src/settings/vm/VBoxVMSettingsNetwork.h \
     299        src/settings/vm/VBoxVMSettingsPortForwardingDlg.h \
    298300        src/settings/vm/VBoxVMSettingsSerial.h \
    299301        src/settings/vm/VBoxVMSettingsParallel.h \
     
    370372        src/extensions/QISplitter.cpp \
    371373        src/selector/UIVMDesktop.cpp \
     374        src/settings/vm/VBoxVMSettingsPortForwardingDlg.cpp \
    372375        src/runtime/UIActionsPool.cpp \
    373376        src/runtime/UIIndicatorsPool.cpp \
     
    429432        src/extensions/QIStateIndicator.cpp \
    430433        src/extensions/QIStatusBar.cpp \
     434        src/extensions/QITableView.cpp \
    431435        src/extensions/QITreeView.cpp \
    432436        src/extensions/QITreeWidget.cpp \
     
    448452        src/settings/vm/VBoxVMSettingsAudio.cpp \
    449453        src/settings/vm/VBoxVMSettingsNetwork.cpp \
     454        src/settings/vm/VBoxVMSettingsPortForwardingDlg.cpp \
    450455        src/settings/vm/VBoxVMSettingsSerial.cpp \
    451456        src/settings/vm/VBoxVMSettingsParallel.cpp \
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.cpp

    r31320 r31533  
    27832783        tr ("VDE Adapter", "NetworkAttachmentType");
    27842784#endif
     2785
     2786    mNATProtocolTypes [KNATProtocol_UDP] =
     2787        tr ("UDP", "NATProtocolType");
     2788    mNATProtocolTypes [KNATProtocol_TCP] =
     2789        tr ("TCP", "NATProtocolType");
    27852790
    27862791    mClipboardTypes [KClipboardMode_Disabled] =
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/VBoxGlobal.h

    r31319 r31533  
    469469    }
    470470
     471    QString toString (KNATProtocol t) const
     472    {
     473        AssertMsg (!mNATProtocolTypes.value (t).isNull(), ("No text for %d", t));
     474        return mNATProtocolTypes.value (t);
     475    }
     476
     477    KNATProtocol toNATProtocolType (const QString &s) const
     478    {
     479        QULongStringHash::const_iterator it =
     480            qFind (mNATProtocolTypes.begin(), mNATProtocolTypes.end(), s);
     481        AssertMsg (it != mNATProtocolTypes.end(), ("No value for {%s}",
     482                                                   s.toLatin1().constData()));
     483        return KNATProtocol (it.key());
     484    }
     485
    471486    QString toString (KUSBDeviceState aState) const
    472487    {
     
    784799    QULongStringHash mNetworkAdapterTypes;
    785800    QULongStringHash mNetworkAttachmentTypes;
     801    QULongStringHash mNATProtocolTypes;
    786802    QULongStringHash mClipboardTypes;
    787803    QULongStringHash mStorageControllerTypes;
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsNetwork.cpp

    r29972 r31533  
    5757    connect (mAbsAdvanced, SIGNAL (clicked()), this, SLOT (toggleAdvanced()));
    5858    connect (mTbMAC, SIGNAL (clicked()), this, SLOT (generateMac()));
     59    connect (mPbPortForwarding, SIGNAL (clicked()), this, SLOT (sltOpenPortsForwadringDlg()));
    5960
    6061#ifdef Q_WS_MAC
     
    120121    mLeMAC->setText (mAdapter.GetMACAddress());
    121122    mCbCableConnected->setChecked (mAdapter.GetCableConnected());
     123
     124    /* Load port forwarding rules: */
     125    QVector<QString> redirects = mAdapter.GetNatDriver().GetRedirects();
     126    for (int i = 0; i < redirects.size(); ++i)
     127    {
     128        QStringList redirectData = redirects[i].split(',');
     129        AssertMsg(redirectData.size() == 6, ("Redirect rule should be composed of 6 parts!\n"));
     130        mPortForwardingRules << UIPortForwardingData(redirectData[0],
     131                                                     (KNATProtocol)redirectData[1].toUInt(),
     132                                                     redirectData[2],
     133                                                     redirectData[3].toUInt(),
     134                                                     redirectData[4],
     135                                                     redirectData[5].toUInt());
     136    }
    122137}
    123138
     
    165180    mAdapter.SetMACAddress (mLeMAC->text().isEmpty() ? QString::null : mLeMAC->text());
    166181    mAdapter.SetCableConnected (mCbCableConnected->isChecked());
     182
     183    /* Save port forwarding rules: */
     184    QVector<QString> redirects = mAdapter.GetNatDriver().GetRedirects();
     185    for (int i = 0; i < redirects.size(); ++i)
     186        mAdapter.GetNatDriver().RemoveRedirect(redirects[i].section(',', 0, 0));
     187    for (int i = 0; i < mPortForwardingRules.size(); ++i)
     188    {
     189        UIPortForwardingData redirectData = mPortForwardingRules[i];
     190        mAdapter.GetNatDriver().AddRedirect(redirectData.name, redirectData.protocol,
     191                                            redirectData.hostIp, redirectData.hostPort,
     192                                            redirectData.guestIp, redirectData.guestPort);
     193    }
    167194}
    168195
     
    236263    setTabOrder (mLeMAC, mTbMAC);
    237264    setTabOrder (mTbMAC, mCbCableConnected);
    238     return mCbCableConnected;
     265    setTabOrder (mCbCableConnected, mPbPortForwarding);
     266    return mPbPortForwarding;
    239267}
    240268
     
    414442    updateAlternativeName();
    415443
     444    /* Update Forwarding rules button availability: */
     445    mPbPortForwarding->setEnabled(attachmentType() == KNetworkAttachmentType_NAT);
     446
    416447    /* Unblocking signals as content is changed already */
    417448    mCbAdapterName->blockSignals (false);
     
    488519    mTbMAC->setVisible (mAbsAdvanced->isExpanded());
    489520    mCbCableConnected->setVisible (mAbsAdvanced->isExpanded());
     521    mPbPortForwarding->setVisible (mAbsAdvanced->isExpanded());
    490522}
    491523
     
    494526    mAdapter.SetMACAddress (QString::null);
    495527    mLeMAC->setText (mAdapter.GetMACAddress());
     528}
     529
     530void VBoxVMSettingsNetwork::sltOpenPortsForwadringDlg()
     531{
     532    VBoxVMSettingsPortForwardingDlg dlg(this, mPortForwardingRules);
     533    if (dlg.exec() == QDialog::Accepted)
     534        mPortForwardingRules = dlg.rules();
    496535}
    497536
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsNetwork.h

    r29972 r31533  
    2424#include "VBoxSettingsPage.h"
    2525#include "VBoxVMSettingsNetwork.gen.h"
     26#include "VBoxVMSettingsPortForwardingDlg.h"
    2627
    2728/* VBox Forwardes */
     
    6263    void toggleAdvanced();
    6364    void generateMac();
     65    void sltOpenPortsForwadringDlg();
    6466
    6567private:
     
    8082    bool mPolished;
    8183    bool mDisableStaticControls;
     84    UIPortForwardingDataList mPortForwardingRules;
    8285};
    8386
  • trunk/src/VBox/Frontends/VirtualBox/src/settings/vm/VBoxVMSettingsNetwork.ui

    r28800 r31533  
    217217       </widget>
    218218      </item>
    219       <item row="6" column="0" colspan="4">
     219      <item row="6" column="1">
     220       <widget class="QPushButton" name="mPbPortForwarding">
     221        <property name="whatsThis">
     222         <string>Opens dialog to manage port forwarding rules.</string>
     223        </property>
     224        <property name="text">
     225         <string>&amp;Port Forwarding</string>
     226        </property>
     227       </widget>
     228      </item>
     229      <item row="7" column="0" colspan="4">
    220230       <spacer name="verticalSpacer">
    221231        <property name="orientation">
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