everywhere same code header

reformatings
cdoc
This commit is contained in:
lukas 2020-05-08 16:45:27 +02:00
parent 12de026842
commit 713e7a1f95
21 changed files with 108 additions and 94 deletions

View File

@ -5,22 +5,26 @@
## libcurl (with sources)
## libconfig (with sources)
#
# documenation build needs doxygen to be installed.
# for documenation build doxygen needs to be installed.
# for test build gtest needs to be installed.
cmake_minimum_required(VERSION 3.13)
project(iprefresher DESCRIPTION "Dynu ip refresher")
SET(PROJECT_VERSION 1.3.3)
SET(CMAKE_CXX_STANDARD 17)
# CONFIGURATION
SET(CMAKE_BUILD_TYPE Release) # manually SET build type (Release / Debug)
SET(LIB_METHOD STATIC) #SHARED / STATIC
option(BUILD_DOC "Build documentation" OFF) # additional dependency for Doxygen
option(BUILD_DOC "Build documentation" ON) # additional dependency for Doxygen
option(PACKAGING "Allow Packaging to <exe>, <deb> or <rpm>" ON) # additional dependencies for RPMbuild,dpkg or NSIS
option(TESTS "Build Tests" ON) # additional dependencies for GTEST - to build tests
set(WinBuild false)
# helper variables
SET(CMAKE_CXX_STANDARD 17)
string(TIMESTAMP TIMESTAMP_NOW "%d.%m.%Y")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -131,8 +135,18 @@ message("")
FILE(READ ${CMAKE_SOURCE_DIR}/config/iprefresher.cfg SAMPLECONFIG)
#add version header
FILE(WRITE ${CMAKE_SOURCE_DIR}/inc/Version.h
"\#pragma once
"/**
* Version header to store Version, Config dir and a Sample config
* Do not edit this file manually, it is generated by the cmake script!
*
* @author Lukas Heiligenbrunner
* @date ${TIMESTAMP_NOW}
*/
#pragma once
#include <string>
namespace Version {
const std::string VERSION = \"${PROJECT_VERSION}\";
const std::string ConfigDir = \"${CONFIG_PATH}\";
@ -146,20 +160,18 @@ add_library(api ${LIB_METHOD}
src/api/DynuAPI.cpp
src/api/IPAPI.cpp)
add_library(logger ${LIB_METHOD}
src/FileLogger.cpp
src/Logger.cpp)
SET(SOURCE
add_library(dynuiprefresher ${LIB_METHOD}
src/IPRefresher.cpp
src/Config.cpp
src/IpHelper.cpp)
src/IpHelper.cpp
src/FileLogger.cpp
src/Logger.cpp
)
add_executable(iprefresher src/main.cpp ${SOURCE})
add_executable(iprefresher src/main.cpp)
# LINK generated LIBS #
target_link_libraries(iprefresher api logger ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
target_link_libraries(iprefresher dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
# setting install targets
IF (NOT ${WinBuild})
@ -209,6 +221,8 @@ if (${PACKAGING})
# generate post script for checking if configuration already exists
FILE(WRITE ${CMAKE_SOURCE_DIR}/postinst
"#!/bin/bash
# Post installation script for linux packages
# do not edit this file manually, it is generated by the cmake script
if [ ! -f ${CONFIG_PATH} ]; then
cat > ${CONFIG_PATH} <<- EOM
${SAMPLECONFIG}EOM
@ -311,7 +325,7 @@ if (TESTS)
# create an exectuable in which the tests will be stored
add_executable(${TESTNAME} ${ARGN})
# link the Google test infrastructure, mocking library, and a default main fuction to
target_link_libraries(${TESTNAME} gtest gtest_main -lpthread -lm api logger ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
target_link_libraries(${TESTNAME} gtest gtest_main -lpthread -lm dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
# see https://cmake.org/cmake/help/v3.10/module/GoogleTest.html for more options to pass to it
gtest_discover_tests(${TESTNAME}
WORKING_DIRECTORY ${PROJECT_DIR}

View File

@ -1,14 +1,14 @@
//
// Created by lukas on 11.02.20.
//
/**
* A static class to manage the configuration file, read/write parameters to it.
*
* @author Lukas Heiligenbrunner
* @date 11.02.2020
*/
#pragma once
#include <string>
/**
* A static class to manage the configuration file, read/write parameters to it.
*/
class Config {
public:
/**
@ -75,11 +75,12 @@ private:
*/
static bool telegramSupport;
/**
* helper variables for storing keys and ids
*/
static std::string dynuapikey;
static std::string domainid; //id of the dynu domain
static std::string domainname;
static std::string telegramApiKey;
static std::string chatId;
};

View File

@ -1,6 +1,9 @@
//
// Created by lukas on 05.05.19.
//
/**
* Read and write current ip to a temp file to remember last ip until restart
*
* @author Lukas Heiligenbrunner
* @date 05.05.2019
*/
#pragma once

View File

@ -1,6 +1,11 @@
//
// Created by lukas on 02.08.19.
//
/**
* IPrefresher library
* - start checking ip once
* - or in loop mode
*
* @author Lukas Heiligenbrunner
* @date 06.04.2019
*/
#pragma once

View File

@ -1,14 +1,14 @@
//
// Created by lukas on 07.05.20.
//
/**
* A helper class for general IP String actions
*
* @author Lukas Heiligenbrunner
* @date 07.05.2020
*/
#pragma once
#include <string>
/**
* General helper class for IP actions
*/
class IpHelper {
public:
/**

View File

@ -1,6 +1,10 @@
//
// Created by lukas on 26.10.19.
//
/**
* Fancy console log output format
* todo log level support
*
* @author Lukas Heiligenbrunner
* @date 26.10.2019
*/
#pragma once

View File

@ -1,6 +1,11 @@
//
// Created by lukas on 06.04.19.
//
/**
* API class
* - manages all curl download stuff
* - easy POST/GET requests
*
* @author Lukas Heiligenbrunner
* @date 06.04.2019
*/
#pragma once

View File

@ -1,6 +1,9 @@
//
// Created by lukas on 18.06.19.
//
/**
* Dynu API - Refresh the IP
*
* @author Lukas Heiligenbrunner
* @date 18.06.2019
*/
#pragma once
@ -24,8 +27,18 @@ public:
void init(const std::string &dynuApiKey, const std::string &domainId, const std::string &domainName);
private:
std::string dynuapikey; // Dynu API key
/**
* Dynu API Key
*/
std::string dynuapikey;
std::string domainid; //id of the dynu domain
/**
* Dynu Domain ID
*/
std::string domainid;
/**
* Domain name eg. "mydomain.dynu.net"
*/
std::string domainname;
};

View File

@ -1,6 +1,9 @@
//
// Created by lukas on 07.04.19.
//
/**
* A Hashmap class for easier Key-Value maps
*
* @author Lukas Heiligenbrunner
* @date 07.04.2019
*/
#pragma once

View File

@ -1,6 +1,9 @@
//
// Created by lukas on 18.06.19.
//
/**
* IPAPI for getting global ip of current network
*
* @author Lukas Heiligenbrunner
* @date 18.06.2019
*/
#pragma once

View File

@ -1,6 +1,9 @@
//
// Created by lukas on 08.05.19.
//
/**
* Telegram API for sending message to specific chat
*
* @author Lukas Heiligenbrunner
* @date 08.05.2019
*/
#pragma once

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 11.02.20.
//
#include "Config.h"
#include "Logger.h"
#include "Version.h"

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 05.05.19.
//
#include "FileLogger.h"
#include "IpHelper.h"

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 02.08.19.
//
#include "IPRefresher.h"
#include "FileLogger.h"
#include "api/IPAPI.h"

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 07.05.20.
//
#include "IpHelper.h"
#include <climits>

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 26.10.19.
//
#include "Logger.h"
#include <sstream>

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 06.04.19.
//
#include "api/API.h"
#include <sstream>

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 18.06.19.
//
#include "api/DynuAPI.h"
bool DynuAPI::refreshIp(std::string ip) {

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 18.06.19.
//
#include "api/IPAPI.h"
std::string IPAPI::getGlobalIp() {

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 08.05.19.
//
#include "api/TelegramAPI.h"
#include "Logger.h"

View File

@ -1,7 +1,3 @@
//
// Created by lukas on 18.06.19.
//
#include "Version.h"
#include "IPRefresher.h"
#include "Logger.h"