//
// This file is part of the aMule Project.
//
// Copyright (c) 2006-2009 Marcelo Roberto Jimenez ( phoenix@amule.org )
// Copyright (c) 2006-2009 aMule Team ( admin@amule.org / http://www.amule.org )
//
// Any parts of this program derived from the xMule, lMule or eMule project,
// or contributed by third-party developers are copyrighted by their
// respective authors.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
//


//
// Country flags are from FAMFAMFAM (http://www.famfamfam.com)
//
// Flag icons - http://www.famfamfam.com
// 
// These icons are public domain, and as such are free for any use (attribution appreciated but not required).
// 
// Note that these flags are named using the ISO3166-1 alpha-2 country codes where appropriate.
// A list of codes can be found at http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
//
// If you find these icons useful, please donate via paypal to mjames@gmail.com
// (or click the donate button available at http://www.famfamfam.com/lab/icons/silk)
// 
// Contact: mjames@gmail.com
//

#ifndef IP2COUNTRY_H
#define IP2COUNTRY_H


#include <map>

#include <wx/bitmap.h>
#include <wx/string.h>


typedef struct {
	wxString Name;
	wxBitmap Flag;
} CountryData;


typedef std::map<wxString, CountryData> CountryDataMap;


class CIP2Country {
public:
	CIP2Country();
	~CIP2Country();
// ADUNANZA BEGIN	
// Mr Hyde: provo a vedere se usando direttamente i byte dell'IP (e non la stringa)
// alleggerisco un po' la CPU
	wxString GetCountryCode(unsigned long ipv4number);
	wxString GetCountryCode(const wxString& ip);
	const CountryData& GetCountryDataFromCode(const wxString& ccode);

	inline const CountryData& GetCountryData(unsigned long ipv4number)
	{ return GetCountryDataFromCode(GetCountryCode(ipv4number)); }
#if 0
	const CountryData& GetCountryData(const wxString& ip);
#else
	inline const CountryData& GetCountryData(const wxString& ip)
	{ return GetCountryDataFromCode(GetCountryCode(ip)); }
#endif
// ADUNANZA END	

private:
	struct GeoIPTag *m_geoip;
	CountryDataMap m_CountryDataMap;
};

#endif // IP2COUNTRY_H
