summaryrefslogtreecommitdiffstats
path: root/kcontrol
diff options
context:
space:
mode:
authorOBATA Akio <[email protected]>2019-04-06 16:49:26 +0900
committerSlávek Banko <[email protected]>2019-08-18 15:36:50 +0200
commit4741832142e091d641fb8a90607b4595accb905d (patch)
tree31f31b6389635adc523c7a33f873a9562e1adadb /kcontrol
parent0aaebc24cd00c9dd833c16dd14d1814948baac38 (diff)
downloadtdebase-4741832142e091d641fb8a90607b4595accb905d.tar.gz
tdebase-4741832142e091d641fb8a90607b4595accb905d.zip
Revive NetBSD support
Catch up to TDE and OS changes Signed-off-by: OBATA Akio <[email protected]> (cherry picked from commit 2a88ec3c02ab46c8b816cfa348ea53075f57a59c)
Diffstat (limited to 'kcontrol')
-rw-r--r--kcontrol/info/info_netbsd.cpp39
-rw-r--r--kcontrol/info/memory_netbsd.cpp4
-rw-r--r--kcontrol/tdefontinst/tdefontinst/GetPid.c6
-rw-r--r--kcontrol/usbview/usbdevices.cpp95
-rw-r--r--kcontrol/usbview/usbdevices.h5
5 files changed, 128 insertions, 21 deletions
diff --git a/kcontrol/info/info_netbsd.cpp b/kcontrol/info/info_netbsd.cpp
index c2b7b953a..2fced7e40 100644
--- a/kcontrol/info/info_netbsd.cpp
+++ b/kcontrol/info/info_netbsd.cpp
@@ -41,6 +41,7 @@
#include <tqfontmetrics.h>
#include <tqstrlist.h>
#include <tqtextstream.h>
+#include <tqregexp.h>
#include <kdebug.h>
#include <tdeio/global.h> /* for TDEIO::convertSize() */
@@ -123,7 +124,7 @@ static bool GetDmesgInfo(TQListView *lBox, const char *filter,
}
TQListViewItem *olditem = NULL;
- while(!(s = t->readLine().local8Bit()).isEmpty()) {
+ while(!(s = t->readLine().local8Bit()).isNull()) {
if (!seencpu) {
if (s.contains("cpu"))
seencpu = true;
@@ -134,9 +135,7 @@ static bool GetDmesgInfo(TQListView *lBox, const char *filter,
s.contains("WARNING: old BSD partition ID!"))
break;
- if (!filter
- || (filter[0] == '^' && s.find(&filter[1]) == 0)
- || (filter[0] != '^' && s.contains(filter))) {
+ if (!filter || s.contains(TQRegExp(filter))) {
if (func)
func(lBox, s);
else
@@ -163,7 +162,7 @@ AddIRQLine(TQListView *lBox, TQString s)
int pos, irqnum;
char numstr[3];
- pos = s.find(" irq ");
+ pos = s.find(TQRegExp("[ (]irq "));
irqnum = (pos < 0) ? 0 : atoi(&s.ascii()[pos+5]);
if (irqnum)
snprintf(numstr, 3, "%02d", irqnum);
@@ -181,7 +180,7 @@ bool GetInfo_IRQ (TQListView *lBox)
lBox->addColumn(i18n("Device"));
lBox->setSorting(0);
lBox->setShowSortIndicator(FALSE);
- (void) GetDmesgInfo(lBox, " irq ", AddIRQLine);
+ (void) GetDmesgInfo(lBox, "[ (]irq ", AddIRQLine);
return true;
}
@@ -265,9 +264,12 @@ bool GetInfo_SCSI (TQListView *lbox)
bool GetInfo_Partitions (TQListView *lbox)
{
int num; // number of mounts
- // FIXME: older pkgsrc patches checked ST_RDONLY for this declaration
- // what is ST_RDONLY and how does it affect getmntinfo?
+#ifdef HAVE_STATVFS
+ struct statvfs *mnt; // mount data pointer
+#else
struct statfs *mnt; // mount data pointer
+#endif
+ TQString MB(i18n("MB")); /* "MB" = "Mega-Byte" */
// get mount info
if (!(num=getmntinfo(&mnt, MNT_WAIT))) {
@@ -290,24 +292,31 @@ bool GetInfo_Partitions (TQListView *lbox)
unsigned long long big[2];
TQString vv[5];
+#ifdef HAVE_STATVFS
+ big[0] = big[1] = mnt->f_frsize; // coerce the product
+#else
big[0] = big[1] = mnt->f_bsize; // coerce the product
+#endif
big[0] *= mnt->f_blocks;
big[1] *= mnt->f_bavail; // FIXME: use f_bfree if root?
// convert to strings
- vv[0] = TDEIO::convertSize(big[0]);
- vv[1] = TQString::fromLatin1("%1 (%2%%)")
- .arg(TDEIO::convertSize(big[1]))
+ vv[0] = Value((int) (((big[0] / 1024) + 512) / 1024), 6) + MB;
+ vv[1] = TQString("%1 (%2%)")
+ .arg(Value((int) (((big[1] / 1024) + 512) / 1024), 6) + MB)
.arg(mnt->f_blocks ? mnt->f_bavail*100/mnt->f_blocks : 0);
- // FIXME: these two are large enough to punctuate
- vv[2] = TQString::number(mnt->f_files);
- vv[3] = TQString::fromLatin1("%1 (%2%%) ")
+ vv[2] = TQString("%L1").arg(mnt->f_files);
+ vv[3] = TQString("%1 (%2%) ")
.arg(mnt->f_ffree)
.arg(mnt->f_files ? mnt->f_ffree*100/mnt->f_files : 0);
vv[4] = TQString::null;
+#ifdef HAVE_STATVFS
+#define MNTF(x) if (mnt->f_flag & ST_##x) vv[4] += TQString::fromLatin1(#x " ");
+#else
#define MNTF(x) if (mnt->f_flags & MNT_##x) vv[4] += TQString::fromLatin1(#x " ");
+#endif
MNTF(ASYNC)
MNTF(DEFEXPORTED)
MNTF(EXKERB)
@@ -316,7 +325,9 @@ bool GetInfo_Partitions (TQListView *lbox)
MNTF(EXPORTED)
MNTF(EXPUBLIC)
MNTF(EXRDONLY)
+#ifndef HAVE_STATVFS
MNTF(IGNORE)
+#endif
MNTF(LOCAL)
MNTF(NOATIME)
MNTF(NOCOREDUMP)
diff --git a/kcontrol/info/memory_netbsd.cpp b/kcontrol/info/memory_netbsd.cpp
index 39beeaa33..015fdd0ec 100644
--- a/kcontrol/info/memory_netbsd.cpp
+++ b/kcontrol/info/memory_netbsd.cpp
@@ -22,7 +22,7 @@ void KMemoryWidget::update()
int mib[2];
size_t len;
#ifdef UVM
-#if __NetBSD_Version__ > 499000100 /* 4.99.2+ */
+#if __NetBSD_Version__ > 106000000 /* 1.6+ */
struct uvmexp_sysctl uvmexp;
#else
struct uvmexp uvmexp;
@@ -53,7 +53,7 @@ void KMemoryWidget::update()
#ifdef UVM
mib[0] = CTL_VM;
-#if __NetBSD_Version__ > 499000100 /* 4.99.2+ */
+#if __NetBSD_Version__ > 106000000 /* 1.6+ */
mib[1] = VM_UVMEXP2;
#else
mib[1] = VM_UVMEXP;
diff --git a/kcontrol/tdefontinst/tdefontinst/GetPid.c b/kcontrol/tdefontinst/tdefontinst/GetPid.c
index 1a633a76b..e4159f40a 100644
--- a/kcontrol/tdefontinst/tdefontinst/GetPid.c
+++ b/kcontrol/tdefontinst/tdefontinst/GetPid.c
@@ -28,6 +28,10 @@
////////////////////////////////////////////////////////////////////////////////
*/
+#ifdef __NetBSD__
+#define _KMEMUSER
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -173,7 +177,9 @@ unsigned int kfi_getPid(const char *proc, unsigned int ppid)
#endif
#include <sys/sysctl.h>
#include <sys/time.h>
+#if defined(__FreeBSD__) || defined(__DragonFly__)
#include <sys/user.h>
+#endif
#include <unistd.h>
unsigned int kfi_getPid(const char *proc, unsigned int ppid)
{
diff --git a/kcontrol/usbview/usbdevices.cpp b/kcontrol/usbview/usbdevices.cpp
index d8322612a..87f3a7ee5 100644
--- a/kcontrol/usbview/usbdevices.cpp
+++ b/kcontrol/usbview/usbdevices.cpp
@@ -27,7 +27,7 @@
#include <math.h>
-#ifdef Q_OS_FREEBSD
+#if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
#include <sys/ioctl.h>
#include <sys/param.h>
#endif
@@ -197,7 +197,7 @@ TQString USBDevice::dump()
if (!prname.isEmpty())
pr += "<td>(" + prname +")</td>";
r += i18n("<tr><td><i>Protocol</i></td>%1</tr>").arg(pr);
-#ifndef Q_OS_FREEBSD
+#if !(defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD))
r += i18n("<tr><td><i>USB Version</i></td><td>%1.%2</td></tr>")
.arg(_verMajor,0,16)
.arg(TQString::number(_verMinor,16).prepend('0').right(2));
@@ -221,7 +221,7 @@ TQString USBDevice::dump()
r += i18n("<tr><td><i>Speed</i></td><td>%1 Mbit/s</td></tr>").arg(_speed);
r += i18n("<tr><td><i>Channels</i></td><td>%1</td></tr>").arg(_channels);
-#ifdef Q_OS_FREEBSD
+#if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
if ( _power )
r += i18n("<tr><td><i>Power Consumption</i></td><td>%1 mA</td></tr>").arg(_power);
else
@@ -249,7 +249,7 @@ TQString USBDevice::dump()
}
-#ifndef Q_OS_FREEBSD
+#if !(defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD))
bool USBDevice::parse(TQString fname)
{
_devices.clear();
@@ -325,18 +325,29 @@ bool USBDevice::parseSys(TQString dname)
* only little modification on NetBSD.
*/
+#ifdef Q_OS_FREEBSD
void USBDevice::collectData(struct libusb20_backend *pbe,
struct libusb20_device *pdev)
+#else
+void USBDevice::collectData( int fd, int leve, usb_device_info &di, int parent)
+#endif
{
+#ifdef Q_OS_FREEBSD
char tempbuf[32];
struct usb_device_info di;
if (libusb20_dev_get_info(pdev, &di))
memset(&di, 0, sizeof(di));
+#endif
// determine data for this device
+#ifdef Q_OS_FREEBSD
_level = 0;
_parent = 0;
+#else
+ _level = level;
+ _parent = parent;
+#endif
_bus = di.udi_bus;
_device = di.udi_addr;
@@ -354,15 +365,22 @@ void USBDevice::collectData(struct libusb20_backend *pbe,
// determine the speed
switch (di.udi_speed) {
+#ifdef Q_OS_FREEBSD
case LIBUSB20_SPEED_LOW: _speed = 1.5; break;
case LIBUSB20_SPEED_FULL: _speed = 12.0; break;
case LIBUSB20_SPEED_HIGH: _speed = 480.0; break;
case LIBUSB20_SPEED_VARIABLE: _speed = 480.0; break;
case LIBUSB20_SPEED_SUPER: _speed = 4800.0; break;
default: _speed = 480.0; break;
+#else
+ case USB_SPEED_LOW: _speed = 1.5; break;
+ case USB_SPEED_FULL: _speed = 12.0; break;
+ case USB_SPEED_HIGH: _speed = 480.0; break;
+#endif
}
// Get all attached devicenodes
+#ifdef Q_OS_FREEBSD
for (int i = 0; i < 32; ++i) {
if (libusb20_dev_get_iface_desc(pdev, i, tempbuf, sizeof(tempbuf)) == 0) {
_devnodes << tempbuf;
@@ -370,19 +388,52 @@ void USBDevice::collectData(struct libusb20_backend *pbe,
break;
}
}
+#else
+ for (int i = 0; i < USB_MAX_DEVNAMES; ++i)
+ if ( di.udi_devnames[i][0] )
+ _devnodes << di.udi_devnames[i];
+#endif
// For compatibility, split the revision number
sscanf( di.udi_release, "%x.%x", &_revMajor, &_revMinor );
+#ifndef Q_OS_FREEBSD
+ // Cycle through the attached devices if tehre are any
+ for (int p = 0; p < di.udi_nports; ++p) {
+ // Get data for device
+ struct usb_device_info di2;
+
+ di2.udi_addr = di.udi_ports[p];
+
+ if ( di2.udi_addr >= USB_MAX_DEVICES )
+ continue;
+
+ if ( ioctl(fd, USB_DEVICEINFO, &di2) == -1)
+ continue;
+
+ // Only add the device if we don't detect it, yet
+ if (!find( di2.udi_us, di2.udi_addr ) )
+ {
+ USBDevice *device = new USBDevice();
+ device->collectData( fd, level + 1, di2, di.udi_addr );
+ }
+ }
+#endif
}
bool USBDevice::parse(TQString fname)
{
+#ifdef Q_OS_FREEBSD
struct libusb20_backend *pbe;
struct libusb20_device *pdev;
+#else
+ static bool showErrorMessage = true;
+ bool error = false;
+#endif
_devices.clear();
+#ifdef Q_OS_FREEBSD
pbe = libusb20_be_alloc_default();
if (pbe == NULL)
return (false);
@@ -395,6 +446,42 @@ bool USBDevice::parse(TQString fname)
}
libusb20_be_free(pbe);
+#else
+ TQFile controller("?dev/usb0");
+ int i = 1;
+ while ( controller.exists() )
+ {
+ // If the deivicenode exists, continue with further inspection
+ if ( controller.open(IO_ReadOnly) )
+ {
+ for ( int addr = 1; addr < USB_MAX_DEVICES; ++addr )
+ {
+ struct usb_device_info di;
+
+ di.udi_addr = addr;
+ if ( ioctl(controller.handle(), USB_DEVICEINFO, &d1) != -1)
+ {
+ if (!find( di.udi_bus, di.udi_addr) )
+ {
+ USBDevice *device = new USBDevice();
+ device->collectData( controller.handle(), 0, di, 0);
+ }
+ }
+ }
+ controller.close();
+#ifndef Q_OS_NETBSD
+ } else {
+ error = true;
+#endif
+ }
+ controller.setName( TQString::formLocal8Bit("/dev/usb%1".arg(i++) );
+ }
+
+ if ( showErrorMessage && error ) {
+ showErroeMessage = false;
+ KMessageBox::error( 0, i18n("Could not open one or more USB controller, Make sure you have read access to all BSD controllers that shoudl be listed here."));
+ }
+#endif
return true;
}
diff --git a/kcontrol/usbview/usbdevices.h b/kcontrol/usbview/usbdevices.h
index d7a62fbfa..f655ef9a3 100644
--- a/kcontrol/usbview/usbdevices.h
+++ b/kcontrol/usbview/usbdevices.h
@@ -20,6 +20,9 @@
#include <libusb20.h>
#include <dev/usb/usb_ioctl.h>
#endif
+#ifdef Q_OS_NETBSD
+#include <dev/usb/usb.h>
+#endif
class USBDB;
@@ -66,7 +69,7 @@ private:
unsigned int _vendorID, _prodID, _revMajor, _revMinor;
-#ifdef Q_OS_FREEBSD
+#if defined(Q_OS_FREEBSD) || defined(Q_OS_NETBSD)
void collectData(struct libusb20_backend *, struct libusb20_device *);
TQStringList _devnodes;
#endif