]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - include/modules/geolocation.h
Use IsCTCP in blockcolor for ignoring CTCPs.
[user/henk/code/inspircd.git] / include / modules / geolocation.h
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2019 Sadie Powell <sadie@witchery.services>
5  *
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.
9  *
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
13  * details.
14  *
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/>.
17  */
18
19
20 #pragma once
21
22 namespace Geolocation
23 {
24         class APIBase;
25         class API;
26         class Location;
27 }
28
29 class Geolocation::APIBase : public DataProvider
30 {
31  public:
32         APIBase(Module* parent)
33                 : DataProvider(parent, "geolocationapi")
34         {
35         }
36
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.
40          */
41         virtual Location* GetLocation(User* user) = 0;
42
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.
46          */
47         virtual Location* GetLocation(irc::sockets::sockaddrs& sa) = 0;
48 };
49
50 class Geolocation::API : public dynamic_reference<Geolocation::APIBase>
51 {
52  public:
53         API(Module* parent)
54                 : dynamic_reference<Geolocation::APIBase>(parent, "geolocationapi")
55         {
56         }
57 };
58
59 class Geolocation::Location : public usecountbase
60 {
61 private:
62         /** The two character country code for this location. */
63         std::string code;
64
65         /** The country name for this location. */
66         std::string name;
67
68  public:
69         Location(const std::string& Code, const std::string& Name)
70                 : code(Code)
71                 , name(Name)
72         {
73         }
74
75         /** Retrieves the two character country code for this location. */
76         std::string GetCode() const { return code; }
77
78         /** Retrieves the country name for this location. */
79         std::string GetName() const { return name; }
80 };