diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt deleted file mode 100644 index a216b59..0000000 --- a/cpp/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -cmake_minimum_required(VERSION 3.14) -project(LogosSDK) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_AUTOMOC ON) - -# Find Qt packages -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core RemoteObjects) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core RemoteObjects) - -# SDK sources -set(SDK_SOURCES - logos_api.cpp - logos_api.h - logos_api_client.cpp - logos_api_client.h - logos_api_consumer.cpp - logos_api_consumer.h - logos_api_provider.cpp - logos_api_provider.h - module_proxy.cpp - module_proxy.h - token_manager.cpp - token_manager.h - logos_mode.h - plugin_registry.h -) - -# Create the SDK library as STATIC instead of SHARED -add_library(logos_sdk STATIC ${SDK_SOURCES}) - -# Link Qt libraries -target_link_libraries(logos_sdk PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::RemoteObjects) - -# Include directories -target_include_directories(logos_sdk PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} -) - -# Set output directories for static library -set_target_properties(logos_sdk PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" -) - -# Install the library -install(TARGETS logos_sdk - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin -) - -# Install headers -install(FILES - logos_api.h - logos_api_client.h - logos_api_consumer.h - logos_api_provider.h - module_proxy.h - token_manager.h - logos_mode.h - plugin_registry.h - DESTINATION include -) \ No newline at end of file diff --git a/cpp/example_usage.cpp b/cpp/example_usage.cpp deleted file mode 100644 index cf3d205..0000000 --- a/cpp/example_usage.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/** - * @file example_usage.cpp - * @brief Example showing how to use the LogosAPI SDK - * - * This example demonstrates how to use the LogosAPI to connect - * to the Logos Core registry and request remote objects. - */ - -#include "logos_api_client.h" -#include "token_manager.h" -#include -#include -#include - -void exampleUsage() -{ - // Create a client instance (uses default registry URL) - LogosAPIClient client("core_manager", "example"); - - // Check if connected - if (!client.isConnected()) { - qWarning() << "Failed to connect to Logos Core registry"; - return; - } - - // Request the Core Manager object - QRemoteObjectReplica* coreManager = client.requestObject("Core Manager"); - if (!coreManager) { - qWarning() << "Failed to acquire Core Manager replica"; - return; - } - - // Use the replica to call methods - QString pluginName; - bool success = QMetaObject::invokeMethod( - coreManager, - "processPlugin", - Qt::DirectConnection, - Q_RETURN_ARG(QString, pluginName), - Q_ARG(QString, "/path/to/plugin.dylib") - ); - - if (success && !pluginName.isEmpty()) { - qDebug() << "Successfully processed plugin:" << pluginName; - } else { - qWarning() << "Failed to process plugin"; - } - - // Clean up the replica when done - delete coreManager; -} - -// Alternative usage with custom registry URL and timeout -void exampleCustomUsage() -{ - // Create client with custom registry URL - LogosAPI client("custom_registry"); - - if (!client.isConnected()) { - // Try to reconnect - if (!client.reconnect()) { - qWarning() << "Failed to connect to custom registry"; - return; - } - } - - // Request object with custom timeout (10 seconds) - QRemoteObjectReplica* someObject = client.requestObject("Some Object", 10000); - if (someObject) { - // Use the object... - - // Clean up - delete someObject; - } - - // Example TokenManager usage - TokenManager& tokenManager = TokenManager::instance(); - - // Save some tokens - tokenManager.saveToken("auth_token", "abc123xyz"); - tokenManager.saveToken("refresh_token", "def456uvw"); - tokenManager.saveToken("session_token", "ghi789rst"); - - // Retrieve tokens - QString authToken = tokenManager.getToken("auth_token"); - qDebug() << "Auth token:" << authToken; - - // Check if token exists - if (tokenManager.hasToken("refresh_token")) { - qDebug() << "Refresh token exists"; - } - - // Get all token keys - QList keys = tokenManager.getTokenKeys(); - qDebug() << "Token keys:" << keys; - qDebug() << "Total tokens:" << tokenManager.tokenCount(); - - // Remove a token - if (tokenManager.removeToken("session_token")) { - qDebug() << "Session token removed"; - } - - // Clear all tokens when done - // tokenManager.clearAllTokens(); -} \ No newline at end of file diff --git a/cpp/simple_example.cpp b/cpp/simple_example.cpp deleted file mode 100644 index e039760..0000000 --- a/cpp/simple_example.cpp +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file simple_example.cpp - * @brief Simple example showing how to use the LogosAPI class - */ - -#include "logos_api.h" -#include "logos_api_client.h" -#include "logos_api_provider.h" -#include "token_manager.h" -#include - -void simpleExample() -{ - // Create a LogosAPI instance for our module - LogosAPI api("core"); - - // Get the provider and register an object - LogosAPIProvider* provider = api.getProvider(); - QObject* myService = new QObject(); - provider->registerObject("my_service", myService); - - // Get the client to communicate with other modules - LogosAPIClient* client = api.getClient("core_manager"); - // Use client to call remote methods... - - // Get the token manager and save tokens - TokenManager* tokenManager = api.getTokenManager(); - tokenManager->saveToken("auth_token", "abc123"); - - qDebug() << "LogosAPI initialized successfully!"; - - delete myService; -} \ No newline at end of file diff --git a/nix/include.nix b/nix/include.nix index ecc283f..a010cac 100644 --- a/nix/include.nix +++ b/nix/include.nix @@ -15,29 +15,74 @@ pkgs.stdenv.mkDerivation { installPhase = '' runHook preInstall - # Install headers with proper structure - mkdir -p $out/include/core + # BACKWARD COMPATIBILITY: + # The installed include structure uses cpp/ and core/ directories to remain + # compatible with logos-module-builder and other downstream projects that + # expect the original layout. The internal source is organized differently + # (src/client/, src/provider/) but the installed output maintains the old paths. + # + # Since the source files use relative includes (e.g., "../logos_mode.h") that + # work for the internal structure, we use sed to flatten these paths when + # installing to the flat cpp/ directory. + + mkdir -p $out/include mkdir -p $out/include/cpp + mkdir -p $out/include/core - # Install core headers - if [ -f core/interface.h ]; then - cp core/interface.h $out/include/core/ - fi + # Install all SDK source files into include/cpp/ + # From src/ root + for file in logos_api.cpp logos_api.h token_manager.cpp token_manager.h logos_mode.h plugin_registry.h; do + if [ -f src/$file ]; then + cp src/$file $out/include/cpp/ + fi + done - # Install cpp headers and sources - for file in logos_api.cpp logos_api.h logos_api_client.cpp logos_api_client.h \ - logos_api_consumer.cpp logos_api_consumer.h logos_api_provider.cpp logos_api_provider.h \ - token_manager.cpp token_manager.h module_proxy.cpp module_proxy.h logos_mode.h; do - if [ -f cpp/$file ]; then - cp cpp/$file $out/include/cpp/ + # From src/client/ + for file in logos_api_client.cpp logos_api_client.h logos_api_consumer.cpp logos_api_consumer.h; do + if [ -f src/client/$file ]; then + cp src/client/$file $out/include/cpp/ fi done - if [ -f cpp/logos_mode.h ]; then - cp cpp/logos_mode.h $out/include/ + # From src/provider/ + for file in logos_api_provider.cpp logos_api_provider.h module_proxy.cpp module_proxy.h; do + if [ -f src/provider/$file ]; then + cp src/provider/$file $out/include/cpp/ + fi + done + + # Flatten include paths in cpp/ directory + # The source uses relative paths like "../logos_mode.h" which need to become "logos_mode.h" + # in the flat cpp/ directory structure. + # NOTE: These rewrites are for backward compatibility and may be changed later + # when downstream projects are updated to use the new include structure. + for file in $out/include/cpp/*.cpp $out/include/cpp/*.h; do + if [ -f "$file" ]; then + sed -i \ + -e 's|#include "../logos_mode.h"|#include "logos_mode.h"|g' \ + -e 's|#include "../logos_api.h"|#include "logos_api.h"|g' \ + -e 's|#include "../token_manager.h"|#include "token_manager.h"|g' \ + -e 's|#include "../plugin_registry.h"|#include "plugin_registry.h"|g' \ + -e 's|#include "../provider/module_proxy.h"|#include "module_proxy.h"|g' \ + -e 's|#include "logos_api_consumer.h"|#include "logos_api_consumer.h"|g' \ + "$file" + # ^^^ All above rewrites are for backward compatibility, may change later + fi + done + + # Install core headers (interface.h from provider/core/ goes to include/core/) + if [ -f src/provider/core/interface.h ]; then + cp src/provider/core/interface.h $out/include/core/ + # Fix the include path: ../../logos_api.h becomes ../cpp/logos_api.h + # NOTE: This rewrite is for backward compatibility and may be changed later + sed -i 's|#include "../../logos_api.h"|#include "../cpp/logos_api.h"|g' $out/include/core/interface.h + fi + + # Also copy logos_mode.h to root include for backward compatibility + if [ -f src/logos_mode.h ]; then + cp src/logos_mode.h $out/include/ fi runHook postInstall ''; } - diff --git a/nix/lib.nix b/nix/lib.nix index 6e4ea58..f66f971 100644 --- a/nix/lib.nix +++ b/nix/lib.nix @@ -17,7 +17,7 @@ pkgs.stdenv.mkDerivation { # Build SDK library mkdir -p build-sdk cd build-sdk - cmake ../cpp -GNinja $cmakeFlags + cmake ../src -GNinja $cmakeFlags ninja cd .. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..0e0ce45 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,93 @@ +cmake_minimum_required(VERSION 3.14) +project(LogosSDK) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_AUTOMOC ON) + +# Find Qt packages +find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core RemoteObjects) +find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core RemoteObjects) + +# Root sources (shared/common) +set(ROOT_SOURCES + logos_api.cpp + logos_api.h + token_manager.cpp + token_manager.h + logos_mode.h + plugin_registry.h +) + +# Client sources +set(CLIENT_SOURCES + client/logos_api_client.cpp + client/logos_api_client.h + client/logos_api_consumer.cpp + client/logos_api_consumer.h +) + +# Provider sources +set(PROVIDER_SOURCES + provider/logos_api_provider.cpp + provider/logos_api_provider.h + provider/module_proxy.cpp + provider/module_proxy.h +) + +# Create the SDK library as STATIC instead of SHARED +add_library(logos_sdk STATIC ${ROOT_SOURCES} ${CLIENT_SOURCES} ${PROVIDER_SOURCES}) + +# Link Qt libraries +target_link_libraries(logos_sdk PUBLIC Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::RemoteObjects) + +# Include directories +target_include_directories(logos_sdk PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/client + ${CMAKE_CURRENT_SOURCE_DIR}/provider + ${CMAKE_CURRENT_SOURCE_DIR}/provider/core +) + +# Set output directories for static library +set_target_properties(logos_sdk PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" +) + +# Install the library +install(TARGETS logos_sdk + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin +) + +# BACKWARD COMPATIBILITY: +# The installed include structure uses cpp/ and core/ directories to remain +# compatible with logos-module-builder and other downstream projects that +# expect the original layout. The internal source is organized differently +# (client/, provider/) but the installed output maintains the old paths. + +# Install all SDK headers into include/cpp/ +install(FILES + logos_api.h + token_manager.h + logos_mode.h + plugin_registry.h + client/logos_api_client.h + client/logos_api_consumer.h + provider/logos_api_provider.h + provider/module_proxy.h + DESTINATION include/cpp +) + +# Install core headers +install(FILES + provider/core/interface.h + DESTINATION include/core +) + +# Also copy logos_mode.h to root include for backward compatibility +install(FILES + logos_mode.h + DESTINATION include +) diff --git a/cpp/logos_api_client.cpp b/src/client/logos_api_client.cpp similarity index 72% rename from cpp/logos_api_client.cpp rename to src/client/logos_api_client.cpp index cee77a5..a44cbe5 100644 --- a/cpp/logos_api_client.cpp +++ b/src/client/logos_api_client.cpp @@ -1,10 +1,10 @@ #include "logos_api_client.h" #include "logos_api_consumer.h" -#include "token_manager.h" +#include "../token_manager.h" LogosAPIClient::LogosAPIClient(const QString& module_to_talk_to, const QString& origin_module, TokenManager* token_manager, QObject *parent) : QObject(parent) - , m_consumer(new LogosAPIConsumer(module_to_talk_to, origin_module, token_manager, this)) + , m_consumer(new LogosAPIConsumer(module_to_talk_to, origin_module, this)) , m_token_manager(token_manager) , m_origin_module(origin_module) { @@ -45,21 +45,10 @@ QVariant LogosAPIClient::invokeRemoteMethod(const QString& objectName, const QSt if (token.isEmpty() && objectName != "capability_module") { qDebug() << "LogosAPIClient: calling requestModule for" << objectName; - LogosAPIConsumer* packageManagerConsumer = new LogosAPIConsumer("capability_module", m_origin_module, m_token_manager, this); + LogosAPIConsumer* packageManagerConsumer = new LogosAPIConsumer("capability_module", m_origin_module, this); QString capabilityToken = getToken("capability_module"); QVariant result = packageManagerConsumer->invokeRemoteMethod(capabilityToken, "capability_module", "requestModule", QVariantList() << m_origin_module << objectName, timeout); - qDebug() << "================================================"; - qDebug() << "================================================"; - qDebug() << "================================================"; - qDebug() << "================================================"; - qDebug() << "================================================"; - qDebug() << "================================================"; qDebug() << "LogosAPIClient: requestModule result for" << objectName << ":" << result.toString(); - qDebug() << "================================================"; - qDebug() << "================================================"; - qDebug() << "================================================"; - qDebug() << "================================================"; - qDebug() << "================================================"; token = result.toString(); } @@ -150,30 +139,12 @@ TokenManager* LogosAPIClient::getTokenManager() const QString LogosAPIClient::getToken(const QString& module_name) { - qDebug() << "getoken: -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; - qDebug() << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; - // if (m_token_manager) { - qDebug() << "LogosAPIClient: printing keys"; - QList keys = m_token_manager->getTokenKeys(); - for (const QString& key : keys) { - qDebug() << "LogosAPIClient: Token key:" << key << "value:" << m_token_manager->getToken(key); - } - - QString token = m_token_manager->getToken(module_name); - if (!token.isEmpty()) { - qDebug() << "LogosAPIClient: Found token for module:" << module_name; - return token; - } else { - qDebug() << "LogosAPIClient: No token found for module:" << module_name; - } - // } else { - // qDebug() << "LogosAPIClient: No token manager found - using default AUTH_TOKEN"; - // } - - qDebug() << "LogosAPIClient: No stored token for module:" << module_name; - qDebug() << "-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; - - // TODO: this is breaking here for core_manager - // return AUTH_TOKEN; + QString token = m_token_manager->getToken(module_name); + if (!token.isEmpty()) { + qDebug() << "LogosAPIClient: Found token for module:" << module_name; + return token; + } + + qDebug() << "LogosAPIClient: No token found for module:" << module_name; return ""; } \ No newline at end of file diff --git a/cpp/logos_api_client.h b/src/client/logos_api_client.h similarity index 99% rename from cpp/logos_api_client.h rename to src/client/logos_api_client.h index a744bce..d4d9e82 100644 --- a/cpp/logos_api_client.h +++ b/src/client/logos_api_client.h @@ -8,7 +8,7 @@ #include #include -#include "logos_mode.h" +#include "../logos_mode.h" class LogosAPIConsumer; class TokenManager; diff --git a/cpp/logos_api_consumer.cpp b/src/client/logos_api_consumer.cpp similarity index 98% rename from cpp/logos_api_consumer.cpp rename to src/client/logos_api_consumer.cpp index 03d5b90..cc913d1 100644 --- a/cpp/logos_api_consumer.cpp +++ b/src/client/logos_api_consumer.cpp @@ -1,9 +1,8 @@ #include "logos_api_consumer.h" -#include "module_proxy.h" +#include "../provider/module_proxy.h" #include "logos_api_client.h" -#include "token_manager.h" -#include "logos_mode.h" -#include "plugin_registry.h" +#include "../logos_mode.h" +#include "../plugin_registry.h" #include #include #include @@ -13,12 +12,11 @@ #include #include -LogosAPIConsumer::LogosAPIConsumer(const QString& module_to_talk_to, const QString& origin_module, TokenManager* token_manager, QObject *parent) +LogosAPIConsumer::LogosAPIConsumer(const QString& module_to_talk_to, const QString& origin_module, QObject *parent) : QObject(parent) , m_node(nullptr) , m_registryUrl(QString("local:logos_%1").arg(module_to_talk_to)) , m_connected(false) - , m_token_manager(token_manager) { if (LogosModeConfig::isLocal()) { qDebug() << "LogosAPIConsumer: Using Local mode - skipping QRemoteObjectNode"; diff --git a/cpp/logos_api_consumer.h b/src/client/logos_api_consumer.h similarity index 95% rename from cpp/logos_api_consumer.h rename to src/client/logos_api_consumer.h index 77b5e8e..84f348a 100644 --- a/cpp/logos_api_consumer.h +++ b/src/client/logos_api_consumer.h @@ -9,10 +9,9 @@ #include #include -#include "logos_mode.h" +#include "../logos_mode.h" class QRemoteObjectNode; -class TokenManager; /** * @brief LogosAPIConsumer handles connecting to remote objects and invoking their methods @@ -32,10 +31,9 @@ class LogosAPIConsumer : public QObject * @brief Construct a new LogosAPIConsumer * @param module_to_talk_to The name of the module to connect to * @param origin_module The name of the originating module - * @param token_manager Pointer to the token manager instance * @param parent Parent QObject */ - explicit LogosAPIConsumer(const QString& module_to_talk_to, const QString& origin_module, TokenManager* token_manager, QObject *parent = nullptr); + explicit LogosAPIConsumer(const QString& module_to_talk_to, const QString& origin_module, QObject *parent = nullptr); /** * @brief Destructor - cleans up connections and resources @@ -122,7 +120,6 @@ public slots: QString m_registryUrl; bool m_connected; QMap m_tokens; - TokenManager* m_token_manager; // Store callbacks by event name QHash>> m_eventCallbacks; diff --git a/cpp/compile.sh b/src/compile.sh similarity index 67% rename from cpp/compile.sh rename to src/compile.sh index e7e5a72..fd8d3ed 100755 --- a/cpp/compile.sh +++ b/src/compile.sh @@ -45,7 +45,11 @@ else QT_INCLUDES="-I$QT_PATH/include -I$QT_PATH/include/QtCore -I$QT_PATH/include/QtRemoteObjects" fi +# Add local include paths for the new directory structure +LOCAL_INCLUDES="-I. -Iclient -Iprovider -Iprovider/core" + echo "Using Qt includes: $QT_INCLUDES" +echo "Using local includes: $LOCAL_INCLUDES" # Compiler flags CXXFLAGS="-std=c++17 -fPIC" @@ -53,20 +57,31 @@ CXXFLAGS="-std=c++17 -fPIC" # Generate MOC files for headers with Q_OBJECT echo "Generating MOC files..." -# List of headers that need MOC processing (contain Q_OBJECT) -MOC_HEADERS=( +# Root headers that need MOC processing +ROOT_MOC_HEADERS=( "logos_api.h" - "logos_api_client.h" - "logos_api_provider.h" - "logos_api_consumer.h" - "module_proxy.h" "token_manager.h" ) -for header in "${MOC_HEADERS[@]}"; do +# Client headers that need MOC processing +CLIENT_MOC_HEADERS=( + "client/logos_api_client.h" + "client/logos_api_consumer.h" +) + +# Provider headers that need MOC processing +PROVIDER_MOC_HEADERS=( + "provider/logos_api_provider.h" + "provider/module_proxy.h" +) + +ALL_MOC_HEADERS=("${ROOT_MOC_HEADERS[@]}" "${CLIENT_MOC_HEADERS[@]}" "${PROVIDER_MOC_HEADERS[@]}") + +for header in "${ALL_MOC_HEADERS[@]}"; do if [ -f "$header" ]; then + basename=$(basename "$header" .h) echo "Generating MOC for $header..." - $MOC_BIN $header -o "moc_${header%.h}.cpp" + $MOC_BIN $LOCAL_INCLUDES $header -o "moc_${basename}.cpp" if [ $? -ne 0 ]; then echo "❌ MOC generation failed for $header" exit 1 @@ -77,7 +92,8 @@ done # Try to compile the headers (syntax check) echo "Checking header syntax..." -g++ $CXXFLAGS $QT_INCLUDES -c -x c++-header logos_api.h -o /tmp/logos_api.h.gch +# Root headers +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c -x c++-header logos_api.h -o /tmp/logos_api.h.gch if [ $? -eq 0 ]; then echo "✅ LogosAPI header syntax OK" rm -f /tmp/logos_api.h.gch @@ -86,25 +102,26 @@ else exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c -x c++-header logos_api_client.h -o /tmp/logos_api_client.h.gch +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c -x c++-header token_manager.h -o /tmp/token_manager.h.gch if [ $? -eq 0 ]; then - echo "✅ Client header syntax OK" - rm -f /tmp/logos_api_client.h.gch + echo "✅ Token manager header syntax OK" + rm -f /tmp/token_manager.h.gch else - echo "❌ Client header has syntax errors" + echo "❌ Token manager header has syntax errors" exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c -x c++-header logos_api_provider.h -o /tmp/logos_api_provider.h.gch +# Client headers +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c -x c++-header client/logos_api_client.h -o /tmp/logos_api_client.h.gch if [ $? -eq 0 ]; then - echo "✅ Provider header syntax OK" - rm -f /tmp/logos_api_provider.h.gch + echo "✅ Client header syntax OK" + rm -f /tmp/logos_api_client.h.gch else - echo "❌ Provider header has syntax errors" + echo "❌ Client header has syntax errors" exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c -x c++-header logos_api_consumer.h -o /tmp/logos_api_consumer.h.gch +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c -x c++-header client/logos_api_consumer.h -o /tmp/logos_api_consumer.h.gch if [ $? -eq 0 ]; then echo "✅ Consumer header syntax OK" rm -f /tmp/logos_api_consumer.h.gch @@ -113,28 +130,30 @@ else exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c -x c++-header module_proxy.h -o /tmp/module_proxy.h.gch +# Provider headers +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c -x c++-header provider/logos_api_provider.h -o /tmp/logos_api_provider.h.gch if [ $? -eq 0 ]; then - echo "✅ Module proxy header syntax OK" - rm -f /tmp/module_proxy.h.gch + echo "✅ Provider header syntax OK" + rm -f /tmp/logos_api_provider.h.gch else - echo "❌ Module proxy header has syntax errors" + echo "❌ Provider header has syntax errors" exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c -x c++-header token_manager.h -o /tmp/token_manager.h.gch +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c -x c++-header provider/module_proxy.h -o /tmp/module_proxy.h.gch if [ $? -eq 0 ]; then - echo "✅ Token manager header syntax OK" - rm -f /tmp/token_manager.h.gch + echo "✅ Module proxy header syntax OK" + rm -f /tmp/module_proxy.h.gch else - echo "❌ Token manager header has syntax errors" + echo "❌ Module proxy header has syntax errors" exit 1 fi # Try to compile the implementations (without linking) echo "Checking implementation syntax..." -g++ $CXXFLAGS $QT_INCLUDES -c logos_api.cpp -o /tmp/logos_api.o +# Root implementations +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c logos_api.cpp -o /tmp/logos_api.o if [ $? -eq 0 ]; then echo "✅ LogosAPI implementation compiles OK" rm -f /tmp/logos_api.o @@ -143,25 +162,26 @@ else exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c logos_api_client.cpp -o /tmp/logos_api_client.o +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c token_manager.cpp -o /tmp/token_manager.o if [ $? -eq 0 ]; then - echo "✅ Client implementation compiles OK" - rm -f /tmp/logos_api_client.o + echo "✅ Token manager implementation compiles OK" + rm -f /tmp/token_manager.o else - echo "❌ Client implementation has compilation errors" + echo "❌ Token manager implementation has compilation errors" exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c logos_api_provider.cpp -o /tmp/logos_api_provider.o +# Client implementations +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c client/logos_api_client.cpp -o /tmp/logos_api_client.o if [ $? -eq 0 ]; then - echo "✅ Provider implementation compiles OK" - rm -f /tmp/logos_api_provider.o + echo "✅ Client implementation compiles OK" + rm -f /tmp/logos_api_client.o else - echo "❌ Provider implementation has compilation errors" + echo "❌ Client implementation has compilation errors" exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c logos_api_consumer.cpp -o /tmp/logos_api_consumer.o +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c client/logos_api_consumer.cpp -o /tmp/logos_api_consumer.o if [ $? -eq 0 ]; then echo "✅ Consumer implementation compiles OK" rm -f /tmp/logos_api_consumer.o @@ -170,31 +190,33 @@ else exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c module_proxy.cpp -o /tmp/module_proxy.o +# Provider implementations +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c provider/logos_api_provider.cpp -o /tmp/logos_api_provider.o if [ $? -eq 0 ]; then - echo "✅ Module proxy implementation compiles OK" - rm -f /tmp/module_proxy.o + echo "✅ Provider implementation compiles OK" + rm -f /tmp/logos_api_provider.o else - echo "❌ Module proxy implementation has compilation errors" + echo "❌ Provider implementation has compilation errors" exit 1 fi -g++ $CXXFLAGS $QT_INCLUDES -c token_manager.cpp -o /tmp/token_manager.o +g++ $CXXFLAGS $QT_INCLUDES $LOCAL_INCLUDES -c provider/module_proxy.cpp -o /tmp/module_proxy.o if [ $? -eq 0 ]; then - echo "✅ Token manager implementation compiles OK" - rm -f /tmp/token_manager.o + echo "✅ Module proxy implementation compiles OK" + rm -f /tmp/module_proxy.o else - echo "❌ Token manager implementation has compilation errors" + echo "❌ Module proxy implementation has compilation errors" exit 1 fi # Clean up generated MOC files echo "Cleaning up generated MOC files..." -for header in "${MOC_HEADERS[@]}"; do - moc_file="moc_${header%.h}.cpp" +for header in "${ALL_MOC_HEADERS[@]}"; do + basename=$(basename "$header" .h) + moc_file="moc_${basename}.cpp" if [ -f "$moc_file" ]; then rm -f "$moc_file" fi done -echo "🎉 LogosAPI compilation test passed for all components!" \ No newline at end of file +echo "🎉 LogosAPI compilation test passed for all components!" diff --git a/cpp/logos_api.cpp b/src/logos_api.cpp similarity index 94% rename from cpp/logos_api.cpp rename to src/logos_api.cpp index aae10d7..81c5148 100644 --- a/cpp/logos_api.cpp +++ b/src/logos_api.cpp @@ -1,6 +1,6 @@ #include "logos_api.h" -#include "logos_api_client.h" -#include "logos_api_provider.h" +#include "client/logos_api_client.h" +#include "provider/logos_api_provider.h" #include "token_manager.h" LogosAPI::LogosAPI(const QString& module_name, QObject *parent) diff --git a/cpp/logos_api.h b/src/logos_api.h similarity index 100% rename from cpp/logos_api.h rename to src/logos_api.h diff --git a/cpp/logos_mode.h b/src/logos_mode.h similarity index 100% rename from cpp/logos_mode.h rename to src/logos_mode.h diff --git a/cpp/plugin_registry.h b/src/plugin_registry.h similarity index 100% rename from cpp/plugin_registry.h rename to src/plugin_registry.h diff --git a/core/interface.h b/src/provider/core/interface.h similarity index 96% rename from core/interface.h rename to src/provider/core/interface.h index 8b30e27..9a4e775 100644 --- a/core/interface.h +++ b/src/provider/core/interface.h @@ -3,7 +3,7 @@ #include #include -#include "../cpp/logos_api.h" +#include "../../logos_api.h" // Define the common base interface for all modules class PluginInterface diff --git a/cpp/logos_api_provider.cpp b/src/provider/logos_api_provider.cpp similarity index 98% rename from cpp/logos_api_provider.cpp rename to src/provider/logos_api_provider.cpp index 0f90e62..491694b 100644 --- a/cpp/logos_api_provider.cpp +++ b/src/provider/logos_api_provider.cpp @@ -1,8 +1,8 @@ #include "logos_api_provider.h" #include "module_proxy.h" -#include "logos_api.h" -#include "logos_mode.h" -#include "plugin_registry.h" +#include "../logos_api.h" +#include "../logos_mode.h" +#include "../plugin_registry.h" #include #include #include diff --git a/cpp/logos_api_provider.h b/src/provider/logos_api_provider.h similarity index 98% rename from cpp/logos_api_provider.h rename to src/provider/logos_api_provider.h index 5319851..738cf75 100644 --- a/cpp/logos_api_provider.h +++ b/src/provider/logos_api_provider.h @@ -10,7 +10,7 @@ class QRemoteObjectRegistryHost; class ModuleProxy; -#include "logos_mode.h" +#include "../logos_mode.h" /** * @brief LogosAPIProvider handles registering objects for remote access diff --git a/cpp/module_proxy.cpp b/src/provider/module_proxy.cpp similarity index 87% rename from cpp/module_proxy.cpp rename to src/provider/module_proxy.cpp index c0ba4ec..f2642d2 100644 --- a/cpp/module_proxy.cpp +++ b/src/provider/module_proxy.cpp @@ -6,7 +6,7 @@ #include #include #include -#include "../core/interface.h" +#include "core/interface.h" #include "logos_api.h" #include "token_manager.h" @@ -119,7 +119,6 @@ namespace { return false; } } else if (strcmp(returnTypeName, "bool") == 0) { - qDebug() << "ModuleProxy: invokeMethodByArgCount - bool case with" << args.size() << "arguments"; INVOKE_METHOD_WITH_RETURN(bool, bool); } else if (strcmp(returnTypeName, "int") == 0) { INVOKE_METHOD_WITH_RETURN(int, int); @@ -219,12 +218,6 @@ QVariant ModuleProxy::callRemoteMethod(const QString& authToken, const QString& return false; } - // print keys vand values for debug purposes - QList keys = tokenManager->getTokenKeys(); - for (const QString& key : keys) { - qDebug() << "ModuleProxy: Token key:" << key << "value:" << tokenManager->getToken(key); - } - // check if authToken is valid if (authToken.isEmpty()) { qWarning() << "ModuleProxy: Auth token is empty"; @@ -233,13 +226,8 @@ QVariant ModuleProxy::callRemoteMethod(const QString& authToken, const QString& // check if authToken is stored in tokenManager if (!tokenManager->getToken(authToken).isEmpty()) { - qDebug() << "ERROR: ===================== getToken(authToken) is INVALID ====================="; qWarning() << "ModuleProxy: Auth token not found in stored tokens"; - qDebug() << "ERROR: ===================== getToken(authToken) is INVALID ====================="; - return QVariant(); - } else { - qDebug() << "VALID: ===================== getToken(authToken) is VALID ====================="; } // Each createArgument() call now generates its own unique GUID @@ -248,21 +236,11 @@ QVariant ModuleProxy::callRemoteMethod(const QString& authToken, const QString& const QMetaObject* metaObject = m_module->metaObject(); int methodIndex = -1; - qDebug() << "ModuleProxy: Looking for method" << methodName << "with" << args.size() << "arguments"; - qDebug() << "ModuleProxy: Available methods in" << metaObject->className() << ":"; - - // Debug: List all available methods - for (int i = 0; i < metaObject->methodCount(); ++i) { - QMetaMethod method = metaObject->method(i); - qDebug() << " Method" << i << ":" << method.name() << "with" << method.parameterCount() << "parameters, return type:" << method.returnMetaType().name(); - } - // Find the method with matching name and argument count for (int i = 0; i < metaObject->methodCount(); ++i) { QMetaMethod method = metaObject->method(i); if (method.name() == methodName && method.parameterCount() == args.size()) { methodIndex = i; - qDebug() << "ModuleProxy: Found matching method at index" << i; break; } } @@ -275,12 +253,6 @@ QVariant ModuleProxy::callRemoteMethod(const QString& authToken, const QString& QMetaMethod method = metaObject->method(methodIndex); QMetaType returnType = method.returnMetaType(); - qDebug() << "ModuleProxy: Method signature:" << method.methodSignature(); - qDebug() << "ModuleProxy: Parameter types:"; - for (int i = 0; i < method.parameterCount(); ++i) { - qDebug() << " Param" << i << ":" << method.parameterMetaType(i).name(); - } - // Handle different return types bool success = false; QVariant result; @@ -293,10 +265,8 @@ QVariant ModuleProxy::callRemoteMethod(const QString& authToken, const QString& } } else if (returnType == QMetaType::fromType()) { // Bool return type - qDebug() << "ModuleProxy: Invoking bool method" << methodName; bool boolResult = false; success = invokeMethodByArgCount(m_module, methodName, args, &boolResult, "bool"); - qDebug() << "ModuleProxy: Bool method invocation result:" << success << "value:" << boolResult; if (success) { result = QVariant(boolResult); } @@ -323,19 +293,15 @@ QVariant ModuleProxy::callRemoteMethod(const QString& authToken, const QString& } } else if (returnType == QMetaType::fromType()) { // QJsonArray return type - qDebug() << "ModuleProxy: Invoking QJsonArray method" << methodName; QJsonArray jsonArrayResult; success = invokeMethodByArgCount(m_module, methodName, args, &jsonArrayResult, "QJsonArray"); - qDebug() << "ModuleProxy: QJsonArray method invocation result:" << success << "array size:" << jsonArrayResult.size(); if (success) { result = QVariant(jsonArrayResult); } } else if (returnType == QMetaType::fromType()) { // QStringList return type - qDebug() << "ModuleProxy: Invoking QStringList method" << methodName; QStringList stringListResult; success = invokeMethodByArgCount(m_module, methodName, args, &stringListResult, "QStringList"); - qDebug() << "ModuleProxy: QStringList method invocation result:" << success << "list size:" << stringListResult.size(); if (success) { result = QVariant(stringListResult); } diff --git a/cpp/module_proxy.h b/src/provider/module_proxy.h similarity index 100% rename from cpp/module_proxy.h rename to src/provider/module_proxy.h diff --git a/cpp/token_manager.cpp b/src/token_manager.cpp similarity index 100% rename from cpp/token_manager.cpp rename to src/token_manager.cpp diff --git a/cpp/token_manager.h b/src/token_manager.h similarity index 100% rename from cpp/token_manager.h rename to src/token_manager.h