aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1998-04-18 05:24:10 +0800
committerArturo Espinosa <unammx@src.gnome.org>1998-04-18 05:24:10 +0800
commit2ec1fdc08f38fd071909260d6dbcf4131b3fcfe4 (patch)
tree22dde930944f80a7e46c984073da5dafa6f4f9db /calendar
parent55f88f14fed53f67e4b3cd5337cbe92aee0ec638 (diff)
downloadgsoc2013-evolution-2ec1fdc08f38fd071909260d6dbcf4131b3fcfe4.tar
gsoc2013-evolution-2ec1fdc08f38fd071909260d6dbcf4131b3fcfe4.tar.gz
gsoc2013-evolution-2ec1fdc08f38fd071909260d6dbcf4131b3fcfe4.tar.bz2
gsoc2013-evolution-2ec1fdc08f38fd071909260d6dbcf4131b3fcfe4.tar.lz
gsoc2013-evolution-2ec1fdc08f38fd071909260d6dbcf4131b3fcfe4.tar.xz
gsoc2013-evolution-2ec1fdc08f38fd071909260d6dbcf4131b3fcfe4.tar.zst
gsoc2013-evolution-2ec1fdc08f38fd071909260d6dbcf4131b3fcfe4.zip
Save Recurrence rules -Miguel
svn path=/trunk/; revision=149
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog7
-rw-r--r--calendar/cal-util/calobj.c112
-rw-r--r--calendar/calobj.c112
-rw-r--r--calendar/gui/test.vcf8
-rw-r--r--calendar/pcs/calobj.c112
-rw-r--r--calendar/test.vcf8
6 files changed, 339 insertions, 20 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index f9c54bdaf7..a99da410da 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,10 @@
+1998-04-17 Miguel de Icaza <miguel@nuclecu.unam.mx>
+
+ * calobj.c (ical_object_generate_events): Implement
+ RECUR_MONTHLY_BY_POS implemented.
+
+ (ical_object_to_vobject): Implement recurrence rule saving.
+
1998-04-16 Federico Mena Quintero <federico@nuclecu.unam.mx>
* eventedit.c (ee_store_alarm): Use menu_shell->children, not
diff --git a/calendar/cal-util/calobj.c b/calendar/cal-util/calobj.c
index 76bb488663..e8da288153 100644
--- a/calendar/cal-util/calobj.c
+++ b/calendar/cal-util/calobj.c
@@ -565,8 +565,9 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* FIXME: dalarm */
- if (has (o, VCDAlarmProp))
- ;
+ if (has (o, VCDAlarmProp)){
+
+ }
/* FIXME: aalarm */
if (has (o, VCAAlarmProp))
@@ -625,6 +626,9 @@ store_list (VObject *o, char *prop, GList *values, char sep)
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" };
+
VObject *
ical_object_to_vobject (iCalObject *ical)
{
@@ -702,6 +706,57 @@ ical_object_to_vobject (iCalObject *ical)
if (ical->url)
addPropValue (o, VCURLProp, ical->url);
+ if (ical->recur){
+ char result [256];
+ char buffer [80];
+ int i;
+
+ sprintf (result, "%s%d ", recur_type_name [ical->recur->type], ical->recur->interval);
+ switch (ical->recur->type){
+ case RECUR_DAILY:
+ break;
+
+ case RECUR_WEEKLY:
+ for (i = 0; i < 7; i++){
+ if (ical->recur->weekday & (1 << i)){
+ sprintf (buffer, "%s ", recur_day_list [i]);
+ strcat (result, buffer);
+ }
+ }
+ break;
+
+ case RECUR_MONTHLY_BY_POS: {
+ int nega = ical->recur->u.month_pos < 0;
+
+ sprintf (buffer, "%d%s ", nega ? -ical->recur->u.month_pos : ical->recur->u.month_pos,
+ nega ? "-" : "+");
+ strcat (result, buffer);
+ for (i = 0; i < 7; i++){
+ if (ical->recur->weekday & (1 << i)){
+ sprintf (buffer, "%s ", recur_day_list [i]);
+ strcat (result, buffer);
+ }
+ }
+ }
+ break;
+
+ case RECUR_MONTHLY_BY_DAY:
+ sprintf (buffer, "%d ", ical->recur->u.month_pos);
+ strcat (result, buffer);
+ break;
+
+ case RECUR_YEARLY_BY_MONTH:
+ break;
+
+ case RECUR_YEARLY_BY_DAY:
+ break;
+ }
+ if (ical->recur->_enddate == 0)
+ sprintf (buffer, "#%d ",ical->recur->duration);
+ else
+ sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
+ strcat (result, buffer);
+ }
/* FIXME: alarms */
return o;
}
@@ -758,7 +813,8 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
{
Recurrence *recur = ico->recur;
time_t current;
-
+ int first_week_day, i;
+
if (!ico->recur){
if (time_in_range (ico->dtstart, start, end) ||
time_in_range (ico->dtend, start, end)){
@@ -822,7 +878,55 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
break;
case RECUR_MONTHLY_BY_POS:
- g_warning ("We still do not handle MONTHLY_BY_POS\n");
+ /* FIXME: We only deal with positives now */
+ if (ico->recur->u.month_pos < 0)
+ return;
+
+ if (ico->recur->u.month_pos == 0)
+ return;
+
+ first_week_day = 7;
+ for (i = 6; i >= 0; i--)
+ if (ico->recur->weekday & (1 << i))
+ first_week_day = i;
+
+ /* This should not happen, but take it into account */
+ if (first_week_day == 7)
+ return;
+
+ do {
+ struct tm tm;
+ time_t t;
+ int p, week_day_start;
+
+ tm = *localtime (&current);
+ tm.tm_mday = 1;
+ t = mktime (&tm);
+ tm = *localtime (&t);
+ week_day_start = tm.tm_wday;
+
+ tm.tm_mday = 7 * (ico->recur->u.month_pos -
+ ((week_day_start <= first_week_day ) ? 1 : 0)) -
+ (week_day_start - first_week_day) + 1;
+
+ t = mktime (&tm);
+
+ if (time_in_range (t, start, end))
+ if (!generate (ico, t, cb, closure))
+ return;
+
+ /* Advance a month */
+ current = mktime (&tm);
+
+ tm.tm_mday = 1;
+ tm.tm_mon += recur->interval;
+ current = mktime (&tm);
+
+ if (current == -1){
+ g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
+ return;
+ }
+ } while (current < end || (end == 0));
break;
case RECUR_MONTHLY_BY_DAY:
diff --git a/calendar/calobj.c b/calendar/calobj.c
index 76bb488663..e8da288153 100644
--- a/calendar/calobj.c
+++ b/calendar/calobj.c
@@ -565,8 +565,9 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* FIXME: dalarm */
- if (has (o, VCDAlarmProp))
- ;
+ if (has (o, VCDAlarmProp)){
+
+ }
/* FIXME: aalarm */
if (has (o, VCAAlarmProp))
@@ -625,6 +626,9 @@ store_list (VObject *o, char *prop, GList *values, char sep)
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" };
+
VObject *
ical_object_to_vobject (iCalObject *ical)
{
@@ -702,6 +706,57 @@ ical_object_to_vobject (iCalObject *ical)
if (ical->url)
addPropValue (o, VCURLProp, ical->url);
+ if (ical->recur){
+ char result [256];
+ char buffer [80];
+ int i;
+
+ sprintf (result, "%s%d ", recur_type_name [ical->recur->type], ical->recur->interval);
+ switch (ical->recur->type){
+ case RECUR_DAILY:
+ break;
+
+ case RECUR_WEEKLY:
+ for (i = 0; i < 7; i++){
+ if (ical->recur->weekday & (1 << i)){
+ sprintf (buffer, "%s ", recur_day_list [i]);
+ strcat (result, buffer);
+ }
+ }
+ break;
+
+ case RECUR_MONTHLY_BY_POS: {
+ int nega = ical->recur->u.month_pos < 0;
+
+ sprintf (buffer, "%d%s ", nega ? -ical->recur->u.month_pos : ical->recur->u.month_pos,
+ nega ? "-" : "+");
+ strcat (result, buffer);
+ for (i = 0; i < 7; i++){
+ if (ical->recur->weekday & (1 << i)){
+ sprintf (buffer, "%s ", recur_day_list [i]);
+ strcat (result, buffer);
+ }
+ }
+ }
+ break;
+
+ case RECUR_MONTHLY_BY_DAY:
+ sprintf (buffer, "%d ", ical->recur->u.month_pos);
+ strcat (result, buffer);
+ break;
+
+ case RECUR_YEARLY_BY_MONTH:
+ break;
+
+ case RECUR_YEARLY_BY_DAY:
+ break;
+ }
+ if (ical->recur->_enddate == 0)
+ sprintf (buffer, "#%d ",ical->recur->duration);
+ else
+ sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
+ strcat (result, buffer);
+ }
/* FIXME: alarms */
return o;
}
@@ -758,7 +813,8 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
{
Recurrence *recur = ico->recur;
time_t current;
-
+ int first_week_day, i;
+
if (!ico->recur){
if (time_in_range (ico->dtstart, start, end) ||
time_in_range (ico->dtend, start, end)){
@@ -822,7 +878,55 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
break;
case RECUR_MONTHLY_BY_POS:
- g_warning ("We still do not handle MONTHLY_BY_POS\n");
+ /* FIXME: We only deal with positives now */
+ if (ico->recur->u.month_pos < 0)
+ return;
+
+ if (ico->recur->u.month_pos == 0)
+ return;
+
+ first_week_day = 7;
+ for (i = 6; i >= 0; i--)
+ if (ico->recur->weekday & (1 << i))
+ first_week_day = i;
+
+ /* This should not happen, but take it into account */
+ if (first_week_day == 7)
+ return;
+
+ do {
+ struct tm tm;
+ time_t t;
+ int p, week_day_start;
+
+ tm = *localtime (&current);
+ tm.tm_mday = 1;
+ t = mktime (&tm);
+ tm = *localtime (&t);
+ week_day_start = tm.tm_wday;
+
+ tm.tm_mday = 7 * (ico->recur->u.month_pos -
+ ((week_day_start <= first_week_day ) ? 1 : 0)) -
+ (week_day_start - first_week_day) + 1;
+
+ t = mktime (&tm);
+
+ if (time_in_range (t, start, end))
+ if (!generate (ico, t, cb, closure))
+ return;
+
+ /* Advance a month */
+ current = mktime (&tm);
+
+ tm.tm_mday = 1;
+ tm.tm_mon += recur->interval;
+ current = mktime (&tm);
+
+ if (current == -1){
+ g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
+ return;
+ }
+ } while (current < end || (end == 0));
break;
case RECUR_MONTHLY_BY_DAY:
diff --git a/calendar/gui/test.vcf b/calendar/gui/test.vcf
index b0892bbf5f..ed6aedb8ac 100644
--- a/calendar/gui/test.vcf
+++ b/calendar/gui/test.vcf
@@ -8,14 +8,14 @@ DCREATED:19980402T023552
UID:KOrganizer - 1804289383
SEQUENCE:1
LAST-MODIFIED:19980330T225948
-DTSTART:19980415T116000
-DTEND:19980415T119000
-SUMMARY:Mensual, el 15, durante 4 semanas
+DTSTART:19980401T116000
+DTEND:19980401T119000
+SUMMARY:Primer miercoles, 4 meses
STATUS:NEEDS ACTION
CLASS:PUBLIC
PRIORITY:0
TRANSP:0
-RRULE:MD1 15 #4
+RRULE:MP1 1+ WE # 4
RELATED-TO:0
X-PILOTID:0
X-PILOTSTAT:0
diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c
index 76bb488663..e8da288153 100644
--- a/calendar/pcs/calobj.c
+++ b/calendar/pcs/calobj.c
@@ -565,8 +565,9 @@ ical_object_create_from_vobject (VObject *o, const char *object_name)
}
/* FIXME: dalarm */
- if (has (o, VCDAlarmProp))
- ;
+ if (has (o, VCDAlarmProp)){
+
+ }
/* FIXME: aalarm */
if (has (o, VCAAlarmProp))
@@ -625,6 +626,9 @@ store_list (VObject *o, char *prop, GList *values, char sep)
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" };
+
VObject *
ical_object_to_vobject (iCalObject *ical)
{
@@ -702,6 +706,57 @@ ical_object_to_vobject (iCalObject *ical)
if (ical->url)
addPropValue (o, VCURLProp, ical->url);
+ if (ical->recur){
+ char result [256];
+ char buffer [80];
+ int i;
+
+ sprintf (result, "%s%d ", recur_type_name [ical->recur->type], ical->recur->interval);
+ switch (ical->recur->type){
+ case RECUR_DAILY:
+ break;
+
+ case RECUR_WEEKLY:
+ for (i = 0; i < 7; i++){
+ if (ical->recur->weekday & (1 << i)){
+ sprintf (buffer, "%s ", recur_day_list [i]);
+ strcat (result, buffer);
+ }
+ }
+ break;
+
+ case RECUR_MONTHLY_BY_POS: {
+ int nega = ical->recur->u.month_pos < 0;
+
+ sprintf (buffer, "%d%s ", nega ? -ical->recur->u.month_pos : ical->recur->u.month_pos,
+ nega ? "-" : "+");
+ strcat (result, buffer);
+ for (i = 0; i < 7; i++){
+ if (ical->recur->weekday & (1 << i)){
+ sprintf (buffer, "%s ", recur_day_list [i]);
+ strcat (result, buffer);
+ }
+ }
+ }
+ break;
+
+ case RECUR_MONTHLY_BY_DAY:
+ sprintf (buffer, "%d ", ical->recur->u.month_pos);
+ strcat (result, buffer);
+ break;
+
+ case RECUR_YEARLY_BY_MONTH:
+ break;
+
+ case RECUR_YEARLY_BY_DAY:
+ break;
+ }
+ if (ical->recur->_enddate == 0)
+ sprintf (buffer, "#%d ",ical->recur->duration);
+ else
+ sprintf (buffer, "%s ", isodate_from_time_t (ical->recur->_enddate));
+ strcat (result, buffer);
+ }
/* FIXME: alarms */
return o;
}
@@ -758,7 +813,8 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
{
Recurrence *recur = ico->recur;
time_t current;
-
+ int first_week_day, i;
+
if (!ico->recur){
if (time_in_range (ico->dtstart, start, end) ||
time_in_range (ico->dtend, start, end)){
@@ -822,7 +878,55 @@ ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendar
break;
case RECUR_MONTHLY_BY_POS:
- g_warning ("We still do not handle MONTHLY_BY_POS\n");
+ /* FIXME: We only deal with positives now */
+ if (ico->recur->u.month_pos < 0)
+ return;
+
+ if (ico->recur->u.month_pos == 0)
+ return;
+
+ first_week_day = 7;
+ for (i = 6; i >= 0; i--)
+ if (ico->recur->weekday & (1 << i))
+ first_week_day = i;
+
+ /* This should not happen, but take it into account */
+ if (first_week_day == 7)
+ return;
+
+ do {
+ struct tm tm;
+ time_t t;
+ int p, week_day_start;
+
+ tm = *localtime (&current);
+ tm.tm_mday = 1;
+ t = mktime (&tm);
+ tm = *localtime (&t);
+ week_day_start = tm.tm_wday;
+
+ tm.tm_mday = 7 * (ico->recur->u.month_pos -
+ ((week_day_start <= first_week_day ) ? 1 : 0)) -
+ (week_day_start - first_week_day) + 1;
+
+ t = mktime (&tm);
+
+ if (time_in_range (t, start, end))
+ if (!generate (ico, t, cb, closure))
+ return;
+
+ /* Advance a month */
+ current = mktime (&tm);
+
+ tm.tm_mday = 1;
+ tm.tm_mon += recur->interval;
+ current = mktime (&tm);
+
+ if (current == -1){
+ g_warning ("RECUR_MONTHLY_BY_DAY: mktime error\n");
+ return;
+ }
+ } while (current < end || (end == 0));
break;
case RECUR_MONTHLY_BY_DAY:
diff --git a/calendar/test.vcf b/calendar/test.vcf
index b0892bbf5f..ed6aedb8ac 100644
--- a/calendar/test.vcf
+++ b/calendar/test.vcf
@@ -8,14 +8,14 @@ DCREATED:19980402T023552
UID:KOrganizer - 1804289383
SEQUENCE:1
LAST-MODIFIED:19980330T225948
-DTSTART:19980415T116000
-DTEND:19980415T119000
-SUMMARY:Mensual, el 15, durante 4 semanas
+DTSTART:19980401T116000
+DTEND:19980401T119000
+SUMMARY:Primer miercoles, 4 meses
STATUS:NEEDS ACTION
CLASS:PUBLIC
PRIORITY:0
TRANSP:0
-RRULE:MD1 15 #4
+RRULE:MP1 1+ WE # 4
RELATED-TO:0
X-PILOTID:0
X-PILOTSTAT:0