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

[vidalia-svn] r2666: Aesthetic modificaitons... now with country maps. Reset of o (vidalia/branches/exit-country/src/vidalia/config)



Author: cviecco
Date: 2008-06-04 17:00:36 -0400 (Wed, 04 Jun 2008)
New Revision: 2666

Modified:
   vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp
   vidalia/branches/exit-country/src/vidalia/config/networkoutpage.h
   vidalia/branches/exit-country/src/vidalia/config/networkoutpage.ui
Log:
Aesthetic modificaitons... now with country maps. Reset of old cirucits!


Modified: vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp	2008-06-04 13:17:38 UTC (rev 2665)
+++ vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp	2008-06-04 21:00:36 UTC (rev 2666)
@@ -31,21 +31,11 @@
   _settings = new VidaliaSettings();
 
   /*Create a network status object ... is there one already?*/
-  TorControl *tc ;
-  tc=Vidalia::torControl();
-  QString error_str;
-  NetworkStatus networkstatus=(*tc).getNetworkStatus(&error_str);
-
   _torControl = Vidalia::torControl();
   NetworkStatus networkStatus = _torControl->getNetworkStatus();
 
-
-//  QList<RouterStatus> testlist(networkstatus);
-//  testlist=networkstatus;
-  QString short_country_name;
-  QString ip_addr;
-
   /* Populate combo boxes */
+  /*
   foreach (QString code, LanguageSupport::languageCodes()) {
     ui.cmboLanguage->addItem(LanguageSupport::languageName(code),
                              code);
@@ -53,9 +43,11 @@
   foreach (QString style, QStyleFactory::keys()) {
     ui.cmboStyle->addItem(style, style.toLower());
   }
+ */ 
 
   /*do connections!*/
   connect(_torControl, SIGNAL(authenticated()), this, SLOT(onAuthenticated()));
+  connect(_torControl, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
 
   /*
  connect(ui.lblBandwidthGraph, SIGNAL(clicked()),
@@ -79,20 +71,26 @@
   NetworkSettings settings(Vidalia::torControl());
 
   Q_UNUSED(errmsg);
+/*
   QString languageCode =
     LanguageSupport::languageCode(ui.cmboLanguage->currentText());
   
   _settings->setLanguageCode(languageCode);
   _settings->setInterfaceStyle(ui.cmboStyle->currentText());
  
-  /* Set to new style */
+  ///* Set to new style 
   Vidalia::setStyle(ui.cmboStyle->currentText());
-
+*/
  
   settings.setUseNodePolicy(ui.chkNodePolicy->isChecked());
   /*Need to add validation?*/
   settings.setExitNodeList(ui.lineEditExitNodes->text().split(",", QString::SkipEmptyParts) );    
 
+  /*if clear connections is set, clear them up!*/
+  if(ui.chkCloseAllActiveCircuits->isChecked()){
+     closeAllCircuits();     
+  }
+
   return true;
 }
   
@@ -104,16 +102,18 @@
   NetworkSettings settings(Vidalia::torControl());  
 
   //ok the next three lines can be simiplified.. talk to edmanm
+  /*
   TorControl *tc ;
   tc=Vidalia::torControl();
   NetworkStatus networkstatus=(*tc).getNetworkStatus(NULL);
-
+*/
+/*
   int index = ui.cmboLanguage->findData(_settings->getLanguageCode());
   ui.cmboLanguage->setCurrentIndex(index);
   
   index = ui.cmboStyle->findData(Vidalia::style().toLower());
   ui.cmboStyle->setCurrentIndex(index);
-  
+  */
  
   ui.chkNodePolicy->setChecked(settings.getUseNodePolicy());
   QStringList exit_nodes = settings.getExitNodeList();
@@ -121,6 +121,9 @@
 
   //cmboExitNodesbyCountry->ui.cmboStyle("")
 
+  ui.chkCloseAllActiveCircuits->setChecked(false);
+  ui.chkCloseAllActiveCircuits->setEnabled(false);
+
 }
 
 void
@@ -137,37 +140,62 @@
   QString ip_addr;
   QString count;
   int flags;
+  QString uniqueRouterName;
  
-  fprintf(stderr,"hello2\n");
+  //fprintf(stderr,"hello2\n");
+ 
+  /*Fill up the internal structure*/
   foreach( RouterStatus router, networkStatus){
-     fprintf(stderr,"*");
+     //fprintf(stderr,"*");
+
      //Get the country!
      ip_addr=router.ipAddress().toString();
      short_country_name=_torControl->getIPCountry(ip_addr);    
-
+ 
+     /*Only continue if the router is running,valid,isexit and is NOT badexit*/
      if (!router.isRunning())
       continue;
-
      if (!router.isValid())
       continue;
-
      flags=router.flags();
-     if(0x08 !=(0x08 & flags) )
+     if(0x08 !=((0x08 | 0x02) & flags) )  //must be exit and not badexit!
       continue;
-     fprintf(stderr,"%x\n",flags);
+     //fprintf(stderr,"%x\n",flags);
 
+     /*Get a unique name, if unnamed use the full descriptor id*/
+     uniqueRouterName=router.name();
+     if(uniqueRouterName=="Unnamed"){
+         uniqueRouterName=router.id().prepend("$");
+     }
 
+     /*Now insert the information into the HAsh/MAp*/
      if (by_country_exit_nodes.contains(short_country_name)){
-        by_country_exit_nodes.insert(short_country_name, QStringList(by_country_exit_nodes.value(short_country_name))<<router.name());
+        by_country_exit_nodes.insert(short_country_name, 
+                 QStringList(by_country_exit_nodes.value(short_country_name))<<uniqueRouterName);
      }
      else{
-        by_country_exit_nodes.insert(short_country_name,QStringList()<<router.name());
+        //by_country_exit_nodes.insert(short_country_name,QStringList()<<router.name());
+        by_country_exit_nodes.insert(short_country_name,QStringList()<<uniqueRouterName);
+
      }
   }
-  //* now fill the combo boxes!*/
+
+
+  //* now fill the combo boxes!*/  
   foreach (QString country, by_country_exit_nodes.keys()) {
+    /*Get the count of exit nodes for this country*/
     count=QString("%1").arg(by_country_exit_nodes.value(country).count(),0,10);
-    ui.cmboExitNodesbyCountry->addItem(country,
+ 
+    /*now do de icon for the country*/
+    QIcon country_flag;
+    if(country!="??"){
+      country_flag.addFile(":/images/flags/" + country + ".png");
+    }
+    else{
+      country_flag.addFile(":/images/flags/unkown.png");
+    }
+    /*finally add the country information to the combo box!*/
+    ui.cmboExitNodesbyCountry->addItem(country_flag,country,
                              country.append("(").append(count).append(")"));
   }
 
@@ -185,5 +213,35 @@
   current=countrylist.at(0);
   fprintf(stderr,"nqlen=%d",current.length());
   ui.lineEditExitNodes->setText(by_country_exit_nodes.value(current).join(","));  
- 
+
+  //alsoe enable
+  ui.chkCloseAllActiveCircuits->setEnabled(true); 
+   ui.chkCloseAllActiveCircuits->setChecked(true);
 }
+
+
+  /** Handles when we get disconnected from Tor network */
+ void
+NetworkoutPage::onDisconnected(){
+  //erase data structure
+  by_country_exit_nodes.clear();
+  //remove data from the country combo box?
+
+}
+void
+NetworkoutPage::closeAllCircuits(){
+  //get list of circuits
+   CircuitList circuitList;
+   circuitList=_torControl->getCircuits();
+
+   foreach(Circuit circuit, circuitList){
+    //for each do close!
+    /*     * true, then the circuit will not be closed unless it is unused. */
+    //bool closeCircuit(quint64 circid, bool ifUnused = false, QString *errmsg = 0);
+    _torControl->closeCircuit(circuit.id());    
+  }
+   
+  
+}
+
+

Modified: vidalia/branches/exit-country/src/vidalia/config/networkoutpage.h
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/networkoutpage.h	2008-06-04 13:17:38 UTC (rev 2665)
+++ vidalia/branches/exit-country/src/vidalia/config/networkoutpage.h	2008-06-04 21:00:36 UTC (rev 2666)
@@ -46,14 +46,15 @@
   
 private slots:
   void copyCountryToText();
-
   /*Do stuff once authenticated*/
-  void onAuthenticated();
+  void onAuthenticated();  
+  /** Handles when we get disconnected from Tor network */
+  void onDisconnected();
 
-
-
   
 private:
+  void closeAllCircuits();
+
   /** A VidaliaSettings object used for saving/loading settings */
   VidaliaSettings* _settings;
 
@@ -61,7 +62,7 @@
   Ui::NetworkoutPage ui;
 
   /*struct to hold the country-exit-node-mappings */
-  QHash<QString,QStringList> by_country_exit_nodes;
+  QMap<QString,QStringList> by_country_exit_nodes;
 
   TorControl* _torControl;
 

Modified: vidalia/branches/exit-country/src/vidalia/config/networkoutpage.ui
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/networkoutpage.ui	2008-06-04 13:17:38 UTC (rev 2665)
+++ vidalia/branches/exit-country/src/vidalia/config/networkoutpage.ui	2008-06-04 21:00:36 UTC (rev 2666)
@@ -12,160 +12,13 @@
   <property name="contextMenuPolicy" >
    <enum>Qt::NoContextMenu</enum>
   </property>
-  <widget class="QGroupBox" name="grpLanguage" >
-   <property name="geometry" >
-    <rect>
-     <x>9</x>
-     <y>9</y>
-     <width>476</width>
-     <height>92</height>
-    </rect>
-   </property>
-   <property name="contextMenuPolicy" >
-    <enum>Qt::NoContextMenu</enum>
-   </property>
-   <property name="title" >
-    <string>Language</string>
-   </property>
-   <layout class="QGridLayout" >
-    <property name="leftMargin" >
-     <number>9</number>
-    </property>
-    <property name="topMargin" >
-     <number>9</number>
-    </property>
-    <property name="rightMargin" >
-     <number>9</number>
-    </property>
-    <property name="bottomMargin" >
-     <number>9</number>
-    </property>
-    <property name="horizontalSpacing" >
-     <number>6</number>
-    </property>
-    <property name="verticalSpacing" >
-     <number>6</number>
-    </property>
-    <item row="1" column="0" >
-     <widget class="QComboBox" name="cmboLanguage" >
-      <property name="minimumSize" >
-       <size>
-        <width>150</width>
-        <height>0</height>
-       </size>
-      </property>
-      <property name="contextMenuPolicy" >
-       <enum>Qt::NoContextMenu</enum>
-      </property>
-      <property name="toolTip" >
-       <string>Choose the language used in Vidalia</string>
-      </property>
-      <property name="editable" >
-       <bool>false</bool>
-      </property>
-      <property name="iconSize" >
-       <size>
-        <width>24</width>
-        <height>16</height>
-       </size>
-      </property>
-     </widget>
-    </item>
-    <item row="1" column="1" >
-     <spacer>
-      <property name="orientation" >
-       <enum>Qt::Horizontal</enum>
-      </property>
-      <property name="sizeHint" >
-       <size>
-        <width>300</width>
-        <height>16</height>
-       </size>
-      </property>
-     </spacer>
-    </item>
-    <item row="0" column="0" colspan="2" >
-     <widget class="QLabel" name="label" >
-      <property name="contextMenuPolicy" >
-       <enum>Qt::NoContextMenu</enum>
-      </property>
-      <property name="text" >
-       <string>Changes to language will only take effect after restarting Vidalia!</string>
-      </property>
-     </widget>
-    </item>
-   </layout>
-  </widget>
-  <widget class="QGroupBox" name="grpStyle" >
-   <property name="geometry" >
-    <rect>
-     <x>9</x>
-     <y>107</y>
-     <width>471</width>
-     <height>68</height>
-    </rect>
-   </property>
-   <property name="contextMenuPolicy" >
-    <enum>Qt::NoContextMenu</enum>
-   </property>
-   <property name="toolTip" >
-    <string/>
-   </property>
-   <property name="title" >
-    <string>Style</string>
-   </property>
-   <widget class="QWidget" name="layoutWidget" >
-    <property name="geometry" >
-     <rect>
-      <x>11</x>
-      <y>28</y>
-      <width>451</width>
-      <height>31</height>
-     </rect>
-    </property>
-    <layout class="QHBoxLayout" >
-     <item>
-      <widget class="QComboBox" name="cmboStyle" >
-       <property name="minimumSize" >
-        <size>
-         <width>150</width>
-         <height>0</height>
-        </size>
-       </property>
-       <property name="contextMenuPolicy" >
-        <enum>Qt::NoContextMenu</enum>
-       </property>
-       <property name="toolTip" >
-        <string>Choose Vidalia's interface style</string>
-       </property>
-       <property name="editable" >
-        <bool>false</bool>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer>
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" >
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </widget>
-  </widget>
   <widget class="QCheckBox" name="chkNodePolicy" >
    <property name="geometry" >
     <rect>
      <x>10</x>
-     <y>180</y>
+     <y>10</y>
      <width>405</width>
-     <height>23</height>
+     <height>21</height>
     </rect>
    </property>
    <property name="text" >
@@ -176,8 +29,8 @@
    <property name="geometry" >
     <rect>
      <x>10</x>
-     <y>200</y>
-     <width>471</width>
+     <y>30</y>
+     <width>501</width>
      <height>181</height>
     </rect>
    </property>
@@ -243,6 +96,19 @@
      <string>Country</string>
     </property>
    </widget>
+   <widget class="QCheckBox" name="chkCloseAllActiveCircuits" >
+    <property name="geometry" >
+     <rect>
+      <x>80</x>
+      <y>130</y>
+      <width>171</width>
+      <height>23</height>
+     </rect>
+    </property>
+    <property name="text" >
+     <string>Close All Active Circuits</string>
+    </property>
+   </widget>
   </widget>
  </widget>
  <resources/>