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

[vidalia-svn] r2942: oops forgot two files in prev commit! (vidalia/branches/exit-country/src/vidalia/geoip)



Author: cviecco
Date: 2008-08-05 14:19:36 -0400 (Tue, 05 Aug 2008)
New Revision: 2942

Added:
   vidalia/branches/exit-country/src/vidalia/geoip/geoipresolver.cpp
   vidalia/branches/exit-country/src/vidalia/geoip/geoipresolver.h
Log:

oops forgot two files in prev commit!


Added: vidalia/branches/exit-country/src/vidalia/geoip/geoipresolver.cpp
===================================================================
--- vidalia/branches/exit-country/src/vidalia/geoip/geoipresolver.cpp	                        (rev 0)
+++ vidalia/branches/exit-country/src/vidalia/geoip/geoipresolver.cpp	2008-08-05 18:19:36 UTC (rev 2942)
@@ -0,0 +1,71 @@
+/*
+**  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 geoipresolver.cpp
+** \version $Id: geoipresolver.cpp 2429 2008-03-21 02:27:36Z edmanm $
+** \brief Requests GeoIP information and caches the result
+*/
+
+//#include <torsocket.h>
+#include <vidalia.h>
+#include "geoipresolver.h"
+#include "config.h"
+
+#include <time.h>
+
+
+/** Default constructor. */
+GeoIpResolver::GeoIpResolver()
+{
+    _fileGeoIpResolver=Vidalia::fileGeoIpResolver();   
+    connect(&webGeoResolver, SIGNAL(geoResolved()), this, SLOT(resolved()));
+   
+}
+
+
+QString 
+GeoIpResolver::get_country(QHostAddress ip){
+  QString unknown("??");
+  //return unknown;  
+  GeoIp resolv=search(ip);
+
+  if (resolv.isEmpty() || resolv.isUnknown())
+    return unknown;
+  else 
+    return resolv.country();
+}
+
+
+//Search for a geoip address given a host ip
+GeoIp 
+GeoIpResolver::search(QHostAddress ip){
+  GeoIp invalid;
+
+  return webGeoResolver.search(ip);
+  //return _fileGeoIpResolver->search(ip);
+
+  //return invalid;
+}
+
+void
+GeoIpResolver::setSocksHost(QHostAddress addr, quint16 port)
+{
+
+};
+
+
+void
+GeoIpResolver::resolved(){
+//GeoIpResolver::resolved(){
+   fprintf(stderr,"georeslved signal!\n");
+   emit geoResolved();
+};
+

Added: vidalia/branches/exit-country/src/vidalia/geoip/geoipresolver.h
===================================================================
--- vidalia/branches/exit-country/src/vidalia/geoip/geoipresolver.h	                        (rev 0)
+++ vidalia/branches/exit-country/src/vidalia/geoip/geoipresolver.h	2008-08-05 18:19:36 UTC (rev 2942)
@@ -0,0 +1,72 @@
+/*
+**  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 geoipresolver.h
+** \version $Id: geoipresolver.h 2429 2008-03-21 02:27:36Z edmanm $
+** \brief Requests GeoIP information and caches the result
+*/
+
+#ifndef _GEOIPRESOLVER_H
+#define _GEOIPRESOLVER_H
+
+#include <QObject>
+#include <QList>
+#include <QHash>
+#include <QString>
+#include <QHostAddress>
+#include <QTimer>
+#include <QMutex>
+
+#include <geoip.h>
+#include "geoipcache.h"
+#include "geoiprequest.h"
+#include "geoipresponse.h"
+#include <filegeoipresolver.h>
+#include <webgeoipresolver.h>
+#include <torcontrol.h>
+
+
+
+class GeoIpResolver : public QObject
+{
+  Q_OBJECT
+
+public:
+  /** Default constructor. */
+  GeoIpResolver();
+  
+  /** Sets the address and port of Tor, through which GeoIP requests will be
+   * made. */
+  void setSocksHost(QHostAddress addr, quint16 port);
+  /** Resolves a single IP to a geographic location. */
+
+  /*can we build this?*/
+  GeoIp search(QHostAddress ip);
+  QString get_country(QHostAddress ip);
+
+signals:
+
+   /** Emitted when a list of IPs have been resolved to lat/long. */
+  void geoResolved();
+
+
+private slots:
+  void resolved();
+
+private:
+  /*In Private we actually keep what makes the resolving */
+  FileGeoIpResolver* _fileGeoIpResolver;
+  WebGeoIpResolver webGeoResolver;
+
+};
+
+#endif
+