summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/sysinfo/storage.cpp174
-rw-r--r--noncore/settings/sysinfo/storage.h42
-rw-r--r--noncore/settings/sysinfo/sysinfo.cpp2
-rw-r--r--noncore/settings/sysinfo/versioninfo.cpp23
4 files changed, 82 insertions, 159 deletions
diff --git a/noncore/settings/sysinfo/storage.cpp b/noncore/settings/sysinfo/storage.cpp
index eb157ef..c4474d5 100644
--- a/noncore/settings/sysinfo/storage.cpp
+++ b/noncore/settings/sysinfo/storage.cpp
@@ -1,263 +1,187 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
// additions copyright 2002 by L.J. Potter
+
+#include <qpe/storage.h>
+
#include <qlabel.h>
#include <qlayout.h>
#include <qscrollview.h>
#include <qtimer.h>
#include <qwhatsthis.h>
#include "graph.h"
#include "storage.h"
#include <stdio.h>
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
#include <sys/vfs.h>
#include <mntent.h>
#endif
-StorageInfo::StorageInfo( QWidget *parent, const char *name )
+FileSysInfo::FileSysInfo( QWidget *parent, const char *name )
: QWidget( parent, name )
{
QVBoxLayout *tmpvb = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
tmpvb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
container = new QWidget( sv->viewport() );
sv->addChild( container );
vb = 0x0;
- disks.setAutoDelete(TRUE);
+ storage = new StorageInfo( this );
+ connect( storage, SIGNAL( disksChanged() ), this, SLOT( disksChanged() ) );
+
lines.setAutoDelete(TRUE);
+
+ rebuildDisks = TRUE;
updateMounts();
startTimer( 5000 );
}
-void StorageInfo::timerEvent(QTimerEvent*)
+void FileSysInfo::timerEvent(QTimerEvent*)
{
updateMounts();
}
-static bool isCF(const QString& m)
+void FileSysInfo::updateMounts()
{
- FILE* f = fopen("/var/run/stab", "r");
- if (!f) f = fopen("/var/state/pcmcia/stab", "r");
- if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
- if ( f ) {
- char line[1024];
- char devtype[80];
- char devname[80];
- while ( fgets( line, 1024, f ) ) {
- // 0 ide ide-cs 0 hda 3 0
- if ( sscanf(line,"%*d %s %*s %*s %s", devtype, devname )==2 ) {
- if ( QString(devtype) == "ide" && m.find(devname)>0 ) {
- fclose(f);
- return TRUE;
- }
- }
- }
- fclose(f);
- }
- return FALSE;
-}
+ storage->update();
-void StorageInfo::updateMounts()
+ if ( rebuildDisks )
{
-#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
- struct mntent *me;
- FILE *mntfp = setmntent( "/etc/mtab", "r" );
- QStringList curdisks;
- QStringList curfs;
- QStringList mountList;
- QStringList fsT;
- bool rebuild = FALSE;
- int n=0;
- if ( mntfp ) {
- while ( (me = getmntent( mntfp )) != 0 ) {
- QString fs = me->mnt_fsname;
- if ( fs.left(7)=="/dev/hd" || fs.left(7)=="/dev/sd"
- || fs.left(8)=="/dev/mtd" || fs.left(9) == "/dev/mmcd"
- || fs.left(9) == "/dev/root" || fs.left(5) == "/ramfs"
- || fs.left(5) == "tmpfs" ) {
- n++;
- curdisks.append(fs);
- QString d = me->mnt_dir;
- curfs.append(d);
- QString mount = me->mnt_dir;
- mountList.append(mount);
- QString t = me->mnt_type;
- fsT.append(t);
- if ( !disks.find(d) )
- rebuild = TRUE;
- }
- }
- endmntent( mntfp );
+ // Cannot auto delete QDict<MountInfo> disks because it seems to delete
+ // the filesystem object as well causing a segfault
+ MountInfo *mi;
+ for ( QDictIterator<MountInfo> delit(disks); delit.current(); ++delit )
+ {
+ mi = delit.current();
+ mi->fs = 0x0;
+ delete mi;
}
- if ( rebuild || n != (int)disks.count() ) {
disks.clear();
lines.clear();
+
delete vb;
vb = new QVBoxLayout( container/*, n > 3 ? 1 : 5*/ );
+
bool frst=TRUE;
- QStringList::ConstIterator it = curdisks.begin();
- QStringList::ConstIterator fsit = curfs.begin();
- QStringList::ConstIterator fsmount = mountList.begin();
- QStringList::ConstIterator fsTit = fsT.begin();
- for (; it!=curdisks.end(); ++it, ++fsit) {
- if ( !frst ) {
+ FileSystem *fs;
+ for ( QListIterator<FileSystem> it(storage->fileSystems()); it.current(); ++it )
+ {
+ fs = it.current();
+
+ if ( !frst )
+ {
QFrame *f = new QFrame( container );
vb->addWidget(f);
f->setFrameStyle( QFrame::HLine | QFrame::Sunken );
lines.append(f);
f->show();
- } frst=FALSE;
- QString humanname=*it;
- if ( isCF(humanname) )
- humanname = tr( "CF Card: " );
- else if ( humanname == "/dev/hda1" )
- humanname = tr( "Hard Disk " );
-
- else if ( humanname.left(9) == "/dev/mmcd" )
- humanname = tr( "SD Card " );
-
- else if ( humanname.left(7) == "/dev/hd" )
- humanname = tr( "Hard Disk /dev/hd " );
-
- else if ( humanname.left(7) == "/dev/sd" )
- humanname = tr( "SCSI Hard Disk /dev/sd " );
-
- else if ( humanname == "/dev/mtdblock1"
- || humanname.left(13) == "/dev/mtdblock"
- || humanname.left(9) == "/dev/root")
- humanname = tr( "Int. Storage " );
-
- else if ( humanname.left(5) == "tmpfs" )
- humanname = tr( "RAM disk" );
- // etc.
- humanname.append( *fsmount );
- humanname.append( " " );
- humanname.append( *fsTit );
- humanname.append( " " );
+ }
+ frst = FALSE;
- MountInfo* mi = new MountInfo( *fsit, humanname, container );
+ MountInfo *mi = new MountInfo( fs, container );
vb->addWidget(mi);
- disks.insert(*fsit,mi);
+ disks.insert( fs->path(), mi );
mi->show();
- fsmount++;fsTit++;
- QString tempstr = humanname.left( 2 );
+ QString tempstr = fs->name().left( 2 );
if ( tempstr == tr( "CF" ) )
QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Compact Flash memory card." ) );
else if ( tempstr == tr( "Ha" ) )
QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) );
else if ( tempstr == tr( "SD" ) )
QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used on this Secure Digital memory card." ) );
else if ( tempstr == tr( "SC" ) )
QWhatsThis::add( mi, tr( "This graph represents how much storage is currently used on this hard drive." ) );
else if ( tempstr == tr( "In" ) )
QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the built-in memory (i.e. Flash memory) on this handheld device." ) );
else if ( tempstr == tr( "RA" ) )
QWhatsThis::add( mi, tr( "This graph represents how much memory is currently used of the temporary RAM disk." ) );
}
vb->addStretch();
- } else {
- // just update them
+ }
+ else
+ {
for (QDictIterator<MountInfo> i(disks); i.current(); ++i)
i.current()->updateData();
}
-#endif
+
+ rebuildDisks = FALSE;
}
+void FileSysInfo::disksChanged()
+{
+ rebuildDisks = TRUE;
+}
-MountInfo::MountInfo( const QString &path, const QString &ttl, QWidget *parent, const char *name )
- : QWidget( parent, name ), title(ttl)
+MountInfo::MountInfo( FileSystem *filesys, QWidget *parent, const char *name )
+ : QWidget( parent, name )
{
- fs = new FileSystem( path );
QVBoxLayout *vb = new QVBoxLayout( this, 3 );
totalSize = new QLabel( this );
vb->addWidget( totalSize );
+ fs = filesys;
+ title = fs->name();
+
data = new GraphData();
graph = new BarGraph( this );
graph->setFrameStyle( QFrame::Panel | QFrame::Sunken );
vb->addWidget( graph, 1 );
graph->setData( data );
legend = new GraphLegend( this );
legend->setOrientation(Horizontal);
vb->addWidget( legend );
legend->setData( data );
updateData();
}
MountInfo::~MountInfo()
{
delete data;
delete fs;
}
void MountInfo::updateData()
{
- fs->update();
-
long mult = fs->blockSize() / 1024;
long div = 1024 / fs->blockSize();
if ( !mult ) mult = 1;
if ( !div ) div = 1;
long total = fs->totalBlocks() * mult / div;
long avail = fs->availBlocks() * mult / div;
long used = total - avail;
totalSize->setText( title + tr(" : %1 kB").arg( total ) );
data->clear();
data->addItem( tr("Used (%1 kB)").arg(used), used );
data->addItem( tr("Available (%1 kB)").arg(avail), avail );
graph->repaint( FALSE );
legend->update();
graph->show();
legend->show();
}
-//---------------------------------------------------------------------------
-
-FileSystem::FileSystem( const QString &p )
- : fspath( p ), blkSize(512), totalBlks(0), availBlks(0)
-{
- update();
-}
-
-void FileSystem::update()
-{
-#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
- struct statfs fs;
- if ( !statfs( fspath.latin1(), &fs ) ) {
- blkSize = fs.f_bsize;
- totalBlks = fs.f_blocks;
- availBlks = fs.f_bavail;
- } else {
- blkSize = 0;
- totalBlks = 0;
- availBlks = 0;
- }
-#endif
-}
-
diff --git a/noncore/settings/sysinfo/storage.h b/noncore/settings/sysinfo/storage.h
index 7e8b4e0..b8564af 100644
--- a/noncore/settings/sysinfo/storage.h
+++ b/noncore/settings/sysinfo/storage.h
@@ -1,89 +1,79 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qwidget.h>
#include <qframe.h>
#include <qlist.h>
#include <qdict.h>
class QLabel;
class GraphData;
class Graph;
class GraphLegend;
class FileSystem;
class MountInfo;
class QVBoxLayout;
class QWidget;
+class StorageInfo;
-class StorageInfo : public QWidget
+class FileSysInfo : public QWidget
{
Q_OBJECT
public:
- StorageInfo( QWidget *parent=0, const char *name=0 );
+ FileSysInfo( QWidget *parent=0, const char *name=0 );
protected:
void timerEvent(QTimerEvent*);
private:
void updateMounts();
+
+ QWidget *container;
+ QVBoxLayout *vb;
+
+ StorageInfo *storage;
QDict<MountInfo> disks;
QList<QFrame> lines;
- QVBoxLayout *vb;
- QWidget *container;
+
+ bool rebuildDisks;
+
+private slots:
+ void disksChanged();
};
class MountInfo : public QWidget
{
Q_OBJECT
public:
- MountInfo( const QString &path, const QString &ttl, QWidget *parent=0, const char *name=0 );
+ MountInfo( FileSystem *filesys=0, QWidget *parent=0, const char *name=0 );
~MountInfo();
void updateData();
+ FileSystem *fs;
+
private:
QString title;
- FileSystem *fs;
QLabel *totalSize;
GraphData *data;
Graph *graph;
GraphLegend *legend;
};
-class FileSystem
-{
-public:
- FileSystem( const QString &p );
-
- void update();
-
- const QString &path() const { return fspath; }
- long blockSize() const { return blkSize; }
- long totalBlocks() const { return totalBlks; }
- long availBlocks() const { return availBlks; }
-
-private:
- QString fspath;
- long blkSize;
- long totalBlks;
- long availBlks;
-};
-
-
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp
index c3bdae5..0c5a969 100644
--- a/noncore/settings/sysinfo/sysinfo.cpp
+++ b/noncore/settings/sysinfo/sysinfo.cpp
@@ -1,70 +1,70 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************
**
** Enhancements by: Dan Williams, <williamsdr@acm.org>
**
**********************************************************************/
#include "memory.h"
#include "load.h"
#include "storage.h"
#include "processinfo.h"
#include "modulesinfo.h"
#include "versioninfo.h"
#include "sysinfo.h"
#include <opie/otabwidget.h>
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qlayout.h>
SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags )
: QWidget( parent, name, WStyle_ContextHelp )
{
setIcon( Resource::loadPixmap( "system_icon" ) );
setCaption( tr("System Info") );
resize( 220, 180 );
Config config( "qpe" );
config.setGroup( "Appearance" );
bool advanced = config.readBoolEntry( "Advanced", TRUE );
QVBoxLayout *lay = new QVBoxLayout( this );
OTabWidget *tab = new OTabWidget( this, "tabwidget", OTabWidget::Global );
lay->addWidget( tab );
tab->addTab( new MemoryInfo( tab ), "sysinfo/memorytabicon", tr("Memory") );
#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
- tab->addTab( new StorageInfo( tab ), "sysinfo/storagetabicon", tr("Storage") );
+ tab->addTab( new FileSysInfo( tab ), "sysinfo/storagetabicon", tr("Storage") );
#endif
tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon", tr("CPU") );
if ( advanced )
{
tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon", tr("Process") );
tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon", tr("Modules") );
}
tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon", tr("Version") );
tab->setCurrentTab( tr( "Memory" ) );
}
diff --git a/noncore/settings/sysinfo/versioninfo.cpp b/noncore/settings/sysinfo/versioninfo.cpp
index 9a444df..801af29 100644
--- a/noncore/settings/sysinfo/versioninfo.cpp
+++ b/noncore/settings/sysinfo/versioninfo.cpp
@@ -1,144 +1,153 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qpe/resource.h>
#include <qpe/version.h>
#include <qfile.h>
#include <qimage.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpixmap.h>
#include <qpainter.h>
+#include <qscrollview.h>
#include <qtextstream.h>
#include <qtimer.h>
#include <qwhatsthis.h>
#include "versioninfo.h"
#include <opie/odevice.h>
using namespace Opie;
VersionInfo::VersionInfo( QWidget *parent, const char *name, WFlags f )
: QWidget( parent, name, f )
{
setMinimumSize( 200, 150 );
- QVBoxLayout *vb = new QVBoxLayout( this, 4 );
+ QVBoxLayout *tmpvb = new QVBoxLayout( this );
+ QScrollView *sv = new QScrollView( this );
+ tmpvb->addWidget( sv, 0, 0 );
+ sv->setResizePolicy( QScrollView::AutoOneFit );
+ sv->setFrameStyle( QFrame::NoFrame );
+ QWidget *container = new QWidget( sv->viewport() );
+ sv->addChild( container );
+
+ QVBoxLayout *vb = new QVBoxLayout( container, 4 );
QString kernelVersionString;
QFile file( "/proc/version" );
if ( file.open( IO_ReadOnly ) ) {
QTextStream t( &file );
QString v;
t >> v; t >> v; t >> v;
v = v.left( 20 );
kernelVersionString = tr( "<b>Linux Kernel</b><p>Version: " );
kernelVersionString.append( v );
kernelVersionString.append( "<p>" );
t >> v;
kernelVersionString.append( tr( "Compiled by: " ) );
kernelVersionString.append( v );
file.close();
}
QString palmtopVersionString = tr( "<b>Opie</b><p>Version: " );
palmtopVersionString.append( QPE_VERSION );
palmtopVersionString.append( "<p>" );
#ifdef QPE_VENDOR
QString builder = QPE_VENDOR;
#else
QString builder = "Unknown";
#endif
palmtopVersionString.append( tr( "Compiled by: " ) );
palmtopVersionString.append( builder );
palmtopVersionString.append( "<p>" );
palmtopVersionString.append( tr( "Built on: " ) );
palmtopVersionString.append( __DATE__ );
QHBoxLayout *hb1 = new QHBoxLayout( vb );
hb1->setSpacing( 2 );
- QLabel *palmtopLogo = new QLabel( this );
+ QLabel *palmtopLogo = new QLabel( container );
QImage logo1 = Resource::loadImage( "logo/opielogo" );
logo1 = logo1.smoothScale( 50, 55 );
QPixmap logo1Pixmap;
logo1Pixmap.convertFromImage( logo1 );
palmtopLogo->setPixmap( logo1Pixmap );
palmtopLogo->setFixedSize( 60, 60 );
hb1->addWidget( palmtopLogo, 0, Qt::AlignTop + Qt::AlignLeft );
- QLabel *palmtopVersion = new QLabel( this );
+ QLabel *palmtopVersion = new QLabel( container );
palmtopVersion->setText( palmtopVersionString );
hb1->addWidget( palmtopVersion, 1, Qt::AlignTop + Qt::AlignLeft );
QHBoxLayout *hb2 = new QHBoxLayout( vb );
hb1->setSpacing( 2 );
- QLabel *linuxLogo = new QLabel( this );
+ QLabel *linuxLogo = new QLabel( container );
QImage logo2 = Resource::loadImage( "logo/tux-logo" );
logo2 = logo2.smoothScale( 55, 60 );
QPixmap logo2Pixmap;
logo2Pixmap.convertFromImage( logo2 );
linuxLogo->setPixmap( logo2Pixmap );
linuxLogo->setFixedSize( 60, 60 );
hb2->addWidget( linuxLogo, 0, Qt::AlignTop + Qt::AlignLeft );
- QLabel *kernelVersion = new QLabel( this );
+ QLabel *kernelVersion = new QLabel( container );
kernelVersion->setText( kernelVersionString );
hb2->addWidget( kernelVersion, 1, Qt::AlignTop + Qt::AlignLeft );
QHBoxLayout *hb3 = new QHBoxLayout( vb );
hb3->setSpacing( 2 );
- QLabel *palmtopLogo3 = new QLabel( this );
+ QLabel *palmtopLogo3 = new QLabel( container );
QImage logo3 = Resource::loadImage( "sysinfo/pda" );
logo3 = logo3.smoothScale( 50, 55 );
QPixmap logo3Pixmap;
logo3Pixmap.convertFromImage( logo3 );
palmtopLogo3->setPixmap( logo3Pixmap );
palmtopLogo3->setFixedSize( 60, 60 );
hb3->addWidget( palmtopLogo3, 0, Qt::AlignTop + Qt::AlignLeft );
QString systemString = "<b>";
systemString.append( ODevice::inst()->systemString() );
systemString.append( "</b>" );
systemString.append( tr( "<p>Version: " ) );
systemString.append( ODevice::inst()->systemVersionString() );
systemString.append( tr( "<p>Model: " ) );
systemString.append( ODevice::inst()->modelString() );
systemString.append( tr( "<p>Vendor: " ) );
systemString.append( ODevice::inst()->vendorString() );
- QLabel *systemVersion = new QLabel( this );
+ QLabel *systemVersion = new QLabel( container );
systemVersion->setText( systemString );
hb3->addWidget( systemVersion, 1, Qt::AlignTop + Qt::AlignLeft );
QWhatsThis::add( this, tr( "This page shows the current versions of Opie, the Linux kernel and distribution running on this handheld device." ) );
}
VersionInfo::~VersionInfo()
{
}