author | mickeyl <mickeyl> | 2004-12-20 11:44:19 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-12-20 11:44:19 (UTC) |
commit | 4e1958e50a18bfa9a7cd2d41400a753c99fedbf9 (patch) (unidiff) | |
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 | 13 | ||||
-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, 168 insertions, 7 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 | |||
@@ -27,19 +27,21 @@ | |||
27 | #include "storage.h" | 27 | #include "storage.h" |
28 | #include "processinfo.h" | 28 | #include "processinfo.h" |
29 | #include "modulesinfo.h" | 29 | #include "modulesinfo.h" |
30 | #include "benchmarkinfo.h" | 30 | #include "benchmarkinfo.h" |
31 | #include "sysloginfo.h" | ||
31 | #include "versioninfo.h" | 32 | #include "versioninfo.h" |
32 | #include "sysinfo.h" | 33 | #include "sysinfo.h" |
33 | 34 | ||
35 | /* OPIE */ | ||
34 | #include <opie2/otabwidget.h> | 36 | #include <opie2/otabwidget.h> |
35 | 37 | using namespace Opie::Ui; | |
36 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
37 | #include <qpe/resource.h> | 39 | #include <qpe/resource.h> |
38 | 40 | ||
41 | /* QT */ | ||
39 | #include <qlayout.h> | 42 | #include <qlayout.h> |
40 | 43 | ||
41 | using namespace Opie::Ui; | ||
42 | SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags ) | 44 | SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags ) |
43 | : QWidget( parent, name, WStyle_ContextHelp ) | 45 | : QWidget( parent, name, WStyle_ContextHelp ) |
44 | { | 46 | { |
45 | setIcon( Resource::loadPixmap( "system_icon" ) ); | 47 | setIcon( Resource::loadPixmap( "system_icon" ) ); |
@@ -61,14 +63,13 @@ SystemInfo::SystemInfo( QWidget *parent, const char *name, WFlags ) | |||
61 | #endif | 63 | #endif |
62 | tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon", tr("CPU") ); | 64 | tab->addTab( new LoadInfo( tab ), "sysinfo/cputabicon", tr("CPU") ); |
63 | if ( advanced ) | 65 | if ( advanced ) |
64 | { | 66 | { |
65 | tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon", tr("Process") ); | 67 | tab->addTab( new ProcessInfo( tab ), "sysinfo/processtabicon", tr( "Process" ) ); |
66 | tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon", tr("Modules") ); | 68 | tab->addTab( new ModulesInfo( tab ), "sysinfo/moduletabicon", tr( "Modules" ) ); |
67 | } | 69 | } |
70 | tab->addTab( new SyslogInfo( tab ), "sysinfo/syslogtabicon", tr( "Syslog" ) ); | ||
68 | tab->addTab( new BenchmarkInfo( tab ), "sysinfo/benchmarktabicon", tr( "Benchmark" ) ); | 71 | tab->addTab( new BenchmarkInfo( tab ), "sysinfo/benchmarktabicon", tr( "Benchmark" ) ); |
69 | tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon", tr("Version") ); | 72 | tab->addTab( new VersionInfo( tab ), "sysinfo/versiontabicon", tr("Version") ); |
70 | 73 | ||
71 | tab->setCurrentTab( tr( "Memory" ) ); | 74 | tab->setCurrentTab( tr( "Memory" ) ); |
72 | } | 75 | } |
73 | |||
74 | |||
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 | |||
@@ -8,8 +8,9 @@ HEADERS = \ | |||
8 | modulesinfo.h \ | 8 | modulesinfo.h \ |
9 | detail.h \ | 9 | detail.h \ |
10 | contrib/dhry.h \ | 10 | contrib/dhry.h \ |
11 | benchmarkinfo.h \ | 11 | benchmarkinfo.h \ |
12 | sysloginfo.h \ | ||
12 | versioninfo.h \ | 13 | versioninfo.h \ |
13 | sysinfo.h | 14 | sysinfo.h |
14 | SOURCES = main.cpp \ | 15 | SOURCES = main.cpp \ |
15 | memory.cpp \ | 16 | memory.cpp \ |
@@ -20,15 +21,16 @@ SOURCES = main.cpp \ | |||
20 | modulesinfo.cpp \ | 21 | modulesinfo.cpp \ |
21 | detail.cpp \ | 22 | detail.cpp \ |
22 | contrib/dhry.c contrib/fft.c \ | 23 | contrib/dhry.c contrib/fft.c \ |
23 | benchmarkinfo.cpp \ | 24 | benchmarkinfo.cpp \ |
25 | sysloginfo.cpp \ | ||
24 | versioninfo.cpp \ | 26 | versioninfo.cpp \ |
25 | sysinfo.cpp | 27 | sysinfo.cpp |
26 | 28 | ||
27 | INCLUDEPATH += $(OPIEDIR)/include | 29 | INCLUDEPATH += $(OPIEDIR)/include |
28 | DEPENDPATH += $(OPIEDIR)/include | 30 | DEPENDPATH += $(OPIEDIR)/include |
29 | LIBS += -lqpe -lopiecore2 -lopieui2 | 31 | LIBS += -lqpe -lopiecore2 -lopieui2 |
30 | DEFINES += UNIX | 32 | DEFINES += UNIX |
31 | TARGET = sysinfo | 33 | TARGET = sysinfo |
32 | VERSION = 1.1.1 | 34 | VERSION = 1.2.0 |
33 | 35 | ||
34 | include ( $(OPIEDIR)/include.pro ) | 36 | 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 @@ | |||
1 | /********************************************************************** | ||
2 | ** SyslogInfo | ||
3 | ** | ||
4 | ** Display Syslog information | ||
5 | ** | ||
6 | ** Copyright (C) 2004, Michael Lauer | ||
7 | ** mickey@tm.informatik.uni-frankfurt.de | ||
8 | ** http://www.Vanille.de | ||
9 | ** | ||
10 | ** This file may be distributed and/or modified under the terms of the | ||
11 | ** GNU General Public License version 2 as published by the Free Software | ||
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
13 | ** packaging of this file. | ||
14 | ** | ||
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | ** | ||
18 | **********************************************************************/ | ||
19 | |||
20 | #include "sysloginfo.h" | ||
21 | #include "detail.h" | ||
22 | |||
23 | /* OPIE */ | ||
24 | #include <opie2/olistview.h> | ||
25 | #include <qpe/qpeapplication.h> | ||
26 | using namespace Opie::Ui; | ||
27 | |||
28 | /* QT */ | ||
29 | #include <qcombobox.h> | ||
30 | #include <qfile.h> | ||
31 | #include <qlayout.h> | ||
32 | #include <qmessagebox.h> | ||
33 | #include <qpushbutton.h> | ||
34 | #include <qsocketnotifier.h> | ||
35 | #include <qtextbrowser.h> | ||
36 | #include <qtimer.h> | ||
37 | #include <qwhatsthis.h> | ||
38 | #include <qtextview.h> | ||
39 | |||
40 | /* STD */ | ||
41 | #include <sys/klog.h> | ||
42 | #include <sys/types.h> | ||
43 | #include <sys/stat.h> | ||
44 | #include <fcntl.h> | ||
45 | #include <assert.h> | ||
46 | #include <unistd.h> | ||
47 | #include <string.h> | ||
48 | #include <errno.h> | ||
49 | |||
50 | #define SYSLOG_READ 2 | ||
51 | #define SYSLOG_READ_ALL 3 | ||
52 | #define SYSLOG_READ_ALL_CLEAR 4 | ||
53 | #define SYSLOG_UNREAD 9 | ||
54 | |||
55 | #undef APPEND | ||
56 | |||
57 | const unsigned int bufsize = 16384; | ||
58 | char buf[bufsize]; | ||
59 | |||
60 | SyslogInfo::SyslogInfo( QWidget* parent, const char* name, WFlags fl ) | ||
61 | : QWidget( parent, name, fl ) | ||
62 | { | ||
63 | QGridLayout *layout = new QGridLayout( this ); | ||
64 | layout->setSpacing( 4 ); | ||
65 | layout->setMargin( 4 ); | ||
66 | |||
67 | syslogview = new QTextView( this ); | ||
68 | syslogview->setTextFormat( PlainText ); | ||
69 | syslogview->setFont( QFont( "Fixed" ) ); | ||
70 | layout->addWidget( syslogview, 0, 0 ); | ||
71 | syslogview->setText( "..." ); | ||
72 | |||
73 | memset( buf, 0, bufsize ); | ||
74 | ::klogctl( SYSLOG_READ_ALL, buf, bufsize ); | ||
75 | syslogview->setText( buf ); | ||
76 | |||
77 | #ifdef APPEND | ||
78 | fd = ::open( "/proc/kmsg", O_RDONLY|O_SYNC ); | ||
79 | if ( fd == -1 ) | ||
80 | { | ||
81 | syslogview->setText( "Couldn't open /proc/kmsg: " + QString( strerror( errno ) ) ); | ||
82 | return; | ||
83 | } | ||
84 | QSocketNotifier *sn = new QSocketNotifier( fd, QSocketNotifier::Read, this ); | ||
85 | QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(updateData()) ); | ||
86 | #else | ||
87 | QPushButton* pb = new QPushButton( "&Refresh", this ); | ||
88 | layout->addWidget( pb, 1, 0 ); | ||
89 | QObject::connect( pb, SIGNAL(clicked()), this, SLOT(updateData()) ); | ||
90 | #endif | ||
91 | } | ||
92 | |||
93 | SyslogInfo::~SyslogInfo() | ||
94 | { | ||
95 | if ( fd != -1 ) ::close( fd ); | ||
96 | } | ||
97 | |||
98 | void SyslogInfo::updateData() | ||
99 | { | ||
100 | qDebug( "SyslogInfo: updateData" ); | ||
101 | #ifdef APPEND | ||
102 | memset( buf, 0, bufsize ); | ||
103 | int num = ::read( fd, buf, bufsize ); | ||
104 | if ( num ) // -1 = error (permission denied) | ||
105 | { | ||
106 | syslogview->append( "\n" ); | ||
107 | syslogview->append( buf ); | ||
108 | qDebug( "SyslogInfo: adding '%s'", buf ); | ||
109 | } | ||
110 | #else | ||
111 | memset( buf, 0, bufsize ); | ||
112 | ::klogctl( SYSLOG_READ_ALL, buf, bufsize ); | ||
113 | syslogview->setText( buf ); | ||
114 | syslogview->ensureVisible( 0, syslogview->contentsHeight() ); | ||
115 | #endif | ||
116 | } | ||
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 @@ | |||
1 | /********************************************************************** | ||
2 | ** SyslogInfo | ||
3 | ** | ||
4 | ** Display Syslog information | ||
5 | ** | ||
6 | ** Copyright (C) 2004, Michael Lauer | ||
7 | ** mickey@tm.informatik.uni-frankfurt.de | ||
8 | ** http://www.Vanille.de | ||
9 | ** | ||
10 | ** This file may be distributed and/or modified under the terms of the | ||
11 | ** GNU General Public License version 2 as published by the Free Software | ||
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
13 | ** packaging of this file. | ||
14 | ** | ||
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | ** | ||
18 | **********************************************************************/ | ||
19 | |||
20 | #ifndef SYSLOGINFO_H | ||
21 | #define SYSLOGINFO_H | ||
22 | |||
23 | #include <qwidget.h> | ||
24 | |||
25 | class QTextView; | ||
26 | |||
27 | class SyslogInfo : public QWidget | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | public: | ||
31 | SyslogInfo( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | ||
32 | ~SyslogInfo(); | ||
33 | |||
34 | private: | ||
35 | QTextView* syslogview; | ||
36 | int fd; | ||
37 | |||
38 | private slots: | ||
39 | void updateData(); | ||
40 | }; | ||
41 | |||
42 | #endif | ||