summaryrefslogtreecommitdiff
path: root/noncore/settings/sysinfo/sysloginfo.cpp
Unidiff
Diffstat (limited to 'noncore/settings/sysinfo/sysloginfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/sysloginfo.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/noncore/settings/sysinfo/sysloginfo.cpp b/noncore/settings/sysinfo/sysloginfo.cpp
index 21427f4..279c335 100644
--- a/noncore/settings/sysinfo/sysloginfo.cpp
+++ b/noncore/settings/sysinfo/sysloginfo.cpp
@@ -1,119 +1,117 @@
1/********************************************************************** 1/**********************************************************************
2** SyslogInfo 2** SyslogInfo
3** 3**
4** Display Syslog information 4** Display Syslog information
5** 5**
6** Copyright (C) 2004, Michael Lauer 6** Copyright (C) 2004-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
7** mickey@tm.informatik.uni-frankfurt.de
8** http://www.Vanille.de
9** 7**
10** This file may be distributed and/or modified under the terms of the 8** 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 9** GNU General Public License version 2 as published by the Free Software
12** Foundation and appearing in the file LICENSE.GPL included in the 10** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file. 11** packaging of this file.
14** 12**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 13** 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. 14** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17** 15**
18**********************************************************************/ 16**********************************************************************/
19 17
20#include "sysloginfo.h" 18#include "sysloginfo.h"
21#include "detail.h" 19#include "detail.h"
22 20
23/* OPIE */ 21/* OPIE */
24#include <opie2/olistview.h> 22#include <opie2/olistview.h>
25#include <opie2/oconfig.h> 23#include <opie2/oconfig.h>
26using namespace Opie::Core; 24using namespace Opie::Core;
27using namespace Opie::Ui; 25using namespace Opie::Ui;
28 26
29/* QT */ 27/* QT */
30#include <qcombobox.h> 28#include <qcombobox.h>
31#include <qfile.h> 29#include <qfile.h>
32#include <qlayout.h> 30#include <qlayout.h>
33#include <qmessagebox.h> 31#include <qmessagebox.h>
34#include <qpushbutton.h> 32#include <qpushbutton.h>
35#include <qsocketnotifier.h> 33#include <qsocketnotifier.h>
36#include <qtextbrowser.h> 34#include <qtextbrowser.h>
37#include <qtimer.h> 35#include <qtimer.h>
38#include <qwhatsthis.h> 36#include <qwhatsthis.h>
39#include <qtextview.h> 37#include <qtextview.h>
40 38
41/* STD */ 39/* STD */
42#include <sys/klog.h> 40#include <sys/klog.h>
43#include <sys/types.h> 41#include <sys/types.h>
44#include <sys/stat.h> 42#include <sys/stat.h>
45#include <fcntl.h> 43#include <fcntl.h>
46#include <assert.h> 44#include <assert.h>
47#include <unistd.h> 45#include <unistd.h>
48#include <string.h> 46#include <string.h>
49#include <errno.h> 47#include <errno.h>
50 48
51#define SYSLOG_READ 2 49#define SYSLOG_READ 2
52#define SYSLOG_READ_ALL 3 50#define SYSLOG_READ_ALL 3
53#define SYSLOG_READ_ALL_CLEAR 4 51#define SYSLOG_READ_ALL_CLEAR 4
54#define SYSLOG_UNREAD 9 52#define SYSLOG_UNREAD 9
55 53
56#undef APPEND 54#undef APPEND
57 55
58const unsigned int bufsize = 16384; 56const unsigned int bufsize = 16384;
59char buf[bufsize]; 57char buf[bufsize];
60 58
61SyslogInfo::SyslogInfo( QWidget* parent, const char* name, WFlags fl ) 59SyslogInfo::SyslogInfo( QWidget* parent, const char* name, WFlags fl )
62 : QWidget( parent, name, fl ) 60 : QWidget( parent, name, fl )
63{ 61{
64 QGridLayout *layout = new QGridLayout( this ); 62 QGridLayout *layout = new QGridLayout( this );
65 layout->setSpacing( 2 ); 63 layout->setSpacing( 2 );
66 layout->setMargin( 0 ); 64 layout->setMargin( 0 );
67 65
68 syslogview = new QTextView( this ); 66 syslogview = new QTextView( this );
69 syslogview->setTextFormat( PlainText ); 67 syslogview->setTextFormat( PlainText );
70 OConfig cfg( "qpe" ); 68 OConfig cfg( "qpe" );
71 cfg.setGroup( "Appearance" ); 69 cfg.setGroup( "Appearance" );
72 syslogview->setFont( QFont( "Fixed", cfg.readNumEntry( "FontSize", 10 ) ) ); 70 syslogview->setFont( QFont( cfg.readEntry( "FixedFontFamily", "Fixed" ), cfg.readNumEntry( "FixedFontSize", 10 ) ) );
73 layout->addWidget( syslogview, 0, 0 ); 71 layout->addWidget( syslogview, 0, 0 );
74 syslogview->setText( "..." ); 72 syslogview->setText( "..." );
75 73
76 memset( buf, 0, bufsize ); 74 memset( buf, 0, bufsize );
77 ::klogctl( SYSLOG_READ_ALL, buf, bufsize ); 75 ::klogctl( SYSLOG_READ_ALL, buf, bufsize );
78 syslogview->setText( buf ); 76 syslogview->setText( buf );
79 77
80#ifdef APPEND 78#ifdef APPEND
81 fd = ::open( "/proc/kmsg", O_RDONLY|O_SYNC ); 79 fd = ::open( "/proc/kmsg", O_RDONLY|O_SYNC );
82 if ( fd == -1 ) 80 if ( fd == -1 )
83 { 81 {
84 syslogview->setText( "Couldn't open /proc/kmsg: " + QString( strerror( errno ) ) ); 82 syslogview->setText( "Couldn't open /proc/kmsg: " + QString( strerror( errno ) ) );
85 return; 83 return;
86 } 84 }
87 QSocketNotifier *sn = new QSocketNotifier( fd, QSocketNotifier::Read, this ); 85 QSocketNotifier *sn = new QSocketNotifier( fd, QSocketNotifier::Read, this );
88 QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(updateData()) ); 86 QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(updateData()) );
89#else 87#else
90 QPushButton* pb = new QPushButton( "&Refresh", this ); 88 QPushButton* pb = new QPushButton( "&Refresh", this );
91 layout->addWidget( pb, 1, 0 ); 89 layout->addWidget( pb, 1, 0 );
92 QObject::connect( pb, SIGNAL(clicked()), this, SLOT(updateData()) ); 90 QObject::connect( pb, SIGNAL(clicked()), this, SLOT(updateData()) );
93#endif 91#endif
94} 92}
95 93
96SyslogInfo::~SyslogInfo() 94SyslogInfo::~SyslogInfo()
97{ 95{
98 if ( fd != -1 ) ::close( fd ); 96 if ( fd != -1 ) ::close( fd );
99} 97}
100 98
101void SyslogInfo::updateData() 99void SyslogInfo::updateData()
102{ 100{
103 qDebug( "SyslogInfo: updateData" ); 101 qDebug( "SyslogInfo: updateData" );
104#ifdef APPEND 102#ifdef APPEND
105 memset( buf, 0, bufsize ); 103 memset( buf, 0, bufsize );
106 int num = ::read( fd, buf, bufsize ); 104 int num = ::read( fd, buf, bufsize );
107 if ( num ) // -1 = error (permission denied) 105 if ( num ) // -1 = error (permission denied)
108 { 106 {
109 syslogview->append( "\n" ); 107 syslogview->append( "\n" );
110 syslogview->append( buf ); 108 syslogview->append( buf );
111 qDebug( "SyslogInfo: adding '%s'", buf ); 109 qDebug( "SyslogInfo: adding '%s'", buf );
112 } 110 }
113#else 111#else
114 memset( buf, 0, bufsize ); 112 memset( buf, 0, bufsize );
115 ::klogctl( SYSLOG_READ_ALL, buf, bufsize ); 113 ::klogctl( SYSLOG_READ_ALL, buf, bufsize );
116 syslogview->setText( buf ); 114 syslogview->setText( buf );
117 syslogview->ensureVisible( 0, syslogview->contentsHeight() ); 115 syslogview->ensureVisible( 0, syslogview->contentsHeight() );
118#endif 116#endif
119} 117}