//
//  The contents of this file are subject to the Mozilla Public License
//  Version 1.0 (the "License"); you may not use this file except in
//  compliance with the License. You may obtain a copy of the License at
//  http://www.mozilla.org/MPL/
// 
//  Software distributed under the License is distributed on an "AS IS"
//  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
//  the License for the specific language governing rights and limitations
//  under the License.
// 
//  The Original Code is CPhone, a cross platform voip gui.
//
//  The Initial Developer of the Original Code is Derek Smithies.
//
//  Copyright (C) 2002 Indranet Technologies Ltd, 
//                                  http://www.indranet-technologies.com
//  All Rights Reserved.
//
//  Contributor(s): _______________


/*
 *  $Log: statisticsSub.h,v $
 *  Revision 1.3  2003/09/02 03:37:32  dereksmithies
 *  Add statistics, new icons, toolbuttons (icon + name)
 *
 *  Revision 1.2  2003/08/26 04:48:02  dereksmithies
 *  Fixes to get statistics working right, add icons, add ok,cancel,apply buttons
 *
 *  Revision 1.1  2003/08/26 03:31:12  dereksmithies
 *  Initial release of statistics display
 *
 *
 *
 *
 *
 */


#ifndef STATISTICS_H
#define STATISTICS_H

#include "statistics.h"
#include <ptlib.h>
#include "mainwindowSub.h"
#include <qtimer.h>
#define DATA_ELEMS 40


class StatisticsPacket : public PObject
{ 
  PCLASSINFO(StatisticsPacket, PObject);
 public:
  StatisticsPacket(H323Connection *connection, unsigned sessionId);
  
  unsigned GetPacket(bool isSend);
  unsigned GetOctets(bool isSend);
  double   GetRate  (bool isSend);

  void operator-=(PObject *src);
 
  PTime thisTime;
 
 protected:
  unsigned packetsSent;
  unsigned packetsReceived;

  unsigned octetsSent;
  unsigned octetsReceived;
  
  double rateSent;
  double rateReceived;
};

//////////////////////////////////////////////////////////////////////

PDECLARE_LIST(StatisticsPacketList, StatisticsPacket)
#if 0                                 //Fix emacs bracket matching test.
{
#endif
 public:
  ~StatisticsPacketList();

  StatisticsPacket *GetEntry(PINDEX i);

  void AppendElem(StatisticsPacket *pack);
};

//////////////////////////////////////////////////////////////////////

class Statistics : public FormStatistics
{ 
 public:

    Statistics();
    ~Statistics();

    void Setup();

    //slots to cope with system events.
    void closeEvent(QCloseEvent *e);
    void customEvent(QCustomEvent *e);

    void ApplySlot();
    void CancelSlot();
    void OkSlot();
    
 protected:
    void timerEvent(QTimerEvent *);

    PObject *audioPackets;
    PObject *videoPackets;

    PTime startTime;
    BOOL  inCall;
};

#endif // STATISTICS_H


syntax highlighted by Code2HTML, v. 0.9.1