package meerkat.voting.storage;

import meerkat.protobuf.Voting.*;

import java.io.IOException;
import java.util.Map;

/**
 * An interface for the storage component of the voting booth
 */
public interface StorageManager {

    /**
     * Detect whether an administration key is inserted to the machine. This determines if we gointo the set-up flow or the voting session flow.
     * @return True is a hardware key is inserted. False if not.
     */
    public boolean isAdminHardwareKeyInserted();

    /**
     * load the election params from the storage.
     * @return the current election params
     * @throws IOException
     */
    public ElectionParams readElectionParams () throws IOException;

    /**
     * write the election parameters protobuf to the storage
     * @param params ElectionParams protobuf to save
     * @throws IOException
     */
    public void writeElectionParams(ElectionParams params) throws IOException;


    public Map<String, UIElement> readSystemMessages() throws IOException;

    // These are just static key identifiers for accessing the matching System Messages in the message map
    public final static String WAIT_FOR_COMMIT_MESSAGE = "waitForCommit";
    public final static String WAIT_FOR_AUDIT_MESSAGE = "waitForAudit";
    public final static String WAIT_FOR_CAST_MESSAGE = "waitForCast";
    public final static String RESTART_VOTING_BUTTON = "restartVotingButton";
    public final static String UNRECOGNIZED_FINALIZE_RESPONSE_MESSAGE = "unrecognizedFinalizeResponse";
    public final static String UNSUCCESSFUL_CHANNEL_CHOICE_MESSAGE = "unsuccessfulChannelChoice";
    public final static String OUTPUT_DEVICE_FAILURE_MESSAGE = "outputDeviceFailure";
    public final static String UNSUCCESSFUL_VOTING_MESSAGE = "unsuccessfulVoting";
    public final static String SOMETHING_WRONG_MESSAGE = "somethingWrong";
    public final static String ENCRYPTION_FAILED_MESSAGE = "encryptionFailed";
    public final static String RETRY_BUTTON = "retryButton";
    public final static String CANCEL_VOTE_BUTTON = "cancelVoteButton";
}
