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

[vidalia-svn] r2949: Better naming of the page and associated classes. (in vidalia/branches/exit-country/src/vidalia: . config)



Author: cviecco
Date: 2008-08-08 17:03:51 -0400 (Fri, 08 Aug 2008)
New Revision: 2949

Added:
   vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.cpp
   vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.h
   vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.ui
Removed:
   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
Modified:
   vidalia/branches/exit-country/src/vidalia/CMakeLists.txt
   vidalia/branches/exit-country/src/vidalia/config/configdialog.cpp
   vidalia/branches/exit-country/src/vidalia/config/configdialog.h
   vidalia/branches/exit-country/src/vidalia/config/nodepolicysettings.cpp
Log:
Better naming of the page and associated classes. 


Modified: vidalia/branches/exit-country/src/vidalia/CMakeLists.txt
===================================================================
--- vidalia/branches/exit-country/src/vidalia/CMakeLists.txt	2008-08-08 15:54:29 UTC (rev 2948)
+++ vidalia/branches/exit-country/src/vidalia/CMakeLists.txt	2008-08-08 21:03:51 UTC (rev 2949)
@@ -66,11 +66,12 @@
   config/servicelist.cpp
   config/servicepage.cpp
   config/servicesettings.cpp
-  config/networkoutpage.cpp
+  #config/networkoutpage.cpp
   config/torsettings.cpp
   config/vidaliasettings.cpp
   config/vsettings.cpp
   config/nodepolicysettings.cpp
+  config/nodepolicypage.cpp
 )
 qt4_wrap_cpp(vidalia_SRCS
   config/abstracttorsettings.h
@@ -88,11 +89,12 @@
   config/serverpage.h
   config/serversettings.h
   config/servicepage.h
-  config/networkoutpage.h
+  #config/networkoutpage.h
   config/torsettings.h
   config/vidaliasettings.h
   config/vsettings.h
   config/nodepolicysettings.h
+  config/nodepolicypage.h
 )
 if (USE_MINIUPNPC)
   include_directories(${MINIUPNPC_INCLUDE_DIR})
@@ -229,7 +231,8 @@
   config/networkpage.ui
   config/serverpage.ui
   config/servicepage.ui
-  config/networkoutpage.ui
+  #config/networkoutpage.ui
+  config/nodepolicypage.ui
   help/browser/helpbrowser.ui
   log/messagelog.ui
   network/netviewer.ui

Modified: vidalia/branches/exit-country/src/vidalia/config/configdialog.cpp
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/configdialog.cpp	2008-08-08 15:54:29 UTC (rev 2948)
+++ vidalia/branches/exit-country/src/vidalia/config/configdialog.cpp	2008-08-08 21:03:51 UTC (rev 2949)
@@ -93,7 +93,7 @@
                        createPageAction(QIcon(IMAGE_SERVICE),
                                         tr("Services"), grp));
 
-  ui.stackPages->add(new NetworkoutPage(ui.stackPages),
+  ui.stackPages->add(new NodePolicyPage(ui.stackPages),
                        createPageAction(QIcon(IMAGE_NETWORK),
                                         tr("Relay Policy"), grp));
 

Modified: vidalia/branches/exit-country/src/vidalia/config/configdialog.h
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/configdialog.h	2008-08-08 15:54:29 UTC (rev 2948)
+++ vidalia/branches/exit-country/src/vidalia/config/configdialog.h	2008-08-08 21:03:51 UTC (rev 2949)
@@ -27,7 +27,8 @@
 #include "advancedpage.h"
 #include "appearancepage.h"
 #include "servicepage.h"
-#include "networkoutpage.h"
+//#include "networkoutpage.h"
+#include "nodepolicypage.h"
 
 #include "ui_configdialog.h"
 

Deleted: vidalia/branches/exit-country/src/vidalia/config/networkoutpage.cpp

Deleted: vidalia/branches/exit-country/src/vidalia/config/networkoutpage.h

Deleted: vidalia/branches/exit-country/src/vidalia/config/networkoutpage.ui

Added: vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.cpp
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.cpp	                        (rev 0)
+++ vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.cpp	2008-08-08 21:03:51 UTC (rev 2949)
@@ -0,0 +1,701 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+**  may be copied, modified, propagated, or distributed except according to the
+**  terms described in the LICENSE file.
+*/
+
+/*
+** \file networkoutpage.cpp
+** \version $Id: appearancepage.cpp 2362 2008-02-29 04:30:11Z cviecco $
+** \brief Displays Vidalia Node policy settings
+*/
+
+#include <vidalia.h>
+#include "nodepolicypage.h"
+#include <nodepolicysettings.h>
+
+/** Default Constructor */
+NodePolicyPage::NodePolicyPage(QWidget *parent)
+: ConfigPage(parent, tr("Networkout"))
+{
+  /* Invoke Designer-generated object setup routine */
+  ui.setupUi(this);
+
+  /* Create VidaliaSettings object */
+  _settings = new NodePolicySettings(Vidalia::torControl());
+
+
+  /*Create a network status object ... is there one already?*/
+  _torControl = Vidalia::torControl();
+  NetworkStatus networkStatus = _torControl->getNetworkStatus();
+
+
+  /* Create the timer that will be used to update the internal ans displays once
+   every 30 minutes */
+   _refreshTimer.setInterval(60*30*1000);
+  connect(&_refreshTimer, SIGNAL(timeout()), this, SLOT(refresh()));
+
+
+  /*do connections!*/
+  connect(_torControl, SIGNAL(authenticated()), this, SLOT(onAuthenticated()));
+  connect(_torControl, SIGNAL(disconnected()), this, SLOT(onDisconnected()));
+
+  connect(ui.pButtonApplyCountry,SIGNAL(clicked()),
+          this, SLOT( copyExitCountryToText() ));
+
+  connect(ui.pButtonApplyExcludedCountry,SIGNAL(clicked()),
+          this, SLOT( copyExcludedCountryToText() ));
+
+
+  connect(ui.chkNodePolicy,SIGNAL(clicked()),
+          this, SLOT( HideUnhide() ));
+  connect(ui.chkExitNodePolicy,SIGNAL(clicked()),
+          this, SLOT( HideUnhide() ));
+  connect(ui.chkExcludeNodePolicy,SIGNAL(clicked()),
+          this, SLOT( HideUnhide() ));
+
+
+  /* Connect to  geoip resolver*/
+  _geoIpResolver=Vidalia::geoIpResolver();
+  connect(_geoIpResolver, SIGNAL(geoResolved()), this, SLOT(refresh()));
+ 
+}
+
+/** Destructor */
+NodePolicyPage::~NodePolicyPage()
+{
+  delete _settings;
+}
+
+/** Saves the changes on this page */
+bool
+NodePolicyPage::save(QString &errmsg)
+{
+  //NetworkSettings settings(Vidalia::torControl());
+  NodePolicySettings settings(Vidalia::torControl());
+
+
+  Q_UNUSED(errmsg);
+
+  _settings->setUseNodePolicy(ui.chkNodePolicy->isChecked());
+
+  /*Now save only is settings have been enabled*/
+  if((ui.chkNodePolicy->isChecked())){
+    /*Only save if we have enabled saving exit policies!*/
+    if(ui.chkExitNodePolicy->isChecked()){
+        /*Need to add validation?*/
+       //OK I dont like this:
+        QString current=ui.cmboExitNodesbyCountry->currentText();
+        QStringList countrylist=current.split("(");
+        current=countrylist.at(0);
+        current=getExitCountry();
+
+        _settings->setExitNodeCountry(current);
+    }
+    if(ui.chkExcludeNodePolicy->isChecked()){
+         QStringList excluded=getExcludeCountries();
+        _settings->setExcludeNodeCountry(excluded);
+    }
+  }
+
+  /*now apply tor settings*/
+  applyTorSettings();
+
+  return true;
+}
+  
+/** Loads the settings for this page */
+void
+NodePolicyPage::load()
+{
+  
+  //NetworkSettings settings(Vidalia::torControl());  
+  NodePolicySettings settings(Vidalia::torControl());
+
+
+  //load saved GUIsettings and apply
+  ui.chkNodePolicy->setChecked(_settings->getUseNodePolicy()); 
+  ui.chkExitNodePolicy->setChecked(settings.getUseExitNodePolicy());
+  ui.chkExcludeNodePolicy->setChecked(settings.getUseExcludeNodePolicy());
+ 
+  
+  ui.chkCloseAllActiveCircuits->setChecked(false);
+  //ui.chkCloseAllActiveCircuits->setEnabled(false);
+  
+  HideUnhide();
+  load_longnames();
+}
+
+
+void
+NodePolicyPage::onAuthenticated()
+{
+  refresh();
+   _refreshTimer.start();
+}
+
+
+/* The monster function! does:
+  a. reload the internal strucuter 
+  b. fills the combo boxes
+*/
+
+void
+NodePolicyPage::refresh()
+{
+  
+  NetworkStatus networkStatus = _torControl->getNetworkStatus();  
+  QString short_country_name;
+  QString ip_addr;
+  QString count;
+  int flags;
+  QString uniqueRouterName;
+  quint32 torVersion = Vidalia::torControl()->getTorVersion();
+
+  
+  //initialize the window.. just in case it has not been initialized yet.
+  load();
+  
+  vInfo("Network out refresh!\n"); 
+
+  /*Fill up the internal structure*/
+  //by_country_exit_nodes.clear();
+  by_country_exit_nodes2.clear();
+  foreach( RouterStatus router, networkStatus){
+
+     //Get the country!
+     ip_addr=router.ipAddress().toString();
+     //short_country_name=_torControl->getIPCountry(ip_addr);    
+    
+     //test with file!
+     short_country_name=_geoIpResolver->get_country(router.ipAddress()).toLower();
+    
+ 
+     //Only continue if the router is running,valid,isexit and is NOT badexit
+     if (!router.isRunning())
+      continue;
+     if (!router.isValid())
+      continue;
+     flags=router.flags();
+     //Must be exit AND not badexit
+     if((router.Exit) !=((router.Exit | router.BadExit) & flags) ) 
+      continue;
+
+     //Get a unique name, if unnamed use the full descriptor id
+     uniqueRouterName=router.name();
+    
+     //display names only for registered nodes, this to avoid warnings
+     // on tor and assure name uniquness
+     if(uniqueRouterName=="Unnamed" || (0x00== (flags & router.Named))){
+         uniqueRouterName=router.id().prepend("$");
+     }
+
+     /*Now insert the information into the HAsh/MAp*/
+     if (by_country_exit_nodes2.contains(short_country_name)){
+        //by_country_exit_nodes.insert(short_country_name, 
+        //         QStringList(by_country_exit_nodes.value(short_country_name))<<uniqueRouterName);
+        by_country_exit_nodes2.insert(short_country_name,
+                 QList<RouterStatus>(by_country_exit_nodes2.value(short_country_name))<<router);
+
+     }
+     else{
+        //by_country_exit_nodes.insert(short_country_name,QStringList()<<uniqueRouterName);
+        by_country_exit_nodes2.insert(short_country_name,QList<RouterStatus>()<<router);
+     }
+  }
+  
+
+  //* now fill the combo boxes!*/  
+  QListWidgetItem *countryListItem;
+  int itemcount=0;
+  int saved_index=0;
+  char saved_country[4];
+  memset(saved_country,0x00,4);  
+  memcpy(saved_country,_settings->getExitNodeCountry().toAscii(),2);  
+
+  QList<int> saved_excluded_index;
+  QStringList saved_excluded=_settings->getExcludeNodeCountry();
+
+   //clear the boxes!
+  ui.cmboExitNodesbyCountry->clear();
+  ui.listWidgetExcludedCountries->clear();
+
+  foreach (QString country, by_country_exit_nodes2.keys()) {
+    /*Get the count of exit nodes for this country*/
+    count=QString("%1").arg(by_country_exit_nodes2.value(country).count(),0,10);
+ 
+    /*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/unknown.png");
+    }
+    /*finally add the country information to the combo box!*/
+    QString countryCount(country);
+    countryCount.append("(").append(count).append(")");
+
+    QString longCountryCount;
+    if(country_long.contains(country)){
+        longCountryCount=country_long[country];
+    }
+    longCountryCount.append(" (").append(country);
+    longCountryCount.append(")(").append(count).append(")");
+    ui.cmboExitNodesbyCountry->addItem(country_flag,longCountryCount,
+                             country);
+    if(country.toAscii()==saved_country){
+      saved_index=itemcount; 
+    }
+
+    /*Also add it on the exclude node list*/    
+    ui.listWidgetExcludedCountries->addItem(longCountryCount);
+    
+    countryListItem=ui.listWidgetExcludedCountries->item(itemcount);
+    countryListItem->setIcon(country_flag);
+    itemcount++;
+  }
+  
+  
+  //and enable multiple selections?
+  //ui.listWidgetInvalidCountries->setSelectionMode(QAbstractItemView::MultiSelection);
+  ui.listWidgetExcludedCountries->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ 
+  //Now load settings for country
+  ui.cmboExitNodesbyCountry->setCurrentIndex(saved_index);
+
+  //now apply changes if something was saved!
+  if(0!=saved_index){
+     vInfo("Network out: applying save!\n");
+     //apply a save!
+     QString err;
+     //save(err);
+     ui.cmboExitNodesbyCountry->setCurrentIndex(saved_index);
+     copyExitCountryToText();
+     applyTorSettings();
+  }
+
+}
+
+/*copy the names of routers in the exit
+* country to the appropiate place in the GUI*/
+void 
+NodePolicyPage::copyExitCountryToText()
+{
+  QString current=ui.cmboExitNodesbyCountry->currentText();
+    
+  //fprintf(stderr,"qlen=%d",current.length());
+  QStringList countrylist=current.split("(");
+  
+  current=countrylist.at(1);
+  countrylist=current.split(")");
+  current=countrylist.at(0);
+  current=getExitCountry();
+
+
+  //copy to list listwidget!
+  ui.listWidgetExitNodes->clear();
+  
+  foreach (RouterStatus router, by_country_exit_nodes2.value(current)){
+     QString displayname(router.name());
+     if( router.Named!= (router.flags() & router.Named)){
+          displayname.append(" ($").append(router.id()).append(")");
+     }    
+     ui.listWidgetExitNodes->addItem(displayname);
+  }   
+
+
+  /*Enable ans set the close all active circutuis*/
+  ui.chkCloseAllActiveCircuits->setEnabled(true); 
+  ui.chkCloseAllActiveCircuits->setChecked(true);
+}
+
+
+/*copy the names of routers in the excluded
+* country list to the appropiate place in the GUI*/
+void
+NodePolicyPage::copyExcludedCountryToText()
+{
+  //step 1 get countries
+  //step 2 iterate to insert stuff into display.
+  //step 3 enable close active circuits
+  QStringList invalidCountries;
+  invalidCountries=getExcludeCountries();
+  //fprintf(stderr,"invalid_count=%d\n",invalidCountries.count());
+  //now step2
+  ui.listWidgetExcludedNodes->clear();
+  int itemcount=0;
+  foreach(QString country, invalidCountries){
+     //fprintf(stderr) 
+     foreach (RouterStatus router, by_country_exit_nodes2.value(country)){
+        QString displayname(router.name());
+        if( router.Named!= (router.flags() & router.Named)){
+            displayname.append(" ($").append(router.id()).append(")");
+        }
+       ui.listWidgetExcludedNodes->addItem(displayname); 
+       itemcount++;
+      }
+  }
+
+  ui.chkCloseAllActiveCircuits->setEnabled(true);
+  ui.chkCloseAllActiveCircuits->setChecked(true);
+
+}
+
+
+
+  /** Handles when we get disconnected from Tor network */
+ void
+NodePolicyPage::onDisconnected(){
+  /*clear the internal data structure data structure*/
+  by_country_exit_nodes2.clear();
+  /*stio the refresh timed*/
+   _refreshTimer.stop();
+
+}
+
+
+/*Hide/Undide stuff in the GUI accordint to selections*/
+void 
+NodePolicyPage::HideUnhide(){
+ //  if(ui.chkNodePolicy->isChecked()){
+      //enable all other stuff!
+   ui.chkExitNodePolicy->setEnabled(ui.chkNodePolicy->isChecked());
+   ui.grpExitNodeSettings->setVisible(ui.chkExitNodePolicy->isChecked() & ui.chkNodePolicy->isChecked()); 
+   ui.chkExcludeNodePolicy->setEnabled(ui.chkNodePolicy->isChecked());
+   ui.grpExcludeNodeSettings->setVisible(ui.chkExcludeNodePolicy->isChecked() & ui.chkNodePolicy->isChecked());
+
+}
+
+
+
+/*close all circuits*/
+void
+NodePolicyPage::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. */
+    _torControl->closeCircuit(circuit.id());    
+  }
+   
+  
+}
+
+/*Apply GUI settings if any to tor*/
+void
+NodePolicyPage::applyTorSettings(){
+
+  //NetworkSettings settings(Vidalia::torControl());
+  NodePolicySettings settings(Vidalia::torControl());
+
+
+ /*Now save only is settings have been enabled*/
+  if((ui.chkNodePolicy->isChecked())){
+    settings.setUseExitNodePolicy(ui.chkExitNodePolicy->isChecked());
+    settings.setUseExcludeNodePolicy(ui.chkExcludeNodePolicy->isChecked());
+    vInfo("node pol applyset, checked!\n");
+
+    /*Only save if we have enabled saving exit policies!*/
+    if(ui.chkExitNodePolicy->isChecked()){
+        /*Need to add validation?*/
+        //settings.setExitNodeList(ui.lineEditExitNodes->text().split(",", QString::SkipEmptyParts) );
+        /*iterate over listwidget?*/
+        QStringList exitList;
+        QString current=ui.cmboExitNodesbyCountry->currentText();
+        //fprintf(stderr,"qlen=%d",current.length());
+        QStringList countrylist=current.split("(");
+        current=countrylist.at(0);
+        current=getExitCountry(); 
+
+        foreach (RouterStatus router, by_country_exit_nodes2.value(current)){
+           //ui.listWidgetExitNodes->addItem(router.name());
+           QString id(router.id());
+           id.prepend("$");
+           int flags=router.flags();
+           if( router.Named== (flags & router.Named)){
+              id=router.name();
+           }
+           exitList<<id;
+        }
+        //fprintf(stderr,"exit_size=%d\n",exitList.size()); 
+        //next only stores it, it does not apply it!
+        settings.setExitNodeList(exitList);     
+    }
+    if (ui.chkExcludeNodePolicy->isChecked()){
+       QStringList excludedList;
+       QStringList excludedCountries=getExcludeCountries();
+       
+        foreach(QString country, excludedCountries){
+          foreach (RouterStatus router, by_country_exit_nodes2.value(country)){
+            QString id(router.name());
+            if( router.Named!= (router.flags() & router.Named)){
+               //displayname.append(" ($").append(router.id()).append(")");
+               id=router.id();
+               id.prepend("$");
+               }
+            //ui.listWidgetExcludedNodes->addItem(displayname);
+            excludedList<<id;
+          }
+        }
+        //apply here
+        //settings.setExitNodeList(exitList);
+        settings.setExcludeNodeList(excludedList);
+    }
+  }
+  /*if clear connections is set, clear them up!*/
+  if(ui.chkCloseAllActiveCircuits->isChecked()){
+     closeAllCircuits();
+  }
+  /*Now we finalize by actually applying the settings!*/
+  settings.apply();
+}
+
+/*Get the list of selected exclude countryies from the gui*/
+QStringList 
+NodePolicyPage::getExcludeCountries(){
+  QStringList excludeCountries;
+  QList<QListWidgetItem *> selectedCountries;
+  selectedCountries=ui.listWidgetExcludedCountries->selectedItems ();
+
+  foreach(QListWidgetItem *selected,selectedCountries){
+      QString current=selected->text();
+      QStringList countrylist=current.split("(");
+      current=countrylist.at(1);
+      countrylist=current.split(")");
+      current=countrylist.at(0);
+      excludeCountries<<current;
+  }
+  return excludeCountries;
+}
+
+/*Get the current select country from the GUI*/
+QString
+NodePolicyPage::getExitCountry(){
+  QString current=ui.cmboExitNodesbyCountry->currentText();
+
+  QStringList countrylist=current.split("(");
+
+  current=countrylist.at(1);
+  countrylist=current.split(")");
+  current=countrylist.at(0);
+  return current;
+}
+
+void
+NodePolicyPage::load_longnames(){
+
+  /*clear the db*/ 
+  country_long.clear();
+
+  /*fill in the values*/
+  country_long.insert("af",tr("Afghanistan"));
+  country_long.insert("al",tr("Albania "));
+  country_long.insert("dz",tr("Algeria "));
+  country_long.insert("ad",tr("Andorra"));
+  country_long.insert("ao",tr("Angola"));
+  country_long.insert("ag",tr("Antigua & Barbuda"));
+  country_long.insert("ar",tr("Argentina"));
+  country_long.insert("am",tr("Armenia"));
+  country_long.insert("au",tr("Australia"));
+  country_long.insert("at",tr("Austria "));
+  country_long.insert("az",tr("Azerbaijan"));
+  country_long.insert("bs",tr("Bahamas"));
+  country_long.insert("bh",tr("Bahrain "));
+  country_long.insert("bd",tr("Bangladesh"));
+  country_long.insert("bb",tr("Barbados"));
+  country_long.insert("by",tr("Belarus"));
+  country_long.insert("be",tr("Belgium"));
+  country_long.insert("bz",tr("Belize"));
+  country_long.insert("bj",tr("Benin "));
+  country_long.insert("bt",tr("Bhutan"));
+  country_long.insert("bo",tr("Bolivia"));
+  country_long.insert("ba",tr("Bosnia & Herzegovina"));
+  country_long.insert("bw",tr("Botswana"));
+  country_long.insert("br",tr("Brazil"));
+  country_long.insert("bn",tr("Brunei Darussalam"));
+  country_long.insert("bg",tr("Bulgaria"));
+  country_long.insert("bf",tr("Burkina Faso"));
+  country_long.insert("bi",tr("Burundi"));
+  country_long.insert("kh",tr("Cambodia"));
+  country_long.insert("cm",tr("Cameroon"));
+  country_long.insert("ca",tr("Canada"));
+  country_long.insert("cv",tr("Cape Verde"));
+  country_long.insert("cf",tr("Central African Republic"));
+  country_long.insert("td",tr("Chad"));
+  country_long.insert("cl",tr("Chile"));
+  country_long.insert("cn",tr("China"));
+  country_long.insert("co",tr("Colombia"));
+  country_long.insert("km",tr("Comoros"));
+  country_long.insert("cd",tr("Congo, Dem. Rep."));
+  country_long.insert("cg",tr("Congo, Republic"));
+  country_long.insert("cr",tr("Costa Rica"));
+  country_long.insert("ci",tr("Cote d’Ivoire"));
+  country_long.insert("hr",tr("Croatia"));
+  country_long.insert("cu",tr("Cuba"));
+  country_long.insert("cy",tr("Cyprus"));
+  country_long.insert("cz",tr("Czech Republic"));
+  country_long.insert("dk",tr("Denmark"));
+  country_long.insert("dj",tr("Djibouti"));
+  country_long.insert("dm",tr("Dominica"));
+  country_long.insert("do",tr("Dominican Republic"));
+  country_long.insert("ec",tr("Ecuador"));
+  country_long.insert("eg",tr("Egypt"));
+  country_long.insert("sv",tr("El Salvador"));
+  country_long.insert("gq",tr("Equatorial Guinea"));
+  country_long.insert("er",tr("Eritrea"));
+  country_long.insert("ee",tr("Estonia"));
+  country_long.insert("et",tr("Ethiopia "));
+  country_long.insert("fj",tr("Fiji "));
+  country_long.insert("fi",tr("Finland "));
+  country_long.insert("fr",tr("France"));
+  country_long.insert("ga",tr("Gabon"));
+  country_long.insert("gm",tr("Gambia"));
+  country_long.insert("ge",tr("Georgia"));
+  country_long.insert("de",tr("Germany | Deutschland"));
+  country_long.insert("gh",tr("Ghana"));
+  country_long.insert("gr",tr("Greece "));
+  country_long.insert("gd",tr("Grenada"));
+  country_long.insert("gt",tr("Guatemala"));
+  country_long.insert("gu",tr("Guam "));
+  country_long.insert("gn",tr("Guinea"));
+  country_long.insert("gw",tr("Guinea-Bissau"));
+  country_long.insert("gy",tr("Guyana"));
+  country_long.insert("hk",tr("Hong Kong"));
+  country_long.insert("ht",tr("Haiti"));
+  country_long.insert("hn",tr("Honduras"));
+  country_long.insert("hu",tr("Hungary "));
+  country_long.insert("is",tr("Iceland "));
+  country_long.insert("in",tr("India "));
+  country_long.insert("id",tr("Indonesia "));
+  country_long.insert("ir",tr("Iran "));
+  country_long.insert("iq",tr("Iraq "));
+  country_long.insert("ie",tr("Ireland "));
+  country_long.insert("il",tr("Israel"));
+  country_long.insert("it",tr("Italy | Italia"));
+  country_long.insert("jm",tr("Jamaica"));
+  country_long.insert("jp",tr("Japan"));
+  country_long.insert("jo",tr("Jordan"));
+  country_long.insert("kz",tr("Kazakhstan"));
+  country_long.insert("ke",tr("Kenya"));
+  country_long.insert("ki",tr("Kiribati"));
+  country_long.insert("kp",tr("Korea, North "));
+  country_long.insert("kr",tr("Korea, South "));
+  country_long.insert("kw",tr("Kuwait"));
+  country_long.insert("kg",tr("Kyrgyzstan"));
+  country_long.insert("la",tr("Laos"));
+  country_long.insert("lv",tr("Latvia"));
+  country_long.insert("lb",tr("Lebanon"));
+  country_long.insert("ls",tr("Lesotho"));
+  country_long.insert("lr",tr("Liberia"));
+  country_long.insert("ly",tr("Libya "));
+  country_long.insert("li",tr("Liechtenstein"));
+  country_long.insert("lt",tr("Lithuania | Lietuva"));
+  country_long.insert("lu",tr("Luxembourg | Luxemburg"));
+  country_long.insert("mk",tr("Macedonia"));
+  country_long.insert("mg",tr("Madagascar"));
+  country_long.insert("mw",tr("Malawi"));
+  country_long.insert("my",tr("Malaysia"));
+  country_long.insert("mv",tr("Maldives "));
+  country_long.insert("ml",tr("Mali"));
+  country_long.insert("mt",tr("Malta"));
+  country_long.insert("mh",tr("Marshall Islands"));
+  country_long.insert("mr",tr("Mauritania"));
+  country_long.insert("mu",tr("Mauritius | Maurice"));
+  country_long.insert("mx",tr("Mexico "));
+  country_long.insert("fm",tr("Micronesia"));
+  country_long.insert("md",tr("Moldova"));
+  country_long.insert("mc",tr("Monaco"));
+  country_long.insert("mn",tr("Mongolia"));
+  country_long.insert("me",tr("Montenegro"));
+  country_long.insert("ma",tr("Morocco"));
+  country_long.insert("mz",tr("Mozambique"));
+  country_long.insert("mm",tr("Myanmar "));
+  country_long.insert("na",tr("Namibia"));
+  country_long.insert("nr",tr("Nauru"));
+  country_long.insert("np",tr("Nepal"));
+  country_long.insert("nl",tr("Netherlands"));
+  country_long.insert("nz",tr("New Zealand"));
+  country_long.insert("ni",tr("Nicaragua"));
+  country_long.insert("ne",tr("Niger"));
+  country_long.insert("ng",tr("Nigeria"));
+  country_long.insert("no",tr("Norway"));
+  country_long.insert("om",tr("Oman"));
+  country_long.insert("pk",tr("Pakistan"));
+  country_long.insert("pw",tr("Palau"));
+  country_long.insert("ps",tr("Palestine"));
+  country_long.insert("pa",tr("Panama"));
+  country_long.insert("pg",tr("Papua New Guinea"));
+  country_long.insert("py",tr("Paraguay"));
+  country_long.insert("pe",tr("Peru"));
+  country_long.insert("ph",tr("Philippines"));
+  country_long.insert("pl",tr("Poland"));
+  country_long.insert("pt",tr("Portugal"));
+  country_long.insert("qa",tr("Qatar"));
+  country_long.insert("ro",tr("Romania"));
+  country_long.insert("ru",tr("Russia"));
+  country_long.insert("rw",tr("Rwanda"));
+  country_long.insert("kn",tr("Saint Kitts & Nevis"));
+  country_long.insert("lc",tr("Saint Lucia"));
+  country_long.insert("vc",tr("Saint Vincent & the Grenadines"));
+  country_long.insert("ws",tr("Samoa"));
+  country_long.insert("sm",tr("San Marino"));
+  country_long.insert("st",tr("Sao Tome & Principe"));
+  country_long.insert("sa",tr("Saudi Arabia"));
+  country_long.insert("sn",tr("Senegal"));
+  country_long.insert("rs",tr("Serbia"));
+  country_long.insert("sc",tr("Seychelles"));
+  country_long.insert("sl",tr("Sierra Leone"));
+  country_long.insert("sg",tr("Singapore"));
+  country_long.insert("sk",tr("Slovakia"));
+  country_long.insert("si",tr("Slovenia"));
+  country_long.insert("sb",tr("Solomon Islands"));
+  country_long.insert("so",tr("Somalia"));
+  country_long.insert("za",tr("South Africa"));
+  country_long.insert("es",tr("Spain"));
+  country_long.insert("lk",tr("Sri Lanka"));
+  country_long.insert("sd",tr("Sudan"));
+  country_long.insert("sr",tr("Suriname"));
+  country_long.insert("sz",tr("Swaziland"));
+  country_long.insert("se",tr("Sweden"));
+  country_long.insert("ch",tr("Switzerland"));
+  country_long.insert("sy",tr("Syria"));
+  country_long.insert("tw",tr("Taiwan "));
+  country_long.insert("tj",tr("Tajikistan"));
+  country_long.insert("tz",tr("Tanzania"));
+  country_long.insert("th",tr("Thailand"));
+  country_long.insert("tl",tr("Timor-Leste (East Timor) | Timór-Leste"));
+  country_long.insert("tg",tr("Togo"));
+  country_long.insert("to",tr("Tonga"));
+  country_long.insert("tt",tr("Trinidad & Tobago"));
+  country_long.insert("tn",tr("Tunisia"));
+  country_long.insert("tr",tr("Turkey"));
+  country_long.insert("tm",tr("Turkmenistan"));
+  country_long.insert("tv",tr("Tuvalu"));
+  country_long.insert("ug",tr("Uganda"));
+  country_long.insert("ua",tr("Ukraine"));
+  country_long.insert("ae",tr("United Arab Emirates"));
+  country_long.insert("gb",tr("United Kingdom"));
+  country_long.insert("us",tr("United States"));
+  country_long.insert("uy",tr("Uruguay"));
+  country_long.insert("uz",tr("Uzbekistan"));
+  country_long.insert("vu",tr("Vanuatu"));
+  country_long.insert("va",tr("Vatican"));
+  country_long.insert("ve",tr("Venezuela"));
+  country_long.insert("vn",tr("Vietnam"));
+  country_long.insert("eh",tr("Western Sahara"));
+  country_long.insert("ye",tr("Yemen"));
+  country_long.insert("zm",tr("Zambia"));
+  country_long.insert("zw",tr("Zimbabwe"));
+
+}
+
+
+

Added: vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.h
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.h	                        (rev 0)
+++ vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.h	2008-08-08 21:03:51 UTC (rev 2949)
@@ -0,0 +1,107 @@
+/*
+**  This file is part of Vidalia, and is subject to the license terms in the
+**  LICENSE file, found in the top level directory of this distribution. If you
+**  did not receive the LICENSE file with this file, you may obtain it from the
+**  Vidalia source package distributed by the Vidalia Project at
+**  http://www.vidalia-project.net/. No part of Vidalia, including this file,
+**  may be copied, modified, propagated, or distributed except according to the
+**  terms described in the LICENSE file.
+*/
+
+/*
+** \file appearancepage.h
+** \version $Id: appearancepage.h 2362 2008-02-29 04:30:11Z edmanm $
+** \brief Displays Vidalia language and style settings
+*/
+
+#ifndef _NODEPOLICYPAGE_H
+#define _NODEPOLICYPAGE_H
+
+#include <QStyleFactory>
+#include <QLineEdit>
+
+#include <vidaliasettings.h>
+#include <languagesupport.h>
+#include <routerdescriptor.h>
+#include <torcontrol.h>
+#include <routerstatus.h>
+#include <filegeoipresolver.h>
+#include <geoipresolver.h>
+#include <nodepolicysettings.h>
+//#include <torsettings.h>
+
+#include "configpage.h"
+#include "ui_networkoutpage.h"
+
+
+class NodePolicyPage : public ConfigPage
+{
+  Q_OBJECT
+
+public:
+  /** Default Constructor */
+  NodePolicyPage(QWidget *parent = 0);
+  /** Default Destructor */
+  ~NodePolicyPage();
+  /** Saves the changes on this page */
+  bool save(QString &errmsg);
+  /** Loads the settings for this page */
+  void load();
+  
+private slots:
+  
+  /*This is an ugly thing!*/
+  void HideUnhide();
+
+  /*copies country nodes into exit node text*/
+  void copyExitCountryToText();
+  /**/
+  void copyExcludedCountryToText();
+
+  /*Do stuff once authenticated*/
+  void onAuthenticated();  
+  /** Handles when we get disconnected from Tor network */
+  void onDisconnected();
+  
+  /*refresh the window values*/
+  void refresh();
+
+  
+private:
+  /*closes all circuits*/
+  void closeAllCircuits();
+
+  /*Apply tor gui settings*/
+  void applyTorSettings();
+
+  /*Get the countries from the excludelist*/
+  QStringList getExcludeCountries();
+
+  /*Get the selectec gui exit node*/
+  QString getExitCountry();
+
+  /*load the short to long country name mapping*/
+  void load_longnames();
+
+  /** A VidaliaSettings object used for saving/loading settings */
+  //VidaliaSettings* _settings;
+  NodePolicySettings *_settings;
+
+  /** Qt Designer generated object */
+  Ui::NetworkoutPage ui;
+
+  /*struct to hold the country-exit-node-mappings */
+  //QMap<QString,QStringList> by_country_exit_nodes;
+  QMap<QString,QList<RouterStatus> > by_country_exit_nodes2;
+  QMap<QString,QString> country_long;
+
+  /*pointers to the global torControl and geoResolver objects*/
+  TorControl* _torControl;
+  GeoIpResolver* _geoIpResolver;
+ 
+  /** Timer that fires once an hour to update the combo boxes. */
+  QTimer _refreshTimer;
+
+};
+
+#endif

Added: vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.ui
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.ui	                        (rev 0)
+++ vidalia/branches/exit-country/src/vidalia/config/nodepolicypage.ui	2008-08-08 21:03:51 UTC (rev 2949)
@@ -0,0 +1,133 @@
+<ui version="4.0" >
+ <class>NodePolicyPage</class>
+ <widget class="QWidget" name="NodePolicyPage" >
+  <property name="geometry" >
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>618</width>
+    <height>515</height>
+   </rect>
+  </property>
+  <property name="contextMenuPolicy" >
+   <enum>Qt::NoContextMenu</enum>
+  </property>
+  <layout class="QVBoxLayout" >
+   <item>
+    <widget class="QCheckBox" name="chkNodePolicy" >
+     <property name="text" >
+      <string>Enable Vidalia Relay Policy Management (Will reduce your anonymity and change your Tor Configuration)</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="chkExitNodePolicy" >
+     <property name="text" >
+      <string>Enable Strict Exit Relay Management (Changes 'ExitNodes' settings)</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="grpExitNodeSettings" >
+     <property name="title" >
+      <string>Exit Relay Selection Policy</string>
+     </property>
+     <layout class="QGridLayout" >
+      <item row="0" column="0" >
+       <widget class="QLabel" name="label_2" >
+        <property name="text" >
+         <string>Exit Relays</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="1" colspan="3" >
+       <widget class="QListWidget" name="listWidgetExitNodes" />
+      </item>
+      <item row="1" column="0" >
+       <widget class="QLabel" name="label_3" >
+        <property name="text" >
+         <string>Country</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="1" colspan="2" >
+       <widget class="QComboBox" name="cmboExitNodesbyCountry" />
+      </item>
+      <item row="1" column="3" >
+       <widget class="QPushButton" name="pButtonApplyCountry" >
+        <property name="text" >
+         <string>Set Exits by Country</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="chkExcludeNodePolicy" >
+     <property name="text" >
+      <string>Enable Exclude Relay Management (Changes  'InvalidNodes' settings)</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QGroupBox" name="grpExcludeNodeSettings" >
+     <property name="title" >
+      <string>Exclude Relay Selection Policy</string>
+     </property>
+     <layout class="QGridLayout" >
+      <item row="0" column="0" >
+       <widget class="QLabel" name="label" >
+        <property name="text" >
+         <string>Excluded Relays</string>
+        </property>
+       </widget>
+      </item>
+      <item row="0" column="2" colspan="2" >
+       <widget class="QListWidget" name="listWidgetExcludedNodes" />
+      </item>
+      <item row="1" column="0" colspan="2" >
+       <widget class="QLabel" name="label_4" >
+        <property name="text" >
+         <string>Countries</string>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="2" >
+       <widget class="QListWidget" name="listWidgetExcludedCountries" />
+      </item>
+      <item row="1" column="3" >
+       <widget class="QPushButton" name="pButtonApplyExcludedCountry" >
+        <property name="text" >
+         <string>Set Exclude Nodes by Country</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QCheckBox" name="chkCloseAllActiveCircuits" >
+     <property name="text" >
+      <string>Close All Active Circuits</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>31</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

Modified: vidalia/branches/exit-country/src/vidalia/config/nodepolicysettings.cpp
===================================================================
--- vidalia/branches/exit-country/src/vidalia/config/nodepolicysettings.cpp	2008-08-08 15:54:29 UTC (rev 2948)
+++ vidalia/branches/exit-country/src/vidalia/config/nodepolicysettings.cpp	2008-08-08 21:03:51 UTC (rev 2949)
@@ -51,7 +51,12 @@
   QMultiHash<QString, QString> conf;
   quint32 torVersion = torControl()->getTorVersion();
 
-  fprintf(stderr,"apply nodeolicy!\n");
+  //fprintf(stderr,"apply nodeolicy!\n");
+
+  /*I we are not managing anything, return inmediately*/
+  if(!getUseNodePolicy()){
+    return true;
+  }  
   if(getUseExitNodePolicy()){
     //vInfo(us)
     conf.insert(SETTING_EXIT_NODE_LIST,
@@ -62,10 +67,13 @@
     conf.insert("StrictExitNodes","0");
     conf.insert(SETTING_EXIT_NODE_LIST,"");
   }
+  if(getUseExcludeNodePolicy()){
   conf.insert(SETTING_EXCLUDE_NODE_LIST,
         localValue(SETTING_EXCLUDE_NODE_LIST).toStringList().join(","));
+  } else{
+     conf.insert(SETTING_EXCLUDE_NODE_LIST,"");
+  }
 
-
   return torControl()->setConf(conf, errmsg);
 }
 
@@ -81,14 +89,14 @@
   setValue(SETTING_USE_NODE_POLICY, useNodePolicy);
 }
 
-
+/*Gets the exit country*/
 QString
 NodePolicySettings::getExitNodeCountry()
-//getLanguageCode()
 {
   return value(SETTING_EXIT_NODES_COUNTRY).toString();
 }
 
+/*sets the exit country*/
 void
 NodePolicySettings::
 setExitNodeCountry(QString exitCountry)
@@ -96,13 +104,14 @@
   setValue(SETTING_EXIT_NODES_COUNTRY, exitCountry);
 }
 
-
+/*gets the list of excluded countries*/
 QStringList
 NodePolicySettings::getExcludeNodeCountry()
 {
   return value(SETTING_EXCLUDE_NODES_COUNTRY_LIST).toStringList();
 }
 
+/*Saves the list of excluded countries*/
 void
 NodePolicySettings::setExcludeNodeCountry( QStringList
                                              &excludeCountryList)
@@ -114,44 +123,43 @@
 
 
 
-/** Returns true if Tor should use network policies for its nodes
+/** Returns true if Tor should use exit network policies for its nodes
  * network. */
 bool 
 NodePolicySettings::getUseExitNodePolicy(){
   return value(SETTING_USE_EXIT_NODE_POLICY).toBool();
 }
 
-/** Sets to <b>useNodePolicy</b> whether Tor should try
+/** Sets to <b>useNodeExitPolicy</b> whether Tor should try
  to use node policies to access the newtowk. */
 void 
 NodePolicySettings::setUseExitNodePolicy(bool useNodePolicy){
   setValue(SETTING_USE_EXIT_NODE_POLICY, useNodePolicy);
 }
 
-/** Returns a list of bridge nodes Tor should use. */
+/** Returns a list of exit nodes Tor should use. */
 QStringList
 NodePolicySettings::getExitNodeList()
 {
   return value(SETTING_EXIT_NODE_LIST).toStringList();
 }
 
-/** Sets to <b>bridgeList</b> the list of bridge nodes Tor should use. */
+/** Sets to <b>exitNodeList</b> the list of bridge nodes Tor should use.
+ *  as exits  */
 void
 NodePolicySettings::setExitNodeList(const QStringList &exitNodeList)
 {
-  fprintf(stderr,"setting exit?\n");
   setValue(SETTING_EXIT_NODE_LIST, exitNodeList);
 }
 
 
 bool
 NodePolicySettings::getUseExcludeNodePolicy(){
-  //return value(SETTING_USE_EXCLUDE_NODE_POLICY).toBool();
   return localValue(SETTING_USE_EXCLUDE_NODE_POLICY).toBool();
 }
 
-/** Sets to <b>useNodePolicy</b> whether Tor should try
- to use node policies to access the newtowk. */
+/** Sets to <b>useExcludeNodePolicy</b> whether Tor should try
+ to use node exclude policies when using the newtowk. */
 void
 NodePolicySettings::setUseExcludeNodePolicy(bool useNodeExcludePolicy){
   setValue(SETTING_USE_EXCLUDE_NODE_POLICY, useNodeExcludePolicy);
@@ -159,14 +167,14 @@
 
 
 
-/** Returns a list of bridge nodes Tor should use. */
+/** Returns a list of the excluded nodes */
 QStringList
 NodePolicySettings::getExcludeNodeList()
 {
   return value(SETTING_EXCLUDE_NODE_LIST).toStringList();
 }
 
-/** Sets to <b>bridgeList</b> the list of bridge nodes Tor should use. */
+/** Sets to <b>excludeNodeListt</b> the list nodes Tor should avoid. */
 void
 NodePolicySettings::setExcludeNodeList(const QStringList &excludeNodeList)
 {