refactor: concentrating repo functions into repo class
This commit is contained in:
+39
-39
@@ -733,20 +733,20 @@ void onProjectUpdate(SPIT_Client::ProjUpdate state, string projectId) {
|
||||
bool onCheckSpitTypeVeto(SPIT_Message::ReportSPITType *p_ReportSPITType) {
|
||||
return true; // Bypass veto
|
||||
|
||||
if (p_ReportSPITType == nullptr)
|
||||
return true;
|
||||
SPITType *ptrSPITType;
|
||||
ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID());
|
||||
// if (p_ReportSPITType == nullptr)
|
||||
// return true;
|
||||
// SPITType *ptrSPITType;
|
||||
// ptrSPITType = SPITType::getSPITType(p_ReportSPITType->getID());
|
||||
|
||||
// Don't allow foreign SPITTypes
|
||||
if (ptrSPITType == nullptr) {
|
||||
// ESP_LOGW(TAG, "ObjectVeto NoSpitType");
|
||||
return false;
|
||||
}
|
||||
if (ptrSPITType->getCreatedByClient() == false) {
|
||||
// ESP_LOGW(TAG, "getCreatedByClient");
|
||||
return false;
|
||||
}
|
||||
// if (ptrSPITType == nullptr) {
|
||||
// // ESP_LOGW(TAG, "ObjectVeto NoSpitType");
|
||||
// return false;
|
||||
// }
|
||||
// if (ptrSPITType->getCreatedByClient() == false) {
|
||||
// // ESP_LOGW(TAG, "getCreatedByClient");
|
||||
// return false;
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -755,23 +755,23 @@ bool onCheckSpitObjectVeto(SPIT_Message::ReportSPITObject *p_ReportSPITObject) {
|
||||
|
||||
if (p_ReportSPITObject == nullptr)
|
||||
return true;
|
||||
SPITType *ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID());
|
||||
if (ptrSPITType == nullptr) {
|
||||
// ESP_LOGW(TAG, "ObjectVeto NoSpitObj");
|
||||
return false;
|
||||
}
|
||||
// SPITType *ptrSPITType = SPITType::getSPITType(p_ReportSPITObject->getSPITTypeID());
|
||||
// if (ptrSPITType == nullptr) {
|
||||
// // ESP_LOGW(TAG, "ObjectVeto NoSpitObj");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// Don't allow SPITObjects which refers to a SPITType which is not created by this client - other SPITTypes cannot be handled here
|
||||
if (ptrSPITType->getCreatedByClient() == false) {
|
||||
// ESP_LOGW(TAG, "getCreatedByClient");
|
||||
return false;
|
||||
}
|
||||
SPITObject *ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITObject->getID());
|
||||
// Don't allow foreign SPITTypes
|
||||
if (ptrSPITObject == nullptr) {
|
||||
// ESP_LOGE(TAG, "Unknown ID");
|
||||
return false;
|
||||
}
|
||||
// if (ptrSPITType->getCreatedByClient() == false) {
|
||||
// // ESP_LOGW(TAG, "getCreatedByClient");
|
||||
// return false;
|
||||
// }
|
||||
// SPITObject *ptrSPITObject = SPITObject::getSPITObject(p_ReportSPITObject->getID());
|
||||
// // Don't allow foreign SPITTypes
|
||||
// if (ptrSPITObject == nullptr) {
|
||||
// // ESP_LOGE(TAG, "Unknown ID");
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -790,18 +790,18 @@ void onSpitType(SPIT_Client::ObjectEvent event, bool isRemote, const SPITType &p
|
||||
} else if (event == SPIT_Client::ObjectEvent::Changed) {
|
||||
// we had to inform all Remote SPITObjects using the p_SPITType
|
||||
// perhaps the SPITObject uses information from the SPITType
|
||||
SPITObject *ptrSPITObject;
|
||||
int intSPITObjectCount;
|
||||
intSPITObjectCount = SPITObject::getSPITObjectRemoteCount();
|
||||
for (int intObject = 0; intObject < intSPITObjectCount; intObject++) {
|
||||
ptrSPITObject = SPITObject::getSPITObjectRemote(intObject);
|
||||
if (ptrSPITObject == nullptr)
|
||||
continue;
|
||||
if (ptrSPITObject->getSPITTypeID() == p_SPITType.getID()) {
|
||||
// call ecentSPITObjectRemote
|
||||
// onSpitObjectRemote(SPIT_Client::ObjectEvent::Changed, p_SPITType, *ptrSPITObject);
|
||||
}
|
||||
}
|
||||
// SPITObject *ptrSPITObject;
|
||||
// int intSPITObjectCount;
|
||||
// intSPITObjectCount = SPITObject::getSPITObjectRemoteCount();
|
||||
// for (int intObject = 0; intObject < intSPITObjectCount; intObject++) {
|
||||
// ptrSPITObject = SPITObject::getSPITObjectRemote(intObject);
|
||||
// if (ptrSPITObject == nullptr)
|
||||
// continue;
|
||||
// if (ptrSPITObject->getSPITTypeID() == p_SPITType.getID()) {
|
||||
// // call ecentSPITObjectRemote
|
||||
// // onSpitObjectRemote(SPIT_Client::ObjectEvent::Changed, p_SPITType, *ptrSPITObject);
|
||||
// }
|
||||
// }
|
||||
ESP_LOGI(TAG, "SPIT-REMOTE-Type CHANGED ID: %s GroupName: %s Name: %s confirmed: %d", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data(), p_SPITType.getConfirmed());
|
||||
} else if (event == SPIT_Client::ObjectEvent::Deleted) {
|
||||
ESP_LOGD(TAG, "SPIT-REMOTE-Type Removed ID: %s GroupName: %s Name: %s\n", p_SPITType.getID().data(), p_SPITType.getGroupName().data(), p_SPITType.getName().data());
|
||||
|
||||
Reference in New Issue
Block a user