void CSchedule::executeTask(CTask * paramTask) { string sendString; char sendBuffer[1000]; CModificationInformation * modificationInformation; CAccount * account; int i; switch(paramTask->type) { case 1: if (!paramTask->correctPassword) { sendString = "02524fThe password is wrong."; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 28); break; } modificationInformation = paramTask->modificationInformation; if (modificationInformation->nrOfExpectedDescriptionLines != modificationInformation->nrOfReceivedDescriptionLines) { sendString = "05024fCould not receive all lines of the description."; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 53); break; } account = getAccountFromId(paramTask->id); if (((i = getIdFromName(modificationInformation->firstName)) > 0) && (i != modificationInformation->id)) { sendString = "04924fAn account with the first Name already exists."; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 52); break; } if (((i = getIdFromName(modificationInformation->secondName)) > 0) && (i != modificationInformation->id)) { sendString = "05024fAn account with the second Name already exists."; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 53); break; } if (((i = getIdFromName(modificationInformation->thirdName)) > 0) && (i != modificationInformation->id)) { sendString = "04924fAn account with the third Name already exists."; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 52); break; } account->setFirstName(modificationInformation->firstName); account->setSecondName(modificationInformation->secondName); account->setThirdName(modificationInformation->thirdName); account->setPrivateNrOfEvaluatedTtrsGames(modificationInformation->privateNrOfEvaluatedTtrsGames); account->setDescription(modificationInformation->description); sendString = "00324s"; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 6); // Protocol Send-Syntax: 24:{s,f}ErrorMessage saveToFile(pathToFileToSaveTo); cout << "Modified account:" << endl; account->printDetails(); break; case 2: if (!paramTask->correctPassword) { sendString = "02529fThe password is wrong."; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 28); break; } account = getAccountFromId(paramTask->id); account->setPassword(paramTask->string1); sendString = "00329s"; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 6); // Protocol Send-Syntax: 29:{s,f}ErrorMessage saveToFile(pathToFileToSaveTo); cout << "Changed password of account (id = " << paramTask->id << ")." << endl << endl; break; case 3: if (!paramTask->correctPassword) { sendString = "02531fThe password is wrong."; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 28); break; } removeAccount(paramTask->id); sendString = "00331s"; strcpy(sendBuffer, sendString.c_str()); sendCommand(paramTask->socketFd, sendBuffer, 6); // Protocol Send-Syntax: 31:{s,f}ErrorMessage saveToFile(pathToFileToSaveTo); break; default: break; } }