aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSami Littow <sami.littow@qt.io>2022-11-24 12:28:50 +0200
committerSami Littow <sami.littow@qt.io>2022-11-24 12:28:50 +0200
commit637fd1347c09353d8078566a113a34adb5a5baf4 (patch)
tree4c8b62578042a5003ffc5815514b5b5e2c0b560a
parente9e31d1e843c6156b3085d562e0e36b47e1da259 (diff)
Updated Windows portion to meet with newest changes
* Now compiles in Windows, too
-rw-r--r--[-rwxr-xr-x].gitignore0
-rw-r--r--CHANGELOG (renamed from GHANGELOG)0
-rw-r--r--README.md2
-rw-r--r--[-rwxr-xr-x]build_linux.sh0
-rw-r--r--include/licenser.h11
-rw-r--r--include/utils.h3
-rw-r--r--licenser.cpp7
-rw-r--r--[-rwxr-xr-x]linux_service_scripts/installer.sh0
-rw-r--r--[-rwxr-xr-x]linux_service_scripts/uninstaller.sh0
-rw-r--r--utils.cpp28
10 files changed, 35 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index 11a783e..11a783e 100755..100644
--- a/.gitignore
+++ b/.gitignore
diff --git a/GHANGELOG b/CHANGELOG
index b524066..b524066 100644
--- a/GHANGELOG
+++ b/CHANGELOG
diff --git a/README.md b/README.md
index 704015f..26b0d36 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@ Daemon is a gateway between Qt License Server and Qt developer tools (i.e. Qt Cr
It also keeps users developing Qt apps without Qt tools under valid license by wrapping the MOC (Meta Object Compiler)
into new one which requests license like other tools so.
-Daemon talks to the server via HTTP, with data moving back and worth in JSON format usin HTTP POST method. Clients request for their licenses by connectiong to daemons's TCP/IP server, using plain text.
+Daemon talks to the server via HTTP, with data moving back and worth in JSON format using HTTP POST method. Clients request for their licenses by connectiong to daemons's TCP/IP server, using plain text.
For installation/running, see each system's respective INSTALL_xxx.txt files.
diff --git a/build_linux.sh b/build_linux.sh
index c02b731..c02b731 100755..100644
--- a/build_linux.sh
+++ b/build_linux.sh
diff --git a/include/licenser.h b/include/licenser.h
index ad7296c..762839f 100644
--- a/include/licenser.h
+++ b/include/licenser.h
@@ -30,7 +30,8 @@ enum RequestReply {
e_bad_request = -1,
e_license_granted = 0,
e_license_rejected = 1,
- e_bad_connection = 2
+ e_no_conn_leeway = 2,
+ e_bad_connection = 3
};
enum class RequestType {
@@ -90,6 +91,7 @@ private:
{e_bad_request, "ERROR Bad request"},
{e_license_granted, "License acquired."},
{e_license_rejected, "No valid license acquired"},
+ {e_no_conn_leeway, "License granted with warning: No server connection. Leeway time left: "},
{e_bad_connection, "No connection to server. Try again later."}
};
};
@@ -97,13 +99,6 @@ private:
#ifndef __TIME_IMP
#define __TIME_IMP
#if _WIN32
- // MSVC defines this in winsock2.h!?
-/*
- typedef struct timeval {
- long tv_sec;
- long tv_usec;
- } timeval;
-*/
inline int gettimeofday(struct timeval * tp, struct timezone * tzp)
{
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
diff --git a/include/utils.h b/include/utils.h
index 982e305..b8eceb0 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -11,12 +11,15 @@
#include <sstream>
#include <vector>
#include <algorithm>
+#include <ctime>
+#include <cstring>
#if _WIN32
// Windows
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdint.h> // portable: uint64_t MSVC: __int64
#include <io.h>
+ #include <iomanip>
#include "../3rdparty/dirent/dirent.h"
#define USER_SETTINGS_DIR "AppData\\Roaming\\Qt"// Windows
#define DIR_SEPARATOR '\\'
diff --git a/licenser.cpp b/licenser.cpp
index 35059c5..832dc6a 100644
--- a/licenser.cpp
+++ b/licenser.cpp
@@ -288,19 +288,20 @@ bool Licenser::checkLicenseExpiryDate(std::string &reply, const RequestInfo &req
std::time_t current = std::time(0);
// See if the time has expire
if (current > expEpoch) {
+ std::cout << "Expiry date " << expDate << " exceeded" << std::endl;
// License expired
if (request.appName == MOCWRAPPER_APP_NAME) {
// For MOC, allow some leeway time
int leewayTimeLeft = expEpoch + (license.getInt("leeway_hours") * SECS_IN_HOUR) - current;
- std::cout << "Leeway time left: " << leewayTimeLeft << std::endl;
if (leewayTimeLeft > 0) {
std::stringstream ss;
- ss << "Warning: No connection to server. "
- << "Leeway time left: "
+ ss << replyString[RequestReply::e_no_conn_leeway]
<< std::fixed << std::setprecision(1)
<< (float)leewayTimeLeft / SECS_IN_DAY << " days";
reply = ss.str();
return true;
+ } else {
+ std::cout << "No leeway time left" << std::endl;
}
}
std::cout << "License already expired at " << expDate << ", rejecting\n";
diff --git a/linux_service_scripts/installer.sh b/linux_service_scripts/installer.sh
index 404fb90..404fb90 100755..100644
--- a/linux_service_scripts/installer.sh
+++ b/linux_service_scripts/installer.sh
diff --git a/linux_service_scripts/uninstaller.sh b/linux_service_scripts/uninstaller.sh
index a1f19e4..a1f19e4 100755..100644
--- a/linux_service_scripts/uninstaller.sh
+++ b/linux_service_scripts/uninstaller.sh
diff --git a/utils.cpp b/utils.cpp
index 2a8696f..95c5b66 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -80,6 +80,7 @@ int strToInt(const std::string &str)
std::string getUserHomeDir()
{
// Try to find current user's home
+ std::string retVal = "";
const char* homedir;
#if __linux__ || __APPLE__ || __MACH__
// Linux and Mac
@@ -91,15 +92,15 @@ std::string getUserHomeDir()
// Windows
homedir = getenv("HOMEPATH");
if (homedir != nullptr) {
- homedir = SYSTEM_ROOT + homedir;
+ retVal = SYSTEM_ROOT;
}
-
#endif
if (homedir == nullptr) {
printf("ERROR Not able to determine user's home directory\n");
- homedir = "";
+ return "Not able to get homedir";
}
- return std::string(homedir);
+ retVal += std::string(homedir);
+ return retVal;
}
// Write data to the file
@@ -235,6 +236,8 @@ std::vector<std::string> getDirListing(const std::string &directory, const std::
return files;
}
+#include <time.h>
+
std::string getOsName()
{
@@ -253,6 +256,23 @@ std::string getOsName()
#endif
}
+#if _WIN32
+/*
+ * Windows implementation of missing POSIX strptime()
+*/
+char* strptime(const char* s,
+ const char* f,
+ struct tm* tm) {
+ std::istringstream input(s);
+ input.imbue(std::locale(setlocale(LC_ALL, nullptr)));
+ input >> std::get_time(tm, f);
+ if (input.fail()) {
+ return nullptr;
+ }
+ return (char*)(s + input.tellg());
+}
+#endif
+
std::string epochToString(time_t epochTime, const char* format)
{
char timestamp[64] = {0};