From 713e7a1f951b1b10dc6bad10e8287cc3776ff55c Mon Sep 17 00:00:00 2001 From: lukas Date: Fri, 8 May 2020 16:45:27 +0200 Subject: [PATCH] everywhere same code header reformatings cdoc --- CMakeLists.txt | 42 +++++++++++++++++++++++++++-------------- inc/Config.h | 17 +++++++++-------- inc/FileLogger.h | 9 ++++++--- inc/IPRefresher.h | 11 ++++++++--- inc/IpHelper.h | 12 ++++++------ inc/Logger.h | 10 +++++++--- inc/api/API.h | 11 ++++++++--- inc/api/DynuAPI.h | 23 +++++++++++++++++----- inc/api/Hashmap.h | 9 ++++++--- inc/api/IPAPI.h | 9 ++++++--- inc/api/TelegramAPI.h | 9 ++++++--- src/Config.cpp | 4 ---- src/FileLogger.cpp | 4 ---- src/IPRefresher.cpp | 4 ---- src/IpHelper.cpp | 4 ---- src/Logger.cpp | 4 ---- src/api/API.cpp | 4 ---- src/api/DynuAPI.cpp | 4 ---- src/api/IPAPI.cpp | 4 ---- src/api/TelegramAPI.cpp | 4 ---- src/main.cpp | 4 ---- 21 files changed, 108 insertions(+), 94 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed406c3..70dc0b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 , or " 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 + 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} diff --git a/inc/Config.h b/inc/Config.h index 2c6c835..1529671 100644 --- a/inc/Config.h +++ b/inc/Config.h @@ -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 -/** - * 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; }; \ No newline at end of file diff --git a/inc/FileLogger.h b/inc/FileLogger.h index ee0c6ca..b62f2f7 100644 --- a/inc/FileLogger.h +++ b/inc/FileLogger.h @@ -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 diff --git a/inc/IPRefresher.h b/inc/IPRefresher.h index a930ffe..6bc713d 100644 --- a/inc/IPRefresher.h +++ b/inc/IPRefresher.h @@ -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 diff --git a/inc/IpHelper.h b/inc/IpHelper.h index d239463..8b30ba9 100644 --- a/inc/IpHelper.h +++ b/inc/IpHelper.h @@ -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 -/** - * General helper class for IP actions - */ class IpHelper { public: /** diff --git a/inc/Logger.h b/inc/Logger.h index e0ffccf..f351fc8 100644 --- a/inc/Logger.h +++ b/inc/Logger.h @@ -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 diff --git a/inc/api/API.h b/inc/api/API.h index 9ac9edb..0ceb375 100644 --- a/inc/api/API.h +++ b/inc/api/API.h @@ -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 diff --git a/inc/api/DynuAPI.h b/inc/api/DynuAPI.h index 77c891c..db59214 100644 --- a/inc/api/DynuAPI.h +++ b/inc/api/DynuAPI.h @@ -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; }; diff --git a/inc/api/Hashmap.h b/inc/api/Hashmap.h index 96f4717..f81f484 100644 --- a/inc/api/Hashmap.h +++ b/inc/api/Hashmap.h @@ -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 diff --git a/inc/api/IPAPI.h b/inc/api/IPAPI.h index c442b4b..e5a20d6 100644 --- a/inc/api/IPAPI.h +++ b/inc/api/IPAPI.h @@ -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 diff --git a/inc/api/TelegramAPI.h b/inc/api/TelegramAPI.h index c28aa85..59a41d5 100644 --- a/inc/api/TelegramAPI.h +++ b/inc/api/TelegramAPI.h @@ -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 diff --git a/src/Config.cpp b/src/Config.cpp index 849be48..32aba2a 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 11.02.20. -// - #include "Config.h" #include "Logger.h" #include "Version.h" diff --git a/src/FileLogger.cpp b/src/FileLogger.cpp index aa0f450..78d670c 100644 --- a/src/FileLogger.cpp +++ b/src/FileLogger.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 05.05.19. -// - #include "FileLogger.h" #include "IpHelper.h" diff --git a/src/IPRefresher.cpp b/src/IPRefresher.cpp index 34c9ec1..3dbcf0f 100644 --- a/src/IPRefresher.cpp +++ b/src/IPRefresher.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 02.08.19. -// - #include "IPRefresher.h" #include "FileLogger.h" #include "api/IPAPI.h" diff --git a/src/IpHelper.cpp b/src/IpHelper.cpp index 4a5c40a..67c5384 100644 --- a/src/IpHelper.cpp +++ b/src/IpHelper.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 07.05.20. -// - #include "IpHelper.h" #include diff --git a/src/Logger.cpp b/src/Logger.cpp index 2bfbabe..ab81189 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 26.10.19. -// - #include "Logger.h" #include diff --git a/src/api/API.cpp b/src/api/API.cpp index b41cd89..a1e10f3 100644 --- a/src/api/API.cpp +++ b/src/api/API.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 06.04.19. -// - #include "api/API.h" #include diff --git a/src/api/DynuAPI.cpp b/src/api/DynuAPI.cpp index b711600..792a0e7 100644 --- a/src/api/DynuAPI.cpp +++ b/src/api/DynuAPI.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 18.06.19. -// - #include "api/DynuAPI.h" bool DynuAPI::refreshIp(std::string ip) { diff --git a/src/api/IPAPI.cpp b/src/api/IPAPI.cpp index 4bde56c..ec079b8 100644 --- a/src/api/IPAPI.cpp +++ b/src/api/IPAPI.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 18.06.19. -// - #include "api/IPAPI.h" std::string IPAPI::getGlobalIp() { diff --git a/src/api/TelegramAPI.cpp b/src/api/TelegramAPI.cpp index 1967c82..c89a247 100644 --- a/src/api/TelegramAPI.cpp +++ b/src/api/TelegramAPI.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 08.05.19. -// - #include "api/TelegramAPI.h" #include "Logger.h" diff --git a/src/main.cpp b/src/main.cpp index 0bbd879..6518f92 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,7 +1,3 @@ -// -// Created by lukas on 18.06.19. -// - #include "Version.h" #include "IPRefresher.h" #include "Logger.h"