diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/CMakeLists.txt.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/CMakeLists.txt.mustache index b78e15fb97f..86b1d5affeb 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/CMakeLists.txt.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/CMakeLists.txt.mustache @@ -12,7 +12,8 @@ else () endif () find_package(Qt5Core REQUIRED) -find_package(Qt5Network REQUIRED){{#contentCompression}} +find_package(Qt5Network REQUIRED){{#authMethods}}{{#isOAuth}} +find_package(Qt5Gui REQUIRED){{/isOAuth}}{{/authMethods}}{{#contentCompression}} find_package(ZLIB REQUIRED){{/contentCompression}} add_library(${PROJECT_NAME} @@ -31,9 +32,9 @@ add_library(${PROJECT_NAME} {{prefix}}Helpers.cpp {{prefix}}HttpRequest.cpp {{prefix}}HttpFileElement.cpp + {{prefix}}Oauth.cpp ) -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Network {{#contentCompression}} ${ZLIB_LIBRARIES}{{/contentCompression}}) - +target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Network{{#authMethods}}{{#isOAuth}} Qt5::Gui{{/isOAuth}}{{/authMethods}}{{#contentCompression}} ${ZLIB_LIBRARIES}{{/contentCompression}}) if(NOT APPLE) target_link_libraries(${PROJECT_NAME} PRIVATE ssl crypto) endif() diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/oauth.cpp.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/oauth.cpp.mustache index ebe53654851..7d4ec2b44f6 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/oauth.cpp.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/oauth.cpp.mustache @@ -1,6 +1,8 @@ #include "{{prefix}}Oauth.h" -namespace OpenAPI { +{{#cppNamespaceDeclarations}} +namespace {{this}} { +{{/cppNamespaceDeclarations}} /* * Base class to perform oauth2 flows @@ -343,5 +345,6 @@ void ReplyServer::read() emit dataReceived(queryParams); } - -} \ No newline at end of file +{{#cppNamespaceDeclarations}} +} // namespace {{this}} +{{/cppNamespaceDeclarations}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/cpp-qt-client/oauth.h.mustache b/modules/openapi-generator/src/main/resources/cpp-qt-client/oauth.h.mustache index 03aa0dde901..91aae71a1b4 100644 --- a/modules/openapi-generator/src/main/resources/cpp-qt-client/oauth.h.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-qt-client/oauth.h.mustache @@ -21,8 +21,7 @@ #include #include #include - - +#include {{#cppNamespaceDeclarations}} namespace {{this}} { @@ -32,19 +31,19 @@ class oauthToken { public: oauthToken(QString token, int expiresIn, QString scope, QString tokenType) : m_token(token), m_scope(scope), m_type(tokenType){ - m_validUntil = QDateTime::fromSecsSinceEpoch(QDateTime::currentSecsSinceEpoch() + expiresIn); + m_validUntil = time(0) + expiresIn; } oauthToken(){ - m_validUntil = QDateTime::fromSecsSinceEpoch(QDateTime::currentSecsSinceEpoch() -1); + m_validUntil = time(0) - 1; } QString getToken(){return m_token;}; QString getScope(){return m_scope;}; QString getType(){return m_type;}; - bool isValid(){return QDateTime::currentDateTime() < m_validUntil;}; + bool isValid(){return time(0) < m_validUntil;}; private: QString m_token; - QDateTime m_validUntil; + time_t m_validUntil; QString m_scope; QString m_type; }; diff --git a/samples/client/petstore/cpp-qt/CMakeLists.txt b/samples/client/petstore/cpp-qt/CMakeLists.txt index 5d408c92e72..6938aca8993 100644 --- a/samples/client/petstore/cpp-qt/CMakeLists.txt +++ b/samples/client/petstore/cpp-qt/CMakeLists.txt @@ -10,6 +10,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-unused-variable") find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED) find_package(Qt5Test REQUIRED) +find_package(Qt5Gui REQUIRED) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/client @@ -23,7 +24,7 @@ add_executable(${PROJECT_NAME} PetStore/UserApiTests.cpp ) target_link_libraries(${PROJECT_NAME} PRIVATE client) -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Network Qt5::Test) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Network Qt5::Test Qt5::Gui) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 14) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON) set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_EXTENSIONS OFF) diff --git a/samples/client/petstore/cpp-qt/client/CMakeLists.txt b/samples/client/petstore/cpp-qt/client/CMakeLists.txt index 414d1c08636..29b96a13aae 100644 --- a/samples/client/petstore/cpp-qt/client/CMakeLists.txt +++ b/samples/client/petstore/cpp-qt/client/CMakeLists.txt @@ -13,6 +13,7 @@ endif () find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED) +find_package(Qt5Gui REQUIRED) add_library(${PROJECT_NAME} PFXApiResponse.cpp @@ -27,9 +28,9 @@ add_library(${PROJECT_NAME} PFXHelpers.cpp PFXHttpRequest.cpp PFXHttpFileElement.cpp + PFXOauth.cpp ) -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Network ) - +target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Network Qt5::Gui) if(NOT APPLE) target_link_libraries(${PROJECT_NAME} PRIVATE ssl crypto) endif() diff --git a/samples/client/petstore/cpp-qt/client/PFXOauth.cpp b/samples/client/petstore/cpp-qt/client/PFXOauth.cpp index a5cc0da2606..f5617124bb5 100644 --- a/samples/client/petstore/cpp-qt/client/PFXOauth.cpp +++ b/samples/client/petstore/cpp-qt/client/PFXOauth.cpp @@ -1,6 +1,6 @@ #include "PFXOauth.h" -namespace OpenAPI { +namespace test_namespace { /* * Base class to perform oauth2 flows @@ -343,5 +343,4 @@ void ReplyServer::read() emit dataReceived(queryParams); } - -} \ No newline at end of file +} // namespace test_namespace diff --git a/samples/client/petstore/cpp-qt/client/PFXOauth.h b/samples/client/petstore/cpp-qt/client/PFXOauth.h index f86a29e944f..df282d47cee 100644 --- a/samples/client/petstore/cpp-qt/client/PFXOauth.h +++ b/samples/client/petstore/cpp-qt/client/PFXOauth.h @@ -31,8 +31,7 @@ #include #include #include - - +#include namespace test_namespace { @@ -40,19 +39,19 @@ class oauthToken { public: oauthToken(QString token, int expiresIn, QString scope, QString tokenType) : m_token(token), m_scope(scope), m_type(tokenType){ - m_validUntil = QDateTime::fromSecsSinceEpoch(QDateTime::currentSecsSinceEpoch() + expiresIn); + m_validUntil = time(0) + expiresIn; } oauthToken(){ - m_validUntil = QDateTime::fromSecsSinceEpoch(QDateTime::currentSecsSinceEpoch() -1); + m_validUntil = time(0) - 1; } QString getToken(){return m_token;}; QString getScope(){return m_scope;}; QString getType(){return m_type;}; - bool isValid(){return QDateTime::currentDateTime() < m_validUntil;}; + bool isValid(){return time(0) < m_validUntil;}; private: QString m_token; - QDateTime m_validUntil; + time_t m_validUntil; QString m_scope; QString m_type; };