From 99ebb07d5cd4e9f2ff7f64f0c2e581d52add4883 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Thu, 20 Jan 2022 10:48:57 -0400 Subject: [PATCH] feat: add empty main module --- src-cpp/app/CMakeLists.txt | 6 ++- src-cpp/app/boot/app_controller.cpp | 23 +++++----- .../app/{include => boot}/app_controller.h | 5 +- .../app_controller_delegate.h | 5 ++ src-cpp/app/modules/main/controller.cpp | 18 ++++++++ src-cpp/app/modules/main/controller.h | 24 ++++++++++ .../app/modules/main/controller_interface.h | 21 +++++++++ .../module_controller_delegate_interface.h | 17 +++++++ .../module_view_delegate_interface.h | 18 ++++++++ src-cpp/app/modules/main/module.cpp | 46 +++++++++++++++++++ src-cpp/app/modules/main/module.h | 32 +++++++++++++ .../modules/main/module_access_interface.h | 18 ++++++++ src-cpp/app/modules/main/view.cpp | 23 ++++++++++ src-cpp/app/modules/main/view.h | 23 ++++++++++ 14 files changed, 265 insertions(+), 14 deletions(-) rename src-cpp/app/{include => boot}/app_controller.h (83%) rename src-cpp/app/{include => boot}/app_controller_delegate.h (74%) create mode 100644 src-cpp/app/modules/main/controller.cpp create mode 100644 src-cpp/app/modules/main/controller.h create mode 100644 src-cpp/app/modules/main/controller_interface.h create mode 100644 src-cpp/app/modules/main/interfaces/module_controller_delegate_interface.h create mode 100644 src-cpp/app/modules/main/interfaces/module_view_delegate_interface.h create mode 100644 src-cpp/app/modules/main/module.cpp create mode 100644 src-cpp/app/modules/main/module.h create mode 100644 src-cpp/app/modules/main/module_access_interface.h create mode 100644 src-cpp/app/modules/main/view.cpp create mode 100644 src-cpp/app/modules/main/view.h diff --git a/src-cpp/app/CMakeLists.txt b/src-cpp/app/CMakeLists.txt index 7288aa09ee..74977c0c98 100644 --- a/src-cpp/app/CMakeLists.txt +++ b/src-cpp/app/CMakeLists.txt @@ -17,12 +17,16 @@ add_library(app modules/startup/login/module.cpp modules/startup/login/view.cpp modules/startup/login/selected_account.cpp - + modules/main/controller.cpp + modules/main/module.cpp + modules/main/view.cpp ) target_include_directories(app PUBLIC ./include/ + ./boot/ + ./modules/main ./modules/startup ) diff --git a/src-cpp/app/boot/app_controller.cpp b/src-cpp/app/boot/app_controller.cpp index 9f29bfd2c2..2c951b4b6b 100644 --- a/src-cpp/app/boot/app_controller.cpp +++ b/src-cpp/app/boot/app_controller.cpp @@ -2,6 +2,7 @@ #include "accounts/service.h" #include "app_service.h" #include "modules/startup/module.h" +#include "modules/main/module.h" #include AppController::AppController() @@ -65,8 +66,7 @@ AppController::AppController() // # Modules m_startupModule = new Modules::Startup::Module(this, /*keychainService,*/ m_accountsService); - // result.mainModule = main_module.newModule[AppController]( - // result, + m_mainModule = new Modules::Main::Module(this // statusFoundation.status.events, // result.keychainService, // result.accountsService, @@ -93,7 +93,7 @@ AppController::AppController() // result.nodeConfigurationService, // result.devicesService, // result.mailserversService - // ) + ); // # Do connections connect(); @@ -102,6 +102,7 @@ AppController::AppController() AppController::~AppController() { delete m_startupModule; + delete m_mainModule; delete m_accountsService; } @@ -172,14 +173,14 @@ void AppController::load() // self.buildAndRegisterUserProfile() // # load main module - // self.mainModule.load( - // self.statusFoundation.status.events, - // self.settingsService, - // self.contactsService, - // self.chatService, - // self.communityService, - // self.messageService - // ) + m_mainModule->load( + // self.statusFoundation.status.events, + // self.settingsService, + // self.contactsService, + // self.chatService, + // self.communityService, + // self.messageService + ); } void AppController::userLoggedIn() diff --git a/src-cpp/app/include/app_controller.h b/src-cpp/app/boot/app_controller.h similarity index 83% rename from src-cpp/app/include/app_controller.h rename to src-cpp/app/boot/app_controller.h index 6759c936e6..56f0115e67 100644 --- a/src-cpp/app/include/app_controller.h +++ b/src-cpp/app/boot/app_controller.h @@ -1,7 +1,8 @@ #pragma once #include "accounts/service.h" -#include "module_access_interface.h" +#include "../modules/main/module_access_interface.h" +#include "../modules/startup/module_access_interface.h" #include "app_controller_delegate.h" #include "app_service.h" @@ -21,7 +22,7 @@ class AppController : public AppControllerDelegate // Modules Modules::Startup::ModuleAccessInterface* m_startupModule; - //mainModule: main_module.AccessInterface + Modules::Main::ModuleAccessInterface* m_mainModule; public: AppController(); diff --git a/src-cpp/app/include/app_controller_delegate.h b/src-cpp/app/boot/app_controller_delegate.h similarity index 74% rename from src-cpp/app/include/app_controller_delegate.h rename to src-cpp/app/boot/app_controller_delegate.h index 03d54dc700..eff5a52986 100644 --- a/src-cpp/app/include/app_controller_delegate.h +++ b/src-cpp/app/boot/app_controller_delegate.h @@ -10,6 +10,11 @@ public: throw std::domain_error("Not implemented"); } + virtual void mainDidLoad() + { + throw std::domain_error("Not implemented"); + } + virtual void userLoggedIn() { throw std::domain_error("Not implemented"); diff --git a/src-cpp/app/modules/main/controller.cpp b/src-cpp/app/modules/main/controller.cpp new file mode 100644 index 0000000000..47a53add1a --- /dev/null +++ b/src-cpp/app/modules/main/controller.cpp @@ -0,0 +1,18 @@ +#include "controller.h" +#include "accounts/service_interface.h" +#include "interfaces/module_controller_delegate_interface.h" +#include + +namespace Modules +{ +namespace Main +{ +Controller::Controller(ModuleControllerDelegateInterface* d, QObject* parent) + : QObject(parent) + , m_delegate(d) +{ } + +void Controller::init() { } + +} // namespace Main +} // namespace Modules \ No newline at end of file diff --git a/src-cpp/app/modules/main/controller.h b/src-cpp/app/modules/main/controller.h new file mode 100644 index 0000000000..00f1bf13e9 --- /dev/null +++ b/src-cpp/app/modules/main/controller.h @@ -0,0 +1,24 @@ +#pragma once + +#include "controller_interface.h" +#include "interfaces/module_controller_delegate_interface.h" +#include "signals.h" +#include + +namespace Modules +{ +namespace Main +{ + +class Controller : public QObject, ControllerInterface +{ +public: + Controller(ModuleControllerDelegateInterface* d, QObject* parent = nullptr); + void init() override; + +private: + ModuleControllerDelegateInterface* m_delegate; +}; + +} // namespace Main +} // namespace Modules \ No newline at end of file diff --git a/src-cpp/app/modules/main/controller_interface.h b/src-cpp/app/modules/main/controller_interface.h new file mode 100644 index 0000000000..86de8b2019 --- /dev/null +++ b/src-cpp/app/modules/main/controller_interface.h @@ -0,0 +1,21 @@ +#pragma once + +#include + +namespace Modules +{ +namespace Main +{ + +// Abstract class for any input/interaction with this module. + +class ControllerInterface +{ +public: + virtual void init() + { + throw std::domain_error("Not implemented"); + } +}; +} // namespace Main +} // namespace Modules \ No newline at end of file diff --git a/src-cpp/app/modules/main/interfaces/module_controller_delegate_interface.h b/src-cpp/app/modules/main/interfaces/module_controller_delegate_interface.h new file mode 100644 index 0000000000..23547cc56a --- /dev/null +++ b/src-cpp/app/modules/main/interfaces/module_controller_delegate_interface.h @@ -0,0 +1,17 @@ +#pragma once + +#include "accounts/service_interface.h" +#include "app_controller_delegate.h" +#include "controller.h" +#include + +namespace Modules +{ +namespace Main +{ +class ModuleControllerDelegateInterface +{ +public: +}; +}; // namespace Main +}; // namespace Modules \ No newline at end of file diff --git a/src-cpp/app/modules/main/interfaces/module_view_delegate_interface.h b/src-cpp/app/modules/main/interfaces/module_view_delegate_interface.h new file mode 100644 index 0000000000..d29f50f02f --- /dev/null +++ b/src-cpp/app/modules/main/interfaces/module_view_delegate_interface.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace Modules +{ +namespace Main +{ +class ModuleViewDelegateInterface +{ +public: + virtual void viewDidLoad() + { + throw std::domain_error("Not implemented"); + } +}; +}; // namespace Main +}; // namespace Modules \ No newline at end of file diff --git a/src-cpp/app/modules/main/module.cpp b/src-cpp/app/modules/main/module.cpp new file mode 100644 index 0000000000..239f292a89 --- /dev/null +++ b/src-cpp/app/modules/main/module.cpp @@ -0,0 +1,46 @@ +#include "module.h" +#include "controller.h" +#include "singleton.h" +#include "view.h" +#include +#include +#include +#include + +namespace Modules +{ +namespace Main +{ +Module::Module(AppControllerDelegate* d) + +{ + m_delegate = d; + m_controller = new Controller(this); + m_view = new View(this); +} + +Module::~Module() +{ + delete m_controller; + delete m_view; +} + +void Module::load() +{ + Global::Singleton::instance()->engine()->rootContext()->setContextProperty("mainModule", m_view); + m_controller->init(); + m_view->load(); +} + +void Module::checkIfModuleDidLoad() +{ + m_delegate->mainDidLoad(); +} + +void Module::viewDidLoad() +{ + Module::checkIfModuleDidLoad(); +} + +} // namespace Main +} // namespace Modules \ No newline at end of file diff --git a/src-cpp/app/modules/main/module.h b/src-cpp/app/modules/main/module.h new file mode 100644 index 0000000000..2aa12c1bb2 --- /dev/null +++ b/src-cpp/app/modules/main/module.h @@ -0,0 +1,32 @@ +#pragma once + +#include "app_controller_delegate.h" +#include "controller.h" +#include "interfaces/module_controller_delegate_interface.h" +#include "interfaces/module_view_delegate_interface.h" +#include "login/module_access_interface.h" +#include "module_access_interface.h" +#include "onboarding/module_access_interface.h" +#include "view.h" +#include + +namespace Modules +{ +namespace Main +{ +class Module : public ModuleAccessInterface, ModuleControllerDelegateInterface, ModuleViewDelegateInterface +{ +private: + AppControllerDelegate* m_delegate; + View* m_view; + Controller* m_controller; + +public: + Module(AppControllerDelegate* d); + ~Module(); + void load() override; + void checkIfModuleDidLoad(); + void viewDidLoad() override; +}; +}; // namespace Main +}; // namespace Modules \ No newline at end of file diff --git a/src-cpp/app/modules/main/module_access_interface.h b/src-cpp/app/modules/main/module_access_interface.h new file mode 100644 index 0000000000..9325187312 --- /dev/null +++ b/src-cpp/app/modules/main/module_access_interface.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +namespace Modules +{ +namespace Main +{ +class ModuleAccessInterface +{ +public: + virtual void load() + { + throw std::domain_error("Not implemented"); + } +}; +}; // namespace Main +}; // namespace Modules diff --git a/src-cpp/app/modules/main/view.cpp b/src-cpp/app/modules/main/view.cpp new file mode 100644 index 0000000000..2aeeaf8a99 --- /dev/null +++ b/src-cpp/app/modules/main/view.cpp @@ -0,0 +1,23 @@ +#include "view.h" +#include "interfaces/module_view_delegate_interface.h" +#include + +namespace Modules +{ +namespace Main +{ + +View::View(ModuleViewDelegateInterface* d, QObject* parent) + : QObject(parent) +{ + m_delegate = d; +} + +void View::load() +{ + // In some point, here, we will setup some exposed main module related things. + m_delegate->viewDidLoad(); +} + +} // namespace Main +} // namespace Modules \ No newline at end of file diff --git a/src-cpp/app/modules/main/view.h b/src-cpp/app/modules/main/view.h new file mode 100644 index 0000000000..0c6f8c286b --- /dev/null +++ b/src-cpp/app/modules/main/view.h @@ -0,0 +1,23 @@ +#pragma once + +#include "interfaces/module_view_delegate_interface.h" +#include + +namespace Modules +{ +namespace Main +{ + +class View : public QObject +{ + Q_OBJECT + +public: + explicit View(ModuleViewDelegateInterface* d, QObject* parent = nullptr); + void load(); + +private: + ModuleViewDelegateInterface* m_delegate; +}; +} // namespace Main +} // namespace Modules \ No newline at end of file