From 16413e7bdb5b26847a74dc1a111e022cfa79f120 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 2 May 2019 06:55:41 -0400 Subject: [PATCH] [libcalamares] Stub GeoIPHandler - The handler class should deal with configuration and query --- src/libcalamares/CMakeLists.txt | 1 + src/libcalamares/geoip/GeoIPHandler.cpp | 40 +++++++++++++++++++++ src/libcalamares/geoip/GeoIPHandler.h | 47 +++++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 src/libcalamares/geoip/GeoIPHandler.cpp create mode 100644 src/libcalamares/geoip/GeoIPHandler.h diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index ae702a8b3..d1dbd81b2 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -71,6 +71,7 @@ endif() set( geoipSources geoip/GeoIP.cpp + geoip/GeoIPHandler.cpp geoip/GeoIPJSON.cpp ) set( geoip_libs ) diff --git a/src/libcalamares/geoip/GeoIPHandler.cpp b/src/libcalamares/geoip/GeoIPHandler.cpp new file mode 100644 index 000000000..87aa1cc24 --- /dev/null +++ b/src/libcalamares/geoip/GeoIPHandler.cpp @@ -0,0 +1,40 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * Calamares 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 3 of the License, or + * (at your option) any later version. + * + * Calamares 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 Calamares. If not, see . + */ + +#include "GeoIPHandler.h" + +namespace CalamaresUtils +{ + +GeoIPHandler::GeoIPHandler() +{ +} + +bool +GeoIPHandler::isValid() const +{ + return false; +} + +GeoIP::RegionZonePair +GeoIPHandler::query() const +{ + return GeoIP::RegionZonePair(); +} + +} // namespace diff --git a/src/libcalamares/geoip/GeoIPHandler.h b/src/libcalamares/geoip/GeoIPHandler.h new file mode 100644 index 000000000..92b35eecf --- /dev/null +++ b/src/libcalamares/geoip/GeoIPHandler.h @@ -0,0 +1,47 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * Calamares 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 3 of the License, or + * (at your option) any later version. + * + * Calamares 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 Calamares. If not, see . + */ + +#ifndef GEOIP_GEOIPHANDLER_H +#define GEOIP_GEOIPHANDLER_H + +#include "GeoIP.h" + +namespace CalamaresUtils +{ + +/** @brief Handle one complete GeoIP lookup. + * + * This class handles one complete GeoIP lookup. Create it with + * suitable configuration values, then call lookup(). This is a + * synchronous API and will return an invalid zone pair on + * error or if the configuration is not understood/ + */ +class GeoIPHandler +{ +public: + /** @brief An unconfigured handler; this always returns errors. */ + GeoIPHandler(); + + GeoIP::RegionZonePair query() const; + + bool isValid() const; +}; + +} // namespace +#endif +