super(myWebInterface, viewer, request, _baseL10n);
mIdentityManager = (WoTIdentityManager)mFreetalk.getIdentityManager();
synchronized(mFreetalk.getTaskManager()) {
IntroduceIdentityTask myTask;
try {
myTask = (IntroduceIdentityTask)mFreetalk.getTaskManager().getTask(mTaskID);
} catch(NoSuchTaskException e) {
throw new IllegalArgumentException(e);
}
if(request.isPartSet("Postpone")) {
myTask.onHideForSomeTime();
mNumberOfPuzzles = 0;
mWasPostponed = true;
return;
} else
mWasPostponed = false;
if(!request.isPartSet("SolvePuzzles")) {
// We received an invalid request
mNumberOfPuzzles = 0;
return;
}
int idx = 0;
while(request.isPartSet("PuzzleID" + idx)) {
String id = request.getPartAsString("PuzzleID" + idx, 128);
String solution = request.getPartAsString("Solution" + id, 32); /* TODO: replace "32" with the maximal solution length */
if(!solution.trim().equals("")) {
try {
mIdentityManager.solveIntroductionPuzzle((WoTOwnIdentity)mOwnIdentity, id, solution);
myTask.onPuzzleSolved();
}
catch(Exception e) {
/* The identity or the puzzle might have been deleted here */
Logger.error(this, "solveIntroductionPuzzle() failed", e);
}
}
++idx;
}
mNumberOfPuzzles = myTask.getNumberOfPuzzlesToSolve();
}
}