/***************************************************************************
 *   Copyright (C) 2004 by Judd Baileys                                    *
 *   jbaileys@bigpond.net.au                                               *
 *                                                                         *
 *   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.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#ifndef _KDSL_H_
#define _KDSL_H_

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


#include <qtimer.h>
#include <qevent.h>
#include <kdialog.h>
#include <kmainwindow.h>
#include <qvariant.h>
#include <qpixmap.h>
#include <qwidget.h>
#include "prefdialog.h"
#include "configuration.h"
#include "pppstats.h"
#include <kprocess.h>
#include <kaction.h>
#include "docking.h"
#include "connections.h"
#include "notify.h"
#include <kpassdlg.h>
#include <stdio.h>
#include <qtextedit.h>
#include <qtextview.h>

/**
 * @short Application Main Window
 * @author Judd Baileys <jbaileys@bigpond.net.au>
 * @version 0.5
 */
 class QCheckBox;
 class PrefDialog;
 class DocBrowser;
 class QGridLayout;
 class Startwin;
class Configuration;
class PPPStats;
class DockWidget;
class Notify; 
class PrefGeneral;
class KdslStats;

class SignalEvent : public QEvent {
public:
  SignalEvent(int s) : QEvent(User), sig(s) { }
  int sigType() const { return sig; }
  
private:
  int sig;


    
}; 

 
class kdsl : public QWidget
{
    Q_OBJECT
public:
    kdsl(QWidget *parent=0, const char *name=0);
    virtual ~kdsl();
     void setpasswordLineEdit(const QString &);
    virtual bool eventFilter(QObject *, QEvent *);   

    bool queryClose( void );       
    bool queryExit( void );
    bool setShown();
    QString  m_device;
    QString  m_username;
    QString buf;
    QTextEdit *edit;
    QTextView *logWindow;
    KDialog* aboutDialog;
    FILE* m_pipeout;
    bool ipFound;
    enum ResultCodes { AsUser = 10 };
    QCString m_User;
    QString encodeWord(const QString &s);
    const char *command;
    void startClock();
    void stopClock();
    QString istatus;
    QString ostatus;   
    QGridLayout* StartwinLayoutMain;

    
public slots:
    void executePreferencesDlg();
    void applyPreferences();   
     void resetaccounts();
    void con();
    void discon();
    void connected();
    void startProcess();
    void disconnected( void );
    void getStats();
    void interfaceUp();
    void interfaceDown();
    void lostConnection();
    void ipUp();
    void iconConnect();
    void iconDisconnect();
    void setWidgets();
    void passwordChanged();
    void newdefaultaccount( int );
    void saveMyself();
    void shutDown();   
    void expandbutton();
    void setup();
    void showAbout();
    void checkStatus();
    void if_waiting_timed_out();
    void init();
    void log_window_toggled(bool on);
    void script_timed_out();    
             
protected:
    QGridLayout* StartwinLayout;
  void timerEvent(QTimerEvent *);
    
 private slots:
  void if_waiting_slot();
  void timeclick();
  void autostart_end();

public:
    PPPStats *stats;
    Startwin *startwin;   
    Notify* notify_widget;   
    DockWidget* dock_widget;        
    PrefGeneral    *m_prefGeneral;
    QString time_string2;    
    kdslStats *kdsl_stats;
private:
  QLabel *info1;
  QLabel *info2;
  PrefDialog *m_prefDialog;
  int minutes;
  int seconds;
  int hours;
  int days; 
  
  void interruptConnection();
  void sigChld();   
  void sigPPPDDied();
  QTimer *inittimer;
   QString caption_string;
//  QString time_string2;
  QString time_string; 
  QTimer *timeout_timer;
  bool execppp();
  QTimer *clocktimer;  
  QTimer *if_timer;
  QTimer *if_timeout_timer;
  QTimer *autostart_timer;
  DocBrowser *browser;
  Notify *notify;
  	int pos_x;
	int pos_y;
	
signals:
    void resetStatus();
    void onlineUp();
   void cmdl_start();
   void begin_connect();
   void if_waiting_signal();
    /**
     * Default Destructor
     */
  
};

extern void killppp();
void adddns();
void addpeerdns();
void removedns();
	  


#endif // _KDSL_H_
