/*
** SellaNMS
** $Id: gui.h,v 1.9 2005/11/06 04:51:22 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __DGS_OUTPUT_GUI_H
#define __DGS_OUTPUT_GUI_H

#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#include "defaults.h"
#include "common/util.h"
#include "policy_framework/policy_framework.h"
#include "storage/storage.h"
#include <stdio.h>
#include <stdlib.h>
#include <stl/slist>
#include <stl/string>

#define OUTPUT_GUI_INTERVAL_DEF			15		//15 sec
#define OUTPUT_GUI_INTERVAL_MIN			1		//1 sec
#define OUTPUT_GUI_INTERVAL_MAX			900	//15 min
#define OUTPUT_GUI_INTERVAL_MLT			1000000
#define OUTPUT_GUI_EXPIREINTERVAL_DEF	120	//2 min
#define OUTPUT_GUI_EXPIREINTERVAL_MIN	1		//1 sec
#define OUTPUT_GUI_EXPIREINTERVAL_MAX	86400	//1 day
#define OUTPUT_GUI_EXPIREINTERVAL_MLT	1000000
#define OUTPUT_GUI_EXPIREDELETE_DEF		250
#define OUTPUT_GUI_EXPIREDELETE_MIN		1
#define OUTPUT_GUI_EXPIREDELETE_MAX		1000
#define OUTPUT_GUI_QUEUEDEPTH_DEF		250
#define OUTPUT_GUI_QUEUEDEPTH_MIN		1
#define OUTPUT_GUI_QUEUEDEPTH_MAX		32000

typedef struct output_t {
   unsigned long  id;
   string         timestamp;
   time_t         unix_timestamp;
   string         element;
   string         interface;
   string         ip;
   string         source;
   string         module;
   string         protocol;
   string         channel;
   string         state;
   string         brief;
   string         detail;
} _output_t;

class Gui {
	public:
		Gui();
		virtual ~Gui();
		virtual RESULT execute();
		virtual RESULT readConfig();

	protected:
		virtual void printConfig();

		virtual RESULT policyInputNext(variable_binding_t &policy_input);
		virtual RESULT processPolicyOutput(variable_binding_t &policy_output);
		virtual RESULT readOutput(const string &module);
		virtual RESULT deleteOutput(slist<unsigned long> &output_ids);
		virtual RESULT getPolicyStateList(slist<string> &stateList);

		virtual RESULT buildExpirePolicyInput(variable_binding_t &policy_input, StorageData &data);
		virtual RESULT deleteExpiredEntries(slist<string> &expired_list);

	private:
		static RESULT expire_thread(void *args);

		Storage storage;
		slist<output_t> output;

		unsigned long interval;
		unsigned long expireInterval;
		unsigned long queueDepth;
		unsigned long maxExpireDelete;

      PolicyFramework inputPolicy;
      PolicyFramework outputPolicy;
		slist<string> stateList;
};

#endif

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim600: fdm=marker
** vim: noet ts=3 sw=3
*/
