diff options
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 11 | ||||
-rw-r--r-- | calendar/cal-util/calobj.c | 99 | ||||
-rw-r--r-- | calendar/calobj.c | 99 | ||||
-rw-r--r-- | calendar/gncal-full-day.c | 19 | ||||
-rw-r--r-- | calendar/gnome-cal.c | 2 | ||||
-rw-r--r-- | calendar/gui/gncal-full-day.c | 19 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 2 | ||||
-rw-r--r-- | calendar/gui/year-view.c | 3 | ||||
-rw-r--r-- | calendar/pcs/calobj.c | 99 | ||||
-rw-r--r-- | calendar/year-view.c | 3 |
10 files changed, 245 insertions, 111 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index f6ad8b1a78..3381bb9fd3 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,14 @@ +1998-04-15 Miguel de Icaza <miguel@nuclecu.unam.mx> + + * gncal-full-day.c (layout_kill_rows): Routine to destory rows + array properly. + + * gncal-year-view.c (gncal_year_view_new): Add missing year in + call to strftime. + + * calobj.c (ical_object_create_from_vobject): Fixed memory leaks + from the return values of versit's fakeCString. + 1998-04-14 Arturo Espinosa Aldama <arturo@nuclecu.unam.mx> * gncal-year-view.[hc]: New widget for the year view. diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c index 237017a6f9..f02feaf7a1 100644 --- a/calendar/cal-util/calobj.c +++ b/calendar/cal-util/calobj.c @@ -383,7 +383,7 @@ load_recurrence (iCalObject *o, char *str) } #define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop) -#define str_val(obj) fakeCString (vObjectUStringZValue (obj)) +#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj)) #define has(obj,prop) (vo = isAPropertyOf (obj, prop)) /* FIXME: we need to load the recurrence properties */ @@ -394,6 +394,7 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) iCalObject *ical; VObject *vo; VObjectIterator i; + char *the_str; ical = g_new0 (iCalObject, 1); @@ -405,97 +406,128 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) return 0; /* uid */ - if (has (o, VCUniqueStringProp)) + if (has (o, VCUniqueStringProp)){ ical->uid = g_strdup (str_val (vo)); - + free (the_str); + } + /* seq */ - if (has (o, VCSequenceProp)) + if (has (o, VCSequenceProp)){ ical->seq = atoi (str_val (vo)); - else + free (the_str); + } else ical->seq = 0; /* dtstart */ - if (has (o, VCDTstartProp)) + if (has (o, VCDTstartProp)){ ical->dtstart = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->dtstart = 0; /* dtend */ - if (has (o, VCDTendProp)) + if (has (o, VCDTendProp)){ ical->dtend = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->dtend = 0; /* dcreated */ - if (has (o, VCDCreatedProp)) + if (has (o, VCDCreatedProp)){ ical->created = time_from_isodate (str_val (vo)); + free (the_str); + } /* completed */ - if (has (o, VCCompletedProp)) + if (has (o, VCCompletedProp)){ ical->completed = time_from_isodate (str_val (vo)); + free (the_str); + } /* last_mod */ - if (has (o, VCLastModifiedProp)) + if (has (o, VCLastModifiedProp)){ ical->last_mod = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->last_mod = now; /* exdate */ - if (has (o, VCExpDateProp)) + if (has (o, VCExpDateProp)){ ical->exdate = set_date_list (str_val (vo)); + free (the_str); + } /* description/comment */ - if (has (o, VCDescriptionProp)) + if (has (o, VCDescriptionProp)){ ical->comment = g_strdup (str_val (vo)); + free (the_str); + } /* summary */ - if (has (o, VCSummaryProp)) + if (has (o, VCSummaryProp)){ ical->summary = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->summary = g_strdup (""); /* status */ - if (has (o, VCStatusProp)) + if (has (o, VCStatusProp)){ ical->status = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->status = g_strdup ("NEEDS ACTION"); - if (has (o, VCClassProp)) + if (has (o, VCClassProp)){ ical->class = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->class = "PUBLIC"; /* categories */ - if (has (o, VCCategoriesProp)) + if (has (o, VCCategoriesProp)){ ical->categories = set_list (str_val (vo), ","); - + free (the_str); + } + /* resources */ - if (has (o, VCResourcesProp)) + if (has (o, VCResourcesProp)){ ical->resources = set_list (str_val (vo), ";"); + free (the_str); + } /* priority */ - if (has (o, VCPriorityProp)) + if (has (o, VCPriorityProp)){ ical->priority = atoi (str_val (vo)); - + free (the_str); + } + /* tranparency */ - if (has (o, VCTranspProp)) + if (has (o, VCTranspProp)){ ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE; + free (the_str); + } /* related */ - if (has (o, VCRelatedToProp)) + if (has (o, VCRelatedToProp)){ ical->related = set_list (str_val (vo), ";"); - + free (the_str); + } + /* attach */ initPropIterator (&i, o); while (moreIteration (&i)){ vo = nextVObject (&i); - if (strcmp (vObjectName (vo), VCAttachProp) == 0) + if (strcmp (vObjectName (vo), VCAttachProp) == 0){ ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo))); + free (the_str); + } } /* url */ - if (has (o, VCURLProp)) + if (has (o, VCURLProp)){ ical->url = g_strdup (str_val (vo)); + free (the_str); + } /* FIXME: dalarm */ if (has (o, VCDAlarmProp)) @@ -514,12 +546,13 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) ; /* FIXME: rrule */ - if (has (o, VCRRuleProp)) + if (has (o, VCRRuleProp)){ if (!load_recurrence (ical, str_val (vo))) { ical_object_destroy (ical); return NULL; } - + free (the_str); + } return ical; } diff --git a/calendar/calobj.c b/calendar/calobj.c index 237017a6f9..f02feaf7a1 100644 --- a/calendar/calobj.c +++ b/calendar/calobj.c @@ -383,7 +383,7 @@ load_recurrence (iCalObject *o, char *str) } #define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop) -#define str_val(obj) fakeCString (vObjectUStringZValue (obj)) +#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj)) #define has(obj,prop) (vo = isAPropertyOf (obj, prop)) /* FIXME: we need to load the recurrence properties */ @@ -394,6 +394,7 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) iCalObject *ical; VObject *vo; VObjectIterator i; + char *the_str; ical = g_new0 (iCalObject, 1); @@ -405,97 +406,128 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) return 0; /* uid */ - if (has (o, VCUniqueStringProp)) + if (has (o, VCUniqueStringProp)){ ical->uid = g_strdup (str_val (vo)); - + free (the_str); + } + /* seq */ - if (has (o, VCSequenceProp)) + if (has (o, VCSequenceProp)){ ical->seq = atoi (str_val (vo)); - else + free (the_str); + } else ical->seq = 0; /* dtstart */ - if (has (o, VCDTstartProp)) + if (has (o, VCDTstartProp)){ ical->dtstart = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->dtstart = 0; /* dtend */ - if (has (o, VCDTendProp)) + if (has (o, VCDTendProp)){ ical->dtend = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->dtend = 0; /* dcreated */ - if (has (o, VCDCreatedProp)) + if (has (o, VCDCreatedProp)){ ical->created = time_from_isodate (str_val (vo)); + free (the_str); + } /* completed */ - if (has (o, VCCompletedProp)) + if (has (o, VCCompletedProp)){ ical->completed = time_from_isodate (str_val (vo)); + free (the_str); + } /* last_mod */ - if (has (o, VCLastModifiedProp)) + if (has (o, VCLastModifiedProp)){ ical->last_mod = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->last_mod = now; /* exdate */ - if (has (o, VCExpDateProp)) + if (has (o, VCExpDateProp)){ ical->exdate = set_date_list (str_val (vo)); + free (the_str); + } /* description/comment */ - if (has (o, VCDescriptionProp)) + if (has (o, VCDescriptionProp)){ ical->comment = g_strdup (str_val (vo)); + free (the_str); + } /* summary */ - if (has (o, VCSummaryProp)) + if (has (o, VCSummaryProp)){ ical->summary = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->summary = g_strdup (""); /* status */ - if (has (o, VCStatusProp)) + if (has (o, VCStatusProp)){ ical->status = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->status = g_strdup ("NEEDS ACTION"); - if (has (o, VCClassProp)) + if (has (o, VCClassProp)){ ical->class = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->class = "PUBLIC"; /* categories */ - if (has (o, VCCategoriesProp)) + if (has (o, VCCategoriesProp)){ ical->categories = set_list (str_val (vo), ","); - + free (the_str); + } + /* resources */ - if (has (o, VCResourcesProp)) + if (has (o, VCResourcesProp)){ ical->resources = set_list (str_val (vo), ";"); + free (the_str); + } /* priority */ - if (has (o, VCPriorityProp)) + if (has (o, VCPriorityProp)){ ical->priority = atoi (str_val (vo)); - + free (the_str); + } + /* tranparency */ - if (has (o, VCTranspProp)) + if (has (o, VCTranspProp)){ ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE; + free (the_str); + } /* related */ - if (has (o, VCRelatedToProp)) + if (has (o, VCRelatedToProp)){ ical->related = set_list (str_val (vo), ";"); - + free (the_str); + } + /* attach */ initPropIterator (&i, o); while (moreIteration (&i)){ vo = nextVObject (&i); - if (strcmp (vObjectName (vo), VCAttachProp) == 0) + if (strcmp (vObjectName (vo), VCAttachProp) == 0){ ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo))); + free (the_str); + } } /* url */ - if (has (o, VCURLProp)) + if (has (o, VCURLProp)){ ical->url = g_strdup (str_val (vo)); + free (the_str); + } /* FIXME: dalarm */ if (has (o, VCDAlarmProp)) @@ -514,12 +546,13 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) ; /* FIXME: rrule */ - if (has (o, VCRRuleProp)) + if (has (o, VCRRuleProp)){ if (!load_recurrence (ical, str_val (vo))) { ical_object_destroy (ical); return NULL; } - + free (the_str); + } return ical; } diff --git a/calendar/gncal-full-day.c b/calendar/gncal-full-day.c index a9c157c172..eac1d3fddc 100644 --- a/calendar/gncal-full-day.c +++ b/calendar/gncal-full-day.c @@ -433,7 +433,7 @@ child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int } static struct layout_row * -layout_get_rows (GncalFullDay *fullday) +layout_get_rows (GncalFullDay *fullday, int *rowcount) { struct layout_row *rows; int max_i; @@ -444,6 +444,7 @@ layout_get_rows (GncalFullDay *fullday) get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows); + *rowcount = f_rows; rows = g_new0 (struct layout_row, f_rows); max_i = 0; @@ -467,6 +468,16 @@ layout_get_rows (GncalFullDay *fullday) } static void +layout_kill_rows (struct layout_row *rows, int f_rows) +{ + int i; + + for (i = 0; i < f_rows; i++) + g_free (rows [i].slots); + g_free (rows); +} + +static void layout_get_child_intersections (Child *child, struct layout_row *rows, int *min, int *max) { int i, n; @@ -573,9 +584,9 @@ layout_children (GncalFullDay *fullday) struct layout_row *rows; GList *children; GtkWidget *widget; - int left_x; + int left_x, rowcount; - rows = layout_get_rows (fullday); + rows = layout_get_rows (fullday, &rowcount); widget = GTK_WIDGET (fullday); @@ -584,7 +595,7 @@ layout_children (GncalFullDay *fullday) for (children = fullday->children; children; children = children->next) layout_child (fullday, children->data, rows, left_x); - g_free (rows); + layout_kill_rows (rows, rowcount); } guint diff --git a/calendar/gnome-cal.c b/calendar/gnome-cal.c index 710a9033b9..6be4eb3f1e 100644 --- a/calendar/gnome-cal.c +++ b/calendar/gnome-cal.c @@ -83,7 +83,7 @@ setup_widgets (GnomeCalendar *gcal) gcal->notebook = gtk_notebook_new (); gcal->week_view = gncal_week_view_new (gcal, now); - gcal->year_view = gncal_year_view_new (); + gcal->year_view = gncal_year_view_new (now); gcal->task_view = tasks_create (gcal); setup_day_view (gcal); diff --git a/calendar/gui/gncal-full-day.c b/calendar/gui/gncal-full-day.c index a9c157c172..eac1d3fddc 100644 --- a/calendar/gui/gncal-full-day.c +++ b/calendar/gui/gncal-full-day.c @@ -433,7 +433,7 @@ child_set_pos (GncalFullDay *fullday, Child *child, int x, int y, int width, int } static struct layout_row * -layout_get_rows (GncalFullDay *fullday) +layout_get_rows (GncalFullDay *fullday, int *rowcount) { struct layout_row *rows; int max_i; @@ -444,6 +444,7 @@ layout_get_rows (GncalFullDay *fullday) get_tm_range (fullday, fullday->lower, fullday->upper, NULL, NULL, NULL, &f_rows); + *rowcount = f_rows; rows = g_new0 (struct layout_row, f_rows); max_i = 0; @@ -467,6 +468,16 @@ layout_get_rows (GncalFullDay *fullday) } static void +layout_kill_rows (struct layout_row *rows, int f_rows) +{ + int i; + + for (i = 0; i < f_rows; i++) + g_free (rows [i].slots); + g_free (rows); +} + +static void layout_get_child_intersections (Child *child, struct layout_row *rows, int *min, int *max) { int i, n; @@ -573,9 +584,9 @@ layout_children (GncalFullDay *fullday) struct layout_row *rows; GList *children; GtkWidget *widget; - int left_x; + int left_x, rowcount; - rows = layout_get_rows (fullday); + rows = layout_get_rows (fullday, &rowcount); widget = GTK_WIDGET (fullday); @@ -584,7 +595,7 @@ layout_children (GncalFullDay *fullday) for (children = fullday->children; children; children = children->next) layout_child (fullday, children->data, rows, left_x); - g_free (rows); + layout_kill_rows (rows, rowcount); } guint diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 710a9033b9..6be4eb3f1e 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -83,7 +83,7 @@ setup_widgets (GnomeCalendar *gcal) gcal->notebook = gtk_notebook_new (); gcal->week_view = gncal_week_view_new (gcal, now); - gcal->year_view = gncal_year_view_new (); + gcal->year_view = gncal_year_view_new (now); gcal->task_view = tasks_create (gcal); setup_day_view (gcal); diff --git a/calendar/gui/year-view.c b/calendar/gui/year-view.c index d4c2d218df..a3ae3ce647 100644 --- a/calendar/gui/year-view.c +++ b/calendar/gui/year-view.c @@ -101,7 +101,8 @@ gncal_year_view_new (int year) (gpointer *) yview); my_tm.tm_mon = i; - strftime(monthbuff, 40, "%B", &my_tm); + my_tm.tm_year = year; + strftime(monthbuff, sizeof (monthbuff)-1, "%B", &my_tm); label = gtk_label_new(monthbuff); gtk_container_add(GTK_CONTAINER(frame), vbox); diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index 237017a6f9..f02feaf7a1 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -383,7 +383,7 @@ load_recurrence (iCalObject *o, char *str) } #define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop) -#define str_val(obj) fakeCString (vObjectUStringZValue (obj)) +#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj)) #define has(obj,prop) (vo = isAPropertyOf (obj, prop)) /* FIXME: we need to load the recurrence properties */ @@ -394,6 +394,7 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) iCalObject *ical; VObject *vo; VObjectIterator i; + char *the_str; ical = g_new0 (iCalObject, 1); @@ -405,97 +406,128 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) return 0; /* uid */ - if (has (o, VCUniqueStringProp)) + if (has (o, VCUniqueStringProp)){ ical->uid = g_strdup (str_val (vo)); - + free (the_str); + } + /* seq */ - if (has (o, VCSequenceProp)) + if (has (o, VCSequenceProp)){ ical->seq = atoi (str_val (vo)); - else + free (the_str); + } else ical->seq = 0; /* dtstart */ - if (has (o, VCDTstartProp)) + if (has (o, VCDTstartProp)){ ical->dtstart = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->dtstart = 0; /* dtend */ - if (has (o, VCDTendProp)) + if (has (o, VCDTendProp)){ ical->dtend = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->dtend = 0; /* dcreated */ - if (has (o, VCDCreatedProp)) + if (has (o, VCDCreatedProp)){ ical->created = time_from_isodate (str_val (vo)); + free (the_str); + } /* completed */ - if (has (o, VCCompletedProp)) + if (has (o, VCCompletedProp)){ ical->completed = time_from_isodate (str_val (vo)); + free (the_str); + } /* last_mod */ - if (has (o, VCLastModifiedProp)) + if (has (o, VCLastModifiedProp)){ ical->last_mod = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->last_mod = now; /* exdate */ - if (has (o, VCExpDateProp)) + if (has (o, VCExpDateProp)){ ical->exdate = set_date_list (str_val (vo)); + free (the_str); + } /* description/comment */ - if (has (o, VCDescriptionProp)) + if (has (o, VCDescriptionProp)){ ical->comment = g_strdup (str_val (vo)); + free (the_str); + } /* summary */ - if (has (o, VCSummaryProp)) + if (has (o, VCSummaryProp)){ ical->summary = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->summary = g_strdup (""); /* status */ - if (has (o, VCStatusProp)) + if (has (o, VCStatusProp)){ ical->status = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->status = g_strdup ("NEEDS ACTION"); - if (has (o, VCClassProp)) + if (has (o, VCClassProp)){ ical->class = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->class = "PUBLIC"; /* categories */ - if (has (o, VCCategoriesProp)) + if (has (o, VCCategoriesProp)){ ical->categories = set_list (str_val (vo), ","); - + free (the_str); + } + /* resources */ - if (has (o, VCResourcesProp)) + if (has (o, VCResourcesProp)){ ical->resources = set_list (str_val (vo), ";"); + free (the_str); + } /* priority */ - if (has (o, VCPriorityProp)) + if (has (o, VCPriorityProp)){ ical->priority = atoi (str_val (vo)); - + free (the_str); + } + /* tranparency */ - if (has (o, VCTranspProp)) + if (has (o, VCTranspProp)){ ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE; + free (the_str); + } /* related */ - if (has (o, VCRelatedToProp)) + if (has (o, VCRelatedToProp)){ ical->related = set_list (str_val (vo), ";"); - + free (the_str); + } + /* attach */ initPropIterator (&i, o); while (moreIteration (&i)){ vo = nextVObject (&i); - if (strcmp (vObjectName (vo), VCAttachProp) == 0) + if (strcmp (vObjectName (vo), VCAttachProp) == 0){ ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo))); + free (the_str); + } } /* url */ - if (has (o, VCURLProp)) + if (has (o, VCURLProp)){ ical->url = g_strdup (str_val (vo)); + free (the_str); + } /* FIXME: dalarm */ if (has (o, VCDAlarmProp)) @@ -514,12 +546,13 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) ; /* FIXME: rrule */ - if (has (o, VCRRuleProp)) + if (has (o, VCRRuleProp)){ if (!load_recurrence (ical, str_val (vo))) { ical_object_destroy (ical); return NULL; } - + free (the_str); + } return ical; } diff --git a/calendar/year-view.c b/calendar/year-view.c index d4c2d218df..a3ae3ce647 100644 --- a/calendar/year-view.c +++ b/calendar/year-view.c @@ -101,7 +101,8 @@ gncal_year_view_new (int year) (gpointer *) yview); my_tm.tm_mon = i; - strftime(monthbuff, 40, "%B", &my_tm); + my_tm.tm_year = year; + strftime(monthbuff, sizeof (monthbuff)-1, "%B", &my_tm); label = gtk_label_new(monthbuff); gtk_container_add(GTK_CONTAINER(frame), vbox); |