/*
 * Copyright (C) 2004 Robert Hogan <robert at roberthogan dot net>
 */

#ifndef _KLAMD_H_
#define _KLAMD_H_

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <tdeapplication.h>
#include <tdemainwindow.h>
#include <tqlistview.h>
#include <tqlistbox.h>
#include "tdefiletreeview.h"



class KPrinter;
class TDEToggleAction;
class KURL;
class TQLineEdit;
class TQComboBox;
class TQCheckBox;
class TQListBox;
class TQPushButton;
class TQLabel;
class TDEProcess;
class TDEConfig;
class KURLRequester;
class K3bFileTreeView;
class KArrowButton;
class KProcIO;
class KSystemTray;

class MyListBox : public TQListBox
{

public:
	MyListBox(TQWidget *parent) : TQListBox(parent) {}
	bool isItemVisible(int id) { return itemVisible(id); }
};

/**
 * This class serves as the main window for Klamd.  It handles the
 * menus, toolbars, and status bars.
 *
 * @short Main window class
 * @author $AUTHOR <$EMAIL>
 * @version $APP_VERSION
 */
class Klamd :  public TQWidget
{
    Q_OBJECT
public:
    /**
     * Default Constructor
     */
    Klamd(TQWidget *parent, const char *name=0);

    /**
     * Default Destructor
     */
    virtual ~Klamd();

    /**
     * Use this method to load whatever file/URL you have
     */
    void  setDirName(TQString);
    bool isKlamdAlive();
    TQString  getKlamdConfFile();
    
public slots:
    bool startKlamd();
    void slotCancel();
    
protected:
    /**
     * Overridden virtuals for TQt drag 'n drop (XDND)
     */
    /*virtual void dragEnterEvent(TQDragEnterEvent *event);
    virtual void dropEvent(TQDropEvent *event);*/

protected:
    /**
     * This function is called when it is time for the app to save its
     * properties for session management purposes.
     */
    //void saveProperties(TDEConfig *);

    /**
     * This function is called when this app is restored.  The TDEConfig
     * object points to the session management config file that was saved
     * with @ref saveProperties
     */
    //void readProperties(TDEConfig *);


public:
private:
    void setupAccel();
    void setupActions();

private:
    //KlamdView *m_view;

  /*  KPrinter   *m_printer;
    TDEToggleAction *m_toolbarAction;
    TDEToggleAction *m_statusbarAction;*/


signals:
    void itemSelected(TQString abs_filename, int line);



private slots:
    //void dirButtonClicked();
    //void templateActivated(int index);
    void childExited();
    void receivedOutput(KProcIO *);
    //void itemSelected(const TQString&);
    void slotClear();
    void slotAddIncludeDir();
    void slotAddExcludeDir();
    void slotDelIncludeDir();
    void slotDelExcludeDir();
    void writeConf();
    void Quarantine(TQString fname, TQString virusname);
    void restoreKlamd();
    void handleChecks();
    void checkForDazuko();
    void loadDazuko();
    void lsmodOutput();
    void lsmodCheck();
    void moduleLoaded();
    void receivedmvOutput(KProcIO *);
    void slotAdvOptions();

    //void patternTextChanged( const TQString &);
private:
    void processOutput();
    void finish();
    void getout();
    int runDazuko(bool caller);
    void loadKlamd();
    void enableInputs();
    void disableInputs();
    TQLineEdit *template_edit;
    TQComboBox *files_combo, *pattern_combo/*, *dir_combo*/;
    KURLRequester *dir_combo;
    TQCheckBox *recursive_box;
    TQCheckBox *recursive_box1;
    TQCheckBox *recursive_box2;
    TQListBox *resultbox;
    TQLabel *status_label, *matches_label;
    KProcIO *childproc;
    KProcIO *proc; 
    KProcIO *lsmodproc;
    TQString buf, bufmv, mvbuffer;
    TDEConfig* config;
    TQStringList lastSearchItems;
    TQStringList lastSearchPaths;
    TQStringList lastQuarItems;
    TQListView* table;
    MyListBox	*sessionslb;
    KArrowButton    *btnup, *btndown;
    KFileTreeView* m_fileTreeView;
    KFileTreeBranch* treeBranch;
    MyListBox	*sessionslb2;
    KArrowButton    *btnup2, *btndown2;
    KFileTreeView* m_fileTreeView2;
    KFileTreeBranch* treeBranch2;
    TQString tempFileName;
    TQComboBox *check_combo;
    TQComboBox *check_combo2;
    TQString item2;
    TQStringList includePaths;
    TQStringList excludePaths;
    bool dazukoLoaded;
    bool klamdAlive;
    TQWidget *parent;
    TQString tmpit;
    TQString clamdcommand;
    //TQPushButton *adv_options;
    TQWidget *hlp;
    TQWidget *hlp2;
    TQWidget *hlp3;
public:
    TQPushButton *search_button, *cancel_button;


};

#endif // _Klamd_H_
