aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-21 11:22:09 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-21 11:22:09 +0800
commit07239d418cf2910ac2240559515fae5851db2868 (patch)
tree39e385a60585852301c1f0d4f6047d5567cfa1ed
parent5fda22d8393b161a6539b848bdd5d88db7e77bc5 (diff)
downloadgsoc2013-evolution-07239d418cf2910ac2240559515fae5851db2868.tar
gsoc2013-evolution-07239d418cf2910ac2240559515fae5851db2868.tar.gz
gsoc2013-evolution-07239d418cf2910ac2240559515fae5851db2868.tar.bz2
gsoc2013-evolution-07239d418cf2910ac2240559515fae5851db2868.tar.lz
gsoc2013-evolution-07239d418cf2910ac2240559515fae5851db2868.tar.xz
gsoc2013-evolution-07239d418cf2910ac2240559515fae5851db2868.tar.zst
gsoc2013-evolution-07239d418cf2910ac2240559515fae5851db2868.zip
Enhance the exception date handling -mig
svn path=/trunk/; revision=174
-rw-r--r--calendar/ChangeLog6
-rw-r--r--calendar/cal-util/calobj.c54
-rw-r--r--calendar/calendar.c1
-rw-r--r--calendar/calobj.c54
-rw-r--r--calendar/eventedit.c2
-rw-r--r--calendar/gui/calendar.c1
-rw-r--r--calendar/gui/eventedit.c2
-rw-r--r--calendar/pcs/calobj.c54
8 files changed, 124 insertions, 50 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 2a3844a5a6..2f602c05e7 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,8 @@
+<<<<<<< ChangeLog
+1998-04-20 Miguel de Icaza <miguel@nuclecu.unam.mx>
+
+ * eventedit.c (ee_ok): Mark the event as non-new after accepting changes.
+=======
1998-04-20 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gncal-full-day.c (gncal_full_day_get_day_start_yoffset): New
@@ -18,6 +23,7 @@
is_date_in_list().
1998-04-20 Miguel de Icaza <miguel@nuclecu.unam.mx>
+>>>>>>> 1.58
* calobj.c (duration_callback): Take exception dates into
account.
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 60cb2f29d5..b7578ca397 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -110,12 +110,12 @@ ical_object_destroy (iCalObject *ico)
}
static GList *
-set_list (char *str, char *sc)
+set_list (char *str)
{
GList *list = 0;
char *s;
- for (s = strtok (str, sc); s; s = strtok (NULL, sc))
+ for (s = strtok (str, ";"); s; s = strtok (NULL, ";"))
list = g_list_prepend (list, g_strdup (s));
return list;
@@ -542,13 +542,13 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
/* categories */
if (has (o, VCCategoriesProp)){
- ical->categories = set_list (str_val (vo), ",");
+ ical->categories = set_list (str_val (vo));
free (the_str);
}
/* resources */
if (has (o, VCResourcesProp)){
- ical->resources = set_list (str_val (vo), ";");
+ ical->resources = set_list (str_val (vo));
free (the_str);
}
@@ -566,7 +566,7 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
/* related */
if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo), ";");
+ ical->related = set_list (str_val (vo));
free (the_str);
}
@@ -663,10 +663,10 @@ to_str (int num)
}
/*
- * stores a GList in the property, using SEP as the value separator
+ * stores a GList in the property.
*/
static void
-store_list (VObject *o, char *prop, GList *values, char sep)
+store_list (VObject *o, char *prop, GList *values)
{
GList *l;
int len;
@@ -683,7 +683,7 @@ store_list (VObject *o, char *prop, GList *values, char sep)
strcpy (p, l->data);
if (l->next) {
- p [len] = sep;
+ p [len] = ';';
p += len+1;
} else
p += len;
@@ -695,6 +695,27 @@ store_list (VObject *o, char *prop, GList *values, char sep)
g_free (result);
}
+static void
+store_date_list (VObject *o, char *prop, GList *values)
+{
+ GList *l;
+ int size;
+ char *s, *p;
+
+ size = g_list_length (values);
+ s = p = g_malloc ((size * 17 + 1) * sizeof (char));
+
+ for (l = values; l; l = l->next){
+ strcpy (s, isodate_from_time_t (*(time_t *)l->data));
+ s [16] = ';';
+ s += 17;
+ }
+ s--;
+ *s = 0;
+ addPropValue (o, prop, s);
+ g_free (p);
+}
+
static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
@@ -768,7 +789,7 @@ ical_object_to_vobject (iCalObject *ical)
/* exdate */
if (ical->exdate)
- store_list (o, VCExpDateProp, ical->exdate, ',');
+ store_date_list (o, VCExpDateProp, ical->exdate);
/* description/comment */
if (ical->comment && strlen (ical->comment)){
@@ -794,11 +815,11 @@ ical_object_to_vobject (iCalObject *ical)
/* categories */
if (ical->categories)
- store_list (o, VCCategoriesProp, ical->categories, ',');
+ store_list (o, VCCategoriesProp, ical->categories);
/* resources */
if (ical->categories)
- store_list (o, VCCategoriesProp, ical->resources, ';');
+ store_list (o, VCCategoriesProp, ical->resources);
/* priority */
addPropValue (o, VCPriorityProp, to_str (ical->priority));
@@ -808,7 +829,7 @@ ical_object_to_vobject (iCalObject *ical)
/* related */
if (ical->related)
- store_list (o, VCRelatedToProp, ical->related, ';');
+ store_list (o, VCRelatedToProp, ical->related);
/* attach */
for (l = ical->attach; l; l = l->next)
@@ -902,8 +923,9 @@ is_date_in_list (GList *list, struct tm *date)
tm = localtime (timep);
if (date->tm_mday == tm->tm_mday &&
date->tm_mon == tm->tm_mon &&
- date->tm_year == tm->tm_year)
+ date->tm_year == tm->tm_year){
return 1;
+ }
}
return 0;
}
@@ -1113,11 +1135,9 @@ duration_callback (iCalObject *ico, time_t start, time_t end, void *closure)
int *count = closure;
struct tm *tm;
+ print_time_t (start);
tm = localtime (&start);
- if (ico->exdate && is_date_in_list (ico->exdate, tm))
- return 1;
-
(*count)++;
if (ico->recur->duration == *count) {
ico->recur->enddate = time_end_of_day (end);
@@ -1134,9 +1154,11 @@ ical_object_compute_end (iCalObject *ico)
g_return_if_fail (ico->recur != NULL);
+ printf ("compute end\n");
ico->recur->_enddate = 0;
ico->recur->enddate = 0;
ical_object_generate_events (ico, ico->dtstart, 0, duration_callback, &count);
+ printf ("compute end\n");
}
int
diff --git a/calendar/calendar.c b/calendar/calendar.c
index c9cc4fe984..34020adf38 100644
--- a/calendar/calendar.c
+++ b/calendar/calendar.c
@@ -92,6 +92,7 @@ calendar_add_alarms (Calendar *cal)
void
calendar_add_object (Calendar *cal, iCalObject *obj)
{
+ obj->new = 0;
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_prepend (cal->events, obj);
diff --git a/calendar/calobj.c b/calendar/calobj.c
index 60cb2f29d5..b7578ca397 100644
--- a/calendar/calobj.c
+++ b/calendar/calobj.c
@@ -110,12 +110,12 @@ ical_object_destroy (iCalObject *ico)
}
static GList *
-set_list (char *str, char *sc)
+set_list (char *str)
{
GList *list = 0;
char *s;
- for (s = strtok (str, sc); s; s = strtok (NULL, sc))
+ for (s = strtok (str, ";"); s; s = strtok (NULL, ";"))
list = g_list_prepend (list, g_strdup (s));
return list;
@@ -542,13 +542,13 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
/* categories */
if (has (o, VCCategoriesProp)){
- ical->categories = set_list (str_val (vo), ",");
+ ical->categories = set_list (str_val (vo));
free (the_str);
}
/* resources */
if (has (o, VCResourcesProp)){
- ical->resources = set_list (str_val (vo), ";");
+ ical->resources = set_list (str_val (vo));
free (the_str);
}
@@ -566,7 +566,7 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
/* related */
if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo), ";");
+ ical->related = set_list (str_val (vo));
free (the_str);
}
@@ -663,10 +663,10 @@ to_str (int num)
}
/*
- * stores a GList in the property, using SEP as the value separator
+ * stores a GList in the property.
*/
static void
-store_list (VObject *o, char *prop, GList *values, char sep)
+store_list (VObject *o, char *prop, GList *values)
{
GList *l;
int len;
@@ -683,7 +683,7 @@ store_list (VObject *o, char *prop, GList *values, char sep)
strcpy (p, l->data);
if (l->next) {
- p [len] = sep;
+ p [len] = ';';
p += len+1;
} else
p += len;
@@ -695,6 +695,27 @@ store_list (VObject *o, char *prop, GList *values, char sep)
g_free (result);
}
+static void
+store_date_list (VObject *o, char *prop, GList *values)
+{
+ GList *l;
+ int size;
+ char *s, *p;
+
+ size = g_list_length (values);
+ s = p = g_malloc ((size * 17 + 1) * sizeof (char));
+
+ for (l = values; l; l = l->next){
+ strcpy (s, isodate_from_time_t (*(time_t *)l->data));
+ s [16] = ';';
+ s += 17;
+ }
+ s--;
+ *s = 0;
+ addPropValue (o, prop, s);
+ g_free (p);
+}
+
static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
@@ -768,7 +789,7 @@ ical_object_to_vobject (iCalObject *ical)
/* exdate */
if (ical->exdate)
- store_list (o, VCExpDateProp, ical->exdate, ',');
+ store_date_list (o, VCExpDateProp, ical->exdate);
/* description/comment */
if (ical->comment && strlen (ical->comment)){
@@ -794,11 +815,11 @@ ical_object_to_vobject (iCalObject *ical)
/* categories */
if (ical->categories)
- store_list (o, VCCategoriesProp, ical->categories, ',');
+ store_list (o, VCCategoriesProp, ical->categories);
/* resources */
if (ical->categories)
- store_list (o, VCCategoriesProp, ical->resources, ';');
+ store_list (o, VCCategoriesProp, ical->resources);
/* priority */
addPropValue (o, VCPriorityProp, to_str (ical->priority));
@@ -808,7 +829,7 @@ ical_object_to_vobject (iCalObject *ical)
/* related */
if (ical->related)
- store_list (o, VCRelatedToProp, ical->related, ';');
+ store_list (o, VCRelatedToProp, ical->related);
/* attach */
for (l = ical->attach; l; l = l->next)
@@ -902,8 +923,9 @@ is_date_in_list (GList *list, struct tm *date)
tm = localtime (timep);
if (date->tm_mday == tm->tm_mday &&
date->tm_mon == tm->tm_mon &&
- date->tm_year == tm->tm_year)
+ date->tm_year == tm->tm_year){
return 1;
+ }
}
return 0;
}
@@ -1113,11 +1135,9 @@ duration_callback (iCalObject *ico, time_t start, time_t end, void *closure)
int *count = closure;
struct tm *tm;
+ print_time_t (start);
tm = localtime (&start);
- if (ico->exdate && is_date_in_list (ico->exdate, tm))
- return 1;
-
(*count)++;
if (ico->recur->duration == *count) {
ico->recur->enddate = time_end_of_day (end);
@@ -1134,9 +1154,11 @@ ical_object_compute_end (iCalObject *ico)
g_return_if_fail (ico->recur != NULL);
+ printf ("compute end\n");
ico->recur->_enddate = 0;
ico->recur->enddate = 0;
ical_object_generate_events (ico, ico->dtstart, 0, duration_callback, &count);
+ printf ("compute end\n");
}
int
diff --git a/calendar/eventedit.c b/calendar/eventedit.c
index f14a159fda..12d548d3b5 100644
--- a/calendar/eventedit.c
+++ b/calendar/eventedit.c
@@ -668,8 +668,8 @@ static void
ee_store_recur_values_to_ical (EventEditor *ee)
{
if (ee_store_recur_rule_to_ical (ee)){
- ee_store_recur_end_to_ical (ee);
ee_store_recur_exceptions_to_ical (ee);
+ ee_store_recur_end_to_ical (ee);
} else if (ee->ical->recur) {
g_free (ee->ical->recur);
ee->ical->recur = NULL;
diff --git a/calendar/gui/calendar.c b/calendar/gui/calendar.c
index c9cc4fe984..34020adf38 100644
--- a/calendar/gui/calendar.c
+++ b/calendar/gui/calendar.c
@@ -92,6 +92,7 @@ calendar_add_alarms (Calendar *cal)
void
calendar_add_object (Calendar *cal, iCalObject *obj)
{
+ obj->new = 0;
switch (obj->type){
case ICAL_EVENT:
cal->events = g_list_prepend (cal->events, obj);
diff --git a/calendar/gui/eventedit.c b/calendar/gui/eventedit.c
index f14a159fda..12d548d3b5 100644
--- a/calendar/gui/eventedit.c
+++ b/calendar/gui/eventedit.c
@@ -668,8 +668,8 @@ static void
ee_store_recur_values_to_ical (EventEditor *ee)
{
if (ee_store_recur_rule_to_ical (ee)){
- ee_store_recur_end_to_ical (ee);
ee_store_recur_exceptions_to_ical (ee);
+ ee_store_recur_end_to_ical (ee);
} else if (ee->ical->recur) {
g_free (ee->ical->recur);
ee->ical->recur = NULL;
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
index 60cb2f29d5..b7578ca397 100644
--- a/calendar/pcs/calobj.c
+++ b/calendar/pcs/calobj.c
@@ -110,12 +110,12 @@ ical_object_destroy (iCalObject *ico)
}
static GList *
-set_list (char *str, char *sc)
+set_list (char *str)
{
GList *list = 0;
char *s;
- for (s = strtok (str, sc); s; s = strtok (NULL, sc))
+ for (s = strtok (str, ";"); s; s = strtok (NULL, ";"))
list = g_list_prepend (list, g_strdup (s));
return list;
@@ -542,13 +542,13 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
/* categories */
if (has (o, VCCategoriesProp)){
- ical->categories = set_list (str_val (vo), ",");
+ ical->categories = set_list (str_val (vo));
free (the_str);
}
/* resources */
if (has (o, VCResourcesProp)){
- ical->resources = set_list (str_val (vo), ";");
+ ical->resources = set_list (str_val (vo));
free (the_str);
}
@@ -566,7 +566,7 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
/* related */
if (has (o, VCRelatedToProp)){
- ical->related = set_list (str_val (vo), ";");
+ ical->related = set_list (str_val (vo));
free (the_str);
}
@@ -663,10 +663,10 @@ to_str (int num)
}
/*
- * stores a GList in the property, using SEP as the value separator
+ * stores a GList in the property.
*/
static void
-store_list (VObject *o, char *prop, GList *values, char sep)
+store_list (VObject *o, char *prop, GList *values)
{
GList *l;
int len;
@@ -683,7 +683,7 @@ store_list (VObject *o, char *prop, GList *values, char sep)
strcpy (p, l->data);
if (l->next) {
- p [len] = sep;
+ p [len] = ';';
p += len+1;
} else
p += len;
@@ -695,6 +695,27 @@ store_list (VObject *o, char *prop, GList *values, char sep)
g_free (result);
}
+static void
+store_date_list (VObject *o, char *prop, GList *values)
+{
+ GList *l;
+ int size;
+ char *s, *p;
+
+ size = g_list_length (values);
+ s = p = g_malloc ((size * 17 + 1) * sizeof (char));
+
+ for (l = values; l; l = l->next){
+ strcpy (s, isodate_from_time_t (*(time_t *)l->data));
+ s [16] = ';';
+ s += 17;
+ }
+ s--;
+ *s = 0;
+ addPropValue (o, prop, s);
+ g_free (p);
+}
+
static char *recur_type_name [] = { "D", "W", "MP", "MD", "YM", "YD" };
static char *recur_day_list [] = { "SU", "MO", "TU","WE", "TH", "FR", "SA" };
static char *alarm_names [] = { VCMAlarmProp, VCPAlarmProp, VCDAlarmProp, VCAAlarmProp };
@@ -768,7 +789,7 @@ ical_object_to_vobject (iCalObject *ical)
/* exdate */
if (ical->exdate)
- store_list (o, VCExpDateProp, ical->exdate, ',');
+ store_date_list (o, VCExpDateProp, ical->exdate);
/* description/comment */
if (ical->comment && strlen (ical->comment)){
@@ -794,11 +815,11 @@ ical_object_to_vobject (iCalObject *ical)
/* categories */
if (ical->categories)
- store_list (o, VCCategoriesProp, ical->categories, ',');
+ store_list (o, VCCategoriesProp, ical->categories);
/* resources */
if (ical->categories)
- store_list (o, VCCategoriesProp, ical->resources, ';');
+ store_list (o, VCCategoriesProp, ical->resources);
/* priority */
addPropValue (o, VCPriorityProp, to_str (ical->priority));
@@ -808,7 +829,7 @@ ical_object_to_vobject (iCalObject *ical)
/* related */
if (ical->related)
- store_list (o, VCRelatedToProp, ical->related, ';');
+ store_list (o, VCRelatedToProp, ical->related);
/* attach */
for (l = ical->attach; l; l = l->next)
@@ -902,8 +923,9 @@ is_date_in_list (GList *list, struct tm *date)
tm = localtime (timep);
if (date->tm_mday == tm->tm_mday &&
date->tm_mon == tm->tm_mon &&
- date->tm_year == tm->tm_year)
+ date->tm_year == tm->tm_year){
return 1;
+ }
}
return 0;
}
@@ -1113,11 +1135,9 @@ duration_callback (iCalObject *ico, time_t start, time_t end, void *closure)
int *count = closure;
struct tm *tm;
+ print_time_t (start);
tm = localtime (&start);
- if (ico->exdate && is_date_in_list (ico->exdate, tm))
- return 1;
-
(*count)++;
if (ico->recur->duration == *count) {
ico->recur->enddate = time_end_of_day (end);
@@ -1134,9 +1154,11 @@ ical_object_compute_end (iCalObject *ico)
g_return_if_fail (ico->recur != NULL);
+ printf ("compute end\n");
ico->recur->_enddate = 0;
ico->recur->enddate = 0;
ical_object_generate_events (ico, ico->dtstart, 0, duration_callback, &count);
+ printf ("compute end\n");
}
int