From 5a5c6d2604664478306b29b64bf876d7403b74bb Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 29 Jul 2011 18:01:38 +0200 Subject: Add "force" parameter to notify_check_next_app() This allows to force notify_check_next_app() to update the notification appointment, even if start times are equal (e.g. if the item description was changed). Signed-off-by: Lukas Fleischer --- src/notify.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/notify.c') diff --git a/src/notify.c b/src/notify.c index 14a5f0c..6fedb71 100644 --- a/src/notify.c +++ b/src/notify.c @@ -306,7 +306,7 @@ notify_update_bar (void) notify_app.got_app = 0; pthread_mutex_unlock (¬ify_app.mutex); pthread_mutex_unlock (¬ify.mutex); - notify_check_next_app (); + notify_check_next_app (0); return; } } @@ -353,7 +353,7 @@ notify_main_thread (void *arg) got_app = notify_app.got_app; pthread_mutex_unlock (¬ify_app.mutex); if (!got_app) - notify_check_next_app (); + notify_check_next_app (0); } } pthread_exit ((void *) 0); @@ -427,6 +427,7 @@ static void * notify_thread_app (void *arg) { struct notify_app tmp_app; + int force = (arg ? 1 : 0); if (!notify_get_next (&tmp_app)) pthread_exit ((void *)0); @@ -439,7 +440,7 @@ notify_thread_app (void *arg) } else { - if (!notify_same_item (tmp_app.time)) + if (force || !notify_same_item (tmp_app.time)) { pthread_mutex_lock (¬ify_app.mutex); notify_update_app (tmp_app.time, tmp_app.state, tmp_app.txt); @@ -456,12 +457,13 @@ notify_thread_app (void *arg) /* Launch the thread notify_thread_app to look for next appointment. */ void -notify_check_next_app (void) +notify_check_next_app (int force) { pthread_t notify_t_app; + void *arg = (force ? (void *)1 : (void *)0); pthread_create (¬ify_t_app, &detached_thread_attr, notify_thread_app, - (void *)0); + arg); return; } @@ -566,7 +568,7 @@ void notify_start_main_thread (void) { pthread_create (¬ify_t_main, NULL, notify_main_thread, NULL); - notify_check_next_app (); + notify_check_next_app (0); } /* -- cgit v1.2.3-54-g00ecf From 1a849cfb8e32c88ca795551bdc5c01716d44593f Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 29 Jul 2011 19:51:08 +0200 Subject: Fix notify_check_repeated() Remove the "current_time" check from the first if condition. As "greater than" relations (">") have higher precedence than assignments ("=") in C, this caused "real_app_time" to always be one or zero which definitely isn't what we want here. Reading further down, it turns out that we don't even need this comparison here, so we should be fine removing it. Signed-off-by: Lukas Fleischer --- src/notify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/notify.c') diff --git a/src/notify.c b/src/notify.c index 6fedb71..1b7e924 100644 --- a/src/notify.c +++ b/src/notify.c @@ -510,7 +510,7 @@ notify_check_repeated (struct recur_apoint *i) pthread_mutex_lock (¬ify_app.mutex); if ((real_app_time = recur_item_inday (i->start, &i->exc, i->rpt->type, i->rpt->freq, i->rpt->until, - get_today ()) > current_time)) + get_today ()))) { if (!notify_app.got_app) { -- cgit v1.2.3-54-g00ecf