From 209810428d2f57b7733ab762d37f451726a46bbf Mon Sep 17 00:00:00 2001
From: markus <markus@FreeBSD.org>
Date: Fri, 21 Aug 2009 15:07:14 +0000
Subject: - Implement/Add the sensor 'system/uptime' for/to ksysguardd. As
 intended   sideeffect, this fixes the plasma systemmonitor applets as most of
 them   were using this sensor internally for management of the sensor list
 due   to a limitation of ksysguardd. As this sensor didn't exist on FreeBSD, 
  they showed nada. - Add a patch from upstream to fix the network part of the
 plasma   systemmonitor [1] - Bump PORTREVISION

Obtained from:	KDE SVN (rev. 1001470) [1]
7.x testing by:	decept on #kde-freebsd (Freenode)
---
 x11/kde4-workspace/Makefile                        |  2 +
 ...tch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt | 12 +++++
 .../files/patch-ksysguard-ksysguardd-modules.h     | 18 +++++++
 .../patch-plasma-applets-system-monitor-net.cpp    | 21 ++++++++
 x11/kde4-workspace/files/uptime.c                  | 58 ++++++++++++++++++++++
 x11/kde4-workspace/files/uptime.h                  | 31 ++++++++++++
 x11/kdebase4-workspace/Makefile                    |  2 +
 ...tch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt | 12 +++++
 .../files/patch-ksysguard-ksysguardd-modules.h     | 18 +++++++
 .../patch-plasma-applets-system-monitor-net.cpp    | 21 ++++++++
 x11/kdebase4-workspace/files/uptime.c              | 58 ++++++++++++++++++++++
 x11/kdebase4-workspace/files/uptime.h              | 31 ++++++++++++
 12 files changed, 284 insertions(+)
 create mode 100644 x11/kde4-workspace/files/patch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt
 create mode 100644 x11/kde4-workspace/files/patch-ksysguard-ksysguardd-modules.h
 create mode 100644 x11/kde4-workspace/files/patch-plasma-applets-system-monitor-net.cpp
 create mode 100644 x11/kde4-workspace/files/uptime.c
 create mode 100644 x11/kde4-workspace/files/uptime.h
 create mode 100644 x11/kdebase4-workspace/files/patch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt
 create mode 100644 x11/kdebase4-workspace/files/patch-ksysguard-ksysguardd-modules.h
 create mode 100644 x11/kdebase4-workspace/files/patch-plasma-applets-system-monitor-net.cpp
 create mode 100644 x11/kdebase4-workspace/files/uptime.c
 create mode 100644 x11/kdebase4-workspace/files/uptime.h

diff --git a/x11/kde4-workspace/Makefile b/x11/kde4-workspace/Makefile
index 337edf9ce63..3218cd5fcba 100644
--- a/x11/kde4-workspace/Makefile
+++ b/x11/kde4-workspace/Makefile
@@ -8,6 +8,7 @@
 
 PORTNAME=	kdebase-workspace
 PORTVERSION=	${KDE4_VERSION}
+PORTREVISION=	1
 CATEGORIES=	x11 kde
 MASTER_SITES=	${MASTER_SITE_KDE}
 MASTER_SITE_SUBDIR=	${KDE4_BRANCH}/${PORTVERSION}/src
@@ -73,6 +74,7 @@ post-patch:
 		${PATCH_WRKSRC}/kcontrol/kfontinst/kio/KioFonts.cpp \
 		${PATCH_WRKSRC}/kcontrol/kxkb/x11helper.cpp \
 		${PATCH_WRKSRC}/kdm/kfrontend/genkdmconf.c
+	${CP} ${FILESDIR}/uptime.* ${WRKSRC}/ksysguard/ksysguardd/FreeBSD/
 
 pre-configure:
 	${REINPLACE_CMD} -e 's|<qhash.h>|<QHash>|'\
diff --git a/x11/kde4-workspace/files/patch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt b/x11/kde4-workspace/files/patch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt
new file mode 100644
index 00000000000..7fda482f553
--- /dev/null
+++ b/x11/kde4-workspace/files/patch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt
@@ -0,0 +1,12 @@
+--- ksysguard/ksysguardd/FreeBSD/CMakeLists.txt.orig	2009-08-20 20:01:27.000000000 +0200
++++ ksysguard/ksysguardd/FreeBSD/CMakeLists.txt	2009-08-20 20:01:45.000000000 +0200
+@@ -8,7 +8,8 @@
+             logfile.c
+             Memory.c
+             netdev.c
+-            ProcessList.c)
++            ProcessList.c
++            uptime.c)
+ 
+ TARGET_LINK_LIBRARIES(libksysguardd kvm)
+ 
diff --git a/x11/kde4-workspace/files/patch-ksysguard-ksysguardd-modules.h b/x11/kde4-workspace/files/patch-ksysguard-ksysguardd-modules.h
new file mode 100644
index 00000000000..ab5a1365615
--- /dev/null
+++ b/x11/kde4-workspace/files/patch-ksysguard-ksysguardd-modules.h
@@ -0,0 +1,18 @@
+--- ksysguard/ksysguardd/modules.h.orig	2009-08-20 20:02:06.000000000 +0200
++++ ksysguard/ksysguardd/modules.h	2009-08-20 21:53:11.000000000 +0200
+@@ -59,6 +59,7 @@
+ #include "Memory.h"
+ #include "netdev.h"
+ #include "ProcessList.h"
++#include "uptime.h"
+ #endif /* OSTYPE_FreeBSD */
+ 
+ #ifdef OSTYPE_Irix
+@@ -144,6 +145,7 @@
+   { "Memory", initMemory, exitMemory, updateMemory, NULLVVFUNC, 0, NULLTIME },
+   { "NetDev", initNetDev, exitNetDev, updateNetDev, checkNetDev, 0, NULLTIME },
+   { "ProcessList", initProcessList, exitProcessList, updateProcessList, NULLVVFUNC, 0, NULLTIME },
++  { "Uptime", initUptime, exitUptime, NULLIVFUNC, NULLVVFUNC, 0, NULLTIME },
+ #endif /* OSTYPE_FreeBSD */
+ 
+ #ifdef OSTYPE_Irix
diff --git a/x11/kde4-workspace/files/patch-plasma-applets-system-monitor-net.cpp b/x11/kde4-workspace/files/patch-plasma-applets-system-monitor-net.cpp
new file mode 100644
index 00000000000..4d448a436d3
--- /dev/null
+++ b/x11/kde4-workspace/files/patch-plasma-applets-system-monitor-net.cpp
@@ -0,0 +1,21 @@
+--- plasma/applets/system-monitor/net.cpp.orig	2009-08-21 01:22:09.000000000 +0200
++++ plasma/applets/system-monitor/net.cpp	2009-08-21 01:28:00.000000000 +0200
+@@ -26,7 +26,7 @@
+ 
+ SM::Net::Net(QObject *parent, const QVariantList &args)
+     : SM::Applet(parent, args)
+-    , m_rx("network/interfaces/(\\w+)/transmitter/data")
++    , m_rx("^network/interfaces/(\\w+)/transmitter/data$")
+ {
+     setHasConfigurationInterface(true);
+     resize(234 + 20 + 23, 135 + 20 + 25);
+@@ -58,7 +58,8 @@
+     connect(engine(), SIGNAL(sourceRemoved(const QString&)),
+             this, SLOT(sourceRemoved(const QString&)));
+     if (!engine()->sources().isEmpty()) {
+-        sourcesAdded();
++        foreach (const QString& source, engine()->sources())
++            sourceAdded(source);
+     }
+ }
+ 
diff --git a/x11/kde4-workspace/files/uptime.c b/x11/kde4-workspace/files/uptime.c
new file mode 100644
index 00000000000..4cc92106632
--- /dev/null
+++ b/x11/kde4-workspace/files/uptime.c
@@ -0,0 +1,58 @@
+/*
+    KSysGuard, the KDE System Guard
+   
+	Copyright (c) 2009 Markus Brueffer <markus@brueffer.de>
+    
+    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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+*/
+
+#include <time.h>
+
+#include "Command.h"
+#include "ksysguardd.h"
+#include "uptime.h"
+
+void
+initUptime(struct SensorModul* sm)
+{
+	registerMonitor("system/uptime", "float", printUptime, printUptimeInfo, sm);
+}
+
+void
+exitUptime(void)
+{
+	removeMonitor("system/uptime");
+}
+
+void
+printUptime(const char* c)
+{
+	struct timespec tp;
+	float uptime = 0;
+
+	if (clock_gettime(CLOCK_MONOTONIC, &tp) != -1)
+		uptime = tp.tv_sec + tp.tv_nsec/1000000000.0;
+
+	output("%f\n", uptime);
+}
+
+void
+printUptimeInfo(const char* c)
+{
+	output("System uptime\t0\t0\ts\n");
+}
+
+
diff --git a/x11/kde4-workspace/files/uptime.h b/x11/kde4-workspace/files/uptime.h
new file mode 100644
index 00000000000..336e5db031f
--- /dev/null
+++ b/x11/kde4-workspace/files/uptime.h
@@ -0,0 +1,31 @@
+/*
+    KSysGuard, the KDE System Guard
+   
+	Copyright (c) 2009 Markus Brueffer <markus@brueffer.de>
+    
+    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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+*/
+
+#ifndef _uptime_h_
+#define _uptime_h_
+
+void initUptime(struct SensorModul* sm);
+void exitUptime(void);
+
+void printUptime(const char*);
+void printUptimeInfo(const char*);
+
+#endif
diff --git a/x11/kdebase4-workspace/Makefile b/x11/kdebase4-workspace/Makefile
index 337edf9ce63..3218cd5fcba 100644
--- a/x11/kdebase4-workspace/Makefile
+++ b/x11/kdebase4-workspace/Makefile
@@ -8,6 +8,7 @@
 
 PORTNAME=	kdebase-workspace
 PORTVERSION=	${KDE4_VERSION}
+PORTREVISION=	1
 CATEGORIES=	x11 kde
 MASTER_SITES=	${MASTER_SITE_KDE}
 MASTER_SITE_SUBDIR=	${KDE4_BRANCH}/${PORTVERSION}/src
@@ -73,6 +74,7 @@ post-patch:
 		${PATCH_WRKSRC}/kcontrol/kfontinst/kio/KioFonts.cpp \
 		${PATCH_WRKSRC}/kcontrol/kxkb/x11helper.cpp \
 		${PATCH_WRKSRC}/kdm/kfrontend/genkdmconf.c
+	${CP} ${FILESDIR}/uptime.* ${WRKSRC}/ksysguard/ksysguardd/FreeBSD/
 
 pre-configure:
 	${REINPLACE_CMD} -e 's|<qhash.h>|<QHash>|'\
diff --git a/x11/kdebase4-workspace/files/patch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt b/x11/kdebase4-workspace/files/patch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt
new file mode 100644
index 00000000000..7fda482f553
--- /dev/null
+++ b/x11/kdebase4-workspace/files/patch-ksysguard-ksysguardd-FreeBSD-CMakeLists.txt
@@ -0,0 +1,12 @@
+--- ksysguard/ksysguardd/FreeBSD/CMakeLists.txt.orig	2009-08-20 20:01:27.000000000 +0200
++++ ksysguard/ksysguardd/FreeBSD/CMakeLists.txt	2009-08-20 20:01:45.000000000 +0200
+@@ -8,7 +8,8 @@
+             logfile.c
+             Memory.c
+             netdev.c
+-            ProcessList.c)
++            ProcessList.c
++            uptime.c)
+ 
+ TARGET_LINK_LIBRARIES(libksysguardd kvm)
+ 
diff --git a/x11/kdebase4-workspace/files/patch-ksysguard-ksysguardd-modules.h b/x11/kdebase4-workspace/files/patch-ksysguard-ksysguardd-modules.h
new file mode 100644
index 00000000000..ab5a1365615
--- /dev/null
+++ b/x11/kdebase4-workspace/files/patch-ksysguard-ksysguardd-modules.h
@@ -0,0 +1,18 @@
+--- ksysguard/ksysguardd/modules.h.orig	2009-08-20 20:02:06.000000000 +0200
++++ ksysguard/ksysguardd/modules.h	2009-08-20 21:53:11.000000000 +0200
+@@ -59,6 +59,7 @@
+ #include "Memory.h"
+ #include "netdev.h"
+ #include "ProcessList.h"
++#include "uptime.h"
+ #endif /* OSTYPE_FreeBSD */
+ 
+ #ifdef OSTYPE_Irix
+@@ -144,6 +145,7 @@
+   { "Memory", initMemory, exitMemory, updateMemory, NULLVVFUNC, 0, NULLTIME },
+   { "NetDev", initNetDev, exitNetDev, updateNetDev, checkNetDev, 0, NULLTIME },
+   { "ProcessList", initProcessList, exitProcessList, updateProcessList, NULLVVFUNC, 0, NULLTIME },
++  { "Uptime", initUptime, exitUptime, NULLIVFUNC, NULLVVFUNC, 0, NULLTIME },
+ #endif /* OSTYPE_FreeBSD */
+ 
+ #ifdef OSTYPE_Irix
diff --git a/x11/kdebase4-workspace/files/patch-plasma-applets-system-monitor-net.cpp b/x11/kdebase4-workspace/files/patch-plasma-applets-system-monitor-net.cpp
new file mode 100644
index 00000000000..4d448a436d3
--- /dev/null
+++ b/x11/kdebase4-workspace/files/patch-plasma-applets-system-monitor-net.cpp
@@ -0,0 +1,21 @@
+--- plasma/applets/system-monitor/net.cpp.orig	2009-08-21 01:22:09.000000000 +0200
++++ plasma/applets/system-monitor/net.cpp	2009-08-21 01:28:00.000000000 +0200
+@@ -26,7 +26,7 @@
+ 
+ SM::Net::Net(QObject *parent, const QVariantList &args)
+     : SM::Applet(parent, args)
+-    , m_rx("network/interfaces/(\\w+)/transmitter/data")
++    , m_rx("^network/interfaces/(\\w+)/transmitter/data$")
+ {
+     setHasConfigurationInterface(true);
+     resize(234 + 20 + 23, 135 + 20 + 25);
+@@ -58,7 +58,8 @@
+     connect(engine(), SIGNAL(sourceRemoved(const QString&)),
+             this, SLOT(sourceRemoved(const QString&)));
+     if (!engine()->sources().isEmpty()) {
+-        sourcesAdded();
++        foreach (const QString& source, engine()->sources())
++            sourceAdded(source);
+     }
+ }
+ 
diff --git a/x11/kdebase4-workspace/files/uptime.c b/x11/kdebase4-workspace/files/uptime.c
new file mode 100644
index 00000000000..4cc92106632
--- /dev/null
+++ b/x11/kdebase4-workspace/files/uptime.c
@@ -0,0 +1,58 @@
+/*
+    KSysGuard, the KDE System Guard
+   
+	Copyright (c) 2009 Markus Brueffer <markus@brueffer.de>
+    
+    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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+*/
+
+#include <time.h>
+
+#include "Command.h"
+#include "ksysguardd.h"
+#include "uptime.h"
+
+void
+initUptime(struct SensorModul* sm)
+{
+	registerMonitor("system/uptime", "float", printUptime, printUptimeInfo, sm);
+}
+
+void
+exitUptime(void)
+{
+	removeMonitor("system/uptime");
+}
+
+void
+printUptime(const char* c)
+{
+	struct timespec tp;
+	float uptime = 0;
+
+	if (clock_gettime(CLOCK_MONOTONIC, &tp) != -1)
+		uptime = tp.tv_sec + tp.tv_nsec/1000000000.0;
+
+	output("%f\n", uptime);
+}
+
+void
+printUptimeInfo(const char* c)
+{
+	output("System uptime\t0\t0\ts\n");
+}
+
+
diff --git a/x11/kdebase4-workspace/files/uptime.h b/x11/kdebase4-workspace/files/uptime.h
new file mode 100644
index 00000000000..336e5db031f
--- /dev/null
+++ b/x11/kdebase4-workspace/files/uptime.h
@@ -0,0 +1,31 @@
+/*
+    KSysGuard, the KDE System Guard
+   
+	Copyright (c) 2009 Markus Brueffer <markus@brueffer.de>
+    
+    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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+*/
+
+#ifndef _uptime_h_
+#define _uptime_h_
+
+void initUptime(struct SensorModul* sm);
+void exitUptime(void);
+
+void printUptime(const char*);
+void printUptimeInfo(const char*);
+
+#endif
-- 
cgit