// \file SNFServerConfig.hpp
//
// Copyright (C) 2012 ARM Research Labs, LLC.
// See www.armresearch.com for the copyright terms.
//
// This file defines the SNFServerConfig interface.
//
// $Id$
//
///////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef SNFServerConfighpp_included
#define SNFServerConfighpp_included

#include <string>

#include "UtilityConfig.hpp"
#include "PostfixIntegrate.hpp"
#include "SendmailIntegrate.hpp"

/// Class to manage the SNFServer configuration.
//
// This class creates/maintains the sniffer configuration file, and
// integrates/unintegrates with MTAs.
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////
class SNFServerConfig : public UtilityConfig {

public:

    /// Command specified.
    enum CommandEnum {
	SetupRepairCommand, ///< Setup or repair the configuration.
	UpdateCredentialsCommand, ///< Update the credentials.
	IntegrateWithPostfixCommand, ///< Integrate with postfix.
	IntegrateWithSendmailCommand, ///< Integrate with sendmail.
	IntegrateWithNoneCommand, ///< Unintegrate with all supported MTAs.
	StartSnifferCommand, ///< Start the Sniffer.
	StopSnifferCommand, ///< Stop the Sniffer.
	NoCommand, ///< No command specified.
	UnknownCommand ///< Unknown.
    };

    /// Display usage.
    //
    // \param[in] Version is the SNFServer version.
    //
    void DisplayHelp(std::string Version);

    /// Get the command-line input parameters for SNFServer.
    //
    // \param[in] argc is the number of parameters.
    //
    // \param[in] argv is the parameters.
    //
    // \returns true if all the required command line parameters are
    // present and there are no unknown command-line parameters, false
    // otherwise.
    //
    bool GetCommandLineInput(int argc, char* argv[]);

    /// Execute the command specified by the command-line parameters.
    //
    void ExecuteCommand(void);

    /// Save the state of all files that might be changed, except the
    /// config file.
    //
    void SaveFileState(void); // OBSOLETE.

private:

    PostfixIntegrate Postfix; ///< Postfix integration object.

    SendmailIntegrate Sendmail; ///< Sendmail integration object.

    /// Unintegrate with MTAs.
    //
    // Unintegrate with all MTAs except the specified MTA.
    //
    // \param[in] Except is the MTA to not integrate with.  The
    // acceptable values are:
    //
    // <ol>
    //   <li> "postfix" </li>
    //   <li> "sendmail" </li>
    //   <li> "" </li>
    // </ol>
    //
    // The default value is "", which specifies unintegration with all
    // MTAs.
    //
    void UnintegrateWithAllExcept(std::string Except = "");

    CommandEnum Command; ///< Specified command.

    static const std::string DefaultConfigFile; ///< Default config file.

    static const std::string SampleConfigFile; ///< Sample config file.

    static const std::string SampleIdentityFile; ///< Sample identity file.

    static const std::string ApplicationName; ///< Application name.

};

#endif
