//=============================================================================
//
//   File : kvi_lagmeter.h
//   Creation date : Fri Oct 18 13:30:26 CEST 2002 by Juanjo Álvarez
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 1999-2002 Szymon Stefanek (pragma at kvirc dot net)
//
//   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 opinion) 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 _KVI_LAGMETER_H_
#define _KVI_LAGMETER_H_


#include <qtimer.h>
#include <qdatetime.h>
#include "kvi_console.h"
#include "kvi_config.h"

#include <qdict.h>

class KVIRC_API KviLagMeter : public QObject
{
    Q_OBJECT
public:
    KviLagMeter(KviConsole * par);
    ~KviLagMeter();
protected:
    QTime m_pingTime;
    int m_iLagTime;
    int m_iInterval;
    int m_iLagAlarmTime;
    bool m_bPingSent;
    bool m_bEnabled;
    bool m_bOnAlarm;
    QTimer * m_intervalTimer;
    KviConsole * m_pConsole;
    KviStr  * m_tmpStr;
public:
    void enable();
    void disable();
    int  getLag(){return m_iLagTime;};
    bool pingSent(){return m_bPingSent;};
    void setLagCheckInterval(int interval){m_iInterval = interval;};
    int getLagCheckInterval(){return m_iInterval;};
    void setLagAlarmTime(int time){m_iLagAlarmTime = time;};
    int getLagAlarmTime(){return m_iLagAlarmTime;};
    bool isEnabled(){return m_bEnabled;};
    void pongReceived();
protected slots:
    void issuePing();
signals:
    void OnLagAlarmTimeUp();
    void OnLagAlarmTimeDown();
    void newLag(int lagTime); 
};

#endif // _KVI_LAGMETER_H_
