summaryrefslogtreecommitdiff
path: root/library/qpeapplication.cpp
Unidiff
Diffstat (limited to 'library/qpeapplication.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp181
1 files changed, 105 insertions, 76 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 4dbfbd8..a55f5f9 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -163,25 +163,45 @@ public:
163}; 163};
164 164
165static int muted=0; 165static int muted=0;
166static int micMuted=0;
166 167
167static void setVolume(int t=0, int percent=-1) 168static void setVolume(int t=0, int percent=-1)
168{ 169{
169 switch (t) { 170 switch (t) {
170 case 0: { 171 case 0: {
171 Config cfg("Sound"); 172 Config cfg("Sound");
172 cfg.setGroup("System"); 173 cfg.setGroup("System");
173 if ( percent < 0 ) 174 if ( percent < 0 )
174 percent = cfg.readNumEntry("Volume",50); 175 percent = cfg.readNumEntry("Volume",50);
175 int fd = 0; 176 int fd = 0;
176 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 177 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
177 int vol = muted ? 0 : percent; 178 int vol = muted ? 0 : percent;
178 // set both channels to same volume 179 // set both channels to same volume
179 vol |= vol << 8; 180 vol |= vol << 8;
180 ioctl(fd, MIXER_WRITE(0), &vol); 181 ioctl(fd, MIXER_WRITE(0), &vol);
181 ::close(fd); 182 ::close(fd);
182 } 183 }
183 } break; 184 } break;
184 } 185 }
186}
187
188static void setMic(int t=0, int percent=-1)
189{
190 switch (t) {
191 case 0: {
192 Config cfg("Sound");
193 cfg.setGroup("System");
194 if ( percent < 0 )
195 percent = cfg.readNumEntry("Mic",50);
196
197 int fd = 0;
198 int mic = micMuted ? 0 : percent;
199 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
200 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
201 ::close(fd);
202 }
203 } break;
204 }
185} 205}
186 206
187int qpe_sysBrightnessSteps() 207int qpe_sysBrightnessSteps()
@@ -869,132 +889,141 @@ void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data)
869#ifdef Q_WS_QWS 889#ifdef Q_WS_QWS
870 QDataStream stream( data, IO_ReadOnly ); 890 QDataStream stream( data, IO_ReadOnly );
871 if ( msg == "applyStyle()" ) { 891 if ( msg == "applyStyle()" ) {
872 applyStyle(); 892 applyStyle();
873 } else if ( msg == "setScreenSaverInterval(int)" ) { 893 } else if ( msg == "setScreenSaverInterval(int)" ) {
874 if ( type() == GuiServer ) { 894 if ( type() == GuiServer ) {
875 int time; 895 int time;
876 stream >> time; 896 stream >> time;
877 setScreenSaverInterval(time); 897 setScreenSaverInterval(time);
878 } 898 }
879 } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 899 } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
880 if ( type() == GuiServer ) { 900 if ( type() == GuiServer ) {
881 int t1,t2,t3; 901 int t1,t2,t3;
882 stream >> t1 >> t2 >> t3; 902 stream >> t1 >> t2 >> t3;
883 setScreenSaverIntervals(t1,t2,t3); 903 setScreenSaverIntervals(t1,t2,t3);
884 } 904 }
885 } else if ( msg == "setBacklight(int)" ) { 905 } else if ( msg == "setBacklight(int)" ) {
886 if ( type() == GuiServer ) { 906 if ( type() == GuiServer ) {
887 int bright; 907 int bright;
888 stream >> bright; 908 stream >> bright;
889 setBacklight(bright); 909 setBacklight(bright);
890 } 910 }
891 } else if ( msg == "setDefaultRotation(int)" ) { 911 } else if ( msg == "setDefaultRotation(int)" ) {
892 if ( type() == GuiServer ) { 912 if ( type() == GuiServer ) {
893 int r; 913 int r;
894 stream >> r; 914 stream >> r;
895 setDefaultRotation(r); 915 setDefaultRotation(r);
896 } 916 }
897 } else if ( msg == "shutdown()" ) { 917 } else if ( msg == "shutdown()" ) {
898 if ( type() == GuiServer ) 918 if ( type() == GuiServer )
899 shutdown(); 919 shutdown();
900 } else if ( msg == "quit()" ) { 920 } else if ( msg == "quit()" ) {
901 if ( type() != GuiServer ) 921 if ( type() != GuiServer )
902 tryQuit(); 922 tryQuit();
903 } else if ( msg == "forceQuit()" ) { 923 } else if ( msg == "forceQuit()" ) {
904 if ( type() != GuiServer ) 924 if ( type() != GuiServer )
905 quit(); 925 quit();
906 } else if ( msg == "restart()" ) { 926 } else if ( msg == "restart()" ) {
907 if ( type() == GuiServer ) 927 if ( type() == GuiServer )
908 restart(); 928 restart();
909 } else if ( msg == "grabKeyboard(QString)" ) { 929 } else if ( msg == "grabKeyboard(QString)" ) {
910 QString who; 930 QString who;
911 stream >> who; 931 stream >> who;
912 if ( who.isEmpty() ) 932 if ( who.isEmpty() )
913 d->kbgrabber = 0; 933 d->kbgrabber = 0;
914 else if ( who != d->appName ) 934 else if ( who != d->appName )
915 d->kbgrabber = 1; 935 d->kbgrabber = 1;
916 else 936 else
917 d->kbgrabber = 2; 937 d->kbgrabber = 2;
918 } else if ( msg == "language(QString)" ) { 938 } else if ( msg == "language(QString)" ) {
919 if ( type() == GuiServer ) { 939 if ( type() == GuiServer ) {
920 QString l; 940 QString l;
921 stream >> l; 941 stream >> l;
922 QString cl = getenv("LANG"); 942 QString cl = getenv("LANG");
923 if ( cl != l ) { 943 if ( cl != l ) {
924 if ( l.isNull() ) 944 if ( l.isNull() )
925 unsetenv( "LANG" ); 945 unsetenv( "LANG" );
926 else 946 else
927 setenv( "LANG", l.latin1(), 1 ); 947 setenv( "LANG", l.latin1(), 1 );
928 restart(); 948 restart();
929 } 949 }
930 } 950 }
931 } else if ( msg == "timeChange(QString)" ) { 951 } else if ( msg == "timeChange(QString)" ) {
932 QString t; 952 QString t;
933 stream >> t; 953 stream >> t;
934 if ( t.isNull() ) 954 if ( t.isNull() )
935 unsetenv( "TZ" ); 955 unsetenv( "TZ" );
936 else 956 else
937 setenv( "TZ", t.latin1(), 1 ); 957 setenv( "TZ", t.latin1(), 1 );
938 // emit the signal so everyone else knows... 958 // emit the signal so everyone else knows...
939 emit timeChanged(); 959 emit timeChanged();
940 } else if ( msg == "execute(QString)" ) { 960 } else if ( msg == "execute(QString)" ) {
941 if ( type() == GuiServer ) { 961 if ( type() == GuiServer ) {
942 QString t; 962 QString t;
943 stream >> t; 963 stream >> t;
944 Global::execute( t ); 964 Global::execute( t );
945 } 965 }
946 } else if ( msg == "execute(QString,QString)" ) { 966 } else if ( msg == "execute(QString,QString)" ) {
947 if ( type() == GuiServer ) { 967 if ( type() == GuiServer ) {
948 QString t,d; 968 QString t,d;
949 stream >> t >> d; 969 stream >> t >> d;
950 Global::execute( t, d ); 970 Global::execute( t, d );
951 } 971 }
952 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 972 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
953 if ( type() == GuiServer ) { 973 if ( type() == GuiServer ) {
954 QDateTime when; 974 QDateTime when;
955 QCString channel, message; 975 QCString channel, message;
956 int data; 976 int data;
957 stream >> when >> channel >> message >> data; 977 stream >> when >> channel >> message >> data;
958 AlarmServer::addAlarm( when, channel, message, data ); 978 AlarmServer::addAlarm( when, channel, message, data );
959 } 979 }
960 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 980 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
961 if ( type() == GuiServer ) { 981 if ( type() == GuiServer ) {
962 QDateTime when; 982 QDateTime when;
963 QCString channel, message; 983 QCString channel, message;
964 int data; 984 int data;
965 stream >> when >> channel >> message >> data; 985 stream >> when >> channel >> message >> data;
966 AlarmServer::deleteAlarm( when, channel, message, data ); 986 AlarmServer::deleteAlarm( when, channel, message, data );
967 } 987 }
968 } else if ( msg == "clockChange(bool)" ) { 988 } else if ( msg == "clockChange(bool)" ) {
969 int tmp; 989 int tmp;
970 stream >> tmp; 990 stream >> tmp;
971 emit clockChanged( tmp ); 991 emit clockChanged( tmp );
972 } else if ( msg == "weekChange(bool)" ) { 992 } else if ( msg == "weekChange(bool)" ) {
973 int tmp; 993 int tmp;
974 stream >> tmp; 994 stream >> tmp;
975 emit weekChanged( tmp ); 995 emit weekChanged( tmp );
976 } else if ( msg == "setDateFormat(DateFormat)" ) { 996 } else if ( msg == "setDateFormat(DateFormat)" ) {
977 DateFormat tmp; 997 DateFormat tmp;
978 stream >> tmp; 998 stream >> tmp;
979 emit dateFormatChanged( tmp ); 999 emit dateFormatChanged( tmp );
980 } else if ( msg == "setVolume(int,int)" ) { 1000 } else if ( msg == "setVolume(int,int)" ) {
981 int t,v; 1001 int t,v;
982 stream >> t >> v; 1002 stream >> t >> v;
983 setVolume(t,v); 1003 setVolume(t,v);
984 emit volumeChanged( muted ); 1004 emit volumeChanged( muted );
985 } else if ( msg == "volumeChange(bool)" ) { 1005 } else if ( msg == "volumeChange(bool)" ) {
986 stream >> muted; 1006 stream >> muted;
987 setVolume(); 1007 setVolume();
988 emit volumeChanged( muted ); 1008 emit volumeChanged( muted );
1009 } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1010 int t,v;
1011 stream >> t >> v;
1012 setMic(t,v);
1013 emit micChanged( micMuted );
1014 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1015 stream >> micMuted;
1016 setMic();
1017 emit micChanged( micMuted );
989 } else if ( msg == "setScreenSaverMode(int)" ) { 1018 } else if ( msg == "setScreenSaverMode(int)" ) {
990 if ( type() == GuiServer ) { 1019 if ( type() == GuiServer ) {
991 int old = disable_suspend; 1020 int old = disable_suspend;
992 stream >> disable_suspend; 1021 stream >> disable_suspend;
993 //qDebug("setScreenSaverMode(%d)", disable_suspend ); 1022 //qDebug("setScreenSaverMode(%d)", disable_suspend );
994 if ( disable_suspend > old ) 1023 if ( disable_suspend > old )
995 setScreenSaverInterval( -1 ); 1024 setScreenSaverInterval( -1 );
1025 }
996 } 1026 }
997 }
998#endif 1027#endif
999} 1028}
1000 1029