Migrates Participant and OperatorManagement to generated rtiddsgen API

Converts accessor calls to plain member access in ppm and opm services and plugins.
This commit is contained in:
berrux-dev committed 2026-09-21 02:46:44 +02:00
1 parent bdb2461737
commit 95071993f5
36 files changed
+513 -529

No files matched your search

@@ -74,7 +74,7 @@ bool HandlerOperator::init()
INFO_LOG(m_logger) << "------- opMap size" << opMap.size();
OperatorManagement::OperatorWorkstationAlive alive;
alive.lastAlive(QDateTime::currentMSecsSinceEpoch());
alive.lastAlive = QDateTime::currentMSecsSinceEpoch();
for (const Database::OpmOperator &op : qAsConst(dataVec))
{
ObjectOperator *ifs(new ObjectOperator(m_mainHandler));
@@ -99,8 +99,8 @@ bool HandlerOperator::init()
m_operatorObjMap.insert(ifs->getId(), ifs);
if (!op.workstationId.isNull())
{
alive.operatorId(op.id);
alive.workstationId(op.workstationId.toInt());
alive.operatorId = op.id;
alive.workstationId = op.workstationId.toInt();
onOperatorWorkstationAliveChanged(alive, DataModification::eAdded);
}
}
@@ -139,7 +139,7 @@ void HandlerOperator::onOperatorChangePasswordRequest(const rti::core::SampleIde
const OperatorChangePasswordRequest &request)
{
DEBUG_LOG(m_logger) << "onOperatorChangePasswordRequest()";
ObjectOperator *ifs = m_operatorObjMap.value(request.id());
ObjectOperator *ifs = m_operatorObjMap.value(request.id);
if (!ifs)
{
m_mainHandler->fts()->operatorChangePasswordReply(cookie,
@@ -150,15 +150,15 @@ void HandlerOperator::onOperatorChangePasswordRequest(const rti::core::SampleIde
Core::FunctionReplyObject ret;
Database::OpmOperator op = ifs->data();
const auto &pw = request.oldPassword();
const auto &pw = request.oldPassword;
const QByteArray ba(QByteArray::fromRawData(pw.c_str(), pw.size()));
const QString enteredPassword(QString::fromLatin1(QCryptographicHash::hash(ba, QCryptographicHash::Md5).toHex()));
const auto &pwNew = request.password();
const auto &pwNew = request.password;
const QByteArray baNew(QByteArray::fromRawData(pwNew.c_str(), pwNew.size()));
const QString enteredPasswordNew(QString::fromLatin1(QCryptographicHash::hash(baNew, QCryptographicHash::Md5).toHex()));
if (request.forceSet() || op.password == enteredPassword)
if (request.forceSet || op.password == enteredPassword)
{
if (enteredPassword == enteredPasswordNew)
ret = Core::FunctionReplyObject(0, tr_lts("dds", "Password is identical to old password."));
@@ -185,7 +185,7 @@ void HandlerOperator::onOperatorCreateModifyRequest(const rti::core::SampleIdent
{
Core::FunctionReplyObject ret;
DEBUG_LOG(m_logger) << "onOperatorCreateModifyRequest()";
if (!request.id().is_set())
if (!request.id.is_set())
ret = operatorCreateRequest(request);
else
ret = operatorModifyRequest(request);
@@ -197,15 +197,15 @@ void HandlerOperator::onOperatorCreateModifyRequest(const rti::core::SampleIdent
Core::FunctionReplyObject HandlerOperator::operatorCreateRequest(const OperatorCreateModifyRequest &request)
{
if (!request.name().is_set() ||
!request.password().is_set())
if (!request.name.is_set() ||
!request.password.is_set())
return Core::FunctionReplyObject(tr_lts("dds", "Can not create operator - name or password is empty."));
// Group anlegen
GroupCreateRequest groupRequest;
groupRequest.name(request.name().get());
groupRequest.description(request.description().get());
groupRequest.type(GroupType_def::OperatorGroup);
groupRequest.name = request.name.get();
groupRequest.description = request.description.get();
groupRequest.type = GroupType::OperatorGroup;
const Core::FunctionReplyObject groupRet = m_mainHandler->getHandlerGroup()->create(groupRequest);
if (groupRet.error())
@@ -213,33 +213,33 @@ Core::FunctionReplyObject HandlerOperator::operatorCreateRequest(const OperatorC
// Operator anlegen
Database::OpmOperator op;
op.name = QString::fromStdString(request.name().get());
if (request.description().is_set())
op.description = QString::fromStdString(request.description().get());
op.name = QString::fromStdString(request.name.get());
if (request.description.is_set())
op.description = QString::fromStdString(request.description.get());
const auto &pw = request.password().get();
const auto &pw = request.password.get();
const QByteArray ba(QByteArray::fromRawData(pw.c_str(), pw.size()));
const QString enteredPassword(QString::fromLatin1(QCryptographicHash::hash(ba, QCryptographicHash::Md5).toHex()));
op.password = enteredPassword;
op.primaryGroupId = groupRet.id();
if (request.image().is_set())
op.image = LtsUtils::toQByteArray(request.image().get());
const auto vpbe = request.visiblePartiesByExercise();
if (request.image.is_set())
op.image = LtsUtils::toQByteArray(request.image.get());
const auto vpbe = request.visiblePartiesByExercise;
for (const auto &pbe : vpbe)
{
if (!pbe.visibleParties().is_set() || pbe.exerciseId() != 0) //has_value not support on windows yet so we need depricated is_set
if (!pbe.visibleParties.is_set() || pbe.exerciseId != 0) //has_value not support on windows yet so we need depricated is_set
continue;
op.visibleParties = LtsUtils::IntArray(pbe.visibleParties().get());
op.visibleParties = LtsUtils::IntArray(pbe.visibleParties.get());
}
if (request.rolePresetId().is_set())
if (request.rolePresetId.is_set())
{
op.rolePresetId = request.rolePresetId().get();
op.rolePresetId = request.rolePresetId.get();
}
op.projectionPriority = request.projectionPriority().is_set() ? request.projectionPriority().get() : 1;
op.audioChannelPriority = request.audioChannelPriority().is_set() ? request.audioChannelPriority().get() : 1;
op.projectionPriority = request.projectionPriority.is_set() ? request.projectionPriority.get() : 1;
op.audioChannelPriority = request.audioChannelPriority.is_set() ? request.audioChannelPriority.get() : 1;
ObjectOperator *ifs(new ObjectOperator(m_mainHandler));
const Core::FunctionReplyObject ret = ifs->createObject(op, {});
@@ -250,14 +250,14 @@ Core::FunctionReplyObject HandlerOperator::operatorCreateRequest(const OperatorC
delete ifs;
return ret;
}
if (request.visibleExercises().is_set())
ifs->updateExercises(request.visibleExercises().get());
if (request.visibleExercises.is_set())
ifs->updateExercises(request.visibleExercises.get());
if (request.operatorRights().is_set())
if (request.operatorRights.is_set())
{
GroupChangeMembersRequest grChReq;
grChReq.id(op.primaryGroupId);
grChReq.memberships(request.operatorRights().get());
grChReq.id = op.primaryGroupId;
grChReq.memberships = request.operatorRights.get();
// We don't actually care, if this fails...
m_mainHandler->getHandlerGroup()->changeMembership(grChReq);
ifs->reloadAcls(true);
@@ -286,18 +286,18 @@ void HandlerOperator::operatorModifyRolePresetId( int operatorId, int rolePreset
Core::FunctionReplyObject HandlerOperator::operatorModifyRequest(const OperatorCreateModifyRequest &request)
{
if (request.password().is_set())
if (request.password.is_set())
return Core::FunctionReplyObject(tr_lts("dds", "Can not modify operator password with this function."));
ObjectOperator *ifs = m_operatorObjMap.value(request.id().get());
ObjectOperator *ifs = m_operatorObjMap.value(request.id.get());
if (!ifs)
return Core::FunctionReplyObject(request.id().get(), tr_lts("dds", "No valid operator id given."));
return Core::FunctionReplyObject(request.id.get(), tr_lts("dds", "No valid operator id given."));
Database::OpmOperator op = ifs->data();
if (request.name().is_set())
if (request.name.is_set())
{
op.name = QString::fromStdString(request.name().get());
op.name = QString::fromStdString(request.name.get());
for (const ObjectOperator *o : qAsConst(m_operatorObjMap))
{
@@ -308,32 +308,32 @@ Core::FunctionReplyObject HandlerOperator::operatorModifyRequest(const OperatorC
}
}
if (request.description().is_set())
op.description = QString::fromStdString(request.description().get());
if (request.image().is_set())
op.image = LtsUtils::toQByteArray(request.image().get());
const auto vpbe = request.visiblePartiesByExercise();
if (request.description.is_set())
op.description = QString::fromStdString(request.description.get());
if (request.image.is_set())
op.image = LtsUtils::toQByteArray(request.image.get());
const auto vpbe = request.visiblePartiesByExercise;
for (const auto &pbe : vpbe)
{
// only ex0 updated
if (!pbe.visibleParties().is_set() || pbe.exerciseId() != 0) //has_value not support on windows yet so we need depricated is_set
if (!pbe.visibleParties.is_set() || pbe.exerciseId != 0) //has_value not support on windows yet so we need depricated is_set
continue;
op.visibleParties = LtsUtils::IntArray(pbe.visibleParties().get());
op.visibleParties = LtsUtils::IntArray(pbe.visibleParties.get());
}
if (request.rolePresetId().is_set())
if (request.rolePresetId.is_set())
{
op.rolePresetId = request.rolePresetId().get();
op.rolePresetId = request.rolePresetId.get();
}
if (request.visibleExercises().is_set())
ifs->updateExercises(request.visibleExercises().get());
if (request.projectionPriority().is_set())
op.projectionPriority = request.projectionPriority().get();
if (request.audioChannelPriority().is_set())
op.audioChannelPriority = request.audioChannelPriority().get();
op.properties = QString::fromStdString(request.properties());
if (request.visibleExercises.is_set())
ifs->updateExercises(request.visibleExercises.get());
if (request.projectionPriority.is_set())
op.projectionPriority = request.projectionPriority.get();
if (request.audioChannelPriority.is_set())
op.audioChannelPriority = request.audioChannelPriority.get();
op.properties = QString::fromStdString(request.properties);
return ifs->updateObject(op);
}
@@ -343,7 +343,7 @@ void HandlerOperator::onOperatorRemoveRequest(const rti::core::SampleIdentity &c
{
DEBUG_LOG(m_logger) << "onOperatorRemoveRequest()" << request;
ObjectOperator *ifs = m_operatorObjMap.value(request.id());
ObjectOperator *ifs = m_operatorObjMap.value(request.id);
if (!ifs)
{
m_mainHandler->fts()->operatorRemoveReply(cookie,
@@ -359,12 +359,12 @@ void HandlerOperator::onOperatorRemoveRequest(const rti::core::SampleIdentity &c
}
OperatorManagement::User ddsData;
ddsData.id(request.id());
ddsData.id = request.id;
if (m_mainHandler->dds()->topicLockMaster()->isLocked(ddsData, 0))
{
m_mainHandler->fts()->operatorRemoveReply(cookie,
Core::FunctionReplyObject(request.id(), tr_lts("dds", "Operator '%1' is used by another user!")).arg(ifs->name()));
Core::FunctionReplyObject(request.id, tr_lts("dds", "Operator '%1' is used by another user!")).arg(ifs->name()));
return;
}
@@ -391,7 +391,7 @@ void HandlerOperator::onOperatorLoginRequest(const rti::core::SampleIdentity &co
{
DEBUG_LOG(m_logger) << "OperatorLoginRequest: " << request;
ObjectOperator *ifs = m_operatorObjMap.value(request.id());
ObjectOperator *ifs = m_operatorObjMap.value(request.id);
if (!ifs)
{
m_mainHandler->fts()->operatorLoginReply(cookie,
@@ -399,7 +399,7 @@ void HandlerOperator::onOperatorLoginRequest(const rti::core::SampleIdentity &co
return;
}
const auto &pw = request.password();
const auto &pw = request.password;
const QByteArray ba(QByteArray::fromRawData(pw.c_str(), pw.size()));
const QString enteredPassword(QString::fromLatin1(QCryptographicHash::hash(ba, QCryptographicHash::Md5).toHex()));
if (enteredPassword != ifs->data().password)
@@ -415,16 +415,16 @@ void HandlerOperator::onOperatorLoginRequest(const rti::core::SampleIdentity &co
if (!ifs->data().workstationId.isNull() && ifs->data().workstationId.toInt() > 0)
// operator already logged in
{
if (ifs->data().workstationId == request.workstationId())
if (ifs->data().workstationId == request.workstationId)
{
// do nothing if same operator claims same workstation
}
else if (!request.force())
else if (!request.force)
{
// Already claimed: Return WSid as ID
const auto ws = m_mainHandler->dds()->dtcAsm()->asset(ifs->data().workstationId.toInt());
ret = Core::FunctionReplyObject(ifs->data().workstationId.toInt(),
tr_lts("dds", "Operator already logged in on workstation %1.")).arg(QString::fromStdString(ws.name()));
tr_lts("dds", "Operator already logged in on workstation %1.")).arg(QString::fromStdString(ws.name));
}
else
{
@@ -436,13 +436,13 @@ void HandlerOperator::onOperatorLoginRequest(const rti::core::SampleIdentity &co
if (other)
{
OperatorLogoutRequest req;
req.id(otherOperatorId);
req.id = otherOperatorId;
onOperatorLogoutRequest(cookie, req);
}
}
Database::OpmOperator op = ifs->data();
op.workstationIp = request.workstationIp();
op.workstationId = request.workstationId();
op.workstationIp = request.workstationIp;
op.workstationId = request.workstationId;
ret = ifs->updateObject(op);
}
}
@@ -450,7 +450,7 @@ void HandlerOperator::onOperatorLoginRequest(const rti::core::SampleIdentity &co
// operator not logged in on any workstation
{
// if other operator is logged in on same WS -> logout other operator and login our operator
int otherOperatorId = getLoggedOperatorId(request.workstationId());
int otherOperatorId = getLoggedOperatorId(request.workstationId);
if (otherOperatorId != 0 && otherOperatorId != ifs->data().id)
{
@@ -458,15 +458,15 @@ void HandlerOperator::onOperatorLoginRequest(const rti::core::SampleIdentity &co
if (other)
{
OperatorLogoutRequest req;
req.id(otherOperatorId);
req.id = otherOperatorId;
onOperatorLogoutRequest(cookie, req);
WARNING_LOG(m_logger) << "Logged out operator " << otherOperatorId << " on workstation id " << request.workstationId();
WARNING_LOG(m_logger) << "Logged out operator " << otherOperatorId << " on workstation id " << request.workstationId;
}
}
// Claim WS:
Database::OpmOperator op = ifs->data();
op.workstationIp = request.workstationIp();
op.workstationId = request.workstationId();
op.workstationIp = request.workstationIp;
op.workstationId = request.workstationId;
ret = ifs->updateObject(op);
}
@@ -474,8 +474,8 @@ void HandlerOperator::onOperatorLoginRequest(const rti::core::SampleIdentity &co
WARNING_LOG(m_logger) << ret();
else
{
m_mainHandler->getHandlerLockedTopics()->operatorLoggedIn(request.id(), request.workstationId());
m_mainHandler->getHandlerActiveApps()->cleanupOperator(request.id());
m_mainHandler->getHandlerLockedTopics()->operatorLoggedIn(request.id, request.workstationId);
m_mainHandler->getHandlerActiveApps()->cleanupOperator(request.id);
}
m_mainHandler->fts()->operatorLoginReply(cookie, ret);
@@ -493,7 +493,7 @@ void HandlerOperator::onOperatorLogoutRequest(const rti::core::SampleIdentity &c
{
DEBUG_LOG(m_logger) << "OperatorLogoutRequest: " << request;
ObjectOperator *ifs = m_operatorObjMap.value(request.id());
ObjectOperator *ifs = m_operatorObjMap.value(request.id);
if (!ifs)
{
m_mainHandler->fts()->operatorLogoutReply(cookie, Core::FunctionReplyObject(0, tr_lts("dds", "No valid operator id for logout.")));
@@ -509,7 +509,7 @@ void HandlerOperator::onOperatorLogoutRequest(const rti::core::SampleIdentity &c
op.workstationIp = 0;
op.workstationId = QVariant();
m_mainHandler->getHandlerLockedTopics()->operatorLoggedOut(request.id()); // workstationId = 0 -> logout
m_mainHandler->getHandlerLockedTopics()->operatorLoggedOut(request.id); // workstationId = 0 -> logout
m_mainHandler->getHandlerActiveApps()->cleanupOperator(op.id);
m_mainHandler->fts()->operatorLogoutReply(cookie, ifs->updateObject(op));
@@ -520,45 +520,45 @@ void HandlerOperator::onOperatorGetSetSettingsRequest(const rti::core::SampleIde
{
Core::FunctionReplyObject fro;
OperatorGetSetSettingsReply reply;
reply.id(request.id());
reply.id = request.id;
ObjectOperator *ifs = m_operatorObjMap.value(request.id());
ObjectOperator *ifs = m_operatorObjMap.value(request.id);
if (ifs)
{
if (request.settings().is_set())
if (request.settings.is_set())
{
const auto &data = request.settings().get();
const auto &data = request.settings.get();
const QByteArray settings(QByteArray(reinterpret_cast<const char*>(&data[0]), data.size()));
if (!ifs->saveSettings(settings))
fro = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Error saving settings in database.") );
fro = Core::FunctionReplyObject(request.id, tr_lts("dds", "Error saving settings in database.") );
}
else
{
QByteArray settings;
if (!ifs->loadSettings(settings))
{
fro = Core::FunctionReplyObject(request.id(), tr_lts("dds", "Error loading settings from database.") );
fro = Core::FunctionReplyObject(request.id, tr_lts("dds", "Error loading settings from database.") );
}
else
{
if (!settings.isEmpty())
{
reply.settings().set({});
reply.settings().get() = LtsUtils::convert<std::vector<uint8_t>>(settings);
reply.settings.set({});
reply.settings.get() = LtsUtils::convert<std::vector<uint8_t>>(settings);
}
}
}
}
else
{
fro = Core::FunctionReplyObject(request.id(), tr_lts("dds", "No valid operator id for retrieving settings."));
fro = Core::FunctionReplyObject(request.id, tr_lts("dds", "No valid operator id for retrieving settings."));
}
if (fro.error())
{
reply.id(fro.id());
reply.errorString(fro.str());
reply.errorParams(fro.args());
reply.id = fro.id();
reply.errorString = fro.str();
reply.errorParams = fro.args();
}
m_mainHandler->fts()->operatorGetSetSettingsReply(cookie, reply);
@@ -575,11 +575,11 @@ void HandlerOperator::onOperatorApplyForeignAclsRequest(const rti::core::SampleI
Core::FunctionReplyObject HandlerOperator::operatorApplyForeignAclsRequest(const OperatorApplyForeignAclsRequest &request)
{
ObjectOperator *receiver = m_operatorObjMap.value(request.id());
ObjectOperator *receiver = m_operatorObjMap.value(request.id);
if (!receiver)
return Core::FunctionReplyObject(0, tr_lts("dds", "Receiving operator not present."));
ObjectOperator *remoteOperator = m_operatorObjMap.value(request.remoteOperatorId());
ObjectOperator *remoteOperator = m_operatorObjMap.value(request.remoteOperatorId);
if (!remoteOperator)
return Core::FunctionReplyObject(0, tr_lts("dds", "Remote operator not present."));
@@ -599,20 +599,20 @@ void HandlerOperator::onOperatorUpdateVisiblePartiesByExerciseRequest(const rti:
Core::FunctionReplyObject HandlerOperator::operatorUpdateVisiblePartiesByExerciseRequest(const OperatorUpdateVisiblePartiesByExerciseRequest &request)
{
ObjectOperator *ifs = m_operatorObjMap.value(request.id());
ObjectOperator *ifs = m_operatorObjMap.value(request.id);
if (!ifs)
return Core::FunctionReplyObject(request.id(), tr_lts("dds", "No valid operator id given."));
return Core::FunctionReplyObject(request.id, tr_lts("dds", "No valid operator id given."));
Database::OpmOperatorExercise opEx;
opEx.operatorId = request.id();
opEx.exerciseId = request.exerciseId();
opEx.operatorId = request.id;
opEx.exerciseId = request.exerciseId;
std::vector<int> hiddenParties;
if (request.hiddenParties().is_set())
opEx.hiddenParties = LtsUtils::IntArray(request.hiddenParties().get());
if (request.visibleParties().is_set())
opEx.visibleParties = LtsUtils::IntArray(request.visibleParties().get());
if (request.hiddenParties.is_set())
opEx.hiddenParties = LtsUtils::IntArray(request.hiddenParties.get());
if (request.visibleParties.is_set())
opEx.visibleParties = LtsUtils::IntArray(request.visibleParties.get());
opEx.properties = QString::fromStdString(request.properties());
opEx.properties = QString::fromStdString(request.properties);
return ifs->updateOperatorExercise(opEx);
}
@@ -626,13 +626,13 @@ void HandlerOperator::reloadAcls()
void HandlerOperator::onOperatorWorkstationAliveChanged(const OperatorManagement::OperatorWorkstationAlive &data, DataModification modType)
{
INFO_LOG(m_logger) << "onOperatorWorkstationAliveChanged: " << data << ", " << modType;
if (data.operatorId() < 0)
if (data.operatorId < 0)
{
m_aliveData.remove(data.workstationId());
m_aliveData.remove(data.workstationId);
return;
}
auto &events = m_aliveData[data.workstationId()];
auto &events = m_aliveData[data.workstationId];
events.push_back(data);
// do not store more than 30 history events
if (events.size() > 30)
@@ -651,7 +651,7 @@ void HandlerOperator::onCheckAliveTimeout()
{
DEBUG_LOG(m_logger) << "Checking alive for workstation " << it.key();
auto &events = it.value();
if (events.isEmpty() || events.last().lastAlive() >= tTimeoutTime)
if (events.isEmpty() || events.last().lastAlive >= tTimeoutTime)
{
++it;
continue;
@@ -659,14 +659,14 @@ void HandlerOperator::onCheckAliveTimeout()
// no reference, will be a dangling one after m_aliveData.erase(it) !
const OperatorWorkstationAlive owa = events.last();
WARNING_LOG(m_logger) << "Timeout for workstation " << owa.workstationId()
<< " and operator " << owa.operatorId() << " - logging out";
WARNING_LOG(m_logger) << "Timeout for workstation " << owa.workstationId
<< " and operator " << owa.operatorId << " - logging out";
if (m_logger.isDebugEnabled())
{
for (const auto &event : events)
DEBUG_LOG(m_logger) << "Alive history: " << event;
}
ObjectOperator *ifs = m_operatorObjMap.value(owa.operatorId());
ObjectOperator *ifs = m_operatorObjMap.value(owa.operatorId);
it = m_aliveData.erase(it);
if (!ifs)
@@ -674,8 +674,8 @@ void HandlerOperator::onCheckAliveTimeout()
Database::OpmOperator op = ifs->data();
op.workstationIp = 0;
op.workstationId = QVariant();
m_mainHandler->getHandlerLockedTopics()->operatorLoggedOut(owa.operatorId()); // workstationId = 0 -> logout
m_mainHandler->getHandlerActiveApps()->cleanupOperator(owa.operatorId());
m_mainHandler->getHandlerLockedTopics()->operatorLoggedOut(owa.operatorId); // workstationId = 0 -> logout
m_mainHandler->getHandlerActiveApps()->cleanupOperator(owa.operatorId);
ifs->updateObject(op);
}