summaryrefslogtreecommitdiff
path: root/core/applets/vtapplet/vt.cpp
Unidiff
Diffstat (limited to 'core/applets/vtapplet/vt.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/applets/vtapplet/vt.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/core/applets/vtapplet/vt.cpp b/core/applets/vtapplet/vt.cpp
index bd39093..aec63c3 100644
--- a/core/applets/vtapplet/vt.cpp
+++ b/core/applets/vtapplet/vt.cpp
@@ -1,34 +1,37 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de>
3**
4** Contact me @ mickeyl@handhelds.org
5** 3**
6** This file may be distributed and/or modified under the terms of the 4** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 5** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 6** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 7** packaging of this file.
10** 8**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 9** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 10** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 11**
14**********************************************************************/ 12**********************************************************************/
15 13
14#include "vt.h"
15
16/* OPIE */
17#include <opie2/odebug.h>
16#include <qpe/resource.h> 18#include <qpe/resource.h>
19using namespace Opie::Core;
17 20
21/* QT */
18#include <qpopupmenu.h> 22#include <qpopupmenu.h>
19 23
24/* STD */
20#include <fcntl.h> 25#include <fcntl.h>
21#include <unistd.h> 26#include <unistd.h>
22#include <sys/types.h> 27#include <sys/types.h>
23#include <sys/stat.h> 28#include <sys/stat.h>
24#include <sys/ioctl.h> 29#include <sys/ioctl.h>
25#include <linux/vt.h> 30#include <linux/vt.h>
26 31
27#include "vt.h"
28
29VTApplet::VTApplet ( ) 32VTApplet::VTApplet ( )
30 : QObject ( 0, "VTApplet" ) 33 : QObject ( 0, "VTApplet" )
31{ 34{
32} 35}
33 36
34VTApplet::~VTApplet ( ) 37VTApplet::~VTApplet ( )
@@ -71,13 +74,13 @@ QIconSet VTApplet::icon ( ) const
71 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 74 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
72 return pix; 75 return pix;
73} 76}
74 77
75QPopupMenu *VTApplet::popup ( QWidget* parent ) const 78QPopupMenu *VTApplet::popup ( QWidget* parent ) const
76{ 79{
77 qDebug( "VTApplet::popup" ); 80 odebug << "VTApplet::popup" << oendl;
78 81
79 struct vt_stat vtstat; 82 struct vt_stat vtstat;
80 int fd = ::open( "/dev/tty0", O_RDWR ); 83 int fd = ::open( "/dev/tty0", O_RDWR );
81 if ( fd == -1 ) return 0; 84 if ( fd == -1 ) return 0;
82 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0; 85 if ( ioctl( fd, VT_GETSTATE, &vtstat ) == -1 ) return 0;
83 86
@@ -96,48 +99,48 @@ QPopupMenu *VTApplet::popup ( QWidget* parent ) const
96 return m_subMenu; 99 return m_subMenu;
97} 100}
98 101
99 102
100void VTApplet::changeVT( int index ) 103void VTApplet::changeVT( int index )
101{ 104{
102 //qDebug( "VTApplet::changeVT( %d )", index-500 ); 105 //odebug << "VTApplet::changeVT( " << index-500 << " )" << oendl;
103 106
104 int fd = ::open("/dev/tty0", O_RDWR); 107 int fd = ::open("/dev/tty0", O_RDWR);
105 if ( fd == -1 ) return; 108 if ( fd == -1 ) return;
106 ioctl( fd, VT_ACTIVATE, index-500 ); 109 ioctl( fd, VT_ACTIVATE, index-500 );
107} 110}
108 111
109 112
110void VTApplet::updateMenu() 113void VTApplet::updateMenu()
111{ 114{
112 //qDebug( "VTApplet::updateMenu()" ); 115 //odebug << "VTApplet::updateMenu()" << oendl;
113 116
114 int fd = ::open( "/dev/console", O_RDONLY ); 117 int fd = ::open( "/dev/console", O_RDONLY );
115 if ( fd == -1 ) return; 118 if ( fd == -1 ) return;
116 119
117 for ( int i = 1; i < 10; ++i ) 120 for ( int i = 1; i < 10; ++i )
118 { 121 {
119 int result = ioctl( fd, VT_DISALLOCATE, i ); 122 int result = ioctl( fd, VT_DISALLOCATE, i );
120 123
121 /* 124 /*
122 if ( result == -1 ) 125 if ( result == -1 )
123 qDebug( "VT %d disallocated == free", i ); 126 odebug << "VT " << i << " disallocated == free" << oendl;
124 else 127 else
125 qDebug( "VT %d _not_ disallocated == busy", i ); 128 odebug << "VT " << i << " _not_ disallocated == busy" << oendl;
126 */ 129 */
127 130
128 m_subMenu->setItemEnabled( 500+i, result == -1 ); 131 m_subMenu->setItemEnabled( 500+i, result == -1 );
129 } 132 }
130 133
131 ::close( fd ); 134 ::close( fd );
132} 135}
133 136
134 137
135void VTApplet::activated() 138void VTApplet::activated()
136{ 139{
137 qDebug( "VTApplet::activated()" ); 140 odebug << "VTApplet::activated()" << oendl;
138} 141}
139 142
140 143
141QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 144QRESULT VTApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
142{ 145{
143 *iface = 0; 146 *iface = 0;