[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r2452: * service directory has to be unique to all services now not (vidalia/branches/hidden-services/src/vidalia/config)



Author: borkdomenik
Date: 2008-03-23 19:06:58 -0400 (Sun, 23 Mar 2008)
New Revision: 2452

Modified:
   vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp
Log:
* service directory has to be unique to all services now not just to those enabled
* several bugfixes (additional service options, button enabling)

Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp	2008-03-23 21:35:13 UTC (rev 2451)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp	2008-03-23 23:06:58 UTC (rev 2452)
@@ -132,7 +132,7 @@
 	Service temp = it.next();
 	serviceConfString.append("hiddenservicedir=" + string_escape(temp.serviceDirectory()) + " ");
 	serviceConfString.append("hiddenserviceport=" + string_escape(temp.virtualPort() +
-	  (temp.physicalAddressPort().isEmpty() ? "" : " " + temp.physicalAddressPort()) + " "));
+	  (temp.physicalAddressPort().isEmpty() ? "" : " " + temp.physicalAddressPort())));
 	serviceConfString.append(" "+ temp.additionalServiceOptions());
   }
   _serviceSettings->apply(serviceConfString, &errmsg);
@@ -181,7 +181,7 @@
 ServicePage::extractSingleServices(QString conf)
 {
   QList<Service> list;
-  QStringList strList = conf.split("HiddenServiceDir");
+  QStringList strList = conf.split("250 HiddenServiceDir");
   strList.removeFirst();
   QListIterator<QString> it(strList);
   //for each service directory splitted string = service
@@ -211,6 +211,10 @@
 	  int i = additionalOptions.indexOf("250", 0);
 	  additionalOptions.remove(i, 4);
 	}
+	// prepare for correct quotation
+	if (!additionalOptions.endsWith('\n')) {
+	  additionalOptions.append("\n");
+	}
 	//quote the values
 	int j = additionalOptions.indexOf("=", 0);
 	while(j != -1) {
@@ -219,7 +223,6 @@
 	  additionalOptions.insert(end, "\"");
 	  j = additionalOptions.indexOf("=", end);
 	}
-	additionalOptions.insert(additionalOptions.length(), "\"");
 	//replace the line brakes with a space and create one single line
 	additionalOptions.replace(QString("\n"), QString(" "));  
   } else {
@@ -461,13 +464,17 @@
 	  }
   } 
   QTableWidgetItem* item = ui.serviceWidget->item(ui.serviceWidget->currentRow(), 3);
-  QString selDir = "";
-  selDir.append(_services->value(ui.serviceWidget->currentRow()).serviceDirectory());
-  QStringList strList =  _torServices->keys();
+  QString selDir = _services->value(ui.serviceWidget->currentRow()).serviceDirectory();
+  QList<QString> strList =  _torServices->keys();
   if(selDir.length() > 0) {
-	if(strList.contains(selDir)) {
-	  ui.browseButton->setEnabled(false);
-	}  
+	QListIterator<QString> it(strList);
+	while(it.hasNext()) {
+		QString temp = it.next();
+		if(selDir.compare(temp) == 0) {
+			ui.browseButton->setEnabled(false);
+			break;
+		}
+	}
   }
   // if the user has clicked on the checkbox cell 
   if(ui.serviceWidget->currentColumn() == 4) {
@@ -546,10 +553,6 @@
       item->setData(32, text);
       break;
     case 3: // service directory
-      // only check whether directory is unique if this service is enabled
-      if (!_services->value(item->row()).enabled()) {
-        return;
-      }
       // compare with directories of other enabled services
       for (int index = 0; index < ui.serviceWidget->rowCount(); index++) {
     	// skip own row