Some more renaming SGS -> SGSXL

feature/AudioLoginLogoff
Geoffrey Merck 6 years ago
parent ce5b29c791
commit 576b151f84

@ -38,45 +38,45 @@ std::string CGroupHandler::m_gateway;
std::list<CGroupHandler *> CGroupHandler::m_Groups; std::list<CGroupHandler *> CGroupHandler::m_Groups;
CSGSUser::CSGSUser(const std::string &callsign, unsigned int timeout) : CSGSXLUser::CSGSXLUser(const std::string &callsign, unsigned int timeout) :
m_callsign(callsign), m_callsign(callsign),
m_timer(1000U, timeout) m_timer(1000U, timeout)
{ {
m_timer.start(); m_timer.start();
} }
CSGSUser::~CSGSUser() CSGSXLUser::~CSGSXLUser()
{ {
} }
bool CSGSUser::clock(unsigned int ms) bool CSGSXLUser::clock(unsigned int ms)
{ {
m_timer.clock(ms); m_timer.clock(ms);
return m_timer.isRunning() && m_timer.hasExpired(); return m_timer.isRunning() && m_timer.hasExpired();
} }
bool CSGSUser::hasExpired() bool CSGSXLUser::hasExpired()
{ {
return m_timer.isRunning() && m_timer.hasExpired(); return m_timer.isRunning() && m_timer.hasExpired();
} }
void CSGSUser::reset() void CSGSXLUser::reset()
{ {
m_timer.start(); m_timer.start();
} }
std::string CSGSUser::getCallsign() const std::string CSGSXLUser::getCallsign() const
{ {
return m_callsign; return m_callsign;
} }
CTimer CSGSUser::getTimer() const CTimer CSGSXLUser::getTimer() const
{ {
return m_timer; return m_timer;
} }
CSGSId::CSGSId(unsigned int id, unsigned int timeout, CSGSUser *user) : CSGSXLId::CSGSXLId(unsigned int id, unsigned int timeout, CSGSXLUser *user) :
m_id(id), m_id(id),
m_timer(1000U, timeout), m_timer(1000U, timeout),
m_login(false), m_login(false),
@ -91,80 +91,80 @@ m_textCollector()
m_timer.start(); m_timer.start();
} }
CSGSId::~CSGSId() CSGSXLId::~CSGSXLId()
{ {
} }
unsigned int CSGSId::getId() const unsigned int CSGSXLId::getId() const
{ {
return m_id; return m_id;
} }
void CSGSId::reset() void CSGSXLId::reset()
{ {
m_timer.start(); m_timer.start();
} }
void CSGSId::setLogin() void CSGSXLId::setLogin()
{ {
m_login = true; m_login = true;
} }
void CSGSId::setInfo() void CSGSXLId::setInfo()
{ {
if (!m_login && !m_logoff) if (!m_login && !m_logoff)
m_info = true; m_info = true;
} }
void CSGSId::setLogoff() void CSGSXLId::setLogoff()
{ {
if (!m_login && !m_info) if (!m_login && !m_info)
m_logoff = true; m_logoff = true;
} }
void CSGSId::setEnd() void CSGSXLId::setEnd()
{ {
m_end = true; m_end = true;
} }
bool CSGSId::clock(unsigned int ms) bool CSGSXLId::clock(unsigned int ms)
{ {
m_timer.clock(ms); m_timer.clock(ms);
return m_timer.isRunning() && m_timer.hasExpired(); return m_timer.isRunning() && m_timer.hasExpired();
} }
bool CSGSId::hasExpired() bool CSGSXLId::hasExpired()
{ {
return m_timer.isRunning() && m_timer.hasExpired(); return m_timer.isRunning() && m_timer.hasExpired();
} }
bool CSGSId::isLogin() const bool CSGSXLId::isLogin() const
{ {
return m_login; return m_login;
} }
bool CSGSId::isInfo() const bool CSGSXLId::isInfo() const
{ {
return m_info; return m_info;
} }
bool CSGSId::isLogoff() const bool CSGSXLId::isLogoff() const
{ {
return m_logoff; return m_logoff;
} }
bool CSGSId::isEnd() const bool CSGSXLId::isEnd() const
{ {
return m_end; return m_end;
} }
CSGSUser* CSGSId::getUser() const CSGSXLUser* CSGSXLId::getUser() const
{ {
return m_user; return m_user;
} }
CTextCollector& CSGSId::getTextCollector() CTextCollector& CSGSXLId::getTextCollector()
{ {
return m_textCollector; return m_textCollector;
} }
@ -262,7 +262,7 @@ CRemoteGroup *CGroupHandler::getInfo() const
CRemoteGroup *data = new CRemoteGroup(m_groupCallsign, m_offCallsign, m_repeater, m_infoText, m_linkReflector, m_linkStatus, m_userTimeout); CRemoteGroup *data = new CRemoteGroup(m_groupCallsign, m_offCallsign, m_repeater, m_infoText, m_linkReflector, m_linkStatus, m_userTimeout);
for (auto it=m_users.begin(); it!=m_users.end(); ++it) { for (auto it=m_users.begin(); it!=m_users.end(); ++it) {
CSGSUser* user = it->second; CSGSXLUser* user = it->second;
data->addUser(user->getCallsign(), user->getTimer().getTimer(), user->getTimer().getTimeout()); data->addUser(user->getCallsign(), user->getTimer().getTimer(), user->getTimer().getTimeout());
} }
@ -369,7 +369,7 @@ void CGroupHandler::process(CHeaderData &header)
std::string your = header.getYourCall(); std::string your = header.getYourCall();
unsigned int id = header.getId(); unsigned int id = header.getId();
CSGSUser *group_user = m_users[my]; // if not found, m_user[my] will be created and its value will be set to NULL CSGSXLUser *group_user = m_users[my]; // if not found, m_user[my] will be created and its value will be set to NULL
bool islogin = false; bool islogin = false;
// Ensure that this user is in the cache. // Ensure that this user is in the cache.
@ -383,13 +383,13 @@ void CGroupHandler::process(CHeaderData &header)
if (group_user == NULL) { if (group_user == NULL) {
printf("Adding %s to Smart Group %s\n", my.c_str(), your.c_str()); printf("Adding %s to Smart Group %s\n", my.c_str(), your.c_str());
// This is a new user, add him to the list // This is a new user, add him to the list
group_user = new CSGSUser(my, m_userTimeout * 60U); group_user = new CSGSXLUser(my, m_userTimeout * 60U);
m_users[my] = group_user; m_users[my] = group_user;
logUser(LU_ON, your, my); // inform Quadnet logUser(LU_ON, your, my); // inform Quadnet
// add a new Id for this message // add a new Id for this message
CSGSId* tx = new CSGSId(id, MESSAGE_DELAY, group_user); CSGSXLId* tx = new CSGSXLId(id, MESSAGE_DELAY, group_user);
tx->setLogin(); tx->setLogin();
m_ids[id] = tx; m_ids[id] = tx;
islogin = true; islogin = true;
@ -397,7 +397,7 @@ void CGroupHandler::process(CHeaderData &header)
group_user->reset(); group_user->reset();
// Check that it isn't a duplicate header // Check that it isn't a duplicate header
CSGSId* tx = m_ids[id]; CSGSXLId* tx = m_ids[id];
if (tx) { if (tx) {
//printf("Duplicate header from %s, deleting userData...\n", my.c_str()); //printf("Duplicate header from %s, deleting userData...\n", my.c_str());
delete userData; delete userData;
@ -405,7 +405,7 @@ void CGroupHandler::process(CHeaderData &header)
} }
//printf("Updating %s on Smart Group %s\n", my.c_str(), your.c_str()); //printf("Updating %s on Smart Group %s\n", my.c_str(), your.c_str());
logUser(LU_ON, your, my); // this will be an update logUser(LU_ON, your, my); // this will be an update
m_ids[id] = new CSGSId(id, MESSAGE_DELAY, group_user); m_ids[id] = new CSGSXLId(id, MESSAGE_DELAY, group_user);
} }
} else { } else {
// unsubscribe was sent by someone // unsubscribe was sent by someone
@ -425,7 +425,7 @@ void CGroupHandler::process(CHeaderData &header)
// Remove the user from the user list // Remove the user from the user list
m_users.erase(my); m_users.erase(my);
CSGSId* tx = new CSGSId(id, MESSAGE_DELAY, group_user); CSGSXLId* tx = new CSGSXLId(id, MESSAGE_DELAY, group_user);
tx->setLogoff(); tx->setLogoff();
m_ids[id] = tx; m_ids[id] = tx;
@ -467,7 +467,7 @@ void CGroupHandler::process(CHeaderData &header)
// Build new repeater list, based on users that are currently logged in // Build new repeater list, based on users that are currently logged in
for (auto it = m_users.begin(); it != m_users.end(); ++it) { for (auto it = m_users.begin(); it != m_users.end(); ++it) {
CSGSUser *user = it->second; CSGSXLUser *user = it->second;
if (user != NULL) { if (user != NULL) {
// Find the user in the cache // Find the user in the cache
userData = m_cache->findUser(user->getCallsign()); userData = m_cache->findUser(user->getCallsign());
@ -518,13 +518,13 @@ void CGroupHandler::process(CAMBEData &data)
{ {
unsigned int id = data.getId(); unsigned int id = data.getId();
CSGSId* tx = m_ids[id]; CSGSXLId* tx = m_ids[id];
if (tx == NULL) if (tx == NULL)
return; return;
tx->reset(); tx->reset();
CSGSUser* user = tx->getUser(); CSGSXLUser* user = tx->getUser();
user->reset(); user->reset();
// If we've just logged in, the LOGOFF and INFO commands are disabled // If we've just logged in, the LOGOFF and INFO commands are disabled
@ -606,7 +606,7 @@ bool CGroupHandler::logoff(const std::string &callsign)
{ {
if (0 == callsign.compare("ALL ")) { if (0 == callsign.compare("ALL ")) {
for (auto it = m_users.begin(); it != m_users.end(); ++it) { for (auto it = m_users.begin(); it != m_users.end(); ++it) {
CSGSUser* user = it->second; CSGSXLUser* user = it->second;
if (user) { if (user) {
printf("Removing %s from Smart Group %s, logged off by remote control\n", user->getCallsign().c_str(), m_groupCallsign.c_str()); printf("Removing %s from Smart Group %s, logged off by remote control\n", user->getCallsign().c_str(), m_groupCallsign.c_str());
logUser(LU_OFF, m_groupCallsign, user->getCallsign()); // inform Quadnet logUser(LU_OFF, m_groupCallsign, user->getCallsign()); // inform Quadnet
@ -628,7 +628,7 @@ bool CGroupHandler::logoff(const std::string &callsign)
return true; return true;
} else { } else {
CSGSUser* user = m_users[callsign]; CSGSXLUser* user = m_users[callsign];
if (user == NULL) { if (user == NULL) {
printf("Invalid callsign asked to logoff"); printf("Invalid callsign asked to logoff");
return false; return false;
@ -639,7 +639,7 @@ bool CGroupHandler::logoff(const std::string &callsign)
// Find any associated id structure associated with this use, and the logged off user is the // Find any associated id structure associated with this use, and the logged off user is the
// currently relayed one, remove his id. // currently relayed one, remove his id.
for (auto it = m_ids.begin(); it != m_ids.end(); ++it) { for (auto it = m_ids.begin(); it != m_ids.end(); ++it) {
CSGSId* id = it->second; CSGSXLId* id = it->second;
if (id != NULL && id->getUser() == user) { if (id != NULL && id->getUser() == user) {
if (id->getId() == m_id) if (id->getId() == m_id)
m_id = 0x00U; m_id = 0x00U;
@ -692,7 +692,7 @@ bool CGroupHandler::process(CHeaderData &header, DIRECTION, AUDIO_SOURCE)
// Build new repeater list // Build new repeater list
for (auto it = m_users.begin(); it != m_users.end(); ++it) { for (auto it = m_users.begin(); it != m_users.end(); ++it) {
CSGSUser* user = it->second; CSGSXLUser* user = it->second;
if (user) { if (user) {
// Find the user in the cache // Find the user in the cache
CUserData* userData = m_cache->findUser(user->getCallsign()); CUserData* userData = m_cache->findUser(user->getCallsign());
@ -729,7 +729,7 @@ bool CGroupHandler::process(CHeaderData &header, DIRECTION, AUDIO_SOURCE)
break; break;
} }
CSGSId *tx = m_ids[m_id]; CSGSXLId *tx = m_ids[m_id];
if (tx) { if (tx) {
if (!tx->isLogin()) if (!tx->isLogin())
sendToRepeaters(header); sendToRepeaters(header);
@ -750,7 +750,7 @@ bool CGroupHandler::process(CAMBEData &data, DIRECTION, AUDIO_SOURCE)
m_linkTimer.start(); m_linkTimer.start();
CSGSId *tx = m_ids[id]; CSGSXLId *tx = m_ids[id];
if (tx) { if (tx) {
if (!tx->isLogin()) if (!tx->isLogin())
sendToRepeaters(data); sendToRepeaters(data);
@ -848,7 +848,7 @@ void CGroupHandler::clockInt(unsigned int ms)
// For each incoming id // For each incoming id
for (auto it = m_ids.begin(); it != m_ids.end(); ++it) { for (auto it = m_ids.begin(); it != m_ids.end(); ++it) {
CSGSId* tx = it->second; CSGSXLId* tx = it->second;
if (tx != NULL && tx->clock(ms)) { if (tx != NULL && tx->clock(ms)) {
std::string callsign = tx->getUser()->getCallsign(); std::string callsign = tx->getUser()->getCallsign();
@ -908,7 +908,7 @@ void CGroupHandler::clockInt(unsigned int ms)
// Individual user expiry, but not for the permanent entries // Individual user expiry, but not for the permanent entries
for (auto it = m_users.begin(); it != m_users.end(); ++it) { for (auto it = m_users.begin(); it != m_users.end(); ++it) {
CSGSUser* user = it->second; CSGSXLUser* user = it->second;
if (user && m_permanent.find(user->getCallsign()) == m_permanent.end()) if (user && m_permanent.find(user->getCallsign()) == m_permanent.end())
user->clock(ms); user->clock(ms);
} }
@ -919,7 +919,7 @@ void CGroupHandler::clockInt(unsigned int ms)
// Individual user expiry // Individual user expiry
for (auto it = m_users.begin(); it != m_users.end(); ++it) { for (auto it = m_users.begin(); it != m_users.end(); ++it) {
CSGSUser* user = it->second; CSGSXLUser* user = it->second;
if (user && user->hasExpired()) { if (user && user->hasExpired()) {
printf("Removing %s from Smart Group %s, user timeout\n", user->getCallsign().c_str(), m_groupCallsign.c_str()); printf("Removing %s from Smart Group %s, user timeout\n", user->getCallsign().c_str(), m_groupCallsign.c_str());

@ -42,10 +42,10 @@ enum LOGUSER {
LU_OFF LU_OFF
}; };
class CSGSUser { class CSGSXLUser {
public: public:
CSGSUser(const std::string& callsign, unsigned int timeout); CSGSXLUser(const std::string& callsign, unsigned int timeout);
~CSGSUser(); ~CSGSXLUser();
void reset(); void reset();
@ -60,10 +60,10 @@ private:
CTimer m_timer; CTimer m_timer;
}; };
class CSGSId { class CSGSXLId {
public: public:
CSGSId(unsigned int id, unsigned int timeout, CSGSUser* user); CSGSXLId(unsigned int id, unsigned int timeout, CSGSXLUser* user);
~CSGSId(); ~CSGSXLId();
unsigned int getId() const; unsigned int getId() const;
@ -82,7 +82,7 @@ public:
bool isLogoff() const; bool isLogoff() const;
bool isEnd() const; bool isEnd() const;
CSGSUser* getUser() const; CSGSXLUser* getUser() const;
CTextCollector& getTextCollector(); CTextCollector& getTextCollector();
@ -93,7 +93,7 @@ private:
bool m_info; bool m_info;
bool m_logoff; bool m_logoff;
bool m_end; bool m_end;
CSGSUser *m_user; CSGSXLUser *m_user;
CTextCollector m_textCollector; CTextCollector m_textCollector;
}; };
@ -185,8 +185,8 @@ private:
CALLSIGN_SWITCH m_callsignSwitch; CALLSIGN_SWITCH m_callsignSwitch;
bool m_txMsgSwitch; bool m_txMsgSwitch;
std::map<unsigned int, CSGSId *> m_ids; std::map<unsigned int, CSGSXLId *> m_ids;
std::map<std::string, CSGSUser *> m_users; std::map<std::string, CSGSXLUser *> m_users;
std::map<std::string, CSGSRepeater *> m_repeaters; std::map<std::string, CSGSRepeater *> m_repeaters;
void sendFromText(const std::string &text) const; void sendFromText(const std::string &text) const;

Loading…
Cancel
Save

Powered by TurnKey Linux.