diff --git a/src/preferences/network/EthernetSettingsView.cpp b/src/preferences/network/EthernetSettingsView.cpp
index 0250b24..65404f0 100644
a
|
b
|
static const uint32 kMsgField = 'fild';
|
57 | 57 | static const uint32 kMsgInfo = 'info'; |
58 | 58 | static const uint32 kMsgStaticMode = 'stcm'; |
59 | 59 | static const uint32 kMsgDHCPMode = 'dynm'; |
| 60 | static const uint32 kMsgIPv4Type = 'ipv4'; |
| 61 | static const uint32 kMsgIPv6Type = 'ipv6'; |
60 | 62 | static const uint32 kMsgDisabledMode = 'disa'; |
61 | 63 | static const uint32 kMsgChange = 'chng'; |
62 | 64 | static const uint32 kMsgNetwork = 'netw'; |
… |
… |
EthernetSettingsView::EthernetSettingsView()
|
187 | 189 | layout->AddItem(fDomainTextControl->CreateLabelLayoutItem(), 0, 8); |
188 | 190 | layout->AddItem(fDomainTextControl->CreateTextViewLayoutItem(), 1, 8); |
189 | 191 | |
| 192 | BPopUpMenu* inet4Menu = new BPopUpMenu("IP type"); |
| 193 | inet4Menu->AddItem(new BMenuItem(B_TRANSLATE("IPv4 only"), |
| 194 | new BMessage(kMsgIPv4Type))); |
| 195 | inet4Menu->AddItem(new BMenuItem(B_TRANSLATE("IPv4 and IPv6"), |
| 196 | new BMessage(kMsgIPv6Type))); |
| 197 | fInet4MenuField = new BMenuField(B_TRANSLATE("IP Type:"), inet4Menu); |
| 198 | layout->AddItem(fInet4MenuField->CreateLabelLayoutItem(), 0, 9); |
| 199 | layout->AddItem(fInet4MenuField->CreateMenuBarLayoutItem(), 1, 9); |
| 200 | |
190 | 201 | fErrorMessage = new BStringView("error", ""); |
191 | 202 | fErrorMessage->SetAlignment(B_ALIGN_LEFT); |
192 | 203 | fErrorMessage->SetFont(be_bold_font); |
193 | 204 | fErrorMessage->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); |
194 | 205 | |
195 | | layout->AddView(fErrorMessage, 1, 9); |
| 206 | layout->AddView(fErrorMessage, 1, 10); |
196 | 207 | |
197 | 208 | // button group (TODO: move to window, but take care of |
198 | 209 | // enabling/disabling) |
… |
… |
EthernetSettingsView::AttachedToWindow()
|
234 | 245 | fDeviceMenuField->Menu()->SetTargetForItems(this); |
235 | 246 | fNetworkMenuField->Menu()->SetTargetForItems(this); |
236 | 247 | fTypeMenuField->Menu()->SetTargetForItems(this); |
| 248 | fInet4MenuField->Menu()->SetTargetForItems(this); |
237 | 249 | |
238 | 250 | // Display settigs of first adapter on startup, if any |
239 | 251 | _ShowConfiguration(fSettings.ItemAt(0)); |
… |
… |
EthernetSettingsView::MessageReceived(BMessage* message)
|
258 | 270 | fApplyButton->SetEnabled(true); |
259 | 271 | fRevertButton->SetEnabled(true); |
260 | 272 | break; |
| 273 | case kMsgIPv4Type: |
| 274 | case kMsgIPv6Type: |
| 275 | fApplyButton->SetEnabled(true); |
| 276 | fRevertButton->SetEnabled(true); |
| 277 | break; |
261 | 278 | case kMsgInfo: |
262 | 279 | { |
263 | 280 | const char* name; |
… |
… |
EthernetSettingsView::_ShowConfiguration(Settings* settings)
|
332 | 349 | |
333 | 350 | fDeviceMenuField->SetEnabled(settings != NULL); |
334 | 351 | fTypeMenuField->SetEnabled(settings != NULL); |
| 352 | fInet4MenuField->SetEnabled(settings != NULL); |
335 | 353 | |
336 | 354 | bool enableControls = false; |
337 | 355 | BMenuItem* item; |
… |
… |
EthernetSettingsView::_ShowConfiguration(Settings* settings)
|
347 | 365 | if (item != NULL) |
348 | 366 | item->SetMarked(true); |
349 | 367 | |
| 368 | if (settings == NULL || settings->Inet4()) |
| 369 | item = fInet4MenuField->Menu()->FindItem(B_TRANSLATE("IPv4 only")); |
| 370 | else |
| 371 | item = fInet4MenuField->Menu()->FindItem(B_TRANSLATE("IPv4 and IPv6")); |
| 372 | if (item != NULL) |
| 373 | item->SetMarked(true); |
| 374 | |
350 | 375 | if (settings == NULL) { |
351 | 376 | if (!fNetworkMenuField->IsHidden(fNetworkMenuField)) |
352 | 377 | fNetworkMenuField->Hide(); |
… |
… |
EthernetSettingsView::_ApplyControlsToConfiguration()
|
473 | 498 | fSecondaryDNSTextControl->Text())); |
474 | 499 | fCurrentSettings->SetDomain(fDomainTextControl->Text()); |
475 | 500 | |
| 501 | fCurrentSettings->SetInet4( |
| 502 | strcmp(fInet4MenuField->Menu()->FindMarked()->Label(), |
| 503 | B_TRANSLATE("IPv4 only")) == 0); |
| 504 | |
476 | 505 | fApplyButton->SetEnabled(false); |
477 | 506 | fRevertButton->SetEnabled(true); |
478 | 507 | } |
… |
… |
EthernetSettingsView::_SaveDNSConfiguration()
|
521 | 550 | << settings->Domain() |
522 | 551 | << "\n"; |
523 | 552 | } |
| 553 | if (settings->Inet4()) { |
| 554 | content << "options inet4\n"; |
| 555 | } |
524 | 556 | } |
525 | 557 | |
526 | 558 | file.Write(content.String(), content.Length()); |
diff --git a/src/preferences/network/EthernetSettingsView.h b/src/preferences/network/EthernetSettingsView.h
index 24fd31f..135ace4 100644
a
|
b
|
private:
|
57 | 57 | BMenuField* fDeviceMenuField; |
58 | 58 | BMenuField* fNetworkMenuField; |
59 | 59 | BMenuField* fTypeMenuField; |
| 60 | BMenuField* fInet4MenuField; |
60 | 61 | BTextControl* fIPTextControl; |
61 | 62 | BTextControl* fNetMaskTextControl; |
62 | 63 | BTextControl* fGatewayTextControl; |
diff --git a/src/preferences/network/Settings.cpp b/src/preferences/network/Settings.cpp
index 8601b56..747537d 100644
a
|
b
|
Settings::Settings(const char* name)
|
36 | 36 | : |
37 | 37 | fAuto(true), |
38 | 38 | fDisabled(false), |
39 | | fNameServers(5, true) |
| 39 | fNameServers(5, true), |
| 40 | fInet4(true) |
40 | 41 | { |
41 | 42 | fSocket = socket(AF_INET, SOCK_DGRAM, 0); |
42 | 43 | fName = name; |
… |
… |
Settings::ReadConfiguration()
|
216 | 217 | new BString(inet_ntoa(state->nsaddr_list[i].sin_addr))); |
217 | 218 | } |
218 | 219 | fDomain = state->dnsrch[0]; |
| 220 | fInet4 = (state->options & RES_USE_INET4) != 0; |
219 | 221 | } |
220 | 222 | } |
diff --git a/src/preferences/network/Settings.h b/src/preferences/network/Settings.h
index 2f54ca7..6d03eaf 100644
a
|
b
|
public:
|
33 | 33 | { fDisabled = disabled; } |
34 | 34 | void SetWirelessNetwork(const char* name) |
35 | 35 | { fWirelessNetwork.SetTo(name); } |
| 36 | void SetInet4(bool inet4) |
| 37 | { fInet4 = inet4; } |
36 | 38 | |
37 | 39 | const char* IP() { return fIP.String(); } |
38 | 40 | const char* Gateway() { return fGateway.String(); } |
… |
… |
public:
|
41 | 43 | const char* Domain() { return fDomain.String(); } |
42 | 44 | bool AutoConfigure() { return fAuto; } |
43 | 45 | bool IsDisabled() { return fDisabled; } |
| 46 | bool Inet4() { return fInet4; } |
44 | 47 | const BString& WirelessNetwork() { return fWirelessNetwork; } |
45 | 48 | |
46 | 49 | BObjectList<BString>& NameServers() { return fNameServers; } |
… |
… |
private:
|
60 | 63 | bool fDisabled; |
61 | 64 | BObjectList<BString> fNameServers; |
62 | 65 | BString fWirelessNetwork; |
| 66 | bool fInet4; |
63 | 67 | }; |
64 | 68 | |
65 | 69 | |