Changeset 87305 in vbox
- Timestamp:
- Jan 19, 2021 9:56:36 AM (4 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/networkmanager
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetNATNetwork.cpp
r87297 r87305 79 79 } 80 80 81 void UIDetailsWidgetNATNetwork::updateButtonStates() 82 { 83 // if (m_oldData != m_newData) 84 // printf("Network: %d, %s, %s, %d, %d, %d\n", 85 // m_newData.m_fEnabled, 86 // m_newData.m_strName.toUtf8().constData(), 87 // m_newData.m_strCIDR.toUtf8().constData(), 88 // m_newData.m_fSupportsDHCP, 89 // m_newData.m_fSupportsIPv6, 90 // m_newData.m_fAdvertiseDefaultIPv6Route); 91 92 /* Update 'Apply' / 'Reset' button states: */ 93 if (m_pButtonBoxOptions) 94 { 95 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData); 96 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData); 97 } 98 if (m_pButtonBoxForwarding) 99 { 100 m_pButtonBoxForwarding->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData); 101 m_pButtonBoxForwarding->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData); 102 } 103 104 /* Notify listeners as well: */ 105 emit sigDataChanged(m_oldData != m_newData); 106 } 107 81 108 void UIDetailsWidgetNATNetwork::retranslateUi() 82 109 { … … 499 526 m_fHoldPosition = false; 500 527 } 501 502 void UIDetailsWidgetNATNetwork::updateButtonStates()503 {504 // if (m_oldData != m_newData)505 // printf("Network: %d, %s, %s, %d, %d, %d\n",506 // m_newData.m_fEnabled,507 // m_newData.m_strName.toUtf8().constData(),508 // m_newData.m_strCIDR.toUtf8().constData(),509 // m_newData.m_fSupportsDHCP,510 // m_newData.m_fSupportsIPv6,511 // m_newData.m_fAdvertiseDefaultIPv6Route);512 513 /* Update 'Apply' / 'Reset' button states: */514 if (m_pButtonBoxOptions)515 {516 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);517 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);518 }519 if (m_pButtonBoxForwarding)520 {521 m_pButtonBoxForwarding->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);522 m_pButtonBoxForwarding->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);523 }524 525 /* Notify listeners as well: */526 emit sigDataChanged(m_oldData != m_newData);527 } -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetNATNetwork.h
r87297 r87305 125 125 void setData(const UIDataNATNetwork &data, bool fHoldPosition = false); 126 126 127 /** Revalidates changes. */ 128 bool revalidate(); 127 /** @name Change handling stuff. 128 * @{ */ 129 /** Revalidates changes. */ 130 bool revalidate(); 131 132 /** Updates button states. */ 133 void updateButtonStates(); 134 /** @} */ 129 135 130 136 protected: … … 181 187 /** Loads 'Forwarding' data. */ 182 188 void loadDataForForwarding(); 183 /** @} */184 185 /** @name Change handling stuff.186 * @{ */187 /** Updates button states. */188 void updateButtonStates();189 189 /** @} */ 190 190 -
trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UINetworkManager.cpp
r87297 r87305 1056 1056 /* Update actions availability: */ 1057 1057 m_pActionPool->action(UIActionIndexMN_M_Network_S_Remove)->setEnabled(pItem); 1058 m_pActionPool->action(UIActionIndexMN_M_Network_T_Details)->setEnabled(pItem);1059 1058 1060 1059 /* Check NAT network details-widget: */ … … 1108 1107 1109 1108 /* Revalidate NAT network details: */ 1110 if (!m_pDetailsWidgetNATNetwork->revalidate()) 1111 return; 1112 1113 /* Get item data: */ 1114 UIDataNATNetwork oldData = *pItem; 1115 UIDataNATNetwork newData = m_pDetailsWidgetNATNetwork->data(); 1116 1117 /* Get VirtualBox for further activities: */ 1118 CVirtualBox comVBox = uiCommon().virtualBox(); 1119 1120 /* Find corresponding network: */ 1121 CNATNetwork comNetwork = comVBox.FindNATNetworkByName(oldData.m_strName); 1122 1123 /* Show error message if necessary: */ 1124 if (!comVBox.isOk() || comNetwork.isNull()) 1125 msgCenter().cannotFindNATNetwork(comVBox, oldData.m_strName, this); 1126 else 1127 { 1128 /* Save whether NAT network is enabled: */ 1129 if (comNetwork.isOk() && newData.m_fEnabled != oldData.m_fEnabled) 1130 comNetwork.SetEnabled(newData.m_fEnabled); 1131 /* Save NAT network name: */ 1132 if (comNetwork.isOk() && newData.m_strName != oldData.m_strName) 1133 comNetwork.SetNetworkName(newData.m_strName); 1134 /* Save NAT network CIDR: */ 1135 if (comNetwork.isOk() && newData.m_strCIDR != oldData.m_strCIDR) 1136 comNetwork.SetNetwork(newData.m_strCIDR); 1137 /* Save whether NAT network needs DHCP server: */ 1138 if (comNetwork.isOk() && newData.m_fSupportsDHCP != oldData.m_fSupportsDHCP) 1139 comNetwork.SetNeedDhcpServer(newData.m_fSupportsDHCP); 1140 /* Save whether NAT network supports IPv6: */ 1141 if (comNetwork.isOk() && newData.m_fSupportsIPv6 != oldData.m_fSupportsIPv6) 1142 comNetwork.SetIPv6Enabled(newData.m_fSupportsIPv6); 1143 /* Save whether NAT network should advertise default IPv6 route: */ 1144 if (comNetwork.isOk() && newData.m_fAdvertiseDefaultIPv6Route != oldData.m_fAdvertiseDefaultIPv6Route) 1145 comNetwork.SetAdvertiseDefaultIPv6RouteEnabled(newData.m_fAdvertiseDefaultIPv6Route); 1146 1147 /* Save IPv4 forwarding rules: */ 1148 if (comNetwork.isOk() && newData.m_rules4 != oldData.m_rules4) 1149 { 1150 UIPortForwardingDataList oldRules = oldData.m_rules4; 1151 1152 /* Remove rules to be removed: */ 1153 foreach (const UIDataPortForwardingRule &oldRule, oldData.m_rules4) 1154 if (comNetwork.isOk() && !newData.m_rules4.contains(oldRule)) 1155 { 1156 comNetwork.RemovePortForwardRule(false /* IPv6? */, oldRule.name); 1157 oldRules.removeAll(oldRule); 1158 } 1159 /* Add rules to be added: */ 1160 foreach (const UIDataPortForwardingRule &newRule, newData.m_rules4) 1161 if (comNetwork.isOk() && !oldRules.contains(newRule)) 1162 { 1163 comNetwork.AddPortForwardRule(false /* IPv6? */, newRule.name, newRule.protocol, 1164 newRule.hostIp, newRule.hostPort.value(), 1165 newRule.guestIp, newRule.guestPort.value()); 1166 oldRules.append(newRule); 1167 } 1168 } 1169 /* Save IPv6 forwarding rules: */ 1170 if (comNetwork.isOk() && newData.m_rules6 != oldData.m_rules6) 1171 { 1172 UIPortForwardingDataList oldRules = oldData.m_rules6; 1173 1174 /* Remove rules to be removed: */ 1175 foreach (const UIDataPortForwardingRule &oldRule, oldData.m_rules6) 1176 if (comNetwork.isOk() && !newData.m_rules6.contains(oldRule)) 1177 { 1178 comNetwork.RemovePortForwardRule(true /* IPv6? */, oldRule.name); 1179 oldRules.removeAll(oldRule); 1180 } 1181 /* Add rules to be added: */ 1182 foreach (const UIDataPortForwardingRule &newRule, newData.m_rules6) 1183 if (comNetwork.isOk() && !oldRules.contains(newRule)) 1184 { 1185 comNetwork.AddPortForwardRule(true /* IPv6? */, newRule.name, newRule.protocol, 1186 newRule.hostIp, newRule.hostPort.value(), 1187 newRule.guestIp, newRule.guestPort.value()); 1188 oldRules.append(newRule); 1189 } 1190 } 1109 if (m_pDetailsWidgetNATNetwork->revalidate()) 1110 { 1111 /* Get item data: */ 1112 UIDataNATNetwork oldData = *pItem; 1113 UIDataNATNetwork newData = m_pDetailsWidgetNATNetwork->data(); 1114 1115 /* Get VirtualBox for further activities: */ 1116 CVirtualBox comVBox = uiCommon().virtualBox(); 1117 1118 /* Find corresponding network: */ 1119 CNATNetwork comNetwork = comVBox.FindNATNetworkByName(oldData.m_strName); 1191 1120 1192 1121 /* Show error message if necessary: */ 1193 if (!com Network.isOk())1194 msgCenter().cannot SaveNATNetworkParameter(comNetwork, this);1122 if (!comVBox.isOk() || comNetwork.isNull()) 1123 msgCenter().cannotFindNATNetwork(comVBox, oldData.m_strName, this); 1195 1124 else 1196 1125 { 1126 /* Save whether NAT network is enabled: */ 1127 if (comNetwork.isOk() && newData.m_fEnabled != oldData.m_fEnabled) 1128 comNetwork.SetEnabled(newData.m_fEnabled); 1129 /* Save NAT network name: */ 1130 if (comNetwork.isOk() && newData.m_strName != oldData.m_strName) 1131 comNetwork.SetNetworkName(newData.m_strName); 1132 /* Save NAT network CIDR: */ 1133 if (comNetwork.isOk() && newData.m_strCIDR != oldData.m_strCIDR) 1134 comNetwork.SetNetwork(newData.m_strCIDR); 1135 /* Save whether NAT network needs DHCP server: */ 1136 if (comNetwork.isOk() && newData.m_fSupportsDHCP != oldData.m_fSupportsDHCP) 1137 comNetwork.SetNeedDhcpServer(newData.m_fSupportsDHCP); 1138 /* Save whether NAT network supports IPv6: */ 1139 if (comNetwork.isOk() && newData.m_fSupportsIPv6 != oldData.m_fSupportsIPv6) 1140 comNetwork.SetIPv6Enabled(newData.m_fSupportsIPv6); 1141 /* Save whether NAT network should advertise default IPv6 route: */ 1142 if (comNetwork.isOk() && newData.m_fAdvertiseDefaultIPv6Route != oldData.m_fAdvertiseDefaultIPv6Route) 1143 comNetwork.SetAdvertiseDefaultIPv6RouteEnabled(newData.m_fAdvertiseDefaultIPv6Route); 1144 1145 /* Save IPv4 forwarding rules: */ 1146 if (comNetwork.isOk() && newData.m_rules4 != oldData.m_rules4) 1147 { 1148 UIPortForwardingDataList oldRules = oldData.m_rules4; 1149 1150 /* Remove rules to be removed: */ 1151 foreach (const UIDataPortForwardingRule &oldRule, oldData.m_rules4) 1152 if (comNetwork.isOk() && !newData.m_rules4.contains(oldRule)) 1153 { 1154 comNetwork.RemovePortForwardRule(false /* IPv6? */, oldRule.name); 1155 oldRules.removeAll(oldRule); 1156 } 1157 /* Add rules to be added: */ 1158 foreach (const UIDataPortForwardingRule &newRule, newData.m_rules4) 1159 if (comNetwork.isOk() && !oldRules.contains(newRule)) 1160 { 1161 comNetwork.AddPortForwardRule(false /* IPv6? */, newRule.name, newRule.protocol, 1162 newRule.hostIp, newRule.hostPort.value(), 1163 newRule.guestIp, newRule.guestPort.value()); 1164 oldRules.append(newRule); 1165 } 1166 } 1167 /* Save IPv6 forwarding rules: */ 1168 if (comNetwork.isOk() && newData.m_rules6 != oldData.m_rules6) 1169 { 1170 UIPortForwardingDataList oldRules = oldData.m_rules6; 1171 1172 /* Remove rules to be removed: */ 1173 foreach (const UIDataPortForwardingRule &oldRule, oldData.m_rules6) 1174 if (comNetwork.isOk() && !newData.m_rules6.contains(oldRule)) 1175 { 1176 comNetwork.RemovePortForwardRule(true /* IPv6? */, oldRule.name); 1177 oldRules.removeAll(oldRule); 1178 } 1179 /* Add rules to be added: */ 1180 foreach (const UIDataPortForwardingRule &newRule, newData.m_rules6) 1181 if (comNetwork.isOk() && !oldRules.contains(newRule)) 1182 { 1183 comNetwork.AddPortForwardRule(true /* IPv6? */, newRule.name, newRule.protocol, 1184 newRule.hostIp, newRule.hostPort.value(), 1185 newRule.guestIp, newRule.guestPort.value()); 1186 oldRules.append(newRule); 1187 } 1188 } 1189 1190 /* Show error message if necessary: */ 1191 if (!comNetwork.isOk()) 1192 msgCenter().cannotSaveNATNetworkParameter(comNetwork, this); 1193 1197 1194 /* Update network in the tree: */ 1198 1195 UIDataNATNetwork data; … … 1207 1204 } 1208 1205 } 1206 1207 /* Make sure button states updated: */ 1208 m_pDetailsWidgetNATNetwork->updateButtonStates(); 1209 1209 } 1210 1210
Note:
See TracChangeset
for help on using the changeset viewer.