summaryrefslogtreecommitdiff
authorzecke <zecke>2005-01-13 21:41:55 (UTC)
committer zecke <zecke>2005-01-13 21:41:55 (UTC)
commit4177963b2f0211c3fa9b15a1af227c8217187b72 (patch) (unidiff)
treed6d222f97a3d02caa50ee1f3663bcd7ad790bd0a
parente1a1079f4b12d70a946761443492592236012f79 (diff)
downloadopie-4177963b2f0211c3fa9b15a1af227c8217187b72.zip
opie-4177963b2f0211c3fa9b15a1af227c8217187b72.tar.gz
opie-4177963b2f0211c3fa9b15a1af227c8217187b72.tar.bz2
-Use const char array instead of writing QPE/Application/clock at many applications
-Use const char array for the message the AlarmServer should send -Try to remove the issue with 'sticky' alarms. Remove all alarms with the internal ids
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index e681650..0ad69d9 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -59,12 +59,14 @@
59 59
60static const int sw_prec = 2; 60static const int sw_prec = 2;
61static const int magic_daily = 2292922; 61static const int magic_daily = 2292922;
62static const int magic_countdown = 2292923; 62static const int magic_countdown = 2292923;
63static const int magic_snooze = 2292924; 63static const int magic_snooze = 2292924;
64static const int magic_playmp = 2292925; 64static const int magic_playmp = 2292925;
65static const char ALARM_CLOCK_CHANNEL [] = "QPE/Application/clock";
66static const char ALARM_CLOCK_MESSAGE [] = "alarm(QDateTime,int)";
65 67
66#include <math.h> 68#include <math.h>
67#include <unistd.h> 69#include <unistd.h>
68#include <sys/types.h> 70#include <sys/types.h>
69 71
70#include <pthread.h> 72#include <pthread.h>
@@ -124,21 +126,21 @@ AlarmDlg::setText(const QString &txt)
124void 126void
125AlarmDlg::checkSnooze(void) 127AlarmDlg::checkSnooze(void)
126{ 128{
127 // 129 //
128 // Ensure we have only one snooze alarm. 130 // Ensure we have only one snooze alarm.
129 // 131 //
130 AlarmServer::deleteAlarm(QDateTime(), "QPE/Application/clock", 132 AlarmServer::deleteAlarm(QDateTime(), ALARM_CLOCK_CHANNEL,
131 "alarm(QDateTime,int)", magic_snooze); 133 ALARM_CLOCK_MESSAGE, magic_snooze);
132 134
133 if (snoozeTime->value() > 0) { 135 if (snoozeTime->value() > 0) {
134 QDateTime wake = QDateTime::currentDateTime(); 136 QDateTime wake = QDateTime::currentDateTime();
135 wake = wake.addSecs(snoozeTime->value() * 60); // snoozeTime in minutes 137 wake = wake.addSecs(snoozeTime->value() * 60); // snoozeTime in minutes
136 138
137 AlarmServer::addAlarm(wake, "QPE/Application/clock", 139 AlarmServer::addAlarm(wake, ALARM_CLOCK_CHANNEL,
138 "alarm(QDateTime,int)", magic_snooze); 140 ALARM_CLOCK_MESSAGE, magic_snooze);
139 } 141 }
140 accept(); 142 accept();
141} 143}
142 144
143 145
144 146
@@ -568,13 +570,13 @@ void Clock::enableDaily( bool )
568{ 570{
569 scheduleApplyDailyAlarm(); 571 scheduleApplyDailyAlarm();
570} 572}
571 573
572void Clock::appMessage( const QCString &msg, const QByteArray &data ) 574void Clock::appMessage( const QCString &msg, const QByteArray &data )
573{ 575{
574 if ( msg == "alarm(QDateTime,int)" ) { 576 if ( msg == ALARM_CLOCK_MESSAGE ) {
575 QDataStream ds(data,IO_ReadOnly); 577 QDataStream ds(data,IO_ReadOnly);
576 QDateTime when; 578 QDateTime when;
577 int t; 579 int t;
578 ds >> when >> t; 580 ds >> when >> t;
579 QTime theTime( when.time() ); 581 QTime theTime( when.time() );
580 if ( t == magic_daily || t == magic_snooze || 582 if ( t == magic_daily || t == magic_snooze ||
@@ -713,15 +715,13 @@ void Clock::applyDailyAlarm()
713 Config config( "Clock" ); 715 Config config( "Clock" );
714 config.setGroup( "Daily Alarm" ); 716 config.setGroup( "Daily Alarm" );
715 config.writeEntry( "Hour", hour ); 717 config.writeEntry( "Hour", hour );
716 config.writeEntry( "Minute", minute ); 718 config.writeEntry( "Minute", minute );
717 719
718 bool enableDaily = dailyEnabled->isChecked(); 720 bool enableDaily = dailyEnabled->isChecked();
719 bool wasSound = config.readEntry( "SoundEnabled" );
720 bool isSound = sndCheck->isChecked(); 721 bool isSound = sndCheck->isChecked();
721 int oldMagic = wasSound ? magic_playmp : magic_daily;
722 int isMagic = isSound ? magic_playmp : magic_daily; 722 int isMagic = isSound ? magic_playmp : magic_daily;
723 config.writeEntry( "Enabled", enableDaily ); 723 config.writeEntry( "Enabled", enableDaily );
724 config.writeEntry( "SoundEnabled", isSound ); 724 config.writeEntry( "SoundEnabled", isSound );
725 725
726 QString exclDays; 726 QString exclDays;
727 int exclCount = 0; 727 int exclCount = 0;
@@ -732,19 +732,24 @@ void Clock::applyDailyAlarm()
732 exclDays += QString::number( i ); 732 exclDays += QString::number( i );
733 exclCount++; 733 exclCount++;
734 } 734 }
735 } 735 }
736 config.writeEntry( "ExcludeDays", exclDays ); 736 config.writeEntry( "ExcludeDays", exclDays );
737 737
738 /* try to delete both */ 738 /* try to delete all */
739 AlarmServer::deleteAlarm(QDateTime(), "QPE/Application/clock", 739 AlarmServer::deleteAlarm(QDateTime(), ALARM_CLOCK_CHANNEL,
740 "alarm(QDateTime,int)", oldMagic); 740 ALARM_CLOCK_MESSAGE, magic_daily);
741 AlarmServer::deleteAlarm(QDateTime(), ALARM_CLOCK_CHANNEL,
742 ALARM_CLOCK_MESSAGE, magic_playmp );
743 AlarmServer::deleteAlarm(QDateTime(), ALARM_CLOCK_CHANNEL,
744 ALARM_CLOCK_MESSAGE, magic_snooze);
745
741 if ( enableDaily && exclCount < 7 ) { 746 if ( enableDaily && exclCount < 7 ) {
742 QDateTime when = nextAlarm( hour, minute ); 747 QDateTime when = nextAlarm( hour, minute );
743 AlarmServer::addAlarm(when, "QPE/Application/clock", 748 AlarmServer::addAlarm(when, ALARM_CLOCK_CHANNEL,
744 "alarm(QDateTime,int)", isMagic); 749 ALARM_CLOCK_MESSAGE, isMagic);
745 } 750 }
746} 751}
747 752
748bool Clock::validDaysSelected(void) 753bool Clock::validDaysSelected(void)
749{ 754{
750 for ( int i = 1; i <= 7; i++ ) { 755 for ( int i = 1; i <= 7; i++ ) {