From cda5b29fd3f2c0340f5d891bdd897aad182b4b07 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Thu, 13 Aug 2015 14:19:13 -0600 Subject: [PATCH] Another take at versioning details exchange - checkpoint --- assignment-client/CMakeLists.txt | 1 + assignment-client/src/AssignmentClient.cpp | 3 +-- assignment-client/src/AssignmentClientApp.cpp | 5 ++--- .../macros/ApplicationVersion.h.in | 10 ++++----- cmake/macros/IncludeApplicationVersion.cmake | 22 +++++++++++++++++++ domain-server/CMakeLists.txt | 1 + domain-server/src/DomainServer.cpp | 8 ++----- interface/CMakeLists.txt | 12 ++-------- interface/src/Application.cpp | 2 +- libraries/networking/CMakeLists.txt | 3 ++- libraries/networking/src/Assignment.cpp | 7 ++++++ libraries/networking/src/Assignment.h | 1 + libraries/networking/src/NodeList.cpp | 10 ++++++--- 13 files changed, 53 insertions(+), 32 deletions(-) rename interface/InterfaceVersion.h.in => cmake/macros/ApplicationVersion.h.in (54%) create mode 100644 cmake/macros/IncludeApplicationVersion.cmake diff --git a/assignment-client/CMakeLists.txt b/assignment-client/CMakeLists.txt index 2561a1502d..edd68e12bf 100644 --- a/assignment-client/CMakeLists.txt +++ b/assignment-client/CMakeLists.txt @@ -17,4 +17,5 @@ if (UNIX) target_link_libraries(${TARGET_NAME} ${CMAKE_DL_LIBS}) endif (UNIX) +include_application_version() copy_dlls_beside_windows_executable() \ No newline at end of file diff --git a/assignment-client/src/AssignmentClient.cpp b/assignment-client/src/AssignmentClient.cpp index 40aef1c707..ec0e5b9e5a 100644 --- a/assignment-client/src/AssignmentClient.cpp +++ b/assignment-client/src/AssignmentClient.cpp @@ -129,6 +129,7 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri packetReceiver.registerListener(PacketType::CreateAssignment, this, "handleCreateAssignmentPacket"); packetReceiver.registerListener(PacketType::StopNode, this, "handleStopNodePacket"); } + void AssignmentClient::stopAssignmentClient() { qDebug() << "Forced stop of assignment-client."; @@ -172,7 +173,6 @@ void AssignmentClient::aboutToQuit() { qInstallMessageHandler(0); } - void AssignmentClient::setUpStatusToMonitor() { // send a stats packet every 1 seconds connect(&_statsTimerACM, &QTimer::timeout, this, &AssignmentClient::sendStatusPacketToACM); @@ -217,7 +217,6 @@ void AssignmentClient::sendAssignmentRequest() { qDebug() << "Failed to read local assignment server port from shared memory" << "- will send assignment request to previous assignment server socket."; } - } nodeList->sendAssignment(_requestAssignment); diff --git a/assignment-client/src/AssignmentClientApp.cpp b/assignment-client/src/AssignmentClientApp.cpp index 7268f9281b..2edae340c3 100644 --- a/assignment-client/src/AssignmentClientApp.cpp +++ b/assignment-client/src/AssignmentClientApp.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -40,6 +41,7 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : setOrganizationName("High Fidelity"); setOrganizationDomain("highfidelity.io"); setApplicationName("assignment-client"); + setApplicationName(BUILD_VERSION); // use the verbose message handler in Logging qInstallMessageHandler(LogHandler::verboseMessageHandler); @@ -93,10 +95,8 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : Q_UNREACHABLE(); } - const QVariantMap argumentVariantMap = HifiConfigVariantMap::mergeCLParametersWithJSONConfig(arguments()); - unsigned int numForks = 0; if (parser.isSet(numChildsOption)) { numForks = parser.value(numChildsOption).toInt(); @@ -139,7 +139,6 @@ AssignmentClientApp::AssignmentClientApp(int argc, char* argv[]) : assignmentPool = parser.value(poolOption); } - QUuid walletUUID; if (argumentVariantMap.contains(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION)) { walletUUID = argumentVariantMap.value(ASSIGNMENT_WALLET_DESTINATION_ID_OPTION).toString(); diff --git a/interface/InterfaceVersion.h.in b/cmake/macros/ApplicationVersion.h.in similarity index 54% rename from interface/InterfaceVersion.h.in rename to cmake/macros/ApplicationVersion.h.in index 2f902de41c..736d00726c 100644 --- a/interface/InterfaceVersion.h.in +++ b/cmake/macros/ApplicationVersion.h.in @@ -1,11 +1,9 @@ // -// InterfaceVersion.h -// interface/src +// ApplicationVersion.h.in +// cmake/macros // -// Created by Leonardo Murillo on 12/16/13. -// Copyright 2013 High Fidelity, Inc. -// -// Declaration of version and build data +// Created by Leonardo Murillo on 8/13/15. +// Copyright 2015 High Fidelity, Inc. // // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/cmake/macros/IncludeApplicationVersion.cmake b/cmake/macros/IncludeApplicationVersion.cmake new file mode 100644 index 0000000000..96137294a7 --- /dev/null +++ b/cmake/macros/IncludeApplicationVersion.cmake @@ -0,0 +1,22 @@ +# +# IncludeApplicationVersion.cmake +# cmake/macros +# +# Created by Leonardo Murillo on 07/14/2015. +# Copyright 2015 High Fidelity, Inc. +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# + +macro(INCLUDE_APPLICATION_VERSION) + if (DEFINED ENV{JOB_ID}) + set (BUILD_SEQ $ENV{JOB_ID}) + elseif (DEFINED ENV{ghprbPullId}) + set (BUILD_SEQ "PR: $ENV{ghprbPullId} - Commit: $ENV{ghprbActualCommit}") + else () + set(BUILD_SEQ "dev") + endif () + configure_file("${MACRO_DIR}/ApplicationVersion.h.in" "${PROJECT_BINARY_DIR}/includes/ApplicationVersion.h") + include_directories("${PROJECT_BINARY_DIR}/includes") +endmacro(INCLUDE_APPLICATION_VERSION) diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt index 41f2d15486..e4fa1d874d 100644 --- a/domain-server/CMakeLists.txt +++ b/domain-server/CMakeLists.txt @@ -31,4 +31,5 @@ include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") # append OpenSSL to our list of libraries to link target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES}) +include_application_version() copy_dlls_beside_windows_executable() diff --git a/domain-server/src/DomainServer.cpp b/domain-server/src/DomainServer.cpp index 4e5b563fc6..abfd7efe89 100644 --- a/domain-server/src/DomainServer.cpp +++ b/domain-server/src/DomainServer.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -75,6 +76,7 @@ DomainServer::DomainServer(int argc, char* argv[]) : setOrganizationName("High Fidelity"); setOrganizationDomain("highfidelity.io"); setApplicationName("domain-server"); + setApplicationVersion(BUILD_VERSION); QSettings::setDefaultFormat(QSettings::IniFormat); // make sure we have a fresh AccountManager instance @@ -1478,7 +1480,6 @@ const char JSON_KEY_POOL[] = "pool"; const char JSON_KEY_PENDING_CREDITS[] = "pending_credits"; const char JSON_KEY_WAKE_TIMESTAMP[] = "wake_timestamp"; const char JSON_KEY_USERNAME[] = "username"; - QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) { QJsonObject nodeJson; @@ -1527,7 +1528,6 @@ QJsonObject DomainServer::jsonObjectForNode(const SharedNodePointer& node) { } const char ASSIGNMENT_SCRIPT_HOST_LOCATION[] = "resources/web/assignment"; - QString pathForAssignmentScript(const QUuid& assignmentUUID) { QString newPath(ASSIGNMENT_SCRIPT_HOST_LOCATION); newPath += "/scripts/"; @@ -1537,7 +1537,6 @@ QString pathForAssignmentScript(const QUuid& assignmentUUID) { } const QString URI_OAUTH = "/oauth"; - bool DomainServer::handleHTTPRequest(HTTPConnection* connection, const QUrl& url, bool skipSubHandler) { const QString JSON_MIME_TYPE = "application/json"; @@ -2024,8 +2023,6 @@ bool DomainServer::isAuthenticatedRequest(HTTPConnection* connection, const QUrl } const QString OAUTH_JSON_ACCESS_TOKEN_KEY = "access_token"; - - QNetworkReply* DomainServer::profileRequestGivenTokenReply(QNetworkReply* tokenReply) { // pull the access token from the returned JSON and store it with the matching session UUID QJsonDocument returnedJSON = QJsonDocument::fromJson(tokenReply->readAll()); @@ -2042,7 +2039,6 @@ QNetworkReply* DomainServer::profileRequestGivenTokenReply(QNetworkReply* tokenR } const QString DS_SETTINGS_SESSIONS_GROUP = "web-sessions"; - Headers DomainServer::setupCookieHeadersFromProfileReply(QNetworkReply* profileReply) { Headers cookieHeaders; diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 9ad250bdcf..acafafa006 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -14,20 +14,12 @@ endforeach() find_package(Qt5LinguistTools REQUIRED) find_package(Qt5LinguistToolsMacros) -if (DEFINED ENV{JOB_ID}) - set(BUILD_SEQ $ENV{JOB_ID}) -elseif (DEFINED ENV{ghprbPullId}) - set(BUILD_SEQ "PR: $ENV{ghprbPullId} - Commit: $ENV{ghprbActualCommit}") -else () - set(BUILD_SEQ "dev") -endif () - if (WIN32) add_definitions(-D_USE_MATH_DEFINES) # apparently needed to get M_PI and other defines from cmath/math.h add_definitions(-DWINDOWS_LEAN_AND_MEAN) # needed to make sure windows doesn't go to crazy with its defines endif() -configure_file(InterfaceVersion.h.in "${PROJECT_BINARY_DIR}/includes/InterfaceVersion.h") +include_application_version() # grab the implementation and header files from src dirs file(GLOB_RECURSE INTERFACE_SRCS "src/*.cpp" "src/*.h") @@ -174,7 +166,7 @@ if (RTMIDI_FOUND AND NOT DISABLE_RTMIDI AND APPLE) endif () # include headers for interface and InterfaceConfig. -include_directories("${PROJECT_SOURCE_DIR}/src" "${PROJECT_BINARY_DIR}/includes") +include_directories("${PROJECT_SOURCE_DIR}/src") target_link_libraries( ${TARGET_NAME} diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index d8dad73d82..fe361f8b8f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include #include @@ -100,7 +101,6 @@ #include "AudioClient.h" #include "DiscoverabilityManager.h" #include "GLCanvas.h" -#include "InterfaceVersion.h" #include "LODManager.h" #include "Menu.h" #include "ModelPackager.h" diff --git a/libraries/networking/CMakeLists.txt b/libraries/networking/CMakeLists.txt index 6b386ace92..d79e6bde58 100644 --- a/libraries/networking/CMakeLists.txt +++ b/libraries/networking/CMakeLists.txt @@ -28,4 +28,5 @@ include_directories(SYSTEM "${OPENSSL_INCLUDE_DIR}") target_link_libraries(${TARGET_NAME} ${OPENSSL_LIBRARIES} ${TBB_LIBRARIES}) # append tbb includes to our list of includes to bubble -target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${TBB_INCLUDE_DIRS}) \ No newline at end of file +target_include_directories(${TARGET_NAME} SYSTEM PUBLIC ${TBB_INCLUDE_DIRS}) +include_application_version() \ No newline at end of file diff --git a/libraries/networking/src/Assignment.cpp b/libraries/networking/src/Assignment.cpp index 293d86475f..a7a6fe03ea 100644 --- a/libraries/networking/src/Assignment.cpp +++ b/libraries/networking/src/Assignment.cpp @@ -66,7 +66,9 @@ Assignment::Assignment(NLPacket& packet) : _payload(), _walletUUID() { + qDebug() << "LEOTEST: We are building an Assignment from a packet"; if (packet.getType() == PacketType::RequestAssignment) { + qDebug() << "LEOTEST: This is a request assignment packet"; _command = Assignment::RequestCommand; } else if (packet.getType() == PacketType::CreateAssignment) { _command = Assignment::CreateCommand; @@ -151,11 +153,16 @@ QDataStream& operator<<(QDataStream &out, const Assignment& assignment) { QDataStream& operator>>(QDataStream &in, Assignment& assignment) { quint8 packedType; in >> packedType; + if (assignment._command == Assignment::RequestCommand) { + qDebug() << "We are extracting the version"; + in >> assignment._nodeVersion; + } assignment._type = (Assignment::Type) packedType; in >> assignment._uuid >> assignment._pool >> assignment._payload; if (assignment._command == Assignment::RequestCommand) { + qDebug() << "LEOTEST: Operator for >> in case of RequestCommand"; in >> assignment._walletUUID; } diff --git a/libraries/networking/src/Assignment.h b/libraries/networking/src/Assignment.h index 67f861f850..f1b6cc7fba 100644 --- a/libraries/networking/src/Assignment.h +++ b/libraries/networking/src/Assignment.h @@ -98,6 +98,7 @@ protected: QByteArray _payload; /// an optional payload attached to this assignment, a maximum for 1024 bytes will be packed bool _isStatic; /// defines if this assignment needs to be re-queued in the domain-server if it stops being fulfilled QUuid _walletUUID; /// the UUID for the wallet that should be paid for this assignment + QString _nodeVersion; }; #endif // hifi_Assignment_h diff --git a/libraries/networking/src/NodeList.cpp b/libraries/networking/src/NodeList.cpp index 44b9c0b829..9ecf31edab 100644 --- a/libraries/networking/src/NodeList.cpp +++ b/libraries/networking/src/NodeList.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include "AccountManager.h" @@ -367,7 +368,6 @@ void NodeList::sendDSPathQuery(const QString& newPath) { } } - void NodeList::processDomainServerPathResponse(QSharedPointer packet) { // This is a response to a path query we theoretically made. // In the future we may want to check that this was actually from our DS and for a query we actually made. @@ -457,7 +457,6 @@ void NodeList::pingPunchForDomainServer() { } } - void NodeList::processDomainServerConnectionTokenPacket(QSharedPointer packet) { if (_domainHandler.getSockAddr().isNull()) { // refuse to process this packet if we aren't currently connected to the DS @@ -547,9 +546,14 @@ void NodeList::sendAssignment(Assignment& assignment) { ? PacketType::CreateAssignment : PacketType::RequestAssignment; + qDebug() << "LEOTEST: Packet type name " << nameForPacketType(assignmentPacketType); auto assignmentPacket = NLPacket::create(assignmentPacketType); - + QDataStream packetStream(assignmentPacket.get()); + if (assignmentPacketType == PacketType::RequestAssignment) { + qDebug() << "LEOTEST: This is an assignment request, lets send the node version here " << BUILD_VERSION; + packetStream << BUILD_VERSION; + } packetStream << assignment; // TODO: should this be a non sourced packet?