Changeset 2960
- Timestamp:
- 08/14/08 10:03:39 (3 months ago)
- Location:
- vidalia/branches/hidden-services/src/vidalia/config
- Files:
-
- 6 modified
-
service.cpp (modified) (3 diffs)
-
service.h (modified) (1 diff)
-
servicepage.cpp (modified) (20 diffs)
-
servicepage.h (modified) (3 diffs)
-
servicesettings.cpp (modified) (3 diffs)
-
userauthorizationdata.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
vidalia/branches/hidden-services/src/vidalia/config/service.cpp
r2959 r2960 16 16 17 17 /** Constructor to create a new Service with initial settings */ 18 Service::Service(QString serviceAddress, QString virtualPort, 19 QString physicalAddressPort, QString serviceDirectory, bool enabled,bool stealth)18 Service::Service(QString serviceAddress, QString virtualPort,QString 19 physicalAddressPort,QString serviceDirectory,bool enabled,bool stealth) 20 20 { 21 21 … … 128 128 /* Read in from the data stream */ 129 129 in >> serviceAddress >> virtualPort >> physicalAddressPort 130 >> serviceDirectory >> enabled >> stealth 130 >> serviceDirectory >> enabled >> stealth 131 131 >> additionalServiceOptions >> users; 132 132 … … 155 155 } 156 156 s.append(_serviceAddress +"#"+ _virtualPort +"#"+ _physicalAddressPort + 157 "#"+ _serviceDirectory +"#"+ _enabled + "#"+ stealth +"#"+ 157 "#"+ _serviceDirectory +"#"+ _enabled + "#"+ stealth +"#"+ 158 158 _additionalServiceOptions + "#"); 159 159 foreach(UserAuthorizationData user, _users) -
vidalia/branches/hidden-services/src/vidalia/config/service.h
r2959 r2960 25 25 /** Constructor to create a new Service with initial settings */ 26 26 Service(QString serviceAddress, QString virtualPort, 27 QString physicalAddressPort, QString serviceDirectory, bool enabled, bool stealth); 27 QString physicalAddressPort, QString serviceDirectory, 28 bool enabled, bool stealth); 28 29 /** Destructor */ 29 30 virtual ~Service(); -
vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp
r2959 r2960 43 43 /* a map mapping from the unique identification, to the auth data 44 44 * of a service*/ 45 _consumedServices = new QMap< QString, ServiceAuthorizationData>();45 _consumedServices = new QMap<int, ServiceAuthorizationData>(); 46 46 /** A QRegExpValidator to validate the identification of client auth(Id) 47 47 * and service auth(Id)*/ … … 114 114 connect(ui.serviceAccessWidget, SIGNAL(itemClicked(QTableWidgetItem*)), this, 115 115 SLOT(serviceAccessSelectionChanged())); 116 connect(ui.checkBox_basic, SIGNAL(toggled(bool)), this, SLOT(checkBoxBasicToggled())); 117 connect(ui.checkBox_stealth, SIGNAL(toggled(bool)), this, SLOT(checkBoxStealthToggled())); 116 connect(ui.checkBox_basic, SIGNAL(toggled(bool)), this, 117 SLOT(checkBoxBasicToggled())); 118 connect(ui.checkBox_stealth, SIGNAL(toggled(bool)), this, 119 SLOT(checkBoxStealthToggled())); 118 120 } 119 121 … … 222 224 if(VMessageBox::warning(this, tr("Error"), tr("Some of the required user\ 223 225 authorization identification fields are empty. Do you want Vidalia to\ 224 create some dummy values you can change later? If not, the corresponding\225 authorization data is going to be deleted."),226 create some dummy values you can change later? If not, the\ 227 corresponding authorization data is going to be deleted."), 226 228 VMessageBox::Yes, VMessageBox::No) == VMessageBox::Yes) { 227 229 //create a list containing of all identifications to ensure … … 255 257 for(int i = 0; i < ui.serviceAuthWidget->rowCount(); i++) { 256 258 QTableWidgetItem *currentItem = ui.serviceAuthWidget->item(i, 1); 257 if(currentItem->text() ==NULL || currentItem->text().length()==0){259 if(currentItem->text()==NULL || currentItem->text().length()==0){ 258 260 ui.serviceAuthWidget->removeRow(i); 259 261 i--; … … 313 315 } 314 316 serviceConfString.append(" hiddenserviceversion=\"2\" \ 315 hiddenserviceauthorizeclient="+string_escape(stealthMode+" " + 317 hiddenserviceauthorizeclient="+string_escape(stealthMode+" " + 316 318 createUserAuthStringForTor(publishedUsers))); 317 319 } 318 320 serviceConfString.append(" "+ temp.additionalServiceOptions()); 319 321 } 320 VMessageBox::warning(this, tr("torConfString"), serviceConfString,321 VMessageBox::Ok);322 322 _serviceSettings->applyServices(serviceConfString, &errmsg); 323 323 } … … 380 380 QString torConfigurationString = _serviceSettings-> 381 381 getHiddenServiceDirectories(); 382 VMessageBox::warning(this, tr("kompletter string:"), torConfigurationString,383 VMessageBox::Ok);384 382 torServiceList = extractSingleServices(torConfigurationString); 385 383 // the services stored with vidalia … … 453 451 } 454 452 //remove first appearance of HiddenServiceVerison 455 indexstart = additionalOptions.indexOf("hiddenserviceversion", 0, Qt::CaseInsensitive); 453 indexstart = additionalOptions.indexOf("hiddenserviceversion", 0, 454 Qt::CaseInsensitive); 456 455 endindex = additionalOptions.indexOf("250", indexstart); 457 456 if(endindex != -1) { … … 582 581 } 583 582 } 584 Service service(address, virtualPort, physAddressPort, serviceDir, true,stealth);583 Service service(address,virtualPort,physAddressPort,serviceDir,true,stealth); 585 584 service.setAdditionalServiceOptions(additionalOptions); 586 585 service.setUsers(actualUsers); … … 588 587 return service; 589 588 } 590 591 /** this method is called to parse the client_keys file in order to592 * get all users that had a authorization for the Service593 * @return a list of all users found in client_keys*/594 //QList<UserAuthorizationData>595 //ServicePage::parseClientKeys(QString dir)596 //{597 //QList<UserAuthorizationData> result;598 //QString value;599 //XTODO hier änderungen!!600 //QFile file(dir.append("/hostname"));601 //if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {602 //return result;603 //} else {604 //QTextStream in(&file);605 //QString content;606 //while (!in.atEnd()) {607 //content.append(in.readLine());608 //content.append("\n");609 //}610 //value = content;611 //}612 //QStringList strList1 = value.split("\n");613 //foreach(QString user, strList1) {614 //if(user.length() > 1) {615 //QString onion, cookie, id;616 //QStringList strList2 = user.split(" ");617 //onion = strList2.first();618 //strList2.removeFirst();619 //cookie = strList2.first();620 //strList2.removeFirst();621 //strList2.removeFirst();622 //strList2.removeFirst();623 //id = strList2.first();624 //UserAuthorizationData u(onion+" "+cookie, id);625 //u.setEnabled(false);626 //result.push_back(u);627 //}628 //}629 //return result;630 //}631 589 632 590 /** this method merges the list of services received from Vidalia and Tor … … 743 701 744 702 void 745 ServicePage::initServiceAccessTable(QList<ServiceAuthorizationData> authdataList) 703 ServicePage::initServiceAccessTable(QList<ServiceAuthorizationData> 704 authdataList) 746 705 { 747 706 while(ui.serviceAccessWidget->rowCount() > 0) { 748 707 ui.serviceAccessWidget->removeRow(0); 749 708 } 709 int index = 0; 750 710 foreach(ServiceAuthorizationData tempService, authdataList) { 751 int rows = ui.serviceAccessWidget->rowCount();711 //int rows = ui.serviceAccessWidget->rowCount(); 752 712 QString authdata = tempService.authdata(); 753 QString identification = tempService.identification();713 QString identification = ""+tempService.identification(); 754 714 ServiceAuthorizationData s(authdata, identification); 755 ui.serviceAccessWidget->insertRow( rows);715 ui.serviceAccessWidget->insertRow(index); 756 716 QTableWidgetItem* authdataItem = new QTableWidgetItem(authdata); 757 QTableWidgetItem* identificationItem = new QTableWidgetItem(identification); 717 QTableWidgetItem* identificationItem = new 718 QTableWidgetItem(identification); 758 719 identificationItem->setData(32, identification); 759 720 authdataItem->setData(32, authdata); 760 ui.serviceAccessWidget->setItem(rows, 0, authdataItem); 761 ui.serviceAccessWidget->setItem(rows, 1, identificationItem); 762 _consumedServices->insert(identification, s); 721 ui.serviceAccessWidget->setItem(index, 0, authdataItem); 722 ui.serviceAccessWidget->setItem(index, 1, identificationItem); 723 _consumedServices->insert(index, s); 724 index++; 763 725 } 764 726 } … … 887 849 identification = ui.serviceAuthWidget->item(i, 1)->text(); 888 850 UserAuthorizationData u(authdata, identification); 889 if(ui.serviceAuthWidget->item(i,2)->checkState() == Qt::Checked){851 if(ui.serviceAuthWidget->item(i,2)->checkState()==Qt::Checked){ 890 852 enabled = true; 891 853 } … … 902 864 QList<QString> identifications; 903 865 for(int i = 0; i < ui.serviceAuthWidget->rowCount(); i++) { 904 QTableWidgetItem *selectedItem = ui.serviceAuthWidget->item(i, 1);866 QTableWidgetItem *selectedItem = ui.serviceAuthWidget->item(i,1); 905 867 if(selectedItem->text() != NULL && 906 868 selectedItem->text().length() > 0) { … … 1227 1189 serviceIdentification = ""+ui.commentLineAccess->text(); 1228 1190 if(serviceAuthdata.length() == 0) { 1229 VMessageBox::warning(this, tr("Error"), tr("Authorization data has to be set."),1230 VMessageBox::Ok);1191 VMessageBox::warning(this, tr("Error"), tr("Authorization data\ 1192 has to be set."), VMessageBox::Ok); 1231 1193 return; 1232 1194 } else { … … 1238 1200 QTableWidgetItem* identificationItem = 1239 1201 new QTableWidgetItem(serviceIdentification); 1240 identificationItem->setData(32, serviceIdentification);1202 //identificationItem->setData(32, serviceIdentification); 1241 1203 authItem->setData(32, serviceAuthdata); 1242 1204 ui.serviceAccessWidget->setItem(rows, 0, authItem); … … 1245 1207 ui.commentLineAccess->clear(); 1246 1208 ServiceAuthorizationData s(serviceAuthdata, serviceIdentification); 1247 _consumedServices->insert( serviceIdentification, s);1209 _consumedServices->insert(rows, s); 1248 1210 } else { 1249 1211 VMessageBox::warning(this, tr("Error"), tr("Invalid input for the\ … … 1277 1239 } 1278 1240 } else { 1279 VMessageBox::warning(this, tr("Error"), tr("Your onion adress is not valid,\1280 please correct it."), VMessageBox::Ok);1241 VMessageBox::warning(this, tr("Error"), tr("Your onion adress is\ 1242 not valid, please correct it."), VMessageBox::Ok); 1281 1243 return QValidator::Invalid; 1282 1244 } … … 1287 1249 ServicePage::removeServiceAuthBtnClicked() 1288 1250 { 1289 QString identification = ui.serviceAccessWidget->item(ui.serviceAccessWidget-> 1290 currentRow(), 1)->text(); 1291 _consumedServices->take(identification); 1292 ui.serviceAccessWidget->removeRow(ui.serviceAccessWidget->currentRow()); 1251 int id = ui.serviceAccessWidget->currentRow(); 1252 _consumedServices->take(id); 1253 ui.serviceAccessWidget->removeRow(id); 1254 //shift all higher ones one row up! 1255 for(int index = id+1; index < ui.serviceAccessWidget->rowCount(); index++){ 1256 ServiceAuthorizationData s = _consumedServices->take(index); 1257 _consumedServices->insert(id,s); 1258 QTableWidgetItem* auth = new QTableWidgetItem(s.authdata()); 1259 QTableWidgetItem* ident = new QTableWidgetItem(s.identification()); 1260 ui.serviceAccessWidget->setItem(id, 0, auth); 1261 ui.serviceAccessWidget->setItem(id, 1, ident); 1262 id++; 1263 } 1293 1264 } 1294 1265 … … 1378 1349 ServicePage::serviceAccessValueChanged() 1379 1350 { 1380 QString currentString, currentAuthdata; 1381 QStringList values; 1351 QString currentAuthdata; 1382 1352 QTableWidgetItem *item = ui.serviceAccessWidget->item( 1383 1353 ui.serviceAccessWidget->currentRow(), 1); 1384 1354 QTableWidgetItem* authItem = ui.serviceAccessWidget->item( 1385 1355 ui.serviceAccessWidget->currentRow(), 0); 1386 if(item == NULL || item->text() == NULL || item->text().length() == 0 || 1387 authItem == NULL) { 1356 if(item == NULL || authItem == NULL) { 1388 1357 // nothing to validate here 1389 1358 return; 1390 1359 } else { 1391 currentString = item->text(); 1392 for(int i = 0; i < ui.serviceAccessWidget->rowCount(); i++) { 1393 if(i != ui.serviceAccessWidget->currentRow()) { 1394 QTableWidgetItem* tempItem = ui.serviceAccessWidget->item(i, 1); 1395 if(tempItem != NULL && tempItem->text() != NULL && 1396 tempItem->text().length() > 0) { 1397 values.push_back(tempItem->text()); 1360 QString identification = ""+item->text(); 1361 ServiceAuthorizationData s = _consumedServices->take( 1362 ui.serviceAccessWidget->currentRow()); 1363 s.setIdentification(identification); 1364 _consumedServices->insert(ui.serviceAccessWidget->currentRow(), s); 1365 if(authItem->text() == NULL || authItem->text().length() == 0) { 1366 VMessageBox::warning(this, tr("Error"), tr("No empty authorization\ 1367 allowed!"), VMessageBox::Ok); 1368 if(authItem->data(32).toString() != NULL && 1369 authItem->data(32).toString().length() > 0) { 1370 currentAuthdata = authItem->data(32).toString(); 1371 authItem->setText(currentAuthdata); 1372 s.setAuthdata(currentAuthdata); 1373 _consumedServices->insert(ui.serviceAccessWidget->currentRow(), s); 1374 } else { 1375 authItem->setText(""); 1376 s.setAuthdata(""); 1377 _consumedServices->insert(ui.serviceAccessWidget->currentRow(), s); 1398 1378 } 1399 }1400 }1401 if(values.contains(currentString)) {1402 VMessageBox::warning(this, tr("Error"), tr("The identification has to be\1403 unique, please choose a different one."), VMessageBox::Ok);1404 if(item->data(32).toString() != NULL &&1405 item->data(32).toString().length() > 0) {1406 item->setText(item->data(32).toString());1407 } else {1408 item->setText("");1409 }1410 1379 } else { 1411 int pos = 0; 1412 if(_identificationValidator->validate(currentString, pos) == 1413 QValidator::Acceptable) { 1414 if(authItem->text() == NULL || authItem->text().length() == 0) { 1415 VMessageBox::warning(this, tr("Error"), tr("No empty authorization\ 1416 allowed!"), VMessageBox::Ok); 1417 if(authItem->data(32).toString() != NULL && 1418 authItem->data(32).toString().length() > 0) { 1419 authItem->setText(authItem->data(32).toString()); 1420 } else { 1421 authItem->setText(""); 1422 } 1423 } else { 1424 currentAuthdata = authItem->text(); 1425 if(validateServiceAuth(authItem->text()) == QValidator::Acceptable) { 1426 authItem->setData(32, currentAuthdata); 1427 authItem->setText(currentAuthdata); 1428 } else { 1429 if(authItem->data(32).toString() != NULL && 1430 authItem->data(32).toString().length() > 0) { 1431 authItem->setText(authItem->data(32).toString()); 1432 } else { 1433 authItem->setText(""); 1434 } 1435 } 1436 } 1380 currentAuthdata = authItem->text(); 1381 if(validateServiceAuth(authItem->text()) == QValidator::Acceptable) { 1382 authItem->setData(32, currentAuthdata); 1383 authItem->setText(currentAuthdata); 1384 s.setAuthdata(currentAuthdata); 1385 _consumedServices->insert(ui.serviceAccessWidget->currentRow(), s); 1437 1386 } else { 1438 1387 VMessageBox::warning(this, tr("Error"), tr("Invalid characters for the\ 1439 identification, only {[a-z][A-Z][0-9]+-_} allowed. The length has to\ 1440 be between 1 and 19."), VMessageBox::Ok); 1441 if(item->data(32) == NULL || item->data(32).toString() == NULL || 1442 item->data(32).toString().length() <= 0) { 1443 item->setText(""); 1444 } else { 1445 item->setText(item->data(32).toString()); 1446 } 1447 } 1448 } 1449 } 1388 authorization. Only [onion-Address] [descriptor-cookie] allowed"), 1389 VMessageBox::Ok); 1390 if(authItem->data(32).toString() != NULL && 1391 authItem->data(32).toString().length() > 0) { 1392 currentAuthdata = authItem->data(32).toString(); 1393 authItem->setText(currentAuthdata); 1394 s.setAuthdata(currentAuthdata); 1395 _consumedServices->insert(ui.serviceAccessWidget->currentRow(), s); 1396 } else { 1397 authItem->setText(""); 1398 s.setAuthdata(""); 1399 _consumedServices->insert(ui.serviceAccessWidget->currentRow(), s); 1400 } 1401 } 1402 } 1403 } 1450 1404 } 1451 1405 … … 1524 1478 } 1525 1479 1480 /** Called whenever the user clicks on the basic authorization checkbox*/ 1526 1481 void 1527 1482 ServicePage::checkBoxBasicToggled() … … 1538 1493 } 1539 1494 1495 /** Called whenever the user clicks on the stealth authorization checkbox*/ 1540 1496 void 1541 1497 ServicePage::checkBoxStealthToggled() -
vidalia/branches/hidden-services/src/vidalia/config/servicepage.h
r2959 r2960 51 51 * @return a QValidator::State signalling whether the string is valid or not*/ 52 52 QValidator::State validateServiceAuth(QString authString); 53 /** this method is called to parse the client_keys file in order to54 * get all users that had a authorization for the Service55 * @return a list of all users found in client_keys*/56 //QList<UserAuthorizationData> parseClientKeys(QString dir);57 53 /** this method creates the configuration string for tor including the 58 54 * user authorization*/ … … 114 110 * entry(Provided Services)*/ 115 111 void serviceAuthSelectionChanged(); 112 /** Called whenever the user clicks on the basic authorization checkbox*/ 116 113 void checkBoxBasicToggled(); 114 /** Called whenever the user clicks on the stealth authorization checkbox*/ 117 115 void checkBoxStealthToggled(); 118 116 … … 126 124 QMap<QString, Service>* _torServices; 127 125 /* a map mapping from the unique comment, to the auth data of a service*/ 128 QMap< QString, ServiceAuthorizationData>* _consumedServices;126 QMap<int, ServiceAuthorizationData>* _consumedServices; 129 127 /** Qt Designer generated object */ 130 128 Ui::ServicePage ui; -
vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp
r2959 r2960 54 54 ServiceSettings::apply(QString *errmsg) 55 55 { 56 //dummy57 56 return true; 58 57 } … … 62 61 ServiceSettings::getServices() 63 62 { 64 QString address,virtualPort,physAddrPort,serviceDir,enabledS,stealthS,additionalData; 63 QString address,virtualPort,physAddrPort,serviceDir,enabledS, 64 stealthS,additionalData; 65 65 bool enabled = false; 66 66 bool stealth = false; … … 106 106 } 107 107 } 108 Service s(address, virtualPort, physAddrPort, serviceDir, enabled,stealth);108 Service s(address,virtualPort,physAddrPort,serviceDir,enabled,stealth); 109 109 s.setAdditionalServiceOptions(additionalData); 110 110 s.setUsers(users); -
vidalia/branches/hidden-services/src/vidalia/config/userauthorizationdata.cpp
r2836 r2960 16 16 17 17 /** Constructor to create a new User with initial settings */ 18 UserAuthorizationData::UserAuthorizationData(QString authdata, QString identification):19 AbstractAuthorizationData(authdata,identification)18 UserAuthorizationData::UserAuthorizationData(QString authdata, 19 QString identification):AbstractAuthorizationData(authdata,identification) 20 20 { 21 21 }
