meerkat-java/voting-booth/src/main/java/meerkat/voting/VotingBoothUI.java

72 lines
2.7 KiB
Java

package meerkat.voting;
import com.google.common.util.concurrent.FutureCallback;
import meerkat.protobuf.Voting.*;
/**
* An interface for the user interface component of the voting booth
*/
public interface VotingBoothUI {
public static enum FinalizeBallotChoice {
CAST,
AUDIT
}
/**
* Starts a new session for a voter. Presents whatever initial info is decided to show at the beginning
* @param callback - a boolean future callback to return success when done
*/
public void startNewVoterSession (FutureCallback<Boolean> callback);
/**
* Present a question to the voter to decide on his voting channel.
* @param question a question to determine the right voting channel for this voter
* @param callback that's where we store the channel for the current voter
*/
public void chooseChannel (BallotQuestion question, FutureCallback<BallotAnswer> callback);
/**
* Presents the set of questions to the voter. Collect all his responses.
* @param questions all ballot questions to present to the voter
* @param callback the responses to the questions collected by the UI, to send back to the controller. Responses are null if voter chose to cancel session
*/
public void askVoterQuestions (BallotQuestion[] questions, FutureCallback<BallotAnswer[]> callback);
/**
* Get a response from the voter on how to finalize the ballot.
* @param callback the returned choice of how to finalize the ballot
*/
public void castOrAudit (FutureCallback<FinalizeBallotChoice> callback);
// Admin scenario methods
//TODO: the admin scenario still needs some more thinking
/**
* present a wait-for-finish screen to the voter
* @param message a message to show the user on the UI device while waiting
* @param callback a success return value of the wait (cancelling returns false)
*/
public void notifyVoterToWaitForFinish (UIElement message, FutureCallback<Boolean> callback);
/**
* show a fatal error message in the UI. Halts system. Waits for administrator interrupt or reset
* @param errorMessage message to show in UI device
* @param callback returns interrupt
*/
public void showErrorMessageAndHalt (UIElement errorMessage, FutureCallback<Boolean> callback);
/**
* show an error message and let user press his chosen button for continuation
* @param errorMessage message to show in UI device
* @param buttonLabels labels for buttons to present to voter
* @param callback the number of the selected button
*/
public void showErrorMessageWithButtons (UIElement errorMessage, UIElement[] buttonLabels,
FutureCallback<Integer> callback);
}