temp
This commit is contained in:
@@ -18,6 +18,11 @@ SClient::SClient(string name, string projName, ISocket &socket, Callbacks calls)
|
||||
mCallbacks(calls),
|
||||
mName(name),
|
||||
mProjName(projName),
|
||||
mProcessor(name, projName, getClientHostName(), createGUID(), calls,
|
||||
{
|
||||
.sendSpitTypeInternal = [&](SType &sType) { return sendSPITTypeInternal(sType);}
|
||||
}
|
||||
),
|
||||
mSocket(socket) {
|
||||
mID = createGUID();
|
||||
mComputerName = getClientHostName();
|
||||
@@ -40,7 +45,7 @@ void SClient::clientProjectClose() {
|
||||
|
||||
void SClient::clientProjectLoaded() {
|
||||
// set confirmed = false for all SPITTypes and SPITObjects
|
||||
SType::setConfirmedFalse(mSpitTypes);
|
||||
SType::setConfirmedFalse(mProcessor.mSpitTypes);
|
||||
SObject::setConfirmedFalse(mSpitObjects);
|
||||
|
||||
if (mConnectionStatus == Connection::Ok) {
|
||||
@@ -68,7 +73,7 @@ void SClient::clientProjectLoaded() {
|
||||
* @param actionAssigned
|
||||
*/
|
||||
void SClient::setActionSPITType(string typeId, bool actionAssigned) {
|
||||
SType *spitType = mSpitTypes.getEntry(typeId);
|
||||
SType *spitType = mProcessor.mSpitTypes.getEntry(typeId);
|
||||
if (spitType == nullptr)
|
||||
return;
|
||||
if (spitType->ActionAssigned.set(actionAssigned)) {
|
||||
@@ -383,7 +388,7 @@ void SClient::parseMessage(unique_ptr<Message> message) {
|
||||
break;
|
||||
//----- SPIT Types ------
|
||||
case Message::ReportType::OPFLAG:
|
||||
parseReportType(message->getAs<Message::ReportType>());
|
||||
mProcessor.parseReportType(message->getAs<Message::ReportType>());
|
||||
break;
|
||||
case Message::RemoveType::OPFLAG:
|
||||
parseRemoveSPITType(message->getAs<Message::RemoveType>());
|
||||
@@ -605,7 +610,7 @@ void SClient::parseReportProject(Message::ReportProject &message) {
|
||||
mCallbacks.onProjectUpdate(ProjUpdate::ServerLoaded, mServerProjectID);
|
||||
|
||||
// Set all SPITTypes and SPITObjects confirmed = false
|
||||
SType::setConfirmedFalse(mSpitTypes);
|
||||
SType::setConfirmedFalse(mProcessor.mSpitTypes);
|
||||
SObject::setConfirmedFalse(mSpitObjects);
|
||||
|
||||
// Send RequestProjectTransfer
|
||||
@@ -642,7 +647,7 @@ void SClient::parseRequestProjectTransfer(Message::RequestProjectTransfer &messa
|
||||
}
|
||||
|
||||
// send all listes SPITTypes
|
||||
for (const auto& [key, value] : mSpitTypes.getRepo()) {
|
||||
for (const auto& [key, value] : mProcessor.mSpitTypes.getRepo()) {
|
||||
sendSPITTypeInternal(*value);
|
||||
fos::Task::delayMs(10);
|
||||
}
|
||||
@@ -797,67 +802,16 @@ void SClient::parseEndProjectTransfer(Message::EndProjectTransfer &message) {
|
||||
}
|
||||
}
|
||||
|
||||
//----- SPIT Types ------
|
||||
void SClient::parseReportType(Message::ReportType &message) {
|
||||
ESP_LOGD(TAG, "parse ReportType ID %s Name %s",message.getID().c_str(), message.getName().c_str());
|
||||
SType *ptrSPITType;
|
||||
bool boolNew = false;
|
||||
bool boolChanged = false;
|
||||
{
|
||||
if (message.getServerRemote() == false) {
|
||||
ptrSPITType = mSpitTypes.getEntry(message.getID());
|
||||
if (ptrSPITType == nullptr) {
|
||||
// The user's app my veto the SPITType
|
||||
bool createdByClient = false;
|
||||
if (ptrSPITType) {
|
||||
createdByClient = ptrSPITType->getCreatedByClient();
|
||||
}
|
||||
|
||||
if (mCallbacks.onCheckSpitTypeVeto(false, createdByClient) == false) {
|
||||
ESP_LOGW(TAG, "TypeVeto %s / %s", message.getID().c_str(), message.getName().c_str());
|
||||
return;
|
||||
}
|
||||
auto spitType = make_unique<SType>(message.getID());
|
||||
ptrSPITType = spitType.get();
|
||||
mSpitTypes.addEntry(move(spitType));
|
||||
boolNew = true;
|
||||
}
|
||||
} else {
|
||||
ptrSPITType = mRemoteSpitTypes.getEntry(message.getID());
|
||||
if (ptrSPITType == nullptr) {
|
||||
auto spitType = make_unique<SType>(message.getID());
|
||||
ptrSPITType = spitType.get();
|
||||
mRemoteSpitTypes.addEntry(move(spitType));
|
||||
boolNew = true;
|
||||
}
|
||||
}
|
||||
if (!ptrSPITType->setMessageOP(message)) {
|
||||
// SPITType is not changable -> send back to the server
|
||||
sendSPITTypeInternal(*ptrSPITType);
|
||||
return;
|
||||
}
|
||||
|
||||
auto eventType = boolNew ? ObjectEvent::Created : ObjectEvent::Changed;
|
||||
// add or change SPITType
|
||||
mCallbacks.onSpitType(eventType, ptrSPITType->ServerRemote.get(), *ptrSPITType);
|
||||
|
||||
if (ptrSPITType != nullptr) {
|
||||
if (ptrSPITType->setConfirmed(true) == true || boolChanged == true) {
|
||||
sendSPITTypeInternal(*ptrSPITType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void SClient::parseRemoveSPITType(Message::RemoveType &message) {
|
||||
ESP_LOGD(TAG, "parse RemoveType %s", message.getID().c_str());
|
||||
bool boolRemote = false;
|
||||
string stringSPITTypeID = message.getID();
|
||||
|
||||
SType *ptrSPITType = mRemoteSpitTypes.getEntry(stringSPITTypeID);
|
||||
SType *ptrSPITType = mProcessor.mRemoteSpitTypes.getEntry(stringSPITTypeID);
|
||||
if (!ptrSPITType) {
|
||||
boolRemote = true;
|
||||
} else {
|
||||
ptrSPITType = mSpitTypes.getEntry(stringSPITTypeID);
|
||||
ptrSPITType = mProcessor.mSpitTypes.getEntry(stringSPITTypeID);
|
||||
if (!ptrSPITType) {
|
||||
boolRemote = false;
|
||||
} else {
|
||||
@@ -875,9 +829,9 @@ void SClient::parseRemoveSPITType(Message::RemoveType &message) {
|
||||
|
||||
mCallbacks.onSpitType(ObjectEvent::Deleted, boolRemote, *ptrSPITType);
|
||||
if (boolRemote == false) {
|
||||
mSpitTypes.removeEntry(*ptrSPITType);
|
||||
mProcessor.mSpitTypes.removeEntry(*ptrSPITType);
|
||||
} else {
|
||||
mRemoteSpitTypes.removeEntry(*ptrSPITType);
|
||||
mProcessor.mRemoteSpitTypes.removeEntry(*ptrSPITType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,7 +855,7 @@ int SClient::sendSPITTypeInternal(SType &p_SPITType) {
|
||||
bool SClient::changeSPITType(SType *p_SPITType) {
|
||||
if (p_SPITType == nullptr)
|
||||
return false;
|
||||
SType *ptrSPITType = mSpitTypes.getEntry(p_SPITType->getID());
|
||||
SType *ptrSPITType = mProcessor.mSpitTypes.getEntry(p_SPITType->getID());
|
||||
if (ptrSPITType == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -932,13 +886,13 @@ int SClient::removeSPITType(string p_SPITTypeID) {
|
||||
return -1;
|
||||
SType *ptrSPITType;
|
||||
{
|
||||
ptrSPITType = mSpitTypes.getEntry(p_SPITTypeID);
|
||||
ptrSPITType = mProcessor.mSpitTypes.getEntry(p_SPITTypeID);
|
||||
if (ptrSPITType == nullptr)
|
||||
return -1;
|
||||
Message::RemoveType sMRemoveSPITType;
|
||||
ptrSPITType->fillMessageOP(sMRemoveSPITType);
|
||||
mCallbacks.onSpitType(ObjectEvent::Deleted, false, *ptrSPITType);
|
||||
mSpitTypes.removeEntry(*ptrSPITType);
|
||||
mProcessor.mSpitTypes.removeEntry(*ptrSPITType);
|
||||
return sendSPITMessage(sMRemoveSPITType);
|
||||
}
|
||||
return -1;
|
||||
@@ -950,11 +904,11 @@ SType *SClient::createTypeFixed(string iD, string p_GroupName, string p_Name, ui
|
||||
|
||||
SType *SClient::createType(string p_ID, string p_GroupName, string p_Name, uint64_t p_DefaultDelay, uint64_t p_DefaultDuration, bool p_FIxed, bool p_ProjectIndepended) {
|
||||
bool boolNew;
|
||||
SType *ptrSPITType = mSpitTypes.getEntry(p_ID);
|
||||
SType *ptrSPITType = mProcessor.mSpitTypes.getEntry(p_ID);
|
||||
if (ptrSPITType == nullptr) {
|
||||
auto spitType = make_unique<SType>(p_ID, p_GroupName, p_Name, p_FIxed, p_ProjectIndepended, p_DefaultDelay, p_DefaultDuration);
|
||||
ptrSPITType = spitType.get();
|
||||
mSpitTypes.addEntry(move(spitType));
|
||||
mProcessor.mSpitTypes.addEntry(move(spitType));
|
||||
ptrSPITType->setCreatedByClient(true);
|
||||
boolNew = true;
|
||||
} else {
|
||||
@@ -986,7 +940,7 @@ void SClient::parseReportSPITObject(Message::ReportObject &message) {
|
||||
if (message.getServerRemote() == false) {
|
||||
boolRemote = false;
|
||||
ptrSPITObject = mSpitObjects.getEntry(message.getID());
|
||||
ptrSPITType = mSpitTypes.getEntry(message.getSPITTypeID());
|
||||
ptrSPITType = mProcessor.mSpitTypes.getEntry(message.getSPITTypeID());
|
||||
|
||||
if (ptrSPITType == nullptr) {
|
||||
// No associated SPITType found
|
||||
@@ -1020,7 +974,7 @@ void SClient::parseReportSPITObject(Message::ReportObject &message) {
|
||||
} else {
|
||||
boolRemote = true;
|
||||
ptrSPITObject = mRemoteSpitObjects.getEntry(message.getID());
|
||||
ptrSPITType = mRemoteSpitTypes.getEntry(message.getSPITTypeID());
|
||||
ptrSPITType = mProcessor.mRemoteSpitTypes.getEntry(message.getSPITTypeID());
|
||||
if (ptrSPITType == nullptr) {
|
||||
// No associated SPITType found
|
||||
return;
|
||||
@@ -1058,7 +1012,7 @@ void SClient::parseRemoveSPITObject(Message::RemoveObject &message) {
|
||||
ESP_LOGD(TAG, "parse RemoveObject %s", message.getID().c_str());
|
||||
SObject *ptrSPITObject = mRemoteSpitObjects.getEntry(message.getID());
|
||||
if (ptrSPITObject != nullptr) {
|
||||
SType *ptrSPITType = mRemoteSpitTypes.getEntry(ptrSPITObject->SPITTypeID.get());
|
||||
SType *ptrSPITType = mProcessor.mRemoteSpitTypes.getEntry(ptrSPITObject->SPITTypeID.get());
|
||||
if (ptrSPITType != nullptr) {
|
||||
mCallbacks.onSpitObject(ObjectEvent::Deleted, true, *ptrSPITType, *ptrSPITObject);
|
||||
}
|
||||
@@ -1094,7 +1048,7 @@ bool SClient::changeSPITObject(SObject *obj) {
|
||||
ptrSPITObject = mSpitObjects.getEntry(obj->getID());
|
||||
if (ptrSPITObject == nullptr)
|
||||
return false;
|
||||
ptrSPITType = mSpitTypes.getEntry(obj->getID());
|
||||
ptrSPITType = mProcessor.mSpitTypes.getEntry(obj->getID());
|
||||
if (ptrSPITObject == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -1141,7 +1095,7 @@ int SClient::removeSPITObject(string objId) {
|
||||
ptrSPITObject = mSpitObjects.getEntry(objId);
|
||||
if (ptrSPITObject == nullptr)
|
||||
return -1;
|
||||
ptrSPITType = mSpitTypes.getEntry(ptrSPITObject->SPITTypeID.get());
|
||||
ptrSPITType = mProcessor.mSpitTypes.getEntry(ptrSPITObject->SPITTypeID.get());
|
||||
if (ptrSPITType == nullptr)
|
||||
return -1;
|
||||
ptrSPITObject->fillMessageOP(sMRemoveSPITObject);
|
||||
@@ -1189,7 +1143,7 @@ void SClient::parsePlaySPITEnd(Message::PlayEnd &message) {
|
||||
SPlayer::PlayType *ptrPlaySPITType = i->second.get();
|
||||
bool boolStarted = ptrPlaySPITType->getIsNew();
|
||||
bool boolStopped = (ptrPlaySPITType->getIsPlayed() == false);
|
||||
SType *ptrSPITType = mSpitTypes.getEntry(ptrPlaySPITType->getSPITTypeID());
|
||||
SType *ptrSPITType = mProcessor.mSpitTypes.getEntry(ptrPlaySPITType->getSPITTypeID());
|
||||
if (ptrSPITType == nullptr) {
|
||||
// set isplayed to false, the ptrPlayObject will be removed by ptrSPITPlayer.endPlaySequence()
|
||||
ptrPlaySPITType->setIsPlayed(false);
|
||||
@@ -1211,9 +1165,9 @@ void SClient::parseReportPlayStatus(Message::ReportPlayStatus &message) {
|
||||
}
|
||||
}
|
||||
if (ptrSPITObject->ServerRemote.get() == false) {
|
||||
ptrSPITType = mSpitTypes.getEntry(ptrSPITObject->SPITTypeID.get());
|
||||
ptrSPITType = mProcessor.mSpitTypes.getEntry(ptrSPITObject->SPITTypeID.get());
|
||||
} else {
|
||||
ptrSPITType = mRemoteSpitTypes.getEntry(ptrSPITObject->SPITTypeID.get());
|
||||
ptrSPITType = mProcessor.mRemoteSpitTypes.getEntry(ptrSPITObject->SPITTypeID.get());
|
||||
}
|
||||
|
||||
if (ptrSPITType == nullptr) {
|
||||
|
||||
+1114
-1117
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user