diff options
author | jdolecek <jdolecek> | 2001-09-22 14:51:49 +0000 |
---|---|---|
committer | jdolecek <jdolecek> | 2001-09-22 14:51:49 +0000 |
commit | 57e0a16cbe1be7baf9bf9bc822d5d3351e69d2d9 (patch) | |
tree | 01931d912659a223d039f158c0e1a1233ad3c77a /x11 | |
parent | dfa6671e69d45bd4c002a7f90b8a48d26f265f2a (diff) | |
download | pkgsrc-57e0a16cbe1be7baf9bf9bc822d5d3351e69d2d9.tar.gz |
Changes to kcontrol/info/info_netbsd.cpp:
GetDmesgInfo():
- changed to support '^foobar' in the filter string
- the filter function is now supposed to add the appropriate stuff
to passed QListView immediatelly, opaque/final is not passed any more
Couple fixes to kcontrol Information stuff:
- fix the display of IRQs, simplify the AddIRQLine(), use the QListView sort
facilities instead separate QStrList
- remove the 'waiting x seconds for devices to settle' on SCSI display
- fix the display of audio devices
- include Total Size and Free Size on Partition display, remove parentheses
in Mount Options
The patch will be fed to KDE Team for inclusion in future KDE versions.
Diffstat (limited to 'x11')
-rw-r--r-- | x11/kdebase2/distinfo | 3 | ||||
-rw-r--r-- | x11/kdebase2/patches/patch-ba | 256 |
2 files changed, 258 insertions, 1 deletions
diff --git a/x11/kdebase2/distinfo b/x11/kdebase2/distinfo index 59d940139dc..2d4aa41057a 100644 --- a/x11/kdebase2/distinfo +++ b/x11/kdebase2/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.5 2001/09/07 14:34:33 drochner Exp $ +$NetBSD: distinfo,v 1.6 2001/09/22 14:51:49 jdolecek Exp $ SHA1 (kdebase-2.1.1.tar.bz2) = af38d452c957715fa6ae59e99af3e7da2c3369b0 Size (kdebase-2.1.1.tar.bz2) = 9188425 bytes @@ -30,3 +30,4 @@ SHA1 (patch-aw) = 6510c6e55f619778c318a96cd5120bb07d9aa6d9 SHA1 (patch-ax) = bd3a8494663da789fffd1a9d5340b0f44819f26c SHA1 (patch-ay) = 287912fd2f3ff04f0239545a1d215b36cb8c1d0f SHA1 (patch-az) = 5af89343863ed55268c9ef22dee394665270cb8b +SHA1 (patch-ba) = a1984f490868565dfe114b579be1279d50de1e0b diff --git a/x11/kdebase2/patches/patch-ba b/x11/kdebase2/patches/patch-ba new file mode 100644 index 00000000000..96875e6a060 --- /dev/null +++ b/x11/kdebase2/patches/patch-ba @@ -0,0 +1,256 @@ +$NetBSD: patch-ba,v 1.1 2001/09/22 14:51:50 jdolecek Exp $ + +--- kcontrol/info/info_netbsd.cpp.orig Fri Sep 21 23:01:26 2001 ++++ kcontrol/info/info_netbsd.cpp Sat Sep 22 16:25:36 2001 +@@ -34,8 +34,10 @@ + #include <sys/types.h> + #include <sys/param.h> + #include <sys/sysctl.h> ++#include <sys/mount.h> + #include <stdio.h> /* for NULL */ + #include <stdlib.h> /* for malloc(3) */ ++#include <fstab.h> + + #include <qfile.h> + #include <qfontmetrics.h> +@@ -100,20 +102,18 @@ bool GetInfo_CPU(QListView *lBox) + // this is used to find out which devices are currently + // on system + static bool GetDmesgInfo(QListView *lBox, const char *filter, +- void func(QListView *, QCString s, void **, bool)) ++ void func(QListView *, QString s)) + { + QFile *dmesg = new QFile("/var/run/dmesg.boot"); + bool usepipe=false; + FILE *pipe=NULL; + QTextStream *t; + bool seencpu=false; +- void *opaque=NULL; +- QCString s; ++ QString s; + bool found=false; + +- if (dmesg->exists() && dmesg->open(IO_ReadOnly)) { ++ if (dmesg->exists() && dmesg->open(IO_ReadOnly)) + t = new QTextStream(dmesg); +- } + else { + delete dmesg; + pipe = popen("/sbin/dmesg", "r"); +@@ -134,25 +134,20 @@ static bool GetDmesgInfo(QListView *lBox + s.contains("WARNING: old BSD partition ID!")) + break; + +- if (!filter || s.contains(filter)) { +- if (func) { +- func(lBox, s, &opaque, false); +- } +- else { ++ if (!filter ++ || (filter[0] == '^' && s.find(&filter[1]) == 0) ++ || (filter[0] != '^' && s.contains(filter))) { ++ if (func) ++ func(lBox, s); ++ else + olditem = new QListViewItem(lBox, olditem, s); +- } + found = true; + } + } +- if (func) { +- func(lBox, s, &opaque, true); +- } +- //lBox->triggerUpdate(); + + delete t; +- if (pipe) { ++ if (pipe) + pclose(pipe); +- } + else { + dmesg->close(); + delete dmesg; +@@ -161,40 +156,31 @@ static bool GetDmesgInfo(QListView *lBox + return found; + } + +-void AddIRQLine(QListView *lBox, QCString s, void **opaque, bool ending) ++void ++AddIRQLine(QListView *lBox, QString s) + { +- QStrList *strlist = (QStrList *) *opaque; +- const char *str; +- int pos, irqnum=0; +- +- if (!strlist) { +- strlist = new QStrList(); +- *opaque = (void *) strlist; +- } +- if (ending) { +- str = strlist->first(); +- for(;str; str = strlist->next()) { +- new QListViewItem(lBox, str); +- } +- delete strlist; +- return; +- } ++ int pos, irqnum; ++ char numstr[3]; + + pos = s.find(" irq "); +- irqnum = (pos < 0) ? 0 : atoi(&(((const char *)s)[pos+5])); +- if (irqnum) { +- s.sprintf("%02d%s", irqnum, (const char *)s); +- } ++ irqnum = (pos < 0) ? 0 : atoi(&s.ascii()[pos+5]); ++ if (irqnum) ++ snprintf(numstr, 3, "%02d", irqnum); + else { +- s.sprintf("??%s", (const char *)s); ++ // this should never happen ++ strcpy(numstr, "??"); + } +- strlist->inSort(s); ++ ++ new QListViewItem(lBox, numstr, s); + } + ++ + bool GetInfo_IRQ (QListView *lBox) + { + lBox->addColumn(i18n("IRQ")); + lBox->addColumn(i18n("Device")); ++ lBox->setSorting(0); ++ lBox->setShowSortIndicator(FALSE); + (void) GetDmesgInfo(lBox, " irq ", AddIRQLine); + return true; + } +@@ -220,26 +206,27 @@ bool GetInfo_IO_Ports (QListView *lbox) + + bool GetInfo_Sound (QListView *lbox) + { ++ lbox->setSorting(false); ++ + if (!GetDmesgInfo(lbox, "audio", NULL)) + new QListViewItem(lbox, i18n("No audio devices found.")); + +- // append information on any audio devices found ++ // append information for each audio devices found + QListViewItem *lvitem = lbox->firstChild(); + for(; lvitem; lvitem = lvitem->nextSibling()) { + QString s; + int pos, len; +- const char *start, *end; ++ const char *start; + char *dev; + + s = lvitem->text(0); +- if ((pos = s.find("at ")) >= 0) { +- pos += 3; // skip "at " +- start = end = s.ascii(); +- for(; (*end!=':') && (*end!='\n'); end++); +- len = end - start; +- dev = (char *) malloc(len + 1); +- strncpy(dev, start, len); +- dev[len] = '\0'; ++ // The autoconf message is in form 'audio0 at auvia0: ...' ++ if (s.find("audio") == 0 && (pos = s.find(" at ")) > 0) { ++ pos += 4; // skip " at " ++ start = s.ascii() + pos; ++ len = (int) strcspn(start, ":\n\t "); ++ dev = (char *) malloc(1 + len + 1); ++ sprintf(dev, "^%.*s", len, start); /* safe */ + + GetDmesgInfo(lbox, dev, NULL); + +@@ -260,16 +247,32 @@ bool GetInfo_SCSI (QListView *lbox) + { + if (!GetDmesgInfo(lbox, "scsibus", NULL)) + new QListViewItem(lbox, i18n("No SCSI devices found.")); ++ ++ // remove the 'waiting %d seconds for devices to settle' message ++ QListViewItem *lvitem = lbox->firstChild(); ++ for(; lvitem; lvitem = lvitem->nextSibling()) { ++ QString s = lvitem->text(0); ++ ++ if (s.contains("seconds for devices to settle")) { ++ lbox->removeItem(lvitem); ++ break; ++ } ++ } ++ + return true; + } + + bool GetInfo_Partitions (QListView *lbox) + { +- QCString s; ++ QString s; ++ QString MB; + char *line, *orig_line; + const char *device, *mountpoint, *type, *flags; + FILE *pipe = popen("/sbin/mount", "r"); + QTextStream *t; ++ u_int64_t tsz, fsz; ++ struct statfs sfs; ++ int ok; + + if (!pipe) { + kdError(0) << i18n("Ahh couldn't run /sbin/mount!") << endl; +@@ -277,27 +280,49 @@ bool GetInfo_Partitions (QListView *lbox + } + t = new QTextStream(pipe, IO_ReadOnly); + ++ MB = QString(" ") + QString(i18n("MB")); + lbox->addColumn(i18n("Device")); + lbox->addColumn(i18n("Mount Point")); + lbox->addColumn(i18n("FS Type")); ++ lbox->addColumn(i18n("Total Size")); ++ lbox->addColumn(i18n("Free Size")); + lbox->addColumn(i18n("Mount Options")); + +- QListViewItem *olditem = 0; + while (!(s = t->readLine().latin1()).isEmpty()) { +- orig_line = line = strdup(s); ++ orig_line = line = strdup(s.ascii()); ++ ++ // the lines returned by /sbin/mount look like: ++ // /dev/wd0a on / type ffs (local, soft dependencies) + + device = strsep(&line, " "); + +- (void) strsep(&line, " "); // cosume word "on" ++ (void) strsep(&line, " "); // consume word "on" + mountpoint = strsep(&line, " "); + +- (void) strsep(&line, " "); // cosume word "type" ++ (void) strsep(&line, " "); // consume word "type" + type = strsep(&line, " "); + +- flags = line; ++ /* skip leading '(' and trailing ')' */ ++ line++; ++ flags = strsep(&line, ")"); ++ ++ if (statfs(mountpoint, &sfs) == 0) { ++ tsz = ((1LL * sfs.f_blocks * sfs.f_bsize / 1024) + 513) ++ / 1024; ++ fsz = ((1LL * sfs.f_bfree * sfs.f_bsize / 1024) + 513) ++ / 1024; ++ ok = 1; ++ } else { ++ tsz = fsz = 0; ++ ok = 0; ++ } + +- olditem = new QListViewItem(lbox, olditem, device, mountpoint, +- type, flags); ++ new QListViewItem(lbox, ++ QString(device) + " ", ++ QString(mountpoint) + " ", QString(type) + " ", ++ (ok) ? (Value(tsz, 6) + MB) : " ", ++ (ok) ? (Value(fsz, 6) + MB) : " ", ++ flags); + + free(orig_line); + } |