summaryrefslogtreecommitdiff
authorsandman <sandman>2002-06-09 23:40:20 (UTC)
committer sandman <sandman>2002-06-09 23:40:20 (UTC)
commit4f04ef71be8f36e6251f4e6e7fafbfc36fba415c (patch) (unidiff)
treefd4d907f36fc5291ff9d91237bebaf872313f18d
parent65b1a790493272a38b0ac44e219d5186168fabac (diff)
downloadopie-4f04ef71be8f36e6251f4e6e7fafbfc36fba415c.zip
opie-4f04ef71be8f36e6251f4e6e7fafbfc36fba415c.tar.gz
opie-4f04ef71be8f36e6251f4e6e7fafbfc36fba415c.tar.bz2
Fixed Alarm sound handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 6771a66..693e77f 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,171 +1,169 @@
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 "desktop.h" 21#include "desktop.h"
22#include "info.h" 22#include "info.h"
23#include "launcher.h" 23#include "launcher.h"
24#include "mrulist.h" 24#include "mrulist.h"
25#include "qcopbridge.h" 25#include "qcopbridge.h"
26#include "shutdownimpl.h" 26#include "shutdownimpl.h"
27#include "startmenu.h" 27#include "startmenu.h"
28#include "taskbar.h" 28#include "taskbar.h"
29#include "transferserver.h" 29#include "transferserver.h"
30#include "irserver.h" 30#include "irserver.h"
31#include "packageslave.h" 31#include "packageslave.h"
32 32
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/password.h> 35#include <qpe/password.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/power.h> 37#include <qpe/power.h>
38#include <qpe/timeconversion.h> 38#include <qpe/timeconversion.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/global.h> 40#include <qpe/global.h>
41#ifdef QT_QWS_CUSTOM 41#include <qpe/custom.h>
42#include "qpe/custom.h"
43#endif
44 42
45#include <qgfx_qws.h> 43#include <qgfx_qws.h>
46#include <qmainwindow.h> 44#include <qmainwindow.h>
47#include <qmessagebox.h> 45#include <qmessagebox.h>
48#include <qtimer.h> 46#include <qtimer.h>
49#include <qwindowsystem_qws.h> 47#include <qwindowsystem_qws.h>
50 48
51#include <qvaluelist.h> 49#include <qvaluelist.h>
52 50
53#include <stdlib.h> 51#include <stdlib.h>
54#include <unistd.h> 52#include <unistd.h>
55 53
56class QCopKeyRegister 54class QCopKeyRegister
57{ 55{
58public: 56public:
59 QCopKeyRegister() : keyCode(0) { } 57 QCopKeyRegister() : keyCode(0) { }
60 QCopKeyRegister(int k, const QString &c, const QString &m) 58 QCopKeyRegister(int k, const QString &c, const QString &m)
61 : keyCode(k), channel(c), message(m) { } 59 : keyCode(k), channel(c), message(m) { }
62 60
63 int getKeyCode() const { return keyCode; } 61 int getKeyCode() const { return keyCode; }
64 QString getChannel() const { return channel; } 62 QString getChannel() const { return channel; }
65 QString getMessage() const { return message; } 63 QString getMessage() const { return message; }
66 64
67private: 65private:
68 int keyCode; 66 int keyCode;
69 QString channel, message; 67 QString channel, message;
70}; 68};
71 69
72typedef QValueList<QCopKeyRegister> KeyRegisterList; 70typedef QValueList<QCopKeyRegister> KeyRegisterList;
73KeyRegisterList keyRegisterList; 71KeyRegisterList keyRegisterList;
74 72
75static Desktop* qpedesktop = 0; 73static Desktop* qpedesktop = 0;
76static int loggedin=0; 74static int loggedin=0;
77static void login(bool at_poweron) 75static void login(bool at_poweron)
78{ 76{
79 if ( !loggedin ) { 77 if ( !loggedin ) {
80 Global::terminateBuiltin("calibrate"); 78 Global::terminateBuiltin("calibrate");
81 Password::authenticate(at_poweron); 79 Password::authenticate(at_poweron);
82 loggedin=1; 80 loggedin=1;
83 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 81 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
84 } 82 }
85} 83}
86 84
87bool Desktop::screenLocked() 85bool Desktop::screenLocked()
88{ 86{
89 return loggedin == 0; 87 return loggedin == 0;
90} 88}
91 89
92/* 90/*
93 Priority is number of alerts that are needed to pop up 91 Priority is number of alerts that are needed to pop up
94 alert. 92 alert.
95 */ 93 */
96class DesktopPowerAlerter : public QMessageBox 94class DesktopPowerAlerter : public QMessageBox
97{ 95{
98public: 96public:
99 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 97 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
100 : QMessageBox( tr("Battery Status"), "Low Battery", 98 : QMessageBox( tr("Battery Status"), "Low Battery",
101 QMessageBox::Critical, 99 QMessageBox::Critical,
102 QMessageBox::Ok | QMessageBox::Default, 100 QMessageBox::Ok | QMessageBox::Default,
103 QMessageBox::NoButton, QMessageBox::NoButton, 101 QMessageBox::NoButton, QMessageBox::NoButton,
104 parent, name, FALSE ) 102 parent, name, FALSE )
105 { 103 {
106 currentPriority = INT_MAX; 104 currentPriority = INT_MAX;
107 alertCount = 0; 105 alertCount = 0;
108 } 106 }
109 107
110 void alert( const QString &text, int priority ); 108 void alert( const QString &text, int priority );
111 void hideEvent( QHideEvent * ); 109 void hideEvent( QHideEvent * );
112private: 110private:
113 int currentPriority; 111 int currentPriority;
114 int alertCount; 112 int alertCount;
115}; 113};
116 114
117void DesktopPowerAlerter::alert( const QString &text, int priority ) 115void DesktopPowerAlerter::alert( const QString &text, int priority )
118{ 116{
119 alertCount++; 117 alertCount++;
120 if ( alertCount < priority ) 118 if ( alertCount < priority )
121 return; 119 return;
122 if ( priority > currentPriority ) 120 if ( priority > currentPriority )
123 return; 121 return;
124 currentPriority = priority; 122 currentPriority = priority;
125 setText( text ); 123 setText( text );
126 show(); 124 show();
127} 125}
128 126
129 127
130void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 128void DesktopPowerAlerter::hideEvent( QHideEvent *e )
131{ 129{
132 QMessageBox::hideEvent( e ); 130 QMessageBox::hideEvent( e );
133 alertCount = 0; 131 alertCount = 0;
134 currentPriority = INT_MAX; 132 currentPriority = INT_MAX;
135} 133}
136 134
137 135
138 136
139DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 137DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
140 : QPEApplication( argc, argv, appType ) 138 : QPEApplication( argc, argv, appType )
141{ 139{
142 140
143 QTimer *t = new QTimer( this ); 141 QTimer *t = new QTimer( this );
144 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 142 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
145 t->start( 10000 ); 143 t->start( 10000 );
146 ps = new PowerStatus; 144 ps = new PowerStatus;
147 pa = new DesktopPowerAlerter( 0 ); 145 pa = new DesktopPowerAlerter( 0 );
148 146
149 channel = new QCopChannel( "QPE/Desktop", this ); 147 channel = new QCopChannel( "QPE/Desktop", this );
150 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 148 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
151 this, SLOT(receive(const QCString&, const QByteArray&)) ); 149 this, SLOT(receive(const QCString&, const QByteArray&)) );
152} 150}
153 151
154 152
155DesktopApplication::~DesktopApplication() 153DesktopApplication::~DesktopApplication()
156{ 154{
157 delete ps; 155 delete ps;
158 delete pa; 156 delete pa;
159} 157}
160 158
161void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 159void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
162{ 160{
163 QDataStream stream( data, IO_ReadOnly ); 161 QDataStream stream( data, IO_ReadOnly );
164 if (msg == "keyRegister(int key, QString channel, QString message)") 162 if (msg == "keyRegister(int key, QString channel, QString message)")
165 { 163 {
166 int k; 164 int k;
167 QString c, m; 165 QString c, m;
168 stream >> k; 166 stream >> k;
169 stream >> c; 167 stream >> c;
170 stream >> m; 168 stream >> m;
171 169
@@ -644,149 +642,149 @@ void Desktop::toggleNumLockState()
644 642
645void Desktop::toggleCapsLockState() 643void Desktop::toggleCapsLockState()
646{ 644{
647 tb->toggleCapsLockState(); 645 tb->toggleCapsLockState();
648} 646}
649 647
650void Desktop::styleChange( QStyle &s ) 648void Desktop::styleChange( QStyle &s )
651{ 649{
652 QWidget::styleChange( s ); 650 QWidget::styleChange( s );
653 int displayw = qApp->desktop()->width(); 651 int displayw = qApp->desktop()->width();
654 int displayh = qApp->desktop()->height(); 652 int displayh = qApp->desktop()->height();
655 653
656 QSize sz = tb->sizeHint(); 654 QSize sz = tb->sizeHint();
657 655
658 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 656 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
659} 657}
660 658
661void DesktopApplication::shutdown() 659void DesktopApplication::shutdown()
662{ 660{
663 if ( type() != GuiServer ) 661 if ( type() != GuiServer )
664 return; 662 return;
665 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 663 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
666 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 664 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
667 this, SLOT(shutdown(ShutdownImpl::Type)) ); 665 this, SLOT(shutdown(ShutdownImpl::Type)) );
668 sd->showMaximized(); 666 sd->showMaximized();
669} 667}
670 668
671void DesktopApplication::shutdown( ShutdownImpl::Type t ) 669void DesktopApplication::shutdown( ShutdownImpl::Type t )
672{ 670{
673 switch ( t ) { 671 switch ( t ) {
674 case ShutdownImpl::ShutdownSystem: 672 case ShutdownImpl::ShutdownSystem:
675 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 673 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
676 break; 674 break;
677 case ShutdownImpl::RebootSystem: 675 case ShutdownImpl::RebootSystem:
678 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 676 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
679 break; 677 break;
680 case ShutdownImpl::RestartDesktop: 678 case ShutdownImpl::RestartDesktop:
681 restart(); 679 restart();
682 break; 680 break;
683 case ShutdownImpl::TerminateDesktop: 681 case ShutdownImpl::TerminateDesktop:
684 prepareForTermination(FALSE); 682 prepareForTermination(FALSE);
685 quit(); 683 quit();
686 break; 684 break;
687 } 685 }
688} 686}
689 687
690void DesktopApplication::restart() 688void DesktopApplication::restart()
691{ 689{
692 prepareForTermination(TRUE); 690 prepareForTermination(TRUE);
693 691
694#ifdef Q_WS_QWS 692#ifdef Q_WS_QWS
695 for ( int fd = 3; fd < 100; fd++ ) 693 for ( int fd = 3; fd < 100; fd++ )
696 close( fd ); 694 close( fd );
697#if defined(QT_DEMO_SINGLE_FLOPPY) 695#if defined(QT_DEMO_SINGLE_FLOPPY)
698 execl( "/sbin/init", "qpe", 0 ); 696 execl( "/sbin/init", "qpe", 0 );
699#elif defined(QT_QWS_CASSIOPEIA) 697#elif defined(QT_QWS_CASSIOPEIA)
700 execl( "/bin/sh", "sh", 0 ); 698 execl( "/bin/sh", "sh", 0 );
701#else 699#else
702 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 700 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
703#endif 701#endif
704 exit(1); 702 exit(1);
705#endif 703#endif
706} 704}
707 705
708void Desktop::startTransferServer() 706void Desktop::startTransferServer()
709{ 707{
710 // start qcop bridge server 708 // start qcop bridge server
711 qcopBridge = new QCopBridge( 4243 ); 709 qcopBridge = new QCopBridge( 4243 );
712 if ( !qcopBridge->ok() ) { 710 if ( !qcopBridge->ok() ) {
713 delete qcopBridge; 711 delete qcopBridge;
714 qcopBridge = 0; 712 qcopBridge = 0;
715 } 713 }
716 // start transfer server 714 // start transfer server
717 transferServer = new TransferServer( 4242 ); 715 transferServer = new TransferServer( 4242 );
718 if ( !transferServer->ok() ) { 716 if ( !transferServer->ok() ) {
719 delete transferServer; 717 delete transferServer;
720 transferServer = 0; 718 transferServer = 0;
721 } 719 }
722 if ( !transferServer || !qcopBridge ) 720 if ( !transferServer || !qcopBridge )
723 startTimer( 2000 ); 721 startTimer( 2000 );
724} 722}
725 723
726void Desktop::timerEvent( QTimerEvent *e ) 724void Desktop::timerEvent( QTimerEvent *e )
727{ 725{
728 killTimer( e->timerId() ); 726 killTimer( e->timerId() );
729 startTransferServer(); 727 startTransferServer();
730} 728}
731 729
732void Desktop::terminateServers() 730void Desktop::terminateServers()
733{ 731{
734 delete transferServer; 732 delete transferServer;
735 delete qcopBridge; 733 delete qcopBridge;
736 transferServer = 0; 734 transferServer = 0;
737 qcopBridge = 0; 735 qcopBridge = 0;
738} 736}
739 737
740void Desktop::rereadVolumes() 738void Desktop::rereadVolumes()
741{ 739{
742 Config cfg("qpe"); 740 Config cfg("qpe");
743 cfg.setGroup("Volume"); 741 cfg.setGroup("Volume");
744 touchclick = cfg.readBoolEntry("TouchSound"); 742 touchclick = cfg.readBoolEntry("TouchSound");
745 keyclick = cfg.readBoolEntry("KeySound"); 743 keyclick = cfg.readBoolEntry("KeySound");
746 alarmsound = cfg.readBoolEntry("AlarmSound"); 744 alarmsound = cfg.readBoolEntry("AlarmSound");
747// Config cfg("Sound"); 745// Config cfg("Sound");
748// cfg.setGroup("System"); 746// cfg.setGroup("System");
749// touchclick = cfg.readBoolEntry("Touch"); 747// touchclick = cfg.readBoolEntry("Touch");
750// keyclick = cfg.readBoolEntry("Key"); 748// keyclick = cfg.readBoolEntry("Key");
751} 749}
752 750
753void Desktop::keyClick() 751void Desktop::keyClick()
754{ 752{
755#ifdef CUSTOM_SOUND_KEYCLICK 753#ifdef CUSTOM_SOUND_KEYCLICK
756 if ( keyclick ) 754 if ( keyclick )
757 CUSTOM_SOUND_KEYCLICK; 755 CUSTOM_SOUND_KEYCLICK;
758#endif 756#endif
759} 757}
760 758
761void Desktop::screenClick() 759void Desktop::screenClick()
762{ 760{
763#ifdef CUSTOM_SOUND_TOUCH 761#ifdef CUSTOM_SOUND_TOUCH
764 if ( touchclick ) 762 if ( touchclick )
765 CUSTOM_SOUND_TOUCH; 763 CUSTOM_SOUND_TOUCH;
766#endif 764#endif
767} 765}
768 766
769void Desktop::soundAlarm() 767void Desktop::soundAlarm()
770{ 768{
771#ifdef CUSTOM_SOUND_ALARM 769#ifdef CUSTOM_SOUND_ALARM
772 if (alarmsound) 770 if (qpedesktop->alarmsound)
773 CUSTOM_SOUND_ALARM; 771 CUSTOM_SOUND_ALARM;
774#endif 772#endif
775} 773}
776 774
777bool Desktop::eventFilter( QObject *w, QEvent *ev ) 775bool Desktop::eventFilter( QObject *w, QEvent *ev )
778{ 776{
779 if ( ev->type() == QEvent::KeyPress ) { 777 if ( ev->type() == QEvent::KeyPress ) {
780 QKeyEvent *ke = (QKeyEvent *)ev; 778 QKeyEvent *ke = (QKeyEvent *)ev;
781 if ( ke->key() == Qt::Key_F11 ) { // menu key 779 if ( ke->key() == Qt::Key_F11 ) { // menu key
782 QWidget *active = qApp->activeWindow(); 780 QWidget *active = qApp->activeWindow();
783 if ( active && active->isPopup() ) { 781 if ( active && active->isPopup() ) {
784 active->close(); 782 active->close();
785 } 783 }
786 raiseMenu(); 784 raiseMenu();
787 return TRUE; 785 return TRUE;
788 } 786 }
789 } 787 }
790 return FALSE; 788 return FALSE;
791} 789}
792 790