This commit is contained in:
2026-06-16 03:46:02 +05:30
parent dbc9abae6c
commit 3456b2b3f1
10 changed files with 101 additions and 3 deletions
@@ -623,6 +623,14 @@ void Controller::shutdown()
dataStore.shutdown(); dataStore.shutdown();
} }
/*
Function: registerEvents
Description: Registers menu event handles with the authentication
service.
Parameter: HANDLE accountDisabledEvent - account disabled event handle
HANDLE notificationAvailableEvent - notification event handle
Return type: void
*/
void Controller::registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent) void Controller::registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent)
{ {
m_authenticationManagementService.registerEvents(accountDisabledEvent, notificationAvailableEvent); m_authenticationManagementService.registerEvents(accountDisabledEvent, notificationAvailableEvent);
@@ -117,6 +117,14 @@ void AuthenticationManagementService::changePassword(const std::string& newPassw
m_dataStore.saveUsers(); m_dataStore.saveUsers();
} }
/*
Function: registerEvents
Description: Registers menu event handles used to notify the active
menu of account disable and notification events.
Parameter: HANDLE accountDisabledEvent - account disabled event handle
HANDLE notificationAvailableEvent - notification event handle
Return type: void
*/
void AuthenticationManagementService::registerEvents(HANDLE accountDisabledEvent, HANDLE notifictionAvailableEvent) void AuthenticationManagementService::registerEvents(HANDLE accountDisabledEvent, HANDLE notifictionAvailableEvent)
{ {
m_accountDisabledEvent = accountDisabledEvent; m_accountDisabledEvent = accountDisabledEvent;
@@ -153,6 +153,13 @@ bool AdminMenu::handleOperation(int choice)
return true; return true;
} }
/*
Function: handleNotificationEvent
Description: Retrieves and displays the latest notification for the
currently logged in admin.
Parameter: None
Return type: void
*/
void AdminMenu::handleNotificationEvent() void AdminMenu::handleNotificationEvent()
{ {
auto notifications = m_controller.getNotifications(); auto notifications = m_controller.getNotifications();
@@ -11,7 +11,7 @@ Date:19-May-2026
#include "Controller.h" #include "Controller.h"
#include "Menu.h" #include "Menu.h"
class AdminMenu : Menu class AdminMenu : public Menu
{ {
private: private:
bool handleOperation(int choice); bool handleOperation(int choice);
@@ -124,6 +124,13 @@ bool CustomerMenu::handleOperation(int choice)
return true; return true;
} }
/*
Function: handleNotificationEvent
Description: Retrieves and displays the latest notification for the
currently logged in admin.
Parameter: None
Return type: void
*/
void CustomerMenu::handleNotificationEvent() void CustomerMenu::handleNotificationEvent()
{ {
auto notifications = m_controller.getNotifications(); auto notifications = m_controller.getNotifications();
@@ -12,7 +12,7 @@ Date:19-May-2026
#include "Menu.h" #include "Menu.h"
#include "Controller.h" #include "Controller.h"
class CustomerMenu : Menu class CustomerMenu : public Menu
{ {
private: private:
bool handleOperation(int choice); bool handleOperation(int choice);
@@ -1,5 +1,21 @@
/*
File: Menu.cpp
Description: Implementation file containing common menu event listener
functionality, account disable handling, and notification
event dispatching for all menu types.
Author: Trenser
Date:16-Jun-2026
*/
#include "Menu.h" #include "Menu.h"
/*
Function: Menu
Description: Constructs a Menu object and initializes event handles
and menu state.
Parameter: None
Return type: None
*/
Menu::Menu() Menu::Menu()
: :
m_isMenuActive(false), m_isMenuActive(false),
@@ -7,11 +23,26 @@ Menu::Menu()
m_notificationAvailableEvent(NULL), m_notificationAvailableEvent(NULL),
m_shutdownEvent(NULL) {} m_shutdownEvent(NULL) {}
/*
Function: ~Menu
Description: Destroys the Menu object and performs event listener
cleanup.
Parameter: None
Return type: None
*/
Menu::~Menu() Menu::~Menu()
{ {
stopEventListener(); stopEventListener();
} }
/*
Function: startEventListener
Description: Creates menu event handles, registers them with the
authentication service, and starts the event listener
thread.
Parameter: None
Return type: void
*/
void Menu::startEventListener() void Menu::startEventListener()
{ {
if (m_isMenuActive.load()) if (m_isMenuActive.load())
@@ -26,6 +57,14 @@ void Menu::startEventListener()
m_eventListenerThread = std::thread(&Menu::eventListenerLoop, this); m_eventListenerThread = std::thread(&Menu::eventListenerLoop, this);
} }
/*
Function: eventListenerLoop
Description: Waits for account disabled, notification available,
and shutdown events and dispatches them to the
appropriate handlers.
Parameter: None
Return type: void
*/
void Menu::eventListenerLoop() void Menu::eventListenerLoop()
{ {
HANDLE handles[3]; HANDLE handles[3];
@@ -49,6 +88,13 @@ void Menu::eventListenerLoop()
} }
} }
/*
Function: stopEventListener
Description: Stops the event listener thread and releases all
associated event handles.
Parameter: None
Return type: void
*/
void Menu::stopEventListener() void Menu::stopEventListener()
{ {
m_isMenuActive.store(false); m_isMenuActive.store(false);
@@ -77,6 +123,13 @@ void Menu::stopEventListener()
m_shutdownEvent = NULL; m_shutdownEvent = NULL;
} }
/*
Function: handleAccountDisabledEvent
Description: Handles an account disabled event by marking the menu
inactive and notifying the user.
Parameter: None
Return type: void
*/
void Menu::handleAccountDisabledEvent() void Menu::handleAccountDisabledEvent()
{ {
m_isMenuActive.store(false); m_isMenuActive.store(false);
@@ -1409,6 +1409,14 @@ inline std::string selectComboPackage(util::Map<std::string, const ComboPackage*
} }
} }
/*
Function: displayNewNotification
Description: Displays the most recent notification from the supplied
notification collection.
Parameter: util::Vector<const Notification*> notifications -
collection of notifications
Return type: void
*/
inline void displayNewNotification(util::Vector<const Notification*> notifications) inline void displayNewNotification(util::Vector<const Notification*> notifications)
{ {
const Notification* notification = nullptr; const Notification* notification = nullptr;
@@ -99,6 +99,13 @@ bool TechnicianMenu::handleOperation(int choice)
return true; return true;
} }
/*
Function: handleNotificationEvent
Description: Retrieves and displays the latest notification for the
currently logged in admin.
Parameter: None
Return type: void
*/
void TechnicianMenu::handleNotificationEvent() void TechnicianMenu::handleNotificationEvent()
{ {
auto notifications = m_controller.getNotifications(); auto notifications = m_controller.getNotifications();
@@ -11,7 +11,7 @@ Date:19-May-2026
#include "Controller.h" #include "Controller.h"
#include "Menu.h" #include "Menu.h"
class TechnicianMenu : Menu class TechnicianMenu : public Menu
{ {
private: private:
bool handleOperation(int choice); bool handleOperation(int choice);