author | mickeyl <mickeyl> | 2004-12-20 11:44:19 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-12-20 11:44:19 (UTC) |
commit | 4e1958e50a18bfa9a7cd2d41400a753c99fedbf9 (patch) (side-by-side diff) | |
tree | 98bfc2080c87ffeeb93304118d469d83505aeff6 | |
parent | a226cb8cc1ff4f81d43c0c8ecafca889ba817f9f (diff) | |
download | opie-4e1958e50a18bfa9a7cd2d41400a753c99fedbf9.zip opie-4e1958e50a18bfa9a7cd2d41400a753c99fedbf9.tar.gz opie-4e1958e50a18bfa9a7cd2d41400a753c99fedbf9.tar.bz2 |
add syslog and bump version
-rw-r--r-- | noncore/settings/sysinfo/sysinfo.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysinfo.pro | 4 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysloginfo.cpp | 116 | ||||
-rw-r--r-- | noncore/settings/sysinfo/sysloginfo.h | 42 |
4 files changed, 166 insertions, 5 deletions
diff --git a/noncore/settings/sysinfo/sysinfo.cpp b/noncore/settings/sysinfo/sysinfo.cpp index 4c58999..7000175 100644 --- a/noncore/settings/sysinfo/sysinfo.cpp +++ b/noncore/settings/sysinfo/sysinfo.cpp @@ -1,74 +1,75 @@ /********************************************************************** ** 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 "benchmarkinfo.h" +#include "sysloginfo.h" #include "versioninfo.h" #include "sysinfo.h" +/* OPIE */ #include <opie2/otabwidget.h> - +using namespace Opie::Ui; #include <qpe/config.h> #include <qpe/resource.h> +/* QT */ #include <qlayout.h> -using namespace Opie::Ui; 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 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 SyslogInfo( tab ), "sysinfo/syslogtabicon", tr( "Syslog" ) ); tab->addTab( new BenchmarkInfo( tab ), "sysinfo/benchmarktabicon", tr( "Benchmark" ) ); tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon", tr("Version") ); tab->setCurrentTab( tr( "Memory" ) ); } - - diff --git a/noncore/settings/sysinfo/sysinfo.pro b/noncore/settings/sysinfo/sysinfo.pro index dd35563..e92d725 100644 --- a/noncore/settings/sysinfo/sysinfo.pro +++ b/noncore/settings/sysinfo/sysinfo.pro @@ -1,34 +1,36 @@ CONFIG = qt warn_on quick-app HEADERS = \ memory.h \ graph.h \ load.h \ storage.h \ processinfo.h \ modulesinfo.h \ detail.h \ contrib/dhry.h \ benchmarkinfo.h \ + sysloginfo.h \ versioninfo.h \ sysinfo.h SOURCES = main.cpp \ memory.cpp \ graph.cpp \ load.cpp \ storage.cpp \ processinfo.cpp \ modulesinfo.cpp \ detail.cpp \ contrib/dhry.c contrib/fft.c \ benchmarkinfo.cpp \ + sysloginfo.cpp \ versioninfo.cpp \ sysinfo.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include LIBS += -lqpe -lopiecore2 -lopieui2 DEFINES += UNIX TARGET = sysinfo -VERSION = 1.1.1 +VERSION = 1.2.0 include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/settings/sysinfo/sysloginfo.cpp b/noncore/settings/sysinfo/sysloginfo.cpp new file mode 100644 index 0000000..89c04e0 --- a/dev/null +++ b/noncore/settings/sysinfo/sysloginfo.cpp @@ -0,0 +1,116 @@ +/********************************************************************** +** SyslogInfo +** +** Display Syslog information +** +** Copyright (C) 2004, Michael Lauer +** mickey@tm.informatik.uni-frankfurt.de +** http://www.Vanille.de +** +** 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. +** +**********************************************************************/ + +#include "sysloginfo.h" +#include "detail.h" + +/* OPIE */ +#include <opie2/olistview.h> +#include <qpe/qpeapplication.h> +using namespace Opie::Ui; + +/* QT */ +#include <qcombobox.h> +#include <qfile.h> +#include <qlayout.h> +#include <qmessagebox.h> +#include <qpushbutton.h> +#include <qsocketnotifier.h> +#include <qtextbrowser.h> +#include <qtimer.h> +#include <qwhatsthis.h> +#include <qtextview.h> + +/* STD */ +#include <sys/klog.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <assert.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +#define SYSLOG_READ 2 +#define SYSLOG_READ_ALL 3 +#define SYSLOG_READ_ALL_CLEAR 4 +#define SYSLOG_UNREAD 9 + +#undef APPEND + +const unsigned int bufsize = 16384; +char buf[bufsize]; + +SyslogInfo::SyslogInfo( QWidget* parent, const char* name, WFlags fl ) + : QWidget( parent, name, fl ) +{ + QGridLayout *layout = new QGridLayout( this ); + layout->setSpacing( 4 ); + layout->setMargin( 4 ); + + syslogview = new QTextView( this ); + syslogview->setTextFormat( PlainText ); + syslogview->setFont( QFont( "Fixed" ) ); + layout->addWidget( syslogview, 0, 0 ); + syslogview->setText( "..." ); + + memset( buf, 0, bufsize ); + ::klogctl( SYSLOG_READ_ALL, buf, bufsize ); + syslogview->setText( buf ); + +#ifdef APPEND + fd = ::open( "/proc/kmsg", O_RDONLY|O_SYNC ); + if ( fd == -1 ) + { + syslogview->setText( "Couldn't open /proc/kmsg: " + QString( strerror( errno ) ) ); + return; + } + QSocketNotifier *sn = new QSocketNotifier( fd, QSocketNotifier::Read, this ); + QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(updateData()) ); +#else + QPushButton* pb = new QPushButton( "&Refresh", this ); + layout->addWidget( pb, 1, 0 ); + QObject::connect( pb, SIGNAL(clicked()), this, SLOT(updateData()) ); +#endif +} + +SyslogInfo::~SyslogInfo() +{ + if ( fd != -1 ) ::close( fd ); +} + +void SyslogInfo::updateData() +{ + qDebug( "SyslogInfo: updateData" ); +#ifdef APPEND + memset( buf, 0, bufsize ); + int num = ::read( fd, buf, bufsize ); + if ( num ) // -1 = error (permission denied) + { + syslogview->append( "\n" ); + syslogview->append( buf ); + qDebug( "SyslogInfo: adding '%s'", buf ); + } +#else + memset( buf, 0, bufsize ); + ::klogctl( SYSLOG_READ_ALL, buf, bufsize ); + syslogview->setText( buf ); + syslogview->ensureVisible( 0, syslogview->contentsHeight() ); +#endif +} diff --git a/noncore/settings/sysinfo/sysloginfo.h b/noncore/settings/sysinfo/sysloginfo.h new file mode 100644 index 0000000..7bf8d17 --- a/dev/null +++ b/noncore/settings/sysinfo/sysloginfo.h @@ -0,0 +1,42 @@ +/********************************************************************** +** SyslogInfo +** +** Display Syslog information +** +** Copyright (C) 2004, Michael Lauer +** mickey@tm.informatik.uni-frankfurt.de +** http://www.Vanille.de +** +** 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. +** +**********************************************************************/ + +#ifndef SYSLOGINFO_H +#define SYSLOGINFO_H + +#include <qwidget.h> + +class QTextView; + +class SyslogInfo : public QWidget +{ + Q_OBJECT +public: + SyslogInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + ~SyslogInfo(); + +private: + QTextView* syslogview; + int fd; + +private slots: + void updateData(); +}; + +#endif |