package meerkat.voting.gui.ui;

import com.google.common.util.concurrent.FutureCallback;
import meerkat.protobuf.Voting.*;

import java.util.List;


/**
 * An interface for the UI component of the voting booth
 */
public interface VotingBoothUI {

    /**
     * a simple enum for the voter's finalize choice
     */
    public enum FinalizeBallotChoice {
        CAST,
        AUDIT
    }

    /**
     * shut down the UI
     */
    public void callShutDown();

    /**
     * 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 when done
     */
    public void startNewVoterSession (FutureCallback<Void> callback);

    /**
     * Present a question to the voter to decide on his voting channel.
     * @param questions questions to determine the right voting channel for this voter
     * @param callback that's where we store the answers to decide channel upon for the current voter
     */
    public void chooseChannel (List<BallotQuestion> questions, FutureCallback<List<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 (List<BallotQuestion> questions, FutureCallback<List<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<Void> 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);

}
