Changeset 2960

Show
Ignore:
Timestamp:
08/14/08 10:03:39 (3 months ago)
Author:
borkdomenik
Message:

Some more bugfixes and changes according to proposal 121.
* make the comment for client authorization optional (client side)
* changes in the serviceAccessValueChanged because of the point mentioned above
* remove the validation for the comment/identification on client side
* improve the ui.file (not finished yet!)
* applied checkSpace.pl

Location:
vidalia/branches/hidden-services/src/vidalia/config
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • vidalia/branches/hidden-services/src/vidalia/config/service.cpp

    r2959 r2960  
    1616 
    1717/** 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) 
     18Service::Service(QString serviceAddress, QString virtualPort,QString 
     19 physicalAddressPort,QString serviceDirectory,bool enabled,bool stealth) 
    2020{ 
    2121 
     
    128128  /* Read in from the data stream */ 
    129129  in >> serviceAddress >> virtualPort  >> physicalAddressPort 
    130    >> serviceDirectory >> enabled >> stealth  
     130   >> serviceDirectory >> enabled >> stealth 
    131131   >> additionalServiceOptions >> users; 
    132132 
     
    155155  } 
    156156  s.append(_serviceAddress +"#"+ _virtualPort +"#"+  _physicalAddressPort + 
    157     "#"+ _serviceDirectory +"#"+  _enabled + "#"+ stealth +"#"+  
     157    "#"+ _serviceDirectory +"#"+  _enabled + "#"+ stealth +"#"+ 
    158158    _additionalServiceOptions + "#"); 
    159159  foreach(UserAuthorizationData user, _users) 
  • vidalia/branches/hidden-services/src/vidalia/config/service.h

    r2959 r2960  
    2525  /** Constructor to create a new Service with initial settings */ 
    2626  Service(QString serviceAddress, QString virtualPort, 
    27    QString physicalAddressPort, QString serviceDirectory, bool enabled, bool stealth); 
     27   QString physicalAddressPort, QString serviceDirectory, 
     28   bool enabled, bool stealth); 
    2829  /** Destructor */ 
    2930  virtual ~Service(); 
  • vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp

    r2959 r2960  
    4343  /* a map mapping from the unique identification, to the auth data 
    4444   * of a service*/ 
    45   _consumedServices = new QMap<QString, ServiceAuthorizationData>(); 
     45  _consumedServices = new QMap<int, ServiceAuthorizationData>(); 
    4646  /** A QRegExpValidator to validate the identification of client auth(Id) 
    4747   * and service auth(Id)*/ 
     
    114114  connect(ui.serviceAccessWidget, SIGNAL(itemClicked(QTableWidgetItem*)), this, 
    115115   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())); 
    118120} 
    119121 
     
    222224      if(VMessageBox::warning(this, tr("Error"), tr("Some of the required user\ 
    223225       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."), 
    226228        VMessageBox::Yes, VMessageBox::No) == VMessageBox::Yes) { 
    227229          //create a list containing of all identifications to ensure 
     
    255257           for(int i = 0; i < ui.serviceAuthWidget->rowCount(); i++) { 
    256258             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){ 
    258260               ui.serviceAuthWidget->removeRow(i); 
    259261               i--; 
     
    313315      } 
    314316      serviceConfString.append(" hiddenserviceversion=\"2\" \ 
    315        hiddenserviceauthorizeclient="+string_escape(stealthMode+" " +  
     317       hiddenserviceauthorizeclient="+string_escape(stealthMode+" " + 
    316318       createUserAuthStringForTor(publishedUsers))); 
    317319    } 
    318320    serviceConfString.append(" "+ temp.additionalServiceOptions()); 
    319321  } 
    320   VMessageBox::warning(this, tr("torConfString"), serviceConfString, 
    321      VMessageBox::Ok); 
    322322  _serviceSettings->applyServices(serviceConfString, &errmsg); 
    323323} 
     
    380380  QString torConfigurationString = _serviceSettings-> 
    381381   getHiddenServiceDirectories(); 
    382    VMessageBox::warning(this, tr("kompletter string:"), torConfigurationString, 
    383              VMessageBox::Ok); 
    384382  torServiceList = extractSingleServices(torConfigurationString); 
    385383  // the services stored with vidalia 
     
    453451     } 
    454452    //remove first appearance of HiddenServiceVerison 
    455     indexstart = additionalOptions.indexOf("hiddenserviceversion", 0, Qt::CaseInsensitive); 
     453    indexstart = additionalOptions.indexOf("hiddenserviceversion", 0, 
     454     Qt::CaseInsensitive); 
    456455    endindex = additionalOptions.indexOf("250", indexstart); 
    457456    if(endindex != -1) { 
     
    582581        } 
    583582  } 
    584   Service service(address, virtualPort, physAddressPort, serviceDir, true, stealth); 
     583  Service service(address,virtualPort,physAddressPort,serviceDir,true,stealth); 
    585584  service.setAdditionalServiceOptions(additionalOptions); 
    586585  service.setUsers(actualUsers); 
     
    588587  return service; 
    589588} 
    590  
    591 /** this method is called to parse the client_keys file in order to 
    592  *  get all users that had a authorization for the Service 
    593  * @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 //} 
    631589 
    632590/** this method merges the list of services received from Vidalia and Tor 
     
    743701 
    744702void 
    745 ServicePage::initServiceAccessTable(QList<ServiceAuthorizationData> authdataList) 
     703ServicePage::initServiceAccessTable(QList<ServiceAuthorizationData> 
     704 authdataList) 
    746705{ 
    747706  while(ui.serviceAccessWidget->rowCount() > 0) { 
    748707    ui.serviceAccessWidget->removeRow(0); 
    749708  } 
     709  int index = 0; 
    750710  foreach(ServiceAuthorizationData tempService, authdataList) { 
    751     int rows = ui.serviceAccessWidget->rowCount(); 
     711    //int rows = ui.serviceAccessWidget->rowCount(); 
    752712    QString authdata = tempService.authdata(); 
    753     QString identification = tempService.identification(); 
     713    QString identification = ""+tempService.identification(); 
    754714    ServiceAuthorizationData s(authdata, identification); 
    755     ui.serviceAccessWidget->insertRow(rows); 
     715    ui.serviceAccessWidget->insertRow(index); 
    756716    QTableWidgetItem* authdataItem = new QTableWidgetItem(authdata); 
    757     QTableWidgetItem* identificationItem = new QTableWidgetItem(identification); 
     717    QTableWidgetItem* identificationItem = new 
     718     QTableWidgetItem(identification); 
    758719    identificationItem->setData(32, identification); 
    759720    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++; 
    763725  } 
    764726} 
     
    887849              identification = ui.serviceAuthWidget->item(i, 1)->text(); 
    888850              UserAuthorizationData u(authdata, identification); 
    889               if(ui.serviceAuthWidget->item(i,2)->checkState() == Qt::Checked) { 
     851              if(ui.serviceAuthWidget->item(i,2)->checkState()==Qt::Checked){ 
    890852                enabled = true; 
    891853              } 
     
    902864            QList<QString> identifications; 
    903865            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); 
    905867              if(selectedItem->text() != NULL && 
    906868               selectedItem->text().length() > 0) { 
     
    12271189  serviceIdentification = ""+ui.commentLineAccess->text(); 
    12281190  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); 
    12311193     return; 
    12321194  } else { 
     
    12381200        QTableWidgetItem* identificationItem = 
    12391201         new QTableWidgetItem(serviceIdentification); 
    1240         identificationItem->setData(32, serviceIdentification); 
     1202        //identificationItem->setData(32, serviceIdentification); 
    12411203        authItem->setData(32, serviceAuthdata); 
    12421204        ui.serviceAccessWidget->setItem(rows, 0, authItem); 
     
    12451207        ui.commentLineAccess->clear(); 
    12461208        ServiceAuthorizationData s(serviceAuthdata, serviceIdentification); 
    1247         _consumedServices->insert(serviceIdentification, s); 
     1209        _consumedServices->insert(rows, s); 
    12481210      } else { 
    12491211         VMessageBox::warning(this, tr("Error"), tr("Invalid input for the\ 
     
    12771239    } 
    12781240  } 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); 
    12811243    return QValidator::Invalid; 
    12821244  } 
     
    12871249ServicePage::removeServiceAuthBtnClicked() 
    12881250{ 
    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  } 
    12931264} 
    12941265 
     
    13781349ServicePage::serviceAccessValueChanged() 
    13791350{ 
    1380   QString currentString, currentAuthdata; 
    1381   QStringList values; 
     1351  QString currentAuthdata; 
    13821352  QTableWidgetItem *item = ui.serviceAccessWidget->item( 
    13831353   ui.serviceAccessWidget->currentRow(), 1); 
    13841354  QTableWidgetItem* authItem = ui.serviceAccessWidget->item( 
    13851355   ui.serviceAccessWidget->currentRow(), 0); 
    1386   if(item == NULL || item->text() == NULL || item->text().length() == 0 || 
    1387     authItem == NULL) { 
     1356  if(item == NULL || authItem == NULL) { 
    13881357    // nothing to validate here 
    13891358    return; 
    13901359  } 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); 
    13981378        } 
    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        } 
    14101379    } 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); 
    14371386      } else { 
    14381387        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   } 
    14501404} 
    14511405 
     
    15241478} 
    15251479 
     1480/** Called whenever the user clicks on the basic authorization checkbox*/ 
    15261481void 
    15271482ServicePage::checkBoxBasicToggled() 
     
    15381493} 
    15391494 
     1495/** Called whenever the user clicks on the stealth authorization checkbox*/ 
    15401496void 
    15411497ServicePage::checkBoxStealthToggled() 
  • vidalia/branches/hidden-services/src/vidalia/config/servicepage.h

    r2959 r2960  
    5151  *  @return a QValidator::State signalling whether the string is valid or not*/ 
    5252  QValidator::State validateServiceAuth(QString authString); 
    53   /** this method is called to parse the client_keys file in order to 
    54   * get all users that had a authorization for the Service 
    55   * @return a list of all users found in client_keys*/ 
    56   //QList<UserAuthorizationData> parseClientKeys(QString dir); 
    5753  /** this method creates the configuration string for tor including the 
    5854   * user authorization*/ 
     
    114110   * entry(Provided Services)*/ 
    115111  void serviceAuthSelectionChanged(); 
     112  /** Called whenever the user clicks on the basic authorization checkbox*/ 
    116113  void checkBoxBasicToggled(); 
     114  /** Called whenever the user clicks on the stealth authorization checkbox*/ 
    117115  void checkBoxStealthToggled(); 
    118116 
     
    126124  QMap<QString, Service>* _torServices; 
    127125  /* a map mapping from the unique comment, to the auth data of a service*/ 
    128   QMap<QString, ServiceAuthorizationData>* _consumedServices; 
     126  QMap<int, ServiceAuthorizationData>* _consumedServices; 
    129127  /** Qt Designer generated object */ 
    130128  Ui::ServicePage ui; 
  • vidalia/branches/hidden-services/src/vidalia/config/servicesettings.cpp

    r2959 r2960  
    5454ServiceSettings::apply(QString *errmsg) 
    5555{ 
    56   //dummy 
    5756  return true; 
    5857} 
     
    6261ServiceSettings::getServices() 
    6362{ 
    64   QString address,virtualPort,physAddrPort,serviceDir,enabledS,stealthS,additionalData; 
     63  QString address,virtualPort,physAddrPort,serviceDir,enabledS, 
     64   stealthS,additionalData; 
    6565  bool enabled = false; 
    6666  bool stealth = false; 
     
    106106      } 
    107107    } 
    108     Service s(address, virtualPort, physAddrPort, serviceDir, enabled, stealth); 
     108    Service s(address,virtualPort,physAddrPort,serviceDir,enabled,stealth); 
    109109    s.setAdditionalServiceOptions(additionalData); 
    110110    s.setUsers(users); 
  • vidalia/branches/hidden-services/src/vidalia/config/userauthorizationdata.cpp

    r2836 r2960  
    1616 
    1717/** Constructor to create a new User with initial settings */ 
    18 UserAuthorizationData::UserAuthorizationData(QString authdata, QString identification): 
    19  AbstractAuthorizationData(authdata, identification) 
     18UserAuthorizationData::UserAuthorizationData(QString authdata, 
     19 QString identification):AbstractAuthorizationData(authdata,identification) 
    2020{ 
    2121}