-rw-r--r-- | core/apps/calibrate/calibrate.cpp | 2 | ||||
-rw-r--r-- | core/opie-login/loginwindowimpl.cpp | 1 | ||||
-rw-r--r-- | core/opie-login/main.cpp | 1 | ||||
-rw-r--r-- | core/opie-login/opie-login.pro | 4 |
4 files changed, 6 insertions, 2 deletions
diff --git a/core/apps/calibrate/calibrate.cpp b/core/apps/calibrate/calibrate.cpp index 1f4fb1b..b9ad73d 100644 --- a/core/apps/calibrate/calibrate.cpp +++ b/core/apps/calibrate/calibrate.cpp @@ -1,116 +1,118 @@ /********************************************************************** ** 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. ** **********************************************************************/ +#include <math.h> + #include "calibrate.h" #include <qpe/resource.h> #include <qapplication.h> #if defined(Q_WS_QWS) || defined(_WS_QWS_) #include <qpainter.h> #include <qtimer.h> #include <qwindowsystem_qws.h> #include <qgfx_qws.h> Calibrate::Calibrate( QWidget* parent, const char * name, WFlags wf ) : QDialog( parent, name, TRUE, wf | WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop ) { showCross = TRUE; const int offset = 30; QRect desk = qApp->desktop() ->geometry(); setGeometry( 0, 0, desk.width(), desk.height() ); if ( desk.height() < 250 ) { int w = desk.height() / 3; logo.convertFromImage( Resource::loadImage( "launcher/opielogo" ).smoothScale( w, w ) ); } else { logo = Resource::loadPixmap( "launcher/opielogo" ); } cd.screenPoints[ QWSPointerCalibrationData::TopLeft ] = QPoint( offset, offset ); cd.screenPoints[ QWSPointerCalibrationData::BottomLeft ] = QPoint( offset, qt_screen->deviceHeight() - offset ); cd.screenPoints[ QWSPointerCalibrationData::BottomRight ] = QPoint( qt_screen->deviceWidth() - offset, qt_screen->deviceHeight() - offset ); cd.screenPoints[ QWSPointerCalibrationData::TopRight ] = QPoint( qt_screen->deviceWidth() - offset, offset ); cd.screenPoints[ QWSPointerCalibrationData::Center ] = QPoint( qt_screen->deviceWidth() / 2, qt_screen->deviceHeight() / 2 ); goodcd = cd; reset(); timer = new QTimer( this ); connect( timer, SIGNAL( timeout() ), this, SLOT( timeout() ) ); } Calibrate::~Calibrate() { store(); } void Calibrate::show() { grabMouse(); QWSServer::mouseHandler() ->getCalibration( &goodcd ); QWSServer::mouseHandler() ->clearCalibration(); QDialog::show(); } void Calibrate::store() { QWSServer::mouseHandler() ->calibrate( &goodcd ); } void Calibrate::hide() { if ( isVisible() ) store(); QDialog::hide(); } void Calibrate::reset() { penPos = QPoint(); location = QWSPointerCalibrationData::TopLeft; crossPos = fromDevice( cd.screenPoints[ location ] ); } QPoint Calibrate::fromDevice( const QPoint &p ) { return qt_screen->mapFromDevice ( p, QSize( qt_screen->deviceWidth ( ), qt_screen->deviceHeight() ) ); } bool Calibrate::sanityCheck() { QPoint tl = cd.devPoints[QWSPointerCalibrationData::TopLeft]; QPoint tr = cd.devPoints[QWSPointerCalibrationData::TopRight]; QPoint bl = cd.devPoints[QWSPointerCalibrationData::BottomLeft]; QPoint br = cd.devPoints[QWSPointerCalibrationData::BottomRight]; // not needed anywhere .. just calculate it, so it's there cd. devPoints [QWSPointerCalibrationData::Center] = QRect ( tl, br ). normalize ( ). center ( ); int dlx = QABS( bl. x ( ) - tl. x ( )); int dly = QABS( bl. y ( ) - tl. y ( )); int drx = QABS( br. x ( ) - tr. x ( )); int dry = QABS( br. y ( ) - tr. y ( )); int dtx = QABS( tr. x ( ) - tl. x ( )); int dty = QABS( tr. y ( ) - tl. y ( )); int dbx = QABS( br. x ( ) - bl. x ( )); int dby = QABS( br. y ( ) - bl. y ( )); diff --git a/core/opie-login/loginwindowimpl.cpp b/core/opie-login/loginwindowimpl.cpp index 3265b46..26d9225 100644 --- a/core/opie-login/loginwindowimpl.cpp +++ b/core/opie-login/loginwindowimpl.cpp @@ -1,119 +1,120 @@ #include <qapplication.h> #include <qpushbutton.h> #include <qlayout.h> #include <qframe.h> #include <qlineedit.h> #include <qtimer.h> #include <qcombobox.h> #include <qpixmap.h> #include <qlabel.h> #include <qpopupmenu.h> #include <qmessagebox.h> #include <qpe/qcopenvelope_qws.h> #include <opie/odevice.h> #include <stdio.h> #include <pwd.h> #include <grp.h> #include <unistd.h> #include <stdlib.h> +#undef USEPAM // FOR my toolchain #ifdef USEPAM extern "C" { #include <security/pam_appl.h> } #else #include <crypt.h> #include <shadow.h> #endif #include "loginwindowimpl.h" #include "inputmethods.h" LoginWindowImpl::LoginWindowImpl ( ) : LoginWindow ( 0, "LOGIN-WINDOW", WStyle_Customize | WStyle_NoBorder | WDestructiveClose ) { QPopupMenu *pop = new QPopupMenu ( this ); pop-> insertItem ( tr( "Restart" ), this, SLOT( restart ( ))); m_menu-> setPopup ( pop ); QHBoxLayout *lay = new QHBoxLayout ( m_taskbar, 4, 4 ); m_input = new InputMethods ( m_taskbar ); lay-> addWidget ( m_input ); lay-> addStretch ( 10 ); setActiveWindow ( ); m_password-> setFocus ( ); m_user-> insertStringList ( getAllUsers ( )); QTimer::singleShot ( 0, this, SLOT( showIM ( ))); QString opiedir = ::getenv ( "OPIEDIR" ); QPixmap bgpix ( opiedir + "/pics/launcher/opie-background.jpg" ); if ( !bgpix. isNull ( )) setBackgroundPixmap ( bgpix ); m_caption-> setText ( m_caption-> text ( ) + tr( "<center><h1><u>%1 %2</u></h1></center>" ). arg ( ODevice::inst ( )-> systemString ( )). arg ( ODevice::inst ( )-> systemVersionString ( ))); } LoginWindowImpl::~LoginWindowImpl ( ) { } void LoginWindowImpl::keyPressEvent ( QKeyEvent *e ) { switch ( e-> key ( )) { case Key_F34: suspend ( ); break; case Key_F35: backlight ( ); break; default : e-> ignore ( ); break; } LoginWindow::keyPressEvent ( e ); } void LoginWindowImpl::toggleEchoMode ( bool t ) { m_password-> setEchoMode ( t ? QLineEdit::Normal : QLineEdit::Password ); } QStringList LoginWindowImpl::getAllUsers ( ) { struct passwd *pwd; QStringList sl; while (( pwd = getpwent ( ))) { if (( pwd-> pw_uid == 0 ) || ( pwd-> pw_uid >= 500 && pwd-> pw_uid < 65534 )) sl << QString ( pwd-> pw_name ); } endpwent ( ); return sl; } void LoginWindowImpl::showIM ( ) { m_input-> showInputMethod ( ); } void LoginWindowImpl::restart ( ) { qApp-> quit ( ); } void LoginWindowImpl::suspend ( ) { system ( "apm -s" ); usleep ( 1 * 1000 * 1000 ); { QCopEnvelope e("QPE/System", "setBacklight(int)"); e << -3; // Force on } } diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp index 9d52b75..44d6f8d 100644 --- a/core/opie-login/main.cpp +++ b/core/opie-login/main.cpp @@ -1,103 +1,104 @@ #include <sys/time.h> #include <sys/resource.h> #include <unistd.h> #include <syslog.h> #include <sys/types.h> #include <sys/wait.h> #include <stdio.h> +#include <stdlib.h> #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <opie/odevice.h> #include <qwindowsystem_qws.h> #include <qfile.h> #include "loginwindowimpl.h" #include "calibrate.h" int login_main ( int argc, char **argv ); int main ( int argc, char **argv ) { if ( geteuid ( ) != 0 ) { fprintf ( stderr, "%s can only be executed by root. (or chmod +s)", argv [0] ); return 1; } // struct rlimit rl; // getrlimit ( RLIMIT_NOFILE, &rl ); // for ( unsigned int i = 0; i < rl. rlim_cur; i++ ) // close ( i ); setpgid ( 0, 0 ); setsid ( ); openlog ( "opie-login", LOG_CONS, LOG_AUTHPRIV ); while ( true ) { pid_t child = fork ( ); if ( child < 0 ) { syslog ( LOG_ERR, "Could not fork process" ); break; } else if ( child > 0 ) { int status = 0; while ( waitpid ( child, &status, 0 ) < 0 ) { } } else { exit ( login_main ( argc, argv )); } } closelog ( ); } class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter { public: ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) { bool doinst = false; m_model = ODevice::inst ( )-> model ( ); m_power_timer = 0; switch ( m_model ) { case OMODEL_iPAQ_H31xx: case OMODEL_iPAQ_H36xx: case OMODEL_iPAQ_H37xx: case OMODEL_iPAQ_H38xx: doinst = true; break; default : break; } if ( doinst ) QWSServer::setKeyboardFilter ( this ); } virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) { bool kill = false; // Rotate cursor keys 180° switch ( m_model ) { case OMODEL_iPAQ_H31xx: case OMODEL_iPAQ_H38xx: { int newkeycode = keycode; switch ( keycode ) { case Key_Left : newkeycode = Key_Right; break; case Key_Right: newkeycode = Key_Left; break; case Key_Up : newkeycode = Key_Down; break; case Key_Down : newkeycode = Key_Up; break; } if ( newkeycode != keycode ) { QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); kill = true; } diff --git a/core/opie-login/opie-login.pro b/core/opie-login/opie-login.pro index 35c1ed0..ef449ab 100644 --- a/core/opie-login/opie-login.pro +++ b/core/opie-login/opie-login.pro @@ -1,25 +1,25 @@ TEMPLATE = app CONFIG = qt warn_on debug usepam HEADERS = loginwindowimpl.h \ ../launcher/inputmethods.h \ ../apps/calibrate/calibrate.h SOURCES = loginwindowimpl.cpp \ ../launcher/inputmethods.cpp \ ../apps/calibrate/calibrate.cpp \ main.cpp INTERFACES = loginwindow.ui INCLUDEPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate DEPENDPATH += $(OPIEDIR)/include ../launcher ../apps/calibrate LIBS += -lqpe -lopie -usepam:LIBS += -lpam -usepam:DEFINES += USEPAM +#usepam:LIBS += -lpam +#usepam:DEFINES += USEPAM DESTDIR = $(OPIEDIR)/bin TARGET = opie-login |