[haiku-commits] r35938 - in haiku/trunk/src: preferences/network servers/net

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 24 Mar 2010 00:58:41 +0100 (CET)

Author: stippi
Date: 2010-03-24 00:58:41 +0100 (Wed, 24 Mar 2010)
New Revision: 35938
Changeset: http://dev.haiku-os.org/changeset/35938/haiku
Ticket: http://dev.haiku-os.org/ticket/5619

Modified:
   haiku/trunk/src/preferences/network/EthernetSettingsView.cpp
   haiku/trunk/src/preferences/network/EthernetSettingsView.h
   haiku/trunk/src/preferences/network/Settings.cpp
   haiku/trunk/src/preferences/network/Settings.h
   haiku/trunk/src/servers/net/DHCPClient.cpp
Log:
Patch by Vegard Waerp: Added support for setting the the local domain in the
Network settings and setting the domain if received by DHCP.

Thanks a lot, closes #5619.


Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.cpp
===================================================================
--- haiku/trunk/src/preferences/network/EthernetSettingsView.cpp        
2010-03-23 20:03:15 UTC (rev 35937)
+++ haiku/trunk/src/preferences/network/EthernetSettingsView.cpp        
2010-03-23 23:58:41 UTC (rev 35938)
@@ -8,6 +8,7 @@
  *             Axel Dörfler
  *             Hugo Santos
  *             Philippe Saint-Pierre
+ *             Vegard Wærp
  */
 
 
@@ -172,12 +173,17 @@
        layout->AddItem(fSecondaryDNSTextControl->CreateLabelLayoutItem(), 0, 
6);
        layout->AddItem(fSecondaryDNSTextControl->CreateTextViewLayoutItem(), 
1, 6);
 
+       fDomainTextControl = new BTextControl(TR("Domain:"), "", NULL);
+       SetupTextControl(fDomainTextControl);
+       layout->AddItem(fDomainTextControl->CreateLabelLayoutItem(), 0, 7);
+       layout->AddItem(fDomainTextControl->CreateTextViewLayoutItem(), 1, 7);
+
        fErrorMessage = new BStringView("error", "");
        fErrorMessage->SetAlignment(B_ALIGN_LEFT);
        fErrorMessage->SetFont(be_bold_font);
        fErrorMessage->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 
B_SIZE_UNSET));
 
-       layout->AddView(fErrorMessage, 1, 7);
+       layout->AddView(fErrorMessage, 1, 8);
 
        // button group (TODO: move to window, but take care of
        // enabling/disabling)
@@ -268,6 +274,7 @@
        fGatewayTextControl->SetTarget(this);
        fPrimaryDNSTextControl->SetTarget(this);
        fSecondaryDNSTextControl->SetTarget(this);
+       fDomainTextControl->SetTarget(this);
        fDeviceMenuField->Menu()->SetTargetForItems(this);
        fTypeMenuField->Menu()->SetTargetForItems(this);
 
@@ -293,6 +300,7 @@
        fNetMaskTextControl->SetText("");
        fPrimaryDNSTextControl->SetText("");
        fSecondaryDNSTextControl->SetText("");
+       fDomainTextControl->SetText("");
 
        bool enableControls = false;
        fTypeMenuField->SetEnabled(settings != NULL);
@@ -325,6 +333,7 @@
                        fPrimaryDNSTextControl->SetText(
                                settings->NameServers().ItemAt(0)->String());
                }
+               fDomainTextControl->SetText(settings->Domain());
        }
 
        _EnableTextControls(enableControls);
@@ -339,6 +348,7 @@
        fNetMaskTextControl->SetEnabled(enable);
        fPrimaryDNSTextControl->SetEnabled(enable);
        fSecondaryDNSTextControl->SetEnabled(enable);
+       fDomainTextControl->SetEnabled(enable);
 }
 
 
@@ -360,6 +370,7 @@
                fPrimaryDNSTextControl->Text()));
        fCurrentSettings->NameServers().AddItem(new BString(
                fSecondaryDNSTextControl->Text()));
+       fCurrentSettings->SetDomain(fDomainTextControl->Text());
 
        fApplyButton->SetEnabled(false);
        fRevertButton->SetEnabled(true);
@@ -404,6 +415,11 @@
                                        << "\n";
                        }
                }
+               if (strlen(settings->Domain()) > 0) {
+                       content << "domain\t"
+                               << settings->Domain()
+                               << "\n";
+               }
        }
 
        file.Write(content.String(), content.Length());

Modified: haiku/trunk/src/preferences/network/EthernetSettingsView.h
===================================================================
--- haiku/trunk/src/preferences/network/EthernetSettingsView.h  2010-03-23 
20:03:15 UTC (rev 35937)
+++ haiku/trunk/src/preferences/network/EthernetSettingsView.h  2010-03-23 
23:58:41 UTC (rev 35938)
@@ -6,6 +6,7 @@
  *             Andre Alves Garzia, andre@xxxxxxxxxxxxxxx
  *             Axel Dörfler
  *             Hugo Santos
+ *             Vegard Wærp
  */
 #ifndef ETHERNET_SETTINGS_VIEW_H
 #define ETHERNET_SETTINGS_VIEW_H
@@ -65,6 +66,7 @@
 
                                BTextControl*   fPrimaryDNSTextControl;
                                BTextControl*   fSecondaryDNSTextControl;
+                               BTextControl*   fDomainTextControl;
 
                                BStringView*    fErrorMessage;
 

Modified: haiku/trunk/src/preferences/network/Settings.cpp
===================================================================
--- haiku/trunk/src/preferences/network/Settings.cpp    2010-03-23 20:03:15 UTC 
(rev 35937)
+++ haiku/trunk/src/preferences/network/Settings.cpp    2010-03-23 23:58:41 UTC 
(rev 35938)
@@ -5,6 +5,7 @@
  * Authors:
  *             Andre Alves Garzia, andre@xxxxxxxxxxxxxxx
  *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx
+ *             Vegard Wærp, vegarwa@xxxxxxxxx
  */
 
 
@@ -159,5 +160,6 @@
                        fNameServers.AddItem(
                                new 
BString(inet_ntoa(state->nsaddr_list[i].sin_addr)));
                }
+               fDomain = state->dnsrch[0];
        }
 }

Modified: haiku/trunk/src/preferences/network/Settings.h
===================================================================
--- haiku/trunk/src/preferences/network/Settings.h      2010-03-23 20:03:15 UTC 
(rev 35937)
+++ haiku/trunk/src/preferences/network/Settings.h      2010-03-23 23:58:41 UTC 
(rev 35938)
@@ -2,8 +2,9 @@
  * Copyright 2004-2009 Haiku Inc. All rights reserved.
  * Distributed under the terms of the MIT License.
  *
- * Author:
+ * Authors:
  *             Andre Alves Garzia, andre@xxxxxxxxxxxxxxx
+ *             Vegard Wærp, vegarwa@xxxxxxxxx
  */
 #ifndef SETTINGS_H
 #define SETTINGS_H
@@ -21,6 +22,7 @@
                        void                            SetIP(BString ip) { fIP 
= ip; }
                        void                            SetGateway(BString ip) 
{ fGateway = ip; }
                        void                            SetNetmask(BString ip) 
{ fNetmask = ip; }
+                       void                            SetDomain(BString 
domain) { fDomain = domain; }
                        void                            SetAutoConfigure(bool 
autoConfigure)
                                                                        { fAuto 
= autoConfigure; }
 
@@ -28,6 +30,7 @@
                        const char*                     Gateway()  { return 
fGateway.String(); }
                        const char*                     Netmask()  { return 
fNetmask.String(); }
                        const char*                     Name()  { return 
fName.String(); }
+                       const char*                     Domain() { return 
fDomain.String(); }
                        bool                            AutoConfigure() { 
return fAuto; }
 
                        BObjectList<BString>& NameServers() { return 
fNameServers; }
@@ -41,6 +44,7 @@
                        BString                         fGateway;
                        BString                         fNetmask;
                        BString                         fName;
+                       BString                         fDomain;
                        int                                     fSocket;
                        bool                            fAuto;
                        BObjectList<BString> fNameServers;

Modified: haiku/trunk/src/servers/net/DHCPClient.cpp
===================================================================
--- haiku/trunk/src/servers/net/DHCPClient.cpp  2010-03-23 20:03:15 UTC (rev 
35937)
+++ haiku/trunk/src/servers/net/DHCPClient.cpp  2010-03-23 23:58:41 UTC (rev 
35938)
@@ -4,6 +4,7 @@
  *
  * Authors:
  *             Axel Dörfler, axeld@xxxxxxxxxxxxxxxx
+ *             Vegard Wærp, vegarwa@xxxxxxxxx
  */
 
 
@@ -681,6 +682,18 @@
                                memcpy(name, data, size);
                                name[size] = '\0';
                                syslog(LOG_INFO, "DHCP domain name: \"%s\"\n", 
name);
+
+                               BPath path;
+                               if (find_directory(B_COMMON_SETTINGS_DIRECTORY, 
&path) != B_OK)
+                                       break;
+       
+                               path.Append("network/resolv.conf");
+
+                               FILE* file = fopen(path.Path(), "a");
+                               if (file != NULL) {
+                                       fprintf(file, "domain %s\n", name);
+                                       fclose(file);
+                               }
                                break;
                        }
 


Other related posts: