-rw-r--r-- | noncore/tools/clock/clock.cpp | 29 |
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 | |||
@@ -62,6 +62,8 @@ static const int magic_daily = 2292922; | |||
62 | static const int magic_countdown = 2292923; | 62 | static const int magic_countdown = 2292923; |
63 | static const int magic_snooze = 2292924; | 63 | static const int magic_snooze = 2292924; |
64 | static const int magic_playmp = 2292925; | 64 | static const int magic_playmp = 2292925; |
65 | static const char ALARM_CLOCK_CHANNEL [] = "QPE/Application/clock"; | ||
66 | static 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> |
@@ -127,15 +129,15 @@ AlarmDlg::checkSnooze(void) | |||
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 | } |
@@ -571,7 +573,7 @@ void Clock::enableDaily( bool ) | |||
571 | 573 | ||
572 | void Clock::appMessage( const QCString &msg, const QByteArray &data ) | 574 | void 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; |
@@ -716,9 +718,7 @@ void Clock::applyDailyAlarm() | |||
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 ); |
@@ -735,13 +735,18 @@ void Clock::applyDailyAlarm() | |||
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 | ||