1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-10-19 19:59:43 +00:00

- Update to version 0.34

- Remove upstream applied patches
This commit is contained in:
Markus Brueffer 2004-07-13 21:30:08 +00:00
parent e91906cecf
commit fee1be13a0
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=113586
13 changed files with 9 additions and 694 deletions

View File

@ -5,11 +5,11 @@
# $FreeBSD$
PORTNAME= superkaramba
PORTVERSION= 0.33
PORTREVISION= 5
PORTVERSION= 0.34
CATEGORIES= deskutils kde
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE}
MASTER_SITE_SUBDIR= netdragon
DISTNAME= ${PORTNAME}-${PORTVERSION}-1
MAINTAINER= markus@FreeBSD.org
COMMENT= KDE tool that allows interactive eye-candy on the desktop
@ -22,6 +22,7 @@ LIB_DEPENDS= xmms.4:${PORTSDIR}/multimedia/xmms
RUN_DEPENDS= mbmon:${PORTSDIR}/sysutils/xmbmon
.endif
WRKSRC= ${WRKDIR}/${DISTNAME:S/-1//}
USE_KDEBASE_VER= 3
GNU_CONFIGURE= yes
USE_GMAKE= yes

View File

@ -1,2 +1,2 @@
MD5 (superkaramba-0.33.tar.gz) = 132d094a8e35383c757aaf5739fcb856
SIZE (superkaramba-0.33.tar.gz) = 1343029
MD5 (superkaramba-0.34-1.tar.gz) = a3d981f62b8bc6aeb519706672fe3255
SIZE (superkaramba-0.34-1.tar.gz) = 1299148

View File

@ -1,11 +0,0 @@
--- configure.orig Mon Oct 20 05:45:57 2003
+++ configure Mon Oct 20 05:49:00 2003
@@ -31352,7 +31352,7 @@
ac_save_libs="$LIBS"
LIBS="`xmms-config --libs`"
ac_CPPFLAGS_save="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS $all_includes `xmms-config --cflags`"
+ CPPFLAGS="$CPPFLAGS $all_includes `xmms-config --cflags` $LIBPTHREAD"
ac_LDFLAGS_save="$LDFLAGS"
LDFLAGS="$LDFLAGS $all_libraries"
cat >conftest.$ac_ext <<_ACEOF

View File

@ -1,53 +0,0 @@
--- src/cpusensor.cpp.orig Mon Apr 21 15:17:03 2003
+++ src/cpusensor.cpp Wed Aug 27 16:27:57 2003
@@ -8,6 +8,14 @@
* (at your option) any later version. *
***************************************************************************/
+#ifdef __FreeBSD__
+#include <sys/time.h>
+#include <sys/dkstat.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/resource.h>
+#endif
+
#include "cpusensor.h"
CPUSensor::CPUSensor( QString cpu, int interval ) : Sensor( interval )
@@ -24,6 +32,19 @@
void CPUSensor::getTicks (long &u,long &s,long &n,long &i)
{
+#ifdef __FreeBSD__
+ static long cp_time[CPUSTATES];
+
+ size_t size = sizeof(cp_time);
+
+ /* get the cp_time array */
+ if (sysctlbyname("kern.cp_time", &cp_time, &size, NULL, 0) != -1) {
+ u = cp_time[CP_USER];
+ s = cp_time[CP_SYS] + cp_time[CP_INTR];
+ n = cp_time[CP_NICE];
+ i = cp_time[CP_IDLE];
+ }
+#else
QFile file("/proc/stat");
QString line;
if ( file.open(IO_ReadOnly | IO_Translate) )
@@ -46,6 +67,7 @@
i = rx.cap(4).toLong();
file.close();
}
+#endif
else
{
u = 0;
@@ -53,7 +75,6 @@
n = 0;
i = 0;
}
-
}
int CPUSensor::getCPULoad()

View File

@ -1,38 +0,0 @@
--- src/karamba.cpp.orig Sun Oct 19 22:02:45 2003
+++ src/karamba.cpp Mon Feb 9 00:57:18 2004
@@ -2243,7 +2243,7 @@
//Matthew Kay: set window type to "dock" (plays better with taskbar themes this way)
- KWin::setType(winId(), NET::Dock);
+ //KWin::setType(winId(), NET::Dock);
widgetMask = 0;
info = new NETWinInfo( qt_xdisplay(), winId(), qt_xrootwin(), NET::WMState );
@@ -2662,6 +2662,26 @@
}
+ if( getBoolean("RIGHTBAR", line ) )
+ {
+ int dw = QApplication::desktop()->width();
+ move( dw - w, y );
+ KWin::setStrut( winId(), 0, w, 0, 0 );
+ toggleLocked->setChecked( true );
+ slotToggleLocked();
+ toggleLocked->setEnabled(false);
+
+ }
+ if( getBoolean("LEFTBAR", line) )
+ {
+ int dw = QApplication::desktop()->width();
+ move( 0, y );
+ KWin::setStrut( winId(), w, 0, 0, 0 );
+ toggleLocked->setChecked( true );
+ slotToggleLocked();
+ toggleLocked->setEnabled(false);
+
+ }
bool found = false;
QString path = getString( "MASK", line, found );

View File

@ -1,261 +0,0 @@
--- src/memsensor.cpp.orig Mon Apr 21 15:17:03 2003
+++ src/memsensor.cpp Fri Sep 5 12:07:36 2003
@@ -12,63 +12,202 @@
#include <qtextstream.h>
#include <qstring.h>
#include <qregexp.h>
+
+#ifdef __FreeBSD__
+#include <sys/time.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/resource.h>
+#include <unistd.h>
+#include <kvm.h>
+#include <sys/file.h>
+#include <osreldate.h>
+
+/* define pagetok in terms of pageshift */
+#define pagetok(size) ((size) << pageshift)
+#endif
+
MemSensor::MemSensor(int msec) : Sensor(msec)
{
+#ifdef __FreeBSD__
+ /* get the page size with "getpagesize" and calculate pageshift from it */
+ int pagesize = getpagesize();
+ pageshift = 0;
+ while (pagesize > 1)
+ {
+ pageshift++;
+ pagesize >>= 1;
+ }
+
+ /* we only need the amount of log(2)1024 for our conversion */
+ pageshift -= 10;
+
+# if __FreeBSD_version < 500018
+ connect(&ksp, SIGNAL(receivedStdout(KProcess *, char *, int )),
+ this,SLOT(receivedStdout(KProcess *, char *, int )));
+ connect(&ksp, SIGNAL(processExited(KProcess *)),
+ this,SLOT(processExited( KProcess * )));
+
+ swapTotal = swapUsed = 0;
+
+ MaxSet = false;
+
readValues();
+# else
+ kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open");
+# endif
+#else
+ readValues();
+#endif
}
+
MemSensor::~MemSensor()
{}
+#ifdef __FreeBSD__
+void MemSensor::receivedStdout(KProcess *, char *buffer, int len )
+{
+ buffer[len] = 0;
+ sensorResult += QString( QCString(buffer) );
+}
+
+void MemSensor::processExited(KProcess *)
+{
+ QStringList stringList = QStringList::split('\n',sensorResult);
+ sensorResult = "";
+ QStringList itemsList = QStringList::split(' ', stringList[1]);
+
+ swapUsed = itemsList[2].toInt();
+ swapTotal = itemsList[1].toInt();
+}
+#endif
int MemSensor::getMemTotal()
{
+#ifdef __FreeBSD__
+ static int mem = 0;
+ size_t size = sizeof(mem);
+
+ sysctlbyname("hw.physmem", &mem, &size, NULL, 0);
+ return (mem / 1024);
+#else
QRegExp rx( "MemTotal:\\s*(\\d+)" );
rx.search( meminfo );
return ( rx.cap(1).toInt() );
+#endif
}
int MemSensor::getMemFree()
{
+#ifdef __FreeBSD__
+ static int mem = 0;
+ size_t size = sizeof(mem);
+
+ sysctlbyname("vm.stats.vm.v_free_count", &mem, &size, NULL, 0);
+ return (pagetok(mem));
+#else
QRegExp rx( "MemFree:\\s*(\\d+)" );
rx.search( meminfo );
return ( rx.cap(1).toInt() );
+#endif
}
int MemSensor::getBuffers()
{
+#ifdef __FreeBSD__
+ static int mem = 0;
+ size_t size = sizeof(mem);
+
+ sysctlbyname("vfs.bufspace", &mem, &size, NULL, 0);
+ return (mem / 1024);
+#else
QRegExp rx( "Buffers:\\s*(\\d+)" );
rx.search( meminfo );
return ( rx.cap(1).toInt() );
+#endif
}
int MemSensor::getCached()
{
+#ifdef __FreeBSD__
+ static int mem = 0;
+ size_t size = sizeof(mem);
+
+ sysctlbyname("vm.stats.vm.v_cache_count", &mem, &size, NULL, 0);
+ return (pagetok(mem));
+#else
QRegExp rx1( "Cached:\\s*(\\d+)" );
QRegExp rx2( "SwapCached:\\s*(\\d+)" );
rx1.search( meminfo );
rx2.search( meminfo );
return ( rx1.cap(1).toInt() + rx2.cap(1).toInt() );
+#endif
}
int MemSensor::getSwapTotal()
{
+#ifdef __FreeBSD__
+# if __FreeBSD_version < 500018
+ return(swapTotal);
+# else
+ int n = -1;
+ int pagesize = getpagesize();
+ int retavail = 0;
+
+ if (kd != NULL)
+ n = kvm_getswapinfo(kd, &swapinfo, 1, 0);
+
+ if (n < 0 || swapinfo.ksw_total == 0)
+ return(0);
+
+ retavail = swapinfo.ksw_total * pagesize / 1024;
+
+ return(retavail);
+# endif
+#else
QRegExp rx( "SwapTotal:\\s*(\\d+)" );
rx.search( meminfo );
return ( rx.cap(1).toInt() );
+#endif
}
int MemSensor::getSwapFree()
{
+#ifdef __FreeBSD__
+# if __FreeBSD_version < 500018
+ return(swapTotal - swapUsed);
+# else
+ int n = -1;
+ int pagesize = getpagesize();
+ int retfree = 0;
+
+ if (kd != NULL)
+ n = kvm_getswapinfo(kd, &swapinfo, 1, 0);
+ if (n < 0 || swapinfo.ksw_total == 0)
+ return(0);
+
+ retfree = (swapinfo.ksw_total - swapinfo.ksw_used) * pagesize / 1024;
+
+ return(retfree);
+# endif
+#else
QRegExp rx( "SwapFree:\\s*(\\d+)" );
rx.search( meminfo );
return ( rx.cap(1).toInt() );
+#endif
}
-
void MemSensor::readValues()
{
+#ifdef __FreeBSD__
+# if __FreeBSD_version < 500018
+ ksp.clearArguments();
+ ksp << "swapinfo";
+ ksp.start( KProcess::NotifyOnExit,KProcIO::Stdout);
+# endif
+#else
QFile file("/proc/meminfo");
QString line;
if ( file.open(IO_ReadOnly | IO_Translate) )
@@ -77,15 +216,21 @@
meminfo = t.read();
file.close();
}
+#endif
}
void MemSensor::update()
{
+#if (defined(__FreeBSD__) && __FreeBSD_version < 500018)
readValues();
+#endif
QString format;
SensorParams *sp;
Meter *meter;
QObjectListIt it( *objList );
+#if (defined(__FreeBSD__) && __FreeBSD_version < 500018)
+ bool set = false;
+#endif
int totalMem = getMemTotal();
int usedMem = totalMem - getMemFree();
@@ -96,6 +241,12 @@
while (it != 0)
{
sp = (SensorParams*)(*it);
+#if (defined(__FreeBSD__) && __FreeBSD_version < 500018)
+ if ( (!MaxSet) && (totalSwap > 0) ) {
+ setMaxValue(sp);
+ bool set = true;
+ }
+#endif
meter = sp->getMeter();
format = sp->getParam("FORMAT");
if (format.length() == 0 )
@@ -118,6 +269,11 @@
meter->setValue(format);
++it;
}
+#if (defined(__FreeBSD__) && __FreeBSD_version < 500018)
+ if (set)
+ MaxSet = true;
+#endif
+
}
void MemSensor::setMaxValue( SensorParams *sp )
@@ -133,7 +289,6 @@
}
if( f=="%fm" || f== "%um" || f=="%fmb" || f=="%umb" )
meter->setMax( getMemTotal() / 1024 );
-
if( f=="%fs" || f== "%us" )
meter->setMax( getSwapTotal() / 1024 );
}

View File

@ -1,42 +0,0 @@
--- src/memsensor.h.orig Mon Apr 21 15:17:03 2003
+++ src/memsensor.h Fri Sep 5 12:08:46 2003
@@ -12,6 +12,12 @@
#include "sensor.h"
#include <qstring.h>
#include <qregexp.h>
+#ifdef __FreeBSD__
+#include <kprocess.h>
+#include <kprocio.h>
+#include <kvm.h>
+#include <osreldate.h>
+#endif
class MemSensor : public Sensor
{
@@ -36,6 +42,26 @@
private:
QString meminfo;
void readValues();
+#ifdef __FreeBSD__
+ int pageshift; /* log base 2 of the pagesize */
+ QString sensorResult;
+ int swapTotal;
+ int swapUsed;
+
+# if __FreeBSD_version < 500018
+ KShellProcess ksp;
+ bool MaxSet;
+
+# else
+ kvm_t *kd;
+ kvm_swap swapinfo;
+# endif
+
+private slots:
+ void receivedStdout(KProcess *, char *buffer, int);
+ void processExited(KProcess *);
+
+#endif
};
#endif // MEMSENSOR_H

View File

@ -1,105 +0,0 @@
--- src/networksensor.cpp.orig Mon Apr 21 15:17:03 2003
+++ src/networksensor.cpp Sun Nov 9 18:34:35 2003
@@ -7,14 +7,65 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
+#ifdef __FreeBSD__
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/socket.h>
+#include <net/route.h>
+#endif
+
#include "networksensor.h"
NetworkSensor::NetworkSensor( QString dev, int interval ):Sensor( interval )
{
device = dev.lower();
+
+#ifdef __FreeBSD__
+ /* Determine number of interfaces */
+ u_int n = 0;
+ size_t nlen = 0;
+ nlen = sizeof(n);
+ sysctlbyname("net.link.generic.system.ifcount", &n, &nlen, NULL, 0);
+
+ size_t if_miblen = 0;
+ if_miblen = sizeof(if_mib);
+ static int name[] = { CTL_NET,
+ PF_LINK,
+ NETLINK_GENERIC,
+ IFMIB_IFDATA,
+ 0,
+ IFDATA_GENERAL };
+
+ /*
+ If the device was defined by the theme, find the right devicenumber.
+ If not, use the device that holds the default route.
+ */
+
+ if_number = -1;
+ int if_gw = -1;
+
+ for (int i = 1; i <= n; ++i) {
+ name[4] = i;
+ /* Get data for iface-number i */
+ sysctl(name, 6, (void*)&if_mib, (size_t*)&if_miblen, (void*)NULL, (size_t)0);
+
+ /* We found the right interface? */
+ if (QString(if_mib.ifmd_name) == device) {
+ if_number = i;
+ break;
+ }
+
+ /* Does the interface hold the default route? */
+ if ( if_mib.ifmd_flags & RTF_GATEWAY )
+ if_gw = i;
+ }
+
+ if ((if_number == -1) && (if_gw != -1))
+ if_number = if_gw;
+#else
if( device == "" )
device = "eth0";
-
+#endif
getInOutBytes(receivedBytes,transmittedBytes);
netTimer.start();
@@ -24,6 +75,27 @@
}
void NetworkSensor::getInOutBytes ( unsigned long &in,unsigned long &out) const
{
+#ifdef __FreeBSD__
+ if (if_number != -1) {
+ size_t if_miblen = 0;
+ if_miblen = sizeof(if_mib);
+ int name[] = { CTL_NET,
+ PF_LINK,
+ NETLINK_GENERIC,
+ IFMIB_IFDATA,
+ if_number,
+ IFDATA_GENERAL };
+
+ sysctl(name, 6, (void*)&if_mib, (size_t*)&if_miblen, (void*)NULL, (size_t)0);
+
+ in = if_mib.ifmd_data.ifi_ibytes;
+ out = if_mib.ifmd_data.ifi_obytes;
+ }
+ else {
+ in = 0;
+ out = 0;
+ }
+#else
QFile file("/proc/net/dev");
QString line;
if ( file.open(IO_ReadOnly | IO_Translate) )
@@ -49,6 +121,7 @@
}
file.close();
}
+#endif
}
void NetworkSensor::update()

View File

@ -1,27 +0,0 @@
--- src/networksensor.h.orig Mon Apr 21 15:17:03 2003
+++ src/networksensor.h Wed Aug 27 16:36:58 2003
@@ -15,6 +15,12 @@
#include <qdatetime.h>
#include <qfile.h>
#include <qregexp.h>
+#ifdef __FreeBSD__
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/if_mib.h>
+#endif
class NetworkSensor : public Sensor
{
@@ -30,7 +36,10 @@
unsigned long transmittedBytes;
QTime netTimer;
QString device;
-
+#ifdef __FreeBSD__
+ int if_number;
+ ifmibdata if_mib;
+#endif
void getInOutBytes (unsigned long &in,unsigned long &out) const;
};

View File

@ -1,63 +0,0 @@
--- src/sensorsensor.cpp.orig Mon Apr 21 15:17:03 2003
+++ src/sensorsensor.cpp Fri Sep 5 15:07:50 2003
@@ -12,6 +12,22 @@
SensorSensor::SensorSensor( int interval ) : Sensor( interval )
{
+#ifdef __FreeBSD__
+ sensorMapBSD["VCore 1"] = "VC0";
+ sensorMapBSD["VCore 2"] = "VC1";
+ sensorMapBSD["+3.3V"] = "V33";
+ sensorMapBSD["+5V"] = "V50P";
+ sensorMapBSD["+12V"] = "V12P";
+ sensorMapBSD["-12V"] = "V12N";
+ sensorMapBSD["-5V"] = "V50N";
+ sensorMapBSD["fan1"] = "FAN0";
+ sensorMapBSD["fan2"] = "FAN1";
+ sensorMapBSD["fan3"] = "FAN2";
+ sensorMapBSD["temp1"] = "TEMP0";
+ sensorMapBSD["temp2"] = "TEMP1";
+ sensorMapBSD["temp3"] = "TEMP2";
+#endif
+
connect(&ksp, SIGNAL(receivedStdout(KProcess *, char *, int )),
this,SLOT(receivedStdout(KProcess *, char *, int )));
connect(&ksp, SIGNAL(processExited(KProcess *)),
@@ -36,8 +52,11 @@
QStringList stringList = QStringList::split('\n',sensorResult);
sensorResult = "";
QStringList::Iterator it = stringList.begin();
+#ifdef __FreeBSD__
+ QRegExp rx( "^(\\S+)\\s+:\\s+[\\+\\-]?(\\d+\\.?\\d*)");
+#else
QRegExp rx( "^(\\S+):\\s+[\\+\\-]?(\\d+\\.?\\d*)");
-
+#endif
while( it != stringList.end())
{
rx.search( *it );
@@ -69,7 +88,12 @@
{
format = "%v";
}
+
+#ifdef __FreeBSD__
+ format.replace( QRegExp("%v", false), sensorMap[sensorMapBSD[type]]);
+#else
format.replace( QRegExp("%v", false), sensorMap[type]);
+#endif
meter->setValue(format);
++lit;
}
@@ -78,7 +102,11 @@
void SensorSensor::update()
{
ksp.clearArguments();
+#ifdef __FreeBSD__
+ ksp << "mbmon -r -c 1";
+#else
ksp << "sensors";
+#endif
ksp.start( KProcess::NotifyOnExit,KProcIO::Stdout);
}

View File

@ -1,12 +0,0 @@
--- src/sensorsensor.h.orig Fri Sep 5 15:00:20 2003
+++ src/sensorsensor.h Fri Sep 5 15:12:17 2003
@@ -32,6 +32,9 @@
KShellProcess ksp;
QMap<QString,QString> sensorMap;
+#ifdef __FreeBSD__
+ QMap<QString,QString> sensorMapBSD;
+#endif
QString sensorResult;
private slots:

View File

@ -1,8 +1,8 @@
--- src/Makefile.in.orig Mon Oct 20 04:58:41 2003
+++ src/Makefile.in Mon Oct 20 04:59:19 2003
@@ -261,7 +261,7 @@
--- src/Makefile.in.orig Tue Jul 13 20:27:44 2004
+++ src/Makefile.in Tue Jul 13 20:28:01 2004
@@ -262,7 +262,7 @@
# the application source, library search path, and link libraries
superkaramba_SOURCES = main.cpp karamba.cpp meter.h meter.cpp bar.h bar.cpp sensor.h sensor.cpp datesensor.h datesensor.cpp textlabel.h textlabel.cpp memsensor.h memsensor.cpp uptimesensor.h uptimesensor.cpp cpusensor.h cpusensor.cpp networksensor.h networksensor.cpp imagelabel.h imagelabel.cpp graph.h graph.cpp xmmssensor.h xmmssensor.cpp programsensor.h programsensor.cpp disksensor.h disksensor.cpp sensorparams.h sensorparams.cpp sensorsensor.h sensorsensor.cpp textfilesensor.h textfilesensor.cpp clickarea.h clickarea.cpp noatunsensor.h noatunsensor.cpp karambarootpixmap.h karambarootpixmap.cpp clickmap.h clickmap.cpp rsssensor.h rsssensor.cpp textfield.h textfield.cpp taskmanager.h taskmanager.cpp showdesktop.h showdesktop.cpp richtextlabel.h richtextlabel.cpp karambasessionmanaged.h karambasessionmanaged.cpp welcomeform.h welcomeform.cpp systemtray.h systemtray.cpp
superkaramba_SOURCES = main.cpp karamba.cpp meter.h meter.cpp bar.h bar.cpp sensor.h sensor.cpp datesensor.h datesensor.cpp textlabel.h textlabel.cpp memsensor.h memsensor.cpp uptimesensor.h uptimesensor.cpp cpusensor.h cpusensor.cpp networksensor.h networksensor.cpp imagelabel.h imagelabel.cpp graph.h graph.cpp xmmssensor.h xmmssensor.cpp programsensor.h programsensor.cpp disksensor.h disksensor.cpp sensorparams.h sensorparams.cpp sensorsensor.h sensorsensor.cpp textfilesensor.h textfilesensor.cpp clickarea.h clickarea.cpp noatunsensor.h noatunsensor.cpp karambarootpixmap.h karambarootpixmap.cpp clickmap.h clickmap.cpp rsssensor.h rsssensor.cpp textfield.h textfield.cpp taskmanager.h taskmanager.cpp showdesktop.h showdesktop.cpp richtextlabel.h richtextlabel.cpp karambasessionmanaged.h karambasessionmanaged.cpp welcomeform.h welcomeform.cpp systemtray.h systemtray.cpp bar_python.cpp bar_python.h meter_python.cpp meter_python.h textlabel_python.cpp textlabel_python.h richtextlabel_python.cpp richtextlabel_python.h imagelabel_python.cpp imagelabel_python.h config_python.cpp config_python.h misc_python.cpp misc_python.h systray_python.cpp systray_python.h task_python.cpp task_python.h widget_python.cpp widget_python.h menu_python.cpp menu_python.h themelistwindow.cpp themelistwindow.h karambalistboxitem.h karambalistboxitem.cpp
superkaramba_LDFLAGS = -Wl,-export-dynamic $(KDE_RPATH) $(all_libraries) $(PYTHONLIB)
-superkaramba_LDADD = -lkio -lXpm $(LIB_KDEUI) $(XMMS_LIBS) $(LIBPYTHON)
+superkaramba_LDADD = -lkio -lXpm $(LIB_KDEUI) $(XMMS_LIBS) $(LIBPYTHON) -lkvm

View File

@ -1,74 +0,0 @@
--- src/uptimesensor.cpp.orig Wed Aug 27 01:32:14 2003
+++ src/uptimesensor.cpp Wed Aug 27 02:34:41 2003
@@ -7,6 +7,11 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
+#ifdef __FreeBSD__
+#include <sys/time.h>
+#include <sys/sysctl.h>
+#endif
+
#include "uptimesensor.h"
UptimeSensor::UptimeSensor( int interval ) : Sensor( interval )
@@ -16,6 +21,42 @@
void UptimeSensor::update()
{
+#ifdef __FreeBSD__
+ struct timeval boottime;
+ time_t now; /* the current time of day */
+
+ double avenrun[3];
+ time_t uptime;
+ int days, hours, i, mins, secs;
+ int mib[2];
+ size_t size;
+ char buf[256];
+
+ /*
+ * Get time of day.
+ */
+ (void)time(&now);
+
+ /*
+ * Determine how long system has been up.
+ * (Found by looking getting "boottime" from the kernel)
+ */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_BOOTTIME;
+ size = sizeof(boottime);
+ if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
+ boottime.tv_sec != 0) {
+ uptime = now - boottime.tv_sec;
+ if (uptime > 60)
+ uptime += 30;
+ days = uptime / 86400;
+ uptime %= 86400;
+ hours = uptime / 3600;
+ uptime %= 3600;
+ mins = uptime / 60;
+ secs = uptime % 60;
+ }
+#else
QFile file("/proc/uptime");
QString line;
if ( file.open(IO_ReadOnly | IO_Translate) )
@@ -35,7 +76,7 @@
int mins = uptime / 60;
uptime -= mins * 60;
int secs = uptime;
-
+#endif
QString format;
SensorParams *sp;
@@ -63,5 +104,7 @@
meter->setValue(format);
++it;
}
+#ifndef __FreeBSD__
}
+#endif
}