added c++ doc and replaced ifndef with pragma once
This commit is contained in:
26
inc/Logger.h
Normal file
26
inc/Logger.h
Normal file
@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by lukas on 05.05.19.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
class Logger {
|
||||
public:
|
||||
/**
|
||||
* log messages to logfile
|
||||
* @param text message
|
||||
*/
|
||||
void logToLogfile(std::string text);
|
||||
|
||||
/**
|
||||
* safe ip to temp file
|
||||
* @param ip ip address to save
|
||||
*/
|
||||
void safeip(std::string ip);
|
||||
|
||||
/**
|
||||
* read ip from file
|
||||
* @return read ip
|
||||
*/
|
||||
std::string readip();
|
||||
|
||||
};
|
32
inc/api/API.h
Normal file
32
inc/api/API.h
Normal file
@ -0,0 +1,32 @@
|
||||
//
|
||||
// Created by lukas on 06.04.19.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "Hashmap.h"
|
||||
|
||||
class API {
|
||||
public:
|
||||
/**
|
||||
* Simple API get request
|
||||
* @param myurl api url
|
||||
* @return return string of server
|
||||
*/
|
||||
std::string request(std::string myurl);
|
||||
|
||||
/**
|
||||
* complex request with post/get and header information support
|
||||
* @param myurl base request url
|
||||
* @param post boolean (false=get)
|
||||
* @param map post/get fields
|
||||
* @param headers header fields
|
||||
* @return return string of server
|
||||
*/
|
||||
std::string request(std::string myurl, bool post, Hashmap<std::string, std::string> &map, std::vector<std::string> &headers);
|
||||
|
||||
private:
|
||||
static size_t write_data(void *buffer, size_t size, size_t buffersize, FILE *stream);
|
||||
};
|
23
inc/api/DynuAPI.h
Normal file
23
inc/api/DynuAPI.h
Normal file
@ -0,0 +1,23 @@
|
||||
//
|
||||
// Created by lukas on 18.06.19.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "API.h"
|
||||
|
||||
class DynuAPI : API{
|
||||
public:
|
||||
/**
|
||||
* refresh the ip of domain on Dynu server
|
||||
* @param ip new ip
|
||||
* @return request status
|
||||
*/
|
||||
int refreshIp(std::string ip);
|
||||
private:
|
||||
const std::string dynuapikey = "88vNpMfDhMM2YYDNfWR1DNYfRX9W6fYg";
|
||||
|
||||
const std::string domainid = "8506047"; //id of the dynu domain
|
||||
const std::string domainname = "luki.dynu.net";
|
||||
};
|
65
inc/api/Hashmap.h
Normal file
65
inc/api/Hashmap.h
Normal file
@ -0,0 +1,65 @@
|
||||
//
|
||||
// Created by lukas on 07.04.19.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
template<class keytype, class valuetype>
|
||||
class Hashmap {
|
||||
public:
|
||||
/**
|
||||
* add key-value pair to hashmap
|
||||
* @param key keyvalue
|
||||
* @param value valuevalue
|
||||
*/
|
||||
void add(keytype key, keytype value);
|
||||
|
||||
/**
|
||||
* get key of specific position
|
||||
* @param position int position
|
||||
* @return responding key object
|
||||
*/
|
||||
keytype getKey(int position);
|
||||
|
||||
/**
|
||||
* get value of specific position
|
||||
* @param position int position
|
||||
* @return responding value object
|
||||
*/
|
||||
valuetype getValue(int position);
|
||||
|
||||
/**
|
||||
* get size of Hashmap
|
||||
* @return size of Hashmap
|
||||
*/
|
||||
int size();
|
||||
|
||||
private:
|
||||
std::vector<keytype> keys;
|
||||
std::vector<valuetype> values;
|
||||
};
|
||||
|
||||
template<class keytype, class valuetype>
|
||||
void Hashmap<keytype, valuetype>::add(keytype key, keytype value) {
|
||||
keys.push_back(key);
|
||||
values.push_back(value);
|
||||
}
|
||||
|
||||
template<class keytype, class valuetype>
|
||||
keytype Hashmap<keytype, valuetype>::getKey(int position) {
|
||||
return keys.at(position);
|
||||
}
|
||||
|
||||
template<class keytype, class valuetype>
|
||||
valuetype Hashmap<keytype, valuetype>::getValue(int position) {
|
||||
return values.at(position);
|
||||
}
|
||||
|
||||
template<class keytype, class valuetype>
|
||||
int Hashmap<keytype, valuetype>::size() {
|
||||
return (int) (keys.size());
|
||||
}
|
17
inc/api/IPAPI.h
Normal file
17
inc/api/IPAPI.h
Normal file
@ -0,0 +1,17 @@
|
||||
//
|
||||
// Created by lukas on 18.06.19.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "API.h"
|
||||
|
||||
class IPAPI : API{
|
||||
public:
|
||||
/**
|
||||
* get global ip of current internet connection
|
||||
* @return global ip
|
||||
*/
|
||||
std::string getGlobalIp();
|
||||
};
|
22
inc/api/TelegramAPI.h
Normal file
22
inc/api/TelegramAPI.h
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by lukas on 08.05.19.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "API.h"
|
||||
|
||||
class TelegramAPI : API {
|
||||
public:
|
||||
/**
|
||||
* send telegram Message to predefined destination
|
||||
* @param text message
|
||||
*/
|
||||
void sendMessage(std::string text);
|
||||
|
||||
private:
|
||||
const std::string apikey = "717213769:AAHan1nSXhUsxLJAN1Dv8Oc0z8wqwDdYPn4";
|
||||
const std::string chatid = "618154204";
|
||||
};
|
Reference in New Issue
Block a user