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

svn at pcbsd.org svn at pcbsd.org
Sat Oct 9 07:24:28 PDT 2010


Author: kris
Date: 2010-10-09 07:24:28 -0700 (Sat, 09 Oct 2010)
New Revision: 7768

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

Read and parse ppp.conf properly now



Modified: pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp	2010-10-09 13:44:19 UTC (rev 7767)
+++ pcbsd/current/src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp	2010-10-09 14:24:28 UTC (rev 7768)
@@ -873,68 +873,54 @@
 
         // Check if we are on a profile line
         if ( line.indexOf(":") == line.length() -1  ) {
-  	  if ( line.indexOf("default") == -1 ) {
+  	  if ( line.indexOf("default") == -1 )
 	    // If we find the existing profile for this device, remove it
 	    foundProfile = 1;
-	    
-	  } else {
+	  else
 	    foundProfile = 0;
- 	}
-      }
+        }
 
-	    if ( foundProfile == 1)
-	    {
-		
-		// Search for the username and load it
-		if ( line.indexOf("authname") != -1 )
-		{
-			tmp = line.remove(0, line.indexOf("authname") + 9 );
-			linePPPUsername->setText(tmp);
-		}
-		// Search for the password and load it
-		if ( line.indexOf("authkey") != -1 )
-		{
-			tmp = line.remove(0, line.indexOf("authkey") + 8 );
-			linePPPPassword->setText(tmp);
-		}
+        // Search for the username and load it
+        if ( line.indexOf("set device") != -1 )
+   	{
+	    tmp = line.replace("set device ", "").simplified();
+	    for ( int i = 0 ; i < comboPPPOEDev->count() ; i++ )
+		if ( tmp == comboPPPOEDev->itemText(i) )
+		   comboPPPOEDev->setCurrentIndex(i);
+	}
 
-		// Check if using ppp dns
-		if ( line.indexOf("enable dns") != -1 )
-		   checkPPPOEDNS->setChecked(true);
-		
-		// Get the dialer commands
-		if ( line.indexOf("set dial \"") != -1 ) {
-			tmp = line.replace("set dial \"", "");
-			tmp = tmp.replace("\"", "");
-			textDialerAT->setPlainText(tmp);
-		}
+  	// Get the dialer commands
+	if ( line.indexOf("set dial \"") != -1 ) {
+	    tmp = line.replace("set dial \"", "");
+	    tmp = tmp.replace("\"", "");
+	    textDialerAT->setPlainText(tmp.simplified());
+	}
 
-		// Search for the device / service tag
-		if ( line.indexOf("set device PPPoE:") != -1 )
-		{
-		    tmp = line.remove(0, line.indexOf("set device PPPoE:") + 18 );
-		    
-		    // Search for the service tag in remainder line
-		    if ( tmp.indexOf(":") != -1 ) {
-			tmp2 = tmp.remove(0, tmp.indexOf(":") + 1 );
-			linePPPService->setText(tmp2);
-			tmp.truncate( tmp.indexOf(":") );
-		    }
+        if ( foundProfile == 1)
+        {
+  	   // Search for the username and load it
+	   if ( line.indexOf("authname") != -1 )
+   	   {
+		tmp = line.remove(0, line.indexOf("authname") + 9 );
+		linePPPUsername->setText(tmp);
+	   }
+    	   // Search for the password and load it
+	   if ( line.indexOf("authkey") != -1 )
+	   {
+		tmp = line.remove(0, line.indexOf("authkey") + 8 );
+		linePPPPassword->setText(tmp);
+  	   }
 
-		    
-		    // Now look for device string
-		   /* int i = 0;
-		    while (! Devs[i].isEmpty() ) {
-			if ( tmp == Devs[i] ) {
-			    comboPPPOEDev->setCurrentItem(i);
-			}
-			i++;
-		    }
-		   */
-		}
-	    }
+  	   // Check if using ppp dns
+	   if ( line.indexOf("enable dns") != -1 )
+		checkPPPOEDNS->setChecked(true);
+		
+	   // Search for the profile tag
+	   if ( line.indexOf(":") != -1 )
+ 	        linePPPService->setText(line.replace(":", "").simplified());
+         } // end of foundProfile=1
 
-	} 
+       } 
     } 
 
 }
@@ -1227,26 +1213,32 @@
     QFile filein( "/etc/ppp/ppp.conf" );
     QFile fileout( "/etc/ppp/ppp.conf" );
     QString ProfileName = linePPPService->text();
+    if ( ProfileName.isEmpty() )
+ 	ProfileName = "auto-ppp";
 
     if ( fileout.open( QIODevice::WriteOnly ) ) {
         QTextStream streamout( &fileout );
 
-                    streamout << "default:\n set timeout 180\n";
+		    // Save the default section first
+                    streamout << "default:\n  set timeout 180\n";
+                    streamout << "  set device " + DeviceName + "\n";
+		    if ( ! textDialerAT->toPlainText().isEmpty() ) {
+		      tmp = textDialerAT->toPlainText();
+		      streamout << "  set dial \"" + tmp.simplified() + "\"\n\n";
+		    } else {
+		      streamout << "  set dial\n\n";
+		    }
+
+		    // Now save the specific profile
                     streamout << ProfileName + ":\n";
 
 		    if ( checkPPPOEDNS->isChecked() )
-                      streamout << " enable dns\n\n";
+                      streamout << "  enable dns\n";
 		    else
-                      streamout << "\n\n";
+                      streamout << "\n";
 
 
-                    streamout << "  set device PPPoE:" + DeviceName + ":" + ProfileName + "\n  set authname " + linePPPUsername->text() + "\n  set authkey " + linePPPPassword->text() + "\n";
-		    if ( ! textDialerAT->toPlainText().isEmpty() ) {
-		      tmp = textDialerAT->toPlainText();
-		      streamout << "  set dial \"" + tmp.simplified() + "\"\n";
-		    } else {
-		      streamout << "  set dial\n";
-		    }
+                    streamout << "  set authname " + linePPPUsername->text() + "\n  set authkey " + linePPPPassword->text() + "\n";
 		    streamout << "  set login\n  set ifaddr 0 0\n  add default HISADDR";
 
         fileout.close();



More information about the Commits mailing list