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

[vidalia-svn] r2974: more bugfixes and improvements, e.g. replacing of the checkb (vidalia/branches/hidden-services/src/vidalia/config)



Author: borkdomenik
Date: 2008-08-16 12:57:32 -0400 (Sat, 16 Aug 2008)
New Revision: 2974

Modified:
   vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp
   vidalia/branches/hidden-services/src/vidalia/config/servicepage.h
   vidalia/branches/hidden-services/src/vidalia/config/servicepage.ui
Log:
more bugfixes and improvements, e.g. replacing of the checkboxes for stealth|basic by some radio buttons. 

Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp	2008-08-16 15:30:13 UTC (rev 2973)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.cpp	2008-08-16 16:57:32 UTC (rev 2974)
@@ -45,14 +45,14 @@
   _consumedServices = new QMap<int, ServiceAuthorizationData>();
   /** A QRegExpValidator to validate the identification of client auth(Id)
    * and service auth(Id)*/
-  QRegExp rx("[a-zA-Z0-9\\+\\-\\_]{0,18}([a-zA-Z0-9\\+\\-\\_])");
+  QRegExp rx("[a-zA-Z0-9\\+\\-\\_]{0,15}([a-zA-Z0-9\\+\\-\\_])");
   _identificationValidator = new QRegExpValidator(rx, this);
   /** A QRegExpValidator to validate a onion address (base32,
    * 16 chars +".onion"*/
   QRegExp base32("[a-z2-7]{15}([a-z2-7]).onion");
   _onionAdressValidator = new QRegExpValidator(base32, this);
   /** A QRegExpValidator to validate a cookie(base64, 22 chars)*/
-  QRegExp base64("[a-zA-Z0-9\\+\\-\\/]{21}([a-zA-Z0-9\\+\\-\\/])");
+  QRegExp base64("[a-zA-Z0-9\\+\\-\\/]{20}([a-zA-Z0-9\\+\\-\\/])");
   _cookieValidator = new QRegExpValidator(base64, this);
 
   ui.serviceWidget->horizontalHeader()->resizeSection(0, 150);
@@ -110,10 +110,8 @@
    SLOT(serviceAccessValueChanged()));
   connect(ui.serviceAccessWidget, SIGNAL(itemClicked(QTableWidgetItem*)), this,
    SLOT(serviceAccessSelectionChanged()));
-  connect(ui.checkBox_basic, SIGNAL(toggled(bool)), this,
-   SLOT(checkBoxBasicToggled()));
-  connect(ui.checkBox_stealth, SIGNAL(toggled(bool)), this,
-   SLOT(checkBoxStealthToggled()));
+  connect(ui.basic_radioButton, SIGNAL(toggled(bool)), this,
+   SLOT(checkBoxBasicToggled(bool)));
 }
 
 /** Destructor */
@@ -398,7 +396,6 @@
 
 /** this method returns a Service by parseing the configuration string
  *  of Tor and storing its values into the object */
- //XTODO hier den parser auch anpassen um basic/stealth abzufange!!
 Service
 ServicePage::generateService(QString s)
 {
@@ -922,18 +919,20 @@
   Service selService = _services->take(ui.serviceWidget->currentRow());
   QList<UserAuthorizationData> assoziatedUsers = selService.users();
   if(selService.stealth()) {
-        ui.checkBox_stealth->setCheckState(Qt::Checked);
-        ui.checkBox_basic->setCheckState(Qt::Unchecked);
+        ui.stealth_radioButton->setChecked(true);
+        ui.basic_radioButton->setChecked(false);
   } else {
-    ui.checkBox_basic->setCheckState(Qt::Checked);
-    ui.checkBox_stealth->setCheckState(Qt::Unchecked);
+    ui.stealth_radioButton->setChecked(false);
+    ui.basic_radioButton->setChecked(true);
   }
   if(assoziatedUsers.size() == 0) {
     ui.authClientsGroupBox->setVisible(false);
     ui.restrictAccessCheckBox->setCheckState(Qt::Unchecked);
+    ui.restrictAccessCheckBox->setEnabled(true);
   } else {
       ui.authClientsGroupBox->setVisible(true);
       ui.restrictAccessCheckBox->setCheckState(Qt::Checked);
+      ui.restrictAccessCheckBox->setEnabled(false);
       int rowcount = 0;
       QListIterator<UserAuthorizationData> it(assoziatedUsers);
       while(it.hasNext()) {
@@ -1174,25 +1173,37 @@
 QValidator::State
 ServicePage::validateServiceAuth(QString authString)
 {
+  QStringList authMode;
+  authMode << "A" <<"B" <<"Q" <<"R" <<"g" <<"h" <<"w" <<"x";
   if(authString.length() != 45 || authString.contains(" ") == false) {
     return QValidator::Invalid;
   }
   QStringList strList = authString.split(" ");
   int pos = 0;
-  if(_onionAdressValidator->validate(strList.first(), pos) ==
+  QString onion = strList.first();
+  if(_onionAdressValidator->validate(onion, pos) ==
    QValidator::Acceptable) {
     strList.removeFirst();
-    if(_cookieValidator->validate(strList.first(), pos) ==
-     QValidator::Acceptable) {
+    QString cookieValid = strList.first().left(21);
+    QString cookie = strList.first();
+    for(int i = 0; i < ui.serviceAccessWidget->rowCount(); i++) {
+      QTableWidgetItem *item = ui.serviceAccessWidget->item(i,0);
+      QStringList onionStrList = item->text().split(" ");
+      QString on, cook;
+      on = onionStrList.first();
+      onionStrList.removeFirst();
+      cook = onionStrList.first();
+      if(onion.compare(on) == 0 && cookie.compare(cook) == 0) {
+        return QValidator::Invalid;
+      }
+    }
+    if(_cookieValidator->validate(cookieValid, pos) ==
+     QValidator::Acceptable && authMode.contains(strList.first().right(1))) {
       return QValidator::Acceptable;
     } else {
-      VMessageBox::warning(this, tr("Error"), tr("Your cookie is not valid,\
-       please correct it."), VMessageBox::Ok);
       return QValidator::Invalid;
     }
   } else {
-    VMessageBox::warning(this, tr("Error"), tr("Your onion adress is\
-     not valid, please correct it."), VMessageBox::Ok);
     return QValidator::Invalid;
   }
 }
@@ -1214,6 +1225,7 @@
     ui.serviceAccessWidget->setItem(id, 1, ident);
     id++;
   }
+  serviceAccessSelectionChanged();
 }
 
 /** Called when the user wants to copy athorization data for a service to
@@ -1390,7 +1402,15 @@
     QString address = ui.serviceAuthWidget->item(row,0)->text();
     bool b = address.contains(".onion");
     ui.copyClientAuthBtn->setEnabled(b);
+    ui.removeClientAuthBtn->setEnabled(true);
   }
+  if(ui.serviceAuthWidget->rowCount() < 1) {
+    ui.copyClientAuthBtn->setEnabled(false);
+    ui.removeClientAuthBtn->setEnabled(false);
+    ui.restrictAccessCheckBox->setEnabled(true);
+  } else {
+    ui.restrictAccessCheckBox->setEnabled(false);
+  }
 }
 
 /** this method is called to ensure that all required fields are set
@@ -1410,31 +1430,10 @@
 
 /** Called whenever the user clicks on the basic authorization checkbox*/
 void
-ServicePage::checkBoxBasicToggled()
+ServicePage::checkBoxBasicToggled(bool checked)
 {
-  bool state = ui.checkBox_basic->checkState() == Qt::Checked;
-  if(state) {
-    ui.checkBox_stealth->setCheckState(Qt::Unchecked);
-  } else {
-    ui.checkBox_stealth->setCheckState(Qt::Checked);
-  }
   Service s = _services->take(ui.serviceWidget->currentRow());
-  s.setStealth(!state);
+  s.setStealth(!checked);
   _services->insert(ui.serviceWidget->currentRow(), s);
 }
 
-/** Called whenever the user clicks on the stealth authorization checkbox*/
-void
-ServicePage::checkBoxStealthToggled()
-{
-  bool state = ui.checkBox_stealth->checkState() == Qt::Checked;
-  if(state) {
-    ui.checkBox_basic->setCheckState(Qt::Unchecked);
-  } else {
-    ui.checkBox_basic->setCheckState(Qt::Checked);
-  }
-  Service s = _services->take(ui.serviceWidget->currentRow());
-  s.setStealth(state);
-  _services->insert(ui.serviceWidget->currentRow(), s);
-}
-

Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.h
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.h	2008-08-16 15:30:13 UTC (rev 2973)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.h	2008-08-16 16:57:32 UTC (rev 2974)
@@ -110,9 +110,7 @@
    * entry(Provided Services)*/
   void serviceAuthSelectionChanged();
   /** Called whenever the user clicks on the basic authorization checkbox*/
-  void checkBoxBasicToggled();
-  /** Called whenever the user clicks on the stealth authorization checkbox*/
-  void checkBoxStealthToggled();
+  void checkBoxBasicToggled(bool checked);
 
 private:
 

Modified: vidalia/branches/hidden-services/src/vidalia/config/servicepage.ui
===================================================================
--- vidalia/branches/hidden-services/src/vidalia/config/servicepage.ui	2008-08-16 15:30:13 UTC (rev 2973)
+++ vidalia/branches/hidden-services/src/vidalia/config/servicepage.ui	2008-08-16 16:57:32 UTC (rev 2974)
@@ -6,7 +6,7 @@
     <x>0</x>
     <y>0</y>
     <width>653</width>
-    <height>496</height>
+    <height>492</height>
    </rect>
   </property>
   <property name="sizePolicy" >
@@ -295,126 +295,126 @@
        <property name="title" >
         <string>Authorized Clients</string>
        </property>
-       <layout class="QGridLayout" >
-        <item row="0" column="0" >
-         <layout class="QGridLayout" >
-          <item row="0" column="0" >
-           <widget class="QCheckBox" name="checkBox_basic" >
-            <property name="toolTip" >
-             <string>the basic authorization mode is more scalable but less secure</string>
-            </property>
-            <property name="text" >
-             <string>basic configuration</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="1" >
-           <widget class="QCheckBox" name="checkBox_stealth" >
-            <property name="toolTip" >
-             <string>the stealth authorization mode is more secure but less scalable</string>
-            </property>
-            <property name="text" >
-             <string>stealth configuration</string>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="0" colspan="2" >
-           <layout class="QGridLayout" >
-            <item rowspan="4" row="0" column="0" >
-             <widget class="QTableWidget" name="serviceAuthWidget" >
-              <property name="sizePolicy" >
-               <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
-                <horstretch>0</horstretch>
-                <verstretch>0</verstretch>
-               </sizepolicy>
-              </property>
-              <property name="maximumSize" >
-               <size>
-                <width>16777215</width>
-                <height>16777215</height>
-               </size>
-              </property>
-              <property name="toolTip" >
-               <string>A listing of all ClientAuthorizationData configured with Vidalia</string>
-              </property>
-              <property name="selectionMode" >
-               <enum>QAbstractItemView::SingleSelection</enum>
-              </property>
-              <property name="selectionBehavior" >
-               <enum>QAbstractItemView::SelectRows</enum>
-              </property>
-              <property name="textElideMode" >
-               <enum>Qt::ElideLeft</enum>
-              </property>
-              <column>
-               <property name="text" >
-                <string>Authorization String</string>
-               </property>
-              </column>
-              <column>
-               <property name="text" >
-                <string>Identification</string>
-               </property>
-              </column>
-             </widget>
-            </item>
-            <item row="0" column="1" >
-             <widget class="QToolButton" name="addClientAuthBtn" >
-              <property name="toolTip" >
-               <string>Add a new user with authorization to the selected service</string>
-              </property>
+       <widget class="QWidget" name="" >
+        <property name="geometry" >
+         <rect>
+          <x>12</x>
+          <y>20</y>
+          <width>591</width>
+          <height>141</height>
+         </rect>
+        </property>
+        <layout class="QGridLayout" >
+         <item row="0" column="0" >
+          <widget class="QRadioButton" name="basic_radioButton" >
+           <property name="text" >
+            <string>basic configuration</string>
+           </property>
+          </widget>
+         </item>
+         <item row="0" column="1" >
+          <widget class="QRadioButton" name="stealth_radioButton" >
+           <property name="text" >
+            <string>stealth configuration</string>
+           </property>
+          </widget>
+         </item>
+         <item row="1" column="0" colspan="2" >
+          <layout class="QGridLayout" >
+           <item rowspan="4" row="0" column="0" >
+            <widget class="QTableWidget" name="serviceAuthWidget" >
+             <property name="sizePolicy" >
+              <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
+               <horstretch>0</horstretch>
+               <verstretch>0</verstretch>
+              </sizepolicy>
+             </property>
+             <property name="maximumSize" >
+              <size>
+               <width>16777215</width>
+               <height>16777215</height>
+              </size>
+             </property>
+             <property name="toolTip" >
+              <string>A listing of all ClientAuthorizationData configured with Vidalia</string>
+             </property>
+             <property name="selectionMode" >
+              <enum>QAbstractItemView::SingleSelection</enum>
+             </property>
+             <property name="selectionBehavior" >
+              <enum>QAbstractItemView::SelectRows</enum>
+             </property>
+             <property name="textElideMode" >
+              <enum>Qt::ElideLeft</enum>
+             </property>
+             <column>
               <property name="text" >
-               <string/>
+               <string>Authorization String</string>
               </property>
-              <property name="icon" >
-               <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-add.png</iconset>
-              </property>
-             </widget>
-            </item>
-            <item row="1" column="1" >
-             <widget class="QToolButton" name="removeClientAuthBtn" >
-              <property name="toolTip" >
-               <string>Remove the selected user and his authorization data from the selected service</string>
-              </property>
+             </column>
+             <column>
               <property name="text" >
-               <string/>
+               <string>Identification</string>
               </property>
-              <property name="icon" >
-               <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-remove.png</iconset>
-              </property>
-             </widget>
-            </item>
-            <item row="2" column="1" >
-             <widget class="QToolButton" name="copyClientAuthBtn" >
-              <property name="toolTip" >
-               <string>Copy authorization data to clipboard</string>
-              </property>
-              <property name="text" >
-               <string/>
-              </property>
-              <property name="icon" >
-               <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/edit-copy.png</iconset>
-              </property>
-             </widget>
-            </item>
-            <item row="3" column="1" >
-             <spacer>
-              <property name="orientation" >
-               <enum>Qt::Vertical</enum>
-              </property>
-              <property name="sizeHint" >
-               <size>
-                <width>26</width>
-                <height>66</height>
-               </size>
-              </property>
-             </spacer>
-            </item>
-           </layout>
-          </item>
-         </layout>
-        </item>
-       </layout>
+             </column>
+            </widget>
+           </item>
+           <item row="0" column="1" >
+            <widget class="QToolButton" name="addClientAuthBtn" >
+             <property name="toolTip" >
+              <string>Add a new user with authorization to the selected service</string>
+             </property>
+             <property name="text" >
+              <string/>
+             </property>
+             <property name="icon" >
+              <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-add.png</iconset>
+             </property>
+            </widget>
+           </item>
+           <item row="1" column="1" >
+            <widget class="QToolButton" name="removeClientAuthBtn" >
+             <property name="toolTip" >
+              <string>Remove the selected user and his authorization data from the selected service</string>
+             </property>
+             <property name="text" >
+              <string/>
+             </property>
+             <property name="icon" >
+              <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/list-remove.png</iconset>
+             </property>
+            </widget>
+           </item>
+           <item row="2" column="1" >
+            <widget class="QToolButton" name="copyClientAuthBtn" >
+             <property name="toolTip" >
+              <string>Copy authorization data to clipboard</string>
+             </property>
+             <property name="text" >
+              <string/>
+             </property>
+             <property name="icon" >
+              <iconset resource="../res/vidalia_common.qrc" >:/images/22x22/edit-copy.png</iconset>
+             </property>
+            </widget>
+           </item>
+           <item row="3" column="1" >
+            <spacer>
+             <property name="orientation" >
+              <enum>Qt::Vertical</enum>
+             </property>
+             <property name="sizeHint" >
+              <size>
+               <width>26</width>
+               <height>66</height>
+              </size>
+             </property>
+            </spacer>
+           </item>
+          </layout>
+         </item>
+        </layout>
+       </widget>
       </widget>
      </widget>
      <widget class="QWidget" name="tab_4" >
@@ -561,7 +561,7 @@
           <number>1</number>
          </property>
          <property name="text" >
-          <string>Afterwards you can access the hidden service using the first part of the Client Authorization String, the onion address.! (Don't forget to save before trying.)</string>
+          <string>Afterwards you can access the hidden service using the first part of the Client Authorization String, the onion address. (Don't forget to save before trying.)</string>
          </property>
          <property name="scaledContents" >
           <bool>false</bool>