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