[PC-BSD Commits] r18577 - pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager

svn at pcbsd.org svn at pcbsd.org
Wed Aug 22 12:24:49 PDT 2012


Author: kris
Date: 2012-08-22 19:24:49 +0000 (Wed, 22 Aug 2012)
New Revision: 18577

Modified:
   pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp
   pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.ui
Log:

Improve the network manager DNS / Gateway options. Allow user to 
view them, but click if they explicitly want to set them staticly



Modified: pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp	2012-08-22 18:04:53 UTC (rev 18576)
+++ pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp	2012-08-22 19:24:49 UTC (rev 18577)
@@ -318,7 +318,7 @@
 
 QString NetworkMan::getIpForIdent( QString ident )
 {
-   QString cmd = IFCONFIG + " lagg0 | grep " + ident;
+   QString cmd = IFCONFIG + " lagg0 2>/dev/null | grep " + ident;
    QString checkLagg = getLineFromCommandOutput(cmd.toLatin1());
    if ( ! checkLagg.isEmpty() )
     ident = "lagg0";
@@ -519,10 +519,31 @@
 {    
     QString tmp;
     lineHostname->setText(Utils::getConfFileValue("/etc/rc.conf", "hostname=", 1));
-    lineGateway->setText(Utils::getConfFileValue("/etc/rc.conf", "defaultrouter=", 1) );
+
+    tmp = Utils::getConfFileValue("/etc/rc.conf", "defaultrouter=", 1);
+    if ( tmp.isEmpty() )
+    {
+       groupGateway->setChecked(false);
+       // Check the default route
+       QString checkRoute = getLineFromCommandOutput("route get default | grep gateway").simplified();
+       if ( checkRoute.indexOf("gateway:") != -1 )
+         lineGateway->setText(checkRoute.section(" ", 1, 1));
+    } else {
+        groupGateway->setChecked(true);
+        lineGateway->setText(Utils::getConfFileValue("/etc/rc.conf", "defaultrouter=", 1) );
+    }
+
     /* Use simple regular expressions to distinguish IPv4 and IPv6 addresses. */
     lineDNS1->setText(Utils::getConfFileValue("/etc/resolv.conf", "nameserver ", "\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b", 1) );
     lineDNS2->setText(Utils::getConfFileValue("/etc/resolv.conf", "nameserver ", "\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b", 2) );
+    // Check if we are using custom DNS
+    tmp = Utils::getConfFileValue("/etc/dhclient.conf", "supersede domain-name-servers", 1);
+    if ( tmp.isEmpty() )
+       groupDNS->setChecked(false);
+    else
+       groupDNS->setChecked(true);
+
+
     lineIPv6DNS1->setText(Utils::getConfFileValue("/etc/resolv.conf", "nameserver ", "\\b.*:.*:.*\\b", 1) );
     lineIPv6DNS2->setText(Utils::getConfFileValue("/etc/resolv.conf", "nameserver ", "\\b.*:.*:.*\\b", 2) );
     lineSearchDomain->setText(Utils::getConfFileValue("/etc/resolv.conf", "search ", 1) );
@@ -548,7 +569,7 @@
 
 QString NetworkMan::getNetmaskForIdent( QString ident )
 {
-   QString cmd = IFCONFIG + " lagg0 | grep " + ident;
+   QString cmd = IFCONFIG + " lagg0 2>/dev/null | grep " + ident;
    QString checkLagg = getLineFromCommandOutput(cmd.toLatin1());
    if ( ! checkLagg.isEmpty() )
     ident = "lagg0";
@@ -804,20 +825,20 @@
         }
     }
   
-     if ( lineDNS1->text() != "..."  && ! Utils::validateIPV4(lineDNS1->text() ) ) {
+     if ( lineDNS1->text() != "..."  && ! Utils::validateIPV4(lineDNS1->text() ) && groupDNS->isChecked()) {
 	 QMessageBox::warning( this, tr("Warning"),
 	  tr("DNS #1 is out of range! (") + lineDNS1->text() + tr(") Fields must be between 0-255.") );
 	 return;
      }
     
-    if ( lineDNS2->text() != "..."  && ! Utils::validateIPV4(lineDNS2->text() ) ) {
+    if ( lineDNS2->text() != "..."  && ! Utils::validateIPV4(lineDNS2->text() ) && groupDNS->isChecked()) {
 	 QMessageBox::warning( this, tr("Warning"),
 	  tr("DNS #2 is out of range! (") + lineDNS2->text() + tr(") Fields must be between 0-255.") );
 	 return;
      }
     
     
-     if ( lineGateway->text() != "..."  && ! Utils::validateIPV4(lineGateway->text() ) ) {
+     if ( lineGateway->text() != "..."  && ! Utils::validateIPV4(lineGateway->text())  && groupGateway->isChecked() ) {
 	 QMessageBox::warning( this, tr("Warning"),
 	  tr("Gateway is out of range! (") + lineGateway->text() + tr(") Fields must be between 0-255.") );
 	 return;
@@ -858,7 +879,7 @@
    }
     
     
-   if ( lineGateway->text() == "..." ) {
+   if ( lineGateway->text() == "..." || ! groupGateway->isChecked() ) {
      Utils::setConfFileValue("/etc/rc.conf", "defaultrouter=", "", -1);
    } else {
      Utils::setConfFileValue("/etc/rc.conf", "defaultrouter=", "defaultrouter=\"" + lineGateway->text() + "\"", -1);  
@@ -878,27 +899,27 @@
         }
     }
    
-   if ( lineDNS1->text() == "..." ) {
+   if ( lineDNS1->text() == "..."  || ! groupDNS->isChecked() ) {
      Utils::setConfFileValue("/etc/resolv.conf", "nameserver", "", DNSline);
    } else {
      Utils::setConfFileValue("/etc/resolv.conf", "nameserver", "nameserver " + lineDNS1->text(), DNSline);  
      DNSline++;
    }   
-   if ( lineDNS2->text() == "..." ) {
+   if ( lineDNS2->text() == "..." || ! groupDNS->isChecked() ) {
      Utils::setConfFileValue("/etc/resolv.conf", "nameserver", "", DNSline);
    } else {
      Utils::setConfFileValue("/etc/resolv.conf", "nameserver", "nameserver " + lineDNS2->text(), DNSline);  
    }   
    
    // If we have custom DNS, make sure it survives a dhclient run
-   if ( lineDNS1->text() != "..." && lineDNS2->text() != "..." )
+   if ( lineDNS1->text() != "..." && lineDNS2->text() != "..." && groupDNS->isChecked() )
      Utils::setConfFileValue("/etc/dhclient.conf", "supersede domain-name-servers", "supersede domain-name-servers " + lineDNS1->text() + ", " + lineDNS2->text() +";");  
    else if ( lineDNS1->text() != "..." )
      Utils::setConfFileValue("/etc/dhclient.conf", "supersede domain-name-servers", "supersede domain-name-servers " + lineDNS1->text() +";");  
    else if ( lineDNS2->text() != "..." )
      Utils::setConfFileValue("/etc/dhclient.conf", "supersede domain-name-servers", "supersede domain-name-servers " + lineDNS2->text() +";");  
 
-   if ( lineSearchDomain->text().isEmpty() ) {
+   if ( lineSearchDomain->text().isEmpty() || ! groupDNS->isChecked() ) {
      Utils::setConfFileValue("/etc/resolv.conf", "search", "", 1);
    } else {
      Utils::setConfFileValue("/etc/resolv.conf", "search", "search " + lineSearchDomain->text(), 1);

Modified: pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.ui
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.ui	2012-08-22 18:04:53 UTC (rev 18576)
+++ pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.ui	2012-08-22 19:24:49 UTC (rev 18577)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>772</width>
-    <height>502</height>
+    <width>747</width>
+    <height>454</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -20,13 +20,7 @@
   <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QGridLayout">
-   <property name="margin">
-    <number>11</number>
-   </property>
-   <property name="spacing">
-    <number>6</number>
-   </property>
+  <layout class="QGridLayout" name="gridLayout_11">
    <item row="0" column="0">
     <widget class="QTabWidget" name="tabNetMan">
      <property name="currentIndex">
@@ -237,75 +231,32 @@
        <string>Network Configuration (Advanced)</string>
       </attribute>
       <layout class="QGridLayout" name="gridLayout_8">
-       <item row="0" column="0">
-        <widget class="QGroupBox" name="groupBox_3">
+       <item row="4" column="0">
+        <widget class="QGroupBox" name="groupBox">
          <property name="title">
-          <string>System configuration settings</string>
+          <string>Misc</string>
          </property>
-         <layout class="QHBoxLayout" name="horizontalLayout_2">
-          <item>
-           <spacer name="horizontalSpacer_12">
-            <property name="orientation">
-             <enum>Qt::Horizontal</enum>
+         <layout class="QGridLayout" name="gridLayout_5">
+          <item row="1" column="0">
+           <widget class="QCheckBox" name="checkLagg">
+            <property name="text">
+             <string>Enable wireless / wired failover via lagg0 interface</string>
             </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>40</width>
-              <height>20</height>
-             </size>
-            </property>
-           </spacer>
+           </widget>
           </item>
-          <item>
-           <layout class="QGridLayout" name="gridLayout_2">
-            <item row="0" column="0">
-             <widget class="QLabel" name="textLabel11_2_2">
-              <property name="text">
-               <string>DNS 1:</string>
-              </property>
-              <property name="alignment">
-               <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-              </property>
-              <property name="wordWrap">
-               <bool>false</bool>
-              </property>
-             </widget>
-            </item>
-            <item row="0" column="1">
-             <widget class="QLineEdit" name="lineDNS1">
+          <item row="0" column="0">
+           <layout class="QHBoxLayout" name="horizontalLayout">
+            <item>
+             <widget class="QLabel" name="textLabel11">
               <property name="sizePolicy">
-               <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+               <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
-              <property name="inputMask">
-               <string>999\.999\.999\.999; </string>
-              </property>
-              <property name="alignment">
-               <set>Qt::AlignHCenter</set>
-              </property>
-             </widget>
-            </item>
-            <item row="0" column="2">
-             <widget class="QPushButton" name="PublicDNS1">
               <property name="text">
-               <string>Public servers</string>
+               <string>System Hostname</string>
               </property>
-             </widget>
-            </item>
-            <item row="1" column="2" rowspan="2">
-             <widget class="QPushButton" name="PublicDNS2">
-              <property name="text">
-               <string>Public servers</string>
-              </property>
-             </widget>
-            </item>
-            <item row="2" column="0">
-             <widget class="QLabel" name="textLabel11_2_3">
-              <property name="text">
-               <string>DNS 2:</string>
-              </property>
               <property name="alignment">
                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
               </property>
@@ -314,34 +265,18 @@
               </property>
              </widget>
             </item>
-            <item row="2" column="1">
-             <widget class="QLineEdit" name="lineDNS2">
+            <item>
+             <widget class="QLineEdit" name="lineHostname">
               <property name="sizePolicy">
                <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
               </property>
-              <property name="inputMask">
-               <string>999\.999\.999\.999; </string>
-              </property>
-              <property name="alignment">
-               <set>Qt::AlignHCenter</set>
-              </property>
              </widget>
             </item>
-            <item row="3" column="0">
-             <widget class="QLabel" name="label">
-              <property name="text">
-               <string>Search Domain:</string>
-              </property>
-             </widget>
-            </item>
-            <item row="3" column="1">
-             <widget class="QLineEdit" name="lineSearchDomain"/>
-            </item>
-            <item row="3" column="2">
-             <spacer name="horizontalSpacer_10">
+            <item>
+             <spacer name="horizontalSpacer_3">
               <property name="orientation">
                <enum>Qt::Horizontal</enum>
               </property>
@@ -355,83 +290,193 @@
             </item>
            </layout>
           </item>
-          <item>
-           <layout class="QHBoxLayout" name="horizontalLayout">
-            <item>
-             <layout class="QVBoxLayout" name="verticalLayout_2">
-              <item>
-               <widget class="QLabel" name="textLabel11">
-                <property name="sizePolicy">
-                 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-                  <horstretch>0</horstretch>
-                  <verstretch>0</verstretch>
-                 </sizepolicy>
-                </property>
-                <property name="text">
-                 <string>Hostname:</string>
-                </property>
-                <property name="alignment">
-                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-                </property>
-                <property name="wordWrap">
-                 <bool>false</bool>
-                </property>
-               </widget>
-              </item>
-              <item>
-               <widget class="QLabel" name="textLabel11_2">
-                <property name="sizePolicy">
-                 <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-                  <horstretch>0</horstretch>
-                  <verstretch>0</verstretch>
-                 </sizepolicy>
-                </property>
-                <property name="text">
-                 <string>Gateway:</string>
-                </property>
-                <property name="alignment">
-                 <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-                </property>
-                <property name="wordWrap">
-                 <bool>false</bool>
-                </property>
-               </widget>
-              </item>
-             </layout>
-            </item>
-            <item>
-             <layout class="QVBoxLayout" name="verticalLayout">
-              <item>
-               <widget class="QLineEdit" name="lineHostname">
-                <property name="sizePolicy">
-                 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-                  <horstretch>0</horstretch>
-                  <verstretch>0</verstretch>
-                 </sizepolicy>
-                </property>
-               </widget>
-              </item>
-              <item>
-               <widget class="QLineEdit" name="lineGateway">
-                <property name="sizePolicy">
-                 <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
-                  <horstretch>0</horstretch>
-                  <verstretch>0</verstretch>
-                 </sizepolicy>
-                </property>
-                <property name="inputMask">
-                 <string>999\.999\.999\.999; </string>
-                </property>
-                <property name="alignment">
-                 <set>Qt::AlignHCenter</set>
-                </property>
-               </widget>
-              </item>
-             </layout>
-            </item>
-           </layout>
+         </layout>
+        </widget>
+       </item>
+       <item row="0" column="0">
+        <widget class="QGroupBox" name="groupBox_3">
+         <property name="title">
+          <string/>
+         </property>
+         <layout class="QGridLayout" name="gridLayout_10">
+          <item row="0" column="0">
+           <widget class="QGroupBox" name="groupDNS">
+            <property name="title">
+             <string>Enable Custom DNS</string>
+            </property>
+            <property name="checkable">
+             <bool>true</bool>
+            </property>
+            <property name="checked">
+             <bool>false</bool>
+            </property>
+            <layout class="QGridLayout" name="gridLayout_2">
+             <item row="0" column="0">
+              <widget class="QLabel" name="textLabel11_2_2">
+               <property name="text">
+                <string>DNS 1:</string>
+               </property>
+               <property name="alignment">
+                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+               </property>
+               <property name="wordWrap">
+                <bool>false</bool>
+               </property>
+              </widget>
+             </item>
+             <item row="0" column="1">
+              <widget class="QLineEdit" name="lineDNS1">
+               <property name="sizePolicy">
+                <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+                 <horstretch>0</horstretch>
+                 <verstretch>0</verstretch>
+                </sizepolicy>
+               </property>
+               <property name="inputMask">
+                <string>999\.999\.999\.999; </string>
+               </property>
+               <property name="alignment">
+                <set>Qt::AlignHCenter</set>
+               </property>
+              </widget>
+             </item>
+             <item row="0" column="2">
+              <widget class="QPushButton" name="PublicDNS1">
+               <property name="text">
+                <string>Public servers</string>
+               </property>
+              </widget>
+             </item>
+             <item row="1" column="0">
+              <widget class="QLabel" name="textLabel11_2_3">
+               <property name="text">
+                <string>DNS 2:</string>
+               </property>
+               <property name="alignment">
+                <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+               </property>
+               <property name="wordWrap">
+                <bool>false</bool>
+               </property>
+              </widget>
+             </item>
+             <item row="1" column="1">
+              <widget class="QLineEdit" name="lineDNS2">
+               <property name="sizePolicy">
+                <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+                 <horstretch>0</horstretch>
+                 <verstretch>0</verstretch>
+                </sizepolicy>
+               </property>
+               <property name="inputMask">
+                <string>999\.999\.999\.999; </string>
+               </property>
+               <property name="alignment">
+                <set>Qt::AlignHCenter</set>
+               </property>
+              </widget>
+             </item>
+             <item row="1" column="2">
+              <widget class="QPushButton" name="PublicDNS2">
+               <property name="text">
+                <string>Public servers</string>
+               </property>
+              </widget>
+             </item>
+             <item row="2" column="0">
+              <widget class="QLabel" name="label">
+               <property name="text">
+                <string>Search Domain:</string>
+               </property>
+              </widget>
+             </item>
+             <item row="2" column="1">
+              <widget class="QLineEdit" name="lineSearchDomain"/>
+             </item>
+             <item row="2" column="2">
+              <spacer name="horizontalSpacer_10">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>123</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+            </layout>
+           </widget>
           </item>
-          <item>
+          <item row="0" column="1">
+           <widget class="QGroupBox" name="groupGateway">
+            <property name="title">
+             <string>Enable Custom Gateway</string>
+            </property>
+            <property name="checkable">
+             <bool>true</bool>
+            </property>
+            <property name="checked">
+             <bool>false</bool>
+            </property>
+            <layout class="QGridLayout" name="gridLayout_9">
+             <item row="0" column="0">
+              <layout class="QHBoxLayout" name="horizontalLayout_2">
+               <item>
+                <widget class="QLabel" name="textLabel11_2">
+                 <property name="sizePolicy">
+                  <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+                   <horstretch>0</horstretch>
+                   <verstretch>0</verstretch>
+                  </sizepolicy>
+                 </property>
+                 <property name="text">
+                  <string>Gateway:</string>
+                 </property>
+                 <property name="alignment">
+                  <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+                 </property>
+                 <property name="wordWrap">
+                  <bool>false</bool>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QLineEdit" name="lineGateway">
+                 <property name="sizePolicy">
+                  <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+                   <horstretch>0</horstretch>
+                   <verstretch>0</verstretch>
+                  </sizepolicy>
+                 </property>
+                 <property name="inputMask">
+                  <string>999\.999\.999\.999; </string>
+                 </property>
+                 <property name="alignment">
+                  <set>Qt::AlignHCenter</set>
+                 </property>
+                </widget>
+               </item>
+              </layout>
+             </item>
+             <item row="1" column="0">
+              <spacer name="verticalSpacer_2">
+               <property name="orientation">
+                <enum>Qt::Vertical</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>20</width>
+                 <height>57</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+            </layout>
+           </widget>
+          </item>
+          <item row="0" column="2">
            <spacer name="horizontalSpacer_11">
             <property name="orientation">
              <enum>Qt::Horizontal</enum>
@@ -447,23 +492,7 @@
          </layout>
         </widget>
        </item>
-       <item row="3" column="0">
-        <widget class="QGroupBox" name="groupBox">
-         <property name="title">
-          <string>Misc</string>
-         </property>
-         <layout class="QGridLayout" name="gridLayout_10">
-          <item row="0" column="0">
-           <widget class="QCheckBox" name="checkLagg">
-            <property name="text">
-             <string>Enable wireless / wired failover via lagg0 interface</string>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </widget>
-       </item>
-       <item row="1" column="0" rowspan="2">
+       <item row="1" column="0">
         <widget class="QGroupBox" name="groupIPv6">
          <property name="title">
           <string>Enable IPv6 support</string>
@@ -757,7 +786,7 @@
      </widget>
     </widget>
    </item>
-   <item row="2" column="0">
+   <item row="1" column="0">
     <layout class="QHBoxLayout" name="horizontalLayout_3">
      <item>
       <spacer name="horizontalSpacer">
@@ -788,14 +817,20 @@
      </item>
     </layout>
    </item>
-   <item row="1" column="0">
-    <widget class="QLabel" name="textGlobalError_2">
-     <property name="text">
-      <string/>
-     </property>
-    </widget>
-   </item>
   </layout>
+  <widget class="QLabel" name="textGlobalError_2">
+   <property name="geometry">
+    <rect>
+     <x>11</x>
+     <y>439</y>
+     <width>16</width>
+     <height>17</height>
+    </rect>
+   </property>
+   <property name="text">
+    <string/>
+   </property>
+  </widget>
  </widget>
  <layoutdefault spacing="6" margin="11"/>
  <tabstops>



More information about the Commits mailing list