[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdepim/kalarm
From:       David Jarvie <djarvie () kde ! org>
Date:       2010-11-17 22:50:32
Message-ID: 20101117225032.1E600AC8A0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1198236 by djarvie:

Improve fix for working-time-only alarms not triggering if KAlarm is started up \
outside working hours, after the last trigger time during working hours was missed.


 M  +18 -4     kalarmapp.cpp  
 M  +1 -1      kalarmapp.h  


--- trunk/KDE/kdepim/kalarm/kalarmapp.cpp #1198235:1198236
@@ -1170,9 +1170,12 @@
 			bool updateCalAndDisplay = false;
 			bool alarmToExecuteValid = false;
 			KAAlarm alarmToExecute;
+			bool restart = false;
 			// Check all the alarms in turn.
 			// Note that the main alarm is fetched before any other alarms.
-			for (KAAlarm alarm = event->firstAlarm();  alarm.isValid();  alarm = \
event->nextAlarm(alarm)) +			for (KAAlarm alarm = event->firstAlarm();
+			     alarm.isValid();
+			     alarm = (restart ? event->firstAlarm() : event->nextAlarm(alarm)), restart = \
false)  {
 				// Check if the alarm is due yet.
 				KDateTime nextDT = alarm.dateTime(true).effectiveKDateTime();
@@ -1306,7 +1309,14 @@
 				if (reschedule)
 				{
 					// The latest repetition was too long ago, so schedule the next one
-					rescheduleAlarm(*event, alarm, false, (rescheduleWork ? nextDT : KDateTime()));
+					if (rescheduleAlarm(*event, alarm, false, (rescheduleWork ? nextDT : \
KDateTime()))) +					{
+						// A working-time-only alarm has been rescheduled and the
+						// rescheduled time is already due. Start processing the
+						// event again.
+						alarmToExecuteValid = false;
+						restart = true;
+					}
 					updateCalAndDisplay = true;
 					continue;
 				}
@@ -1370,10 +1380,12 @@
 * instance.
 * If 'nextDt' is valid, the event is rescheduled for the next non-working
 * time occurrence after that.
+* Reply = true if 'nextDt' is valid and the rescheduled event is already due.
 */
-void KAlarmApp::rescheduleAlarm(KAEvent& event, const KAAlarm& alarm, bool \
updateCalAndDisplay, const KDateTime& nextDt) +bool \
KAlarmApp::rescheduleAlarm(KAEvent& event, const KAAlarm& alarm, bool \
updateCalAndDisplay, const KDateTime& nextDt)  {
 	kDebug();
+	bool reply = false;
 	bool update = false;
 	event.startChanges();
 	if (alarm.reminder()  ||  alarm.deferred())
@@ -1402,7 +1414,7 @@
 				case KAEvent::NO_OCCURRENCE:
 					// All repetitions are finished, so cancel the event
 					if (cancelAlarm(event, alarm.type(), updateCalAndDisplay))
-						return;
+						return false;
 					break;
 				default:
 					if (!(type & KAEvent::OCCURRENCE_REPEAT))
@@ -1440,10 +1452,12 @@
 					next = !event.isWorkingTime(next_dt);
 			}
 		} while (next && next_dt <= now);
+		reply = next_dt.isValid() && (next_dt <= now);
 	}
 	event.endChanges();
 	if (update)
 		KAlarm::updateEvent(event);     // update the window lists and calendar file
+	return reply;
 }
 
 /******************************************************************************
--- trunk/KDE/kdepim/kalarm/kalarmapp.h #1198235:1198236
@@ -163,7 +163,7 @@
 		void               queueAlarmId(const QString& id);
 		bool               dbusHandleEvent(const QString& eventID, EventFunc);
 		bool               handleEvent(const QString& eventID, EventFunc);
-		void               rescheduleAlarm(KAEvent&, const KAAlarm&, bool \
updateCalAndDisplay, const KDateTime& nextDt = KDateTime()); +		bool               \
rescheduleAlarm(KAEvent&, const KAAlarm&, bool updateCalAndDisplay, const KDateTime& \
nextDt = KDateTime());  bool               cancelAlarm(KAEvent&, KAAlarm::Type, bool \
updateCalAndDisplay);  ShellProcess*      doShellCommand(const QString& command, \
const KAEvent&, const KAAlarm*, int flags = 0, const QObject* receiver = 0, const \
char* slot = 0);  QString            composeXTermCommand(const QString& command, \
const KAEvent&, const KAAlarm*, int flags, QString& tempScriptFile) const;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic