blob: 0c916a25d0461d1577b81334d48853f734f67319 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/* Copyright (C) 2022 The Qt Company Ltd.
*
* SPDX-License-Identifier: GPL-3.0-only WITH Qt-GPL-exception-1.0
*/
#pragma once
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <string>
#include <vector>
#include <ctime>
#include <cassert>
#if _WIN32
// Windows
#define WIN32_LEAN_AND_MEAN
//#include <windows.h>
#else
#endif
#include "httpclient.h"
#include "tcpserver.h"
#include "licdsetup.h"
#include "clienthandler.h"
namespace QLicenseService {
class Licenser
{
public:
explicit Licenser(uint16_t tcpPort = 0);
~Licenser();
int listen();
int sendServerRequest(std::string &reply);
private:
HttpClient *m_http;
TcpServer *m_tcpServer;
uint64_t m_mocInterval;
std::string m_infoString;
ClientHandler *m_currentClient;
std::vector<ClientHandler*> m_floatingClients;
bool parseInputAndCreateCLient(uint16_t socketId, const std::string &incoming);
bool addClientToParent();
void doHmacHashSha256(const std::string &payload, const std::string &secret, std::string &authKey);
int initDaemonSettings();
std::string checkReservations();
std::string askServerVersion();
std::string getDaemonVersion();
int checkTasksDue();
void removeReservation(int socketId);
void setHwId();
bool clientInStorage(uint16_t socketId);
LicdSetup *settings;
};
} // namespace QLicenseService
|