Lots of fixes:
Lots of fixes: 1. Alarms are rescheduled when an event has been changed. 2. Avoid emitting spurious event changes. 3. Applied black magic to get the mail-notification working. Miguel. svn path=/trunk/; revision=199
This commit is contained in:
@ -1,3 +1,17 @@
|
||||
1998-04-28 Miguel de Icaza <miguel@nuclecu.unam.mx>
|
||||
|
||||
* gnome-cal.c (calendar_notify): Apply black magic to get mail
|
||||
notifications to work.
|
||||
|
||||
* gncal-full-day.c (child_focus_out): Temporary optimization, the
|
||||
child_focus_out is constantly calling the
|
||||
gnome_calendar_object_changed when the property editor has been
|
||||
invoked. This happens every time the mouse moves crosses the main
|
||||
window.
|
||||
|
||||
* calendar.c (calendar_object_changed): Reschedule alarms when a
|
||||
calendar object has changed its times.
|
||||
|
||||
Sat Apr 25 22:20:45 1998 Havoc Pennington <hp@pobox.com>
|
||||
|
||||
* eventedit.c, eventedit.h: Descend from GnomeDialog. Took vbox
|
||||
|
@ -103,7 +103,7 @@ alarm_add (time_t alarm_time, AlarmFunction fn, void *closure)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
alarm_kill (void *closure_key)
|
||||
{
|
||||
GList *p;
|
||||
@ -117,9 +117,10 @@ alarm_kill (void *closure_key)
|
||||
head_alarm = alarms->data;
|
||||
else
|
||||
head_alarm = NULL;
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -7,6 +7,6 @@ typedef void (*AlarmFunction)(time_t time, void *closuse);
|
||||
|
||||
void alarm_init (void);
|
||||
void alarm_add (time_t alarm_time, AlarmFunction fn, void *closure);
|
||||
void alarm_kill (void *closure);
|
||||
int alarm_kill (void *closure);
|
||||
|
||||
#endif
|
||||
|
@ -382,3 +382,15 @@ calendar_get_events_in_range (Calendar *cal, time_t start, time_t end)
|
||||
calendar_iterate (cal, start, end, assemble_event_list, &l);
|
||||
return l;
|
||||
}
|
||||
|
||||
void
|
||||
calendar_object_changed (Calendar *cal, iCalObject *obj, int flags)
|
||||
{
|
||||
if (!(flags & CHANGE_DATES))
|
||||
return;
|
||||
|
||||
/* Remove any alarms on the alarm list for this object */
|
||||
while (alarm_kill (obj))
|
||||
;
|
||||
ical_object_try_alarms (obj);
|
||||
}
|
||||
|
@ -51,6 +51,9 @@ void calendar_iterate (Calendar *cal, time_t start, time_t end
|
||||
/* Note this routine returns a GList with CalendarObjects */
|
||||
GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
|
||||
|
||||
/* Informs the calendar that obj information has changed */
|
||||
void calendar_object_changed (Calendar *cal, iCalObject *obj, int flags);
|
||||
|
||||
/* Destroy the above list with this method */
|
||||
void calendar_destroy_event_list (GList *l);
|
||||
|
||||
|
@ -457,15 +457,20 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
||||
{
|
||||
Child *child;
|
||||
GncalFullDay *fullday;
|
||||
char *text;
|
||||
|
||||
child = data;
|
||||
|
||||
/* Update summary in calendar object */
|
||||
|
||||
text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
|
||||
if (child->ico->summary && strcmp (text, child->ico->summary) == 0)
|
||||
return;
|
||||
|
||||
if (child->ico->summary)
|
||||
g_free (child->ico->summary);
|
||||
|
||||
child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
|
||||
child->ico->summary = text;
|
||||
|
||||
child_set_size (child);
|
||||
|
||||
|
@ -196,14 +196,10 @@ gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
|
||||
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
|
||||
g_return_if_fail (obj != NULL);
|
||||
|
||||
/* FIXME: for now we only update the views. Most likely we
|
||||
* need to do something else like set the last_mod field on
|
||||
* the iCalObject and such - Federico
|
||||
*/
|
||||
|
||||
gcal->cal->modified = TRUE;
|
||||
|
||||
gnome_calendar_update_all (gcal, obj, flags);
|
||||
calendar_object_changed (gcal->cal, obj, flags);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -268,6 +264,35 @@ execute (char *command, int close_standard)
|
||||
sigaction (SIGQUIT, &save_quit, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
mail_notify (char *mail_address, char *text, time_t app_time)
|
||||
{
|
||||
pid_t pid;
|
||||
int p [2];
|
||||
char *command;
|
||||
|
||||
pipe (p);
|
||||
pid = fork ();
|
||||
if (pid == 0){
|
||||
const int top = max_open_files ();
|
||||
int dev_null, i;
|
||||
|
||||
dev_null = open ("/dev/null", O_RDWR);
|
||||
dup2 (p [0], 0);
|
||||
dup2 (dev_null, 1);
|
||||
dup2 (dev_null, 2);
|
||||
execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
|
||||
mail_address, NULL);
|
||||
_exit (127);
|
||||
}
|
||||
command = g_copy_strings ("To: ", mail_address, "\n",
|
||||
"Subject: ", _("Reminder of your appointment at "),
|
||||
ctime (&app_time), "\n\n", text, "\n", NULL);
|
||||
write (p [1], command, strlen (command));
|
||||
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
void
|
||||
calendar_notify (time_t time, void *data)
|
||||
{
|
||||
@ -284,31 +309,9 @@ calendar_notify (time_t time, void *data)
|
||||
}
|
||||
|
||||
if (ico->malarm.enabled && ico->malarm.trigger == time){
|
||||
char *command;
|
||||
time_t app = ico->malarm.trigger + ico->malarm.offset;
|
||||
pid_t pid;
|
||||
int p [2];
|
||||
|
||||
pipe (p);
|
||||
pid = fork ();
|
||||
if (pid == 0){
|
||||
const int top = max_open_files ();
|
||||
int dev_null, i;
|
||||
dev_null = open ("/dev/null", O_RDWR);
|
||||
dup2 (p [1], 0);
|
||||
dup2 (dev_null, 1);
|
||||
dup2 (dev_null, 2);
|
||||
execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
|
||||
ico->malarm.data, NULL);
|
||||
_exit (127);
|
||||
}
|
||||
close (p [1]);
|
||||
command = g_copy_strings ("To: ", ico->malarm.data, "\n",
|
||||
"Subject: ", _("Reminder of your appointment at "),
|
||||
ctime (&app), "\n\n", NULL);
|
||||
write (p [0], command, strlen (command));
|
||||
|
||||
g_free (command);
|
||||
mail_notify (ico->malarm.data, ico->summary, app);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -325,3 +328,4 @@ calendar_notify (time_t time, void *data)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ alarm_add (time_t alarm_time, AlarmFunction fn, void *closure)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
alarm_kill (void *closure_key)
|
||||
{
|
||||
GList *p;
|
||||
@ -117,9 +117,10 @@ alarm_kill (void *closure_key)
|
||||
head_alarm = alarms->data;
|
||||
else
|
||||
head_alarm = NULL;
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -7,6 +7,6 @@ typedef void (*AlarmFunction)(time_t time, void *closuse);
|
||||
|
||||
void alarm_init (void);
|
||||
void alarm_add (time_t alarm_time, AlarmFunction fn, void *closure);
|
||||
void alarm_kill (void *closure);
|
||||
int alarm_kill (void *closure);
|
||||
|
||||
#endif
|
||||
|
@ -103,7 +103,7 @@ alarm_add (time_t alarm_time, AlarmFunction fn, void *closure)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
int
|
||||
alarm_kill (void *closure_key)
|
||||
{
|
||||
GList *p;
|
||||
@ -117,9 +117,10 @@ alarm_kill (void *closure_key)
|
||||
head_alarm = alarms->data;
|
||||
else
|
||||
head_alarm = NULL;
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -7,6 +7,6 @@ typedef void (*AlarmFunction)(time_t time, void *closuse);
|
||||
|
||||
void alarm_init (void);
|
||||
void alarm_add (time_t alarm_time, AlarmFunction fn, void *closure);
|
||||
void alarm_kill (void *closure);
|
||||
int alarm_kill (void *closure);
|
||||
|
||||
#endif
|
||||
|
@ -382,3 +382,15 @@ calendar_get_events_in_range (Calendar *cal, time_t start, time_t end)
|
||||
calendar_iterate (cal, start, end, assemble_event_list, &l);
|
||||
return l;
|
||||
}
|
||||
|
||||
void
|
||||
calendar_object_changed (Calendar *cal, iCalObject *obj, int flags)
|
||||
{
|
||||
if (!(flags & CHANGE_DATES))
|
||||
return;
|
||||
|
||||
/* Remove any alarms on the alarm list for this object */
|
||||
while (alarm_kill (obj))
|
||||
;
|
||||
ical_object_try_alarms (obj);
|
||||
}
|
||||
|
@ -51,6 +51,9 @@ void calendar_iterate (Calendar *cal, time_t start, time_t end
|
||||
/* Note this routine returns a GList with CalendarObjects */
|
||||
GList *calendar_get_events_in_range (Calendar *cal, time_t start, time_t end);
|
||||
|
||||
/* Informs the calendar that obj information has changed */
|
||||
void calendar_object_changed (Calendar *cal, iCalObject *obj, int flags);
|
||||
|
||||
/* Destroy the above list with this method */
|
||||
void calendar_destroy_event_list (GList *l);
|
||||
|
||||
|
@ -457,15 +457,20 @@ child_focus_out (GtkWidget *widget, GdkEventFocus *event, gpointer data)
|
||||
{
|
||||
Child *child;
|
||||
GncalFullDay *fullday;
|
||||
char *text;
|
||||
|
||||
child = data;
|
||||
|
||||
/* Update summary in calendar object */
|
||||
|
||||
text = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
|
||||
if (child->ico->summary && strcmp (text, child->ico->summary) == 0)
|
||||
return;
|
||||
|
||||
if (child->ico->summary)
|
||||
g_free (child->ico->summary);
|
||||
|
||||
child->ico->summary = gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
|
||||
child->ico->summary = text;
|
||||
|
||||
child_set_size (child);
|
||||
|
||||
|
@ -196,14 +196,10 @@ gnome_calendar_object_changed (GnomeCalendar *gcal, iCalObject *obj, int flags)
|
||||
g_return_if_fail (GNOME_IS_CALENDAR (gcal));
|
||||
g_return_if_fail (obj != NULL);
|
||||
|
||||
/* FIXME: for now we only update the views. Most likely we
|
||||
* need to do something else like set the last_mod field on
|
||||
* the iCalObject and such - Federico
|
||||
*/
|
||||
|
||||
gcal->cal->modified = TRUE;
|
||||
|
||||
gnome_calendar_update_all (gcal, obj, flags);
|
||||
calendar_object_changed (gcal->cal, obj, flags);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -268,6 +264,35 @@ execute (char *command, int close_standard)
|
||||
sigaction (SIGQUIT, &save_quit, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
mail_notify (char *mail_address, char *text, time_t app_time)
|
||||
{
|
||||
pid_t pid;
|
||||
int p [2];
|
||||
char *command;
|
||||
|
||||
pipe (p);
|
||||
pid = fork ();
|
||||
if (pid == 0){
|
||||
const int top = max_open_files ();
|
||||
int dev_null, i;
|
||||
|
||||
dev_null = open ("/dev/null", O_RDWR);
|
||||
dup2 (p [0], 0);
|
||||
dup2 (dev_null, 1);
|
||||
dup2 (dev_null, 2);
|
||||
execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
|
||||
mail_address, NULL);
|
||||
_exit (127);
|
||||
}
|
||||
command = g_copy_strings ("To: ", mail_address, "\n",
|
||||
"Subject: ", _("Reminder of your appointment at "),
|
||||
ctime (&app_time), "\n\n", text, "\n", NULL);
|
||||
write (p [1], command, strlen (command));
|
||||
|
||||
g_free (command);
|
||||
}
|
||||
|
||||
void
|
||||
calendar_notify (time_t time, void *data)
|
||||
{
|
||||
@ -284,31 +309,9 @@ calendar_notify (time_t time, void *data)
|
||||
}
|
||||
|
||||
if (ico->malarm.enabled && ico->malarm.trigger == time){
|
||||
char *command;
|
||||
time_t app = ico->malarm.trigger + ico->malarm.offset;
|
||||
pid_t pid;
|
||||
int p [2];
|
||||
|
||||
pipe (p);
|
||||
pid = fork ();
|
||||
if (pid == 0){
|
||||
const int top = max_open_files ();
|
||||
int dev_null, i;
|
||||
dev_null = open ("/dev/null", O_RDWR);
|
||||
dup2 (p [1], 0);
|
||||
dup2 (dev_null, 1);
|
||||
dup2 (dev_null, 2);
|
||||
execl ("/usr/lib/sendmail", "/usr/lib/sendmail",
|
||||
ico->malarm.data, NULL);
|
||||
_exit (127);
|
||||
}
|
||||
close (p [1]);
|
||||
command = g_copy_strings ("To: ", ico->malarm.data, "\n",
|
||||
"Subject: ", _("Reminder of your appointment at "),
|
||||
ctime (&app), "\n\n", NULL);
|
||||
write (p [0], command, strlen (command));
|
||||
|
||||
g_free (command);
|
||||
mail_notify (ico->malarm.data, ico->summary, app);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -325,3 +328,4 @@ calendar_notify (time_t time, void *data)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user