/***************************************************************************
 *   Copyright (C) 2004-2010 by Giovanni Venturi                           *
 *   giovanni@ksniffer.org                                                 *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA  02110-1301, USA.          *
 ***************************************************************************/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <KXmlGuiWindow>
#include <KUrl>
#include <KConfigGroup>

class KSystemTrayIcon;
class KAction;
class PacketListView;

class MainWindow : public KXmlGuiWindow
{
  Q_OBJECT
 
  public:
    MainWindow(QWidget *parent=0);
    void openFile(const QString &inputFileName);
 
  private:
    PacketListView* m_packetListView;
    QString m_fileName;
    KConfigGroup m_config;
    KSystemTrayIcon *m_tray;
    
  /**
   * The status bar action
   */
  //KToggleAction *m_statusbarAction;

  /**
   * The action to start new network packet-capture
   */
  KAction *m_actNew;

  /**
   * The action to open a file
   */
  KAction *m_actOpen;

  /**
   * The action to save a file with all captured packets
   */
  KAction *m_actSave;

  /**
   * The action to "save as" a file with all captured packets
   */
  KAction *m_actSaveAs;

  /**
   * the action to print captured packets
   */
  //KAction *m_actPrint;

  /**
   * The action to pause/continue capturing packets
   */
  KAction *m_actPauseContinue;

  /**
   * The action to stop packets capture
   */
  KAction *m_actStop;

  /**
   * The action to quit packets capture
   */
  KAction *m_actQuit;

  /**
   * The string for the what's this help for Pause/Continue Capture
   */
  QString m_whatsthisPause;

  /**
   * The action to open recent URL
   */
//  KRecentFilesAction *m_actOpenRecent;

  /**
   * Data need to be saved when available
   */
  bool m_needToSavePackets;

  private:
    void setupActions();
    void setupTray();
 
  private slots:
    /**
     * This is executed when you choose the "New Capture" action
     */
    void slotNewCapture();

    /**
     * This is executed when you choose the "Open" action
     */
    void slotOpen( const KUrl& urlParam = KUrl("") );

    /**
     * This is executed when you choose the "Save" action
     */
    void slotSave();

    /**
     * This is executed when you choose the "SaveAs" action
     */
    void slotSaveAs();

    /**
     * This is executed when you choose the "Print" action
     */
    //void slotPrint();

    /**
     * This is executed when you choose the "Pause/Continue" action
     */
    void slotPauseContinue();

    /**
     * This is executed when you choose the "Stop" action
     */
    void slotStop();

    /**
     * This is executed when you choose the "Quit" action
     */
    void slotQuit();

    /**
     * This is executed if the user wants to update the settings
     */
    void slotShowSettings();
};

#endif
