2 * InspIRCd -- Internet Relay Chat Daemon
4 * Copyright (C) 2019 Sadie Powell <sadie@witchery.services>
6 * This file is part of InspIRCd. InspIRCd is free software: you can
7 * redistribute it and/or modify it under the terms of the GNU General Public
8 * License as published by the Free Software Foundation, version 2.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
29 class Geolocation::APIBase : public DataProvider
32 APIBase(Module* parent)
33 : DataProvider(parent, "geolocationapi")
37 /** Looks up the location of the specified user.
38 * @param user The user to look up the location of.
39 * @return Either an instance of the Location class or NULL if no location could be found.
41 virtual Location* GetLocation(User* user) = 0;
43 /** Looks up the location of the specified IP address.
44 * @param sa The IP address to look up the location of.
45 * @return Either an instance of the Location class or NULL if no location could be found.
47 virtual Location* GetLocation(irc::sockets::sockaddrs& sa) = 0;
50 class Geolocation::API : public dynamic_reference<Geolocation::APIBase>
54 : dynamic_reference<Geolocation::APIBase>(parent, "geolocationapi")
59 class Geolocation::Location : public usecountbase
62 /** The two character country code for this location. */
65 /** The country name for this location. */
69 Location(const std::string& Code, const std::string& Name)
75 /** Retrieves the two character country code for this location. */
76 std::string GetCode() const { return code; }
78 /** Retrieves the country name for this location. */
79 std::string GetName() const { return name; }