summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 03a23dc..4c239a6 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,84 +1,86 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** 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 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <syslog.h>
22
21#include "desktop.h" 23#include "desktop.h"
22#include "info.h" 24#include "info.h"
23#include "launcher.h" 25#include "launcher.h"
24#include "qcopbridge.h" 26#include "qcopbridge.h"
25#include "shutdownimpl.h" 27#include "shutdownimpl.h"
26#include "startmenu.h" 28#include "startmenu.h"
27#include "taskbar.h" 29#include "taskbar.h"
28#include "transferserver.h" 30#include "transferserver.h"
29#include "irserver.h" 31#include "irserver.h"
30#include "packageslave.h" 32#include "packageslave.h"
31#include "screensaver.h" 33#include "screensaver.h"
32 34
33#include <qpe/applnk.h> 35#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 36#include <qpe/mimetype.h>
35#include <qpe/password.h> 37#include <qpe/password.h>
36#include <qpe/config.h> 38#include <qpe/config.h>
37#include <qpe/power.h> 39#include <qpe/power.h>
38#include <qpe/timeconversion.h> 40#include <qpe/timeconversion.h>
39#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
40#include <qpe/network.h> 42#include <qpe/network.h>
41#include <qpe/global.h> 43#include <qpe/global.h>
42 44
43#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ ) 45#if defined( QT_QWS_SHARP ) || defined( QT_QWS_IPAQ )
44#include <qpe/custom.h> 46#include <qpe/custom.h>
45#endif 47#endif
46 48
47#include <opie/odevice.h> 49#include <opie/odevice.h>
48 50
49#include <qgfx_qws.h> 51#include <qgfx_qws.h>
50#include <qmainwindow.h> 52#include <qmainwindow.h>
51#include <qmessagebox.h> 53#include <qmessagebox.h>
52#include <qtimer.h> 54#include <qtimer.h>
53#include <qwindowsystem_qws.h> 55#include <qwindowsystem_qws.h>
54 56
55#include <qvaluelist.h> 57#include <qvaluelist.h>
56 58
57#include <stdlib.h> 59#include <stdlib.h>
58#include <unistd.h> 60#include <unistd.h>
59#include <fcntl.h> 61#include <fcntl.h>
60 62
61 63
62using namespace Opie; 64using namespace Opie;
63 65
64class QCopKeyRegister 66class QCopKeyRegister
65{ 67{
66public: 68public:
67 QCopKeyRegister() : keyCode( 0 ) 69 QCopKeyRegister() : keyCode( 0 )
68 { } 70 { }
69 QCopKeyRegister( int k, const QCString &c, const QCString &m ) 71 QCopKeyRegister( int k, const QCString &c, const QCString &m )
70 : keyCode( k ), channel( c ), message( m ) 72 : keyCode( k ), channel( c ), message( m )
71 { } 73 { }
72 74
73 int getKeyCode() const 75 int getKeyCode() const
74 { 76 {
75 return keyCode; 77 return keyCode;
76 } 78 }
77 QCString getChannel() const 79 QCString getChannel() const
78 { 80 {
79 return channel; 81 return channel;
80 } 82 }
81 QCString getMessage() const 83 QCString getMessage() const
82 { 84 {
83 return message; 85 return message;
84 } 86 }
@@ -677,134 +679,142 @@ void Desktop::togglePower()
677#endif 679#endif
678 680
679 ODevice::inst ( )-> suspend ( ); 681 ODevice::inst ( )-> suspend ( );
680 682
681 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 683 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
682 QWSServer::screenSaverActivate ( false ); 684 QWSServer::screenSaverActivate ( false );
683 685
684 { 686 {
685 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 687 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
686 } 688 }
687 689
688 if ( wasloggedin ) 690 if ( wasloggedin )
689 login ( true ); 691 login ( true );
690 692
691 execAutoStart(); 693 execAutoStart();
692 //qcopBridge->closeOpenConnections(); 694 //qcopBridge->closeOpenConnections();
693 695
694 excllock = false; 696 excllock = false;
695} 697}
696 698
697void Desktop::toggleLight() 699void Desktop::toggleLight()
698{ 700{
699 QCopEnvelope e( "QPE/System", "setBacklight(int)" ); 701 QCopEnvelope e( "QPE/System", "setBacklight(int)" );
700 e << -2; // toggle 702 e << -2; // toggle
701} 703}
702 704
703void Desktop::toggleSymbolInput() 705void Desktop::toggleSymbolInput()
704{ 706{
705 tb->toggleSymbolInput(); 707 tb->toggleSymbolInput();
706} 708}
707 709
708void Desktop::toggleNumLockState() 710void Desktop::toggleNumLockState()
709{ 711{
710 tb->toggleNumLockState(); 712 tb->toggleNumLockState();
711} 713}
712 714
713void Desktop::toggleCapsLockState() 715void Desktop::toggleCapsLockState()
714{ 716{
715 tb->toggleCapsLockState(); 717 tb->toggleCapsLockState();
716} 718}
717 719
718void Desktop::styleChange( QStyle &s ) 720void Desktop::styleChange( QStyle &s )
719{ 721{
720 QWidget::styleChange( s ); 722 QWidget::styleChange( s );
721 int displayw = qApp->desktop() ->width(); 723 int displayw = qApp->desktop() ->width();
722 int displayh = qApp->desktop() ->height(); 724 int displayh = qApp->desktop() ->height();
723 725
724 QSize sz = tb->sizeHint(); 726 QSize sz = tb->sizeHint();
725 727
726 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); 728 tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() );
727} 729}
728 730
729void DesktopApplication::shutdown() 731void DesktopApplication::shutdown()
730{ 732{
731 if ( type() != GuiServer ) 733 if ( type() != GuiServer )
732 return ; 734 return ;
733 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 735 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
734 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), 736 connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ),
735 this, SLOT( shutdown( ShutdownImpl::Type ) ) ); 737 this, SLOT( shutdown( ShutdownImpl::Type ) ) );
736 sd->showMaximized(); 738 sd->showMaximized();
737} 739}
738 740
739void DesktopApplication::shutdown( ShutdownImpl::Type t ) 741void DesktopApplication::shutdown( ShutdownImpl::Type t )
740{ 742{
743
744 char *opt = 0;
745
741 switch ( t ) { 746 switch ( t ) {
742 case ShutdownImpl::ShutdownSystem: 747 case ShutdownImpl::ShutdownSystem:
743 execlp( "shutdown", "shutdown", "-h", "now", ( void* ) 0 ); 748 opt = "-h";
744 break; 749 // fall through
745 case ShutdownImpl::RebootSystem: 750 case ShutdownImpl::RebootSystem:
746 execlp( "shutdown", "shutdown", "-r", "now", ( void* ) 0 ); 751 if ( opt == 0 )
752 opt = "-r";
753
754 if ( execle( "shutdown", "shutdown", opt, "now", ( void* ) 0, "/sbin", "/usr/sbin", ( void* ) 0 ) < 0 )
755 ::syslog ( LOG_ERR, "Erroring execing shutdown\n" );
756
747 break; 757 break;
748 case ShutdownImpl::RestartDesktop: 758 case ShutdownImpl::RestartDesktop:
749 restart(); 759 restart();
750 break; 760 break;
751 case ShutdownImpl::TerminateDesktop: 761 case ShutdownImpl::TerminateDesktop:
752 prepareForTermination( FALSE ); 762 prepareForTermination( FALSE );
753 763
754 // This is a workaround for a Qt bug 764 // This is a workaround for a Qt bug
755 // clipboard applet has to stop its poll timer, or Qt/E 765 // clipboard applet has to stop its poll timer, or Qt/E
756 // will hang on quit() right before it emits aboutToQuit() 766 // will hang on quit() right before it emits aboutToQuit()
757 emit aboutToQuit ( ); 767 emit aboutToQuit ( );
758 768
759 quit(); 769 quit();
760 break; 770 break;
761 } 771 }
762} 772}
763 773
764void DesktopApplication::restart() 774void DesktopApplication::restart()
765{ 775{
766 prepareForTermination( TRUE ); 776 prepareForTermination( TRUE );
767 777
768#ifdef Q_WS_QWS 778#ifdef Q_WS_QWS
769 779
770 for ( int fd = 3; fd < 100; fd++ ) 780 for ( int fd = 3; fd < 100; fd++ )
771 close( fd ); 781 close( fd );
772#if defined(QT_DEMO_SINGLE_FLOPPY) 782#if defined(QT_DEMO_SINGLE_FLOPPY)
773 783
774 execl( "/sbin/init", "qpe", 0 ); 784 execl( "/sbin/init", "qpe", 0 );
775#elif defined(QT_QWS_CASSIOPEIA) 785#elif defined(QT_QWS_CASSIOPEIA)
776 786
777 execl( "/bin/sh", "sh", 0 ); 787 execl( "/bin/sh", "sh", 0 );
778#else 788#else
779 789
780 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 790 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
781#endif 791#endif
782 792
783 exit( 1 ); 793 exit( 1 );
784#endif 794#endif
785} 795}
786 796
787void Desktop::startTransferServer() 797void Desktop::startTransferServer()
788{ 798{
789 // start qcop bridge server 799 // start qcop bridge server
790 qcopBridge = new QCopBridge( 4243 ); 800 qcopBridge = new QCopBridge( 4243 );
791 if ( !qcopBridge->ok() ) { 801 if ( !qcopBridge->ok() ) {
792 delete qcopBridge; 802 delete qcopBridge;
793 qcopBridge = 0; 803 qcopBridge = 0;
794 } 804 }
795 // start transfer server 805 // start transfer server
796 transferServer = new TransferServer( 4242 ); 806 transferServer = new TransferServer( 4242 );
797 if ( !transferServer->ok() ) { 807 if ( !transferServer->ok() ) {
798 delete transferServer; 808 delete transferServer;
799 transferServer = 0; 809 transferServer = 0;
800 } 810 }
801 if ( !transferServer || !qcopBridge ) 811 if ( !transferServer || !qcopBridge )
802 startTimer( 2000 ); 812 startTimer( 2000 );
803} 813}
804 814
805void Desktop::timerEvent( QTimerEvent *e ) 815void Desktop::timerEvent( QTimerEvent *e )
806{ 816{
807 killTimer( e->timerId() ); 817 killTimer( e->timerId() );
808 startTransferServer(); 818 startTransferServer();
809} 819}
810 820