networksensor.h

00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Hans Karlsson                                   *
00003  *   karlsson.h@home.se                                                      *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  ***************************************************************************/
00010 #ifndef NETWORKSENSOR_H
00011 #define NETWORKSENSOR_H
00012 
00013 #include "sensor.h"
00014 
00015 #include <qdatetime.h>
00016 #include <qfile.h>
00017 #include <qregexp.h>
00018 #ifdef __FreeBSD__
00019 #include <sys/types.h>
00020 #include <sys/socket.h>
00021 #include <net/if.h>
00022 #include <net/if_mib.h>
00023 #endif
00024 
00025 class NetworkSensor :  public Sensor
00026 {
00027     Q_OBJECT
00028 public:
00029     NetworkSensor( QString device, int interval );
00030     ~NetworkSensor();
00031     void update();
00032 
00033 
00034 private:
00035     unsigned long receivedBytes;
00036     unsigned long transmittedBytes;
00037     QTime netTimer;
00038     QString device;
00039 #ifdef __FreeBSD__
00040     int if_number;
00041     ifmibdata if_mib;
00042 #endif
00043     void getInOutBytes (unsigned long &in,unsigned long &out) const;
00044 
00045 };
00046 #endif // NETWORKSENSOR_H
00047 
KDE Home | KDE Accessibility Home | Description of Access Keys