gnokii-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] libgnokii and core programs branch, master, updated. rel_0_6_28-19


From: Pawel Kot
Subject: [SCM] libgnokii and core programs branch, master, updated. rel_0_6_28-192-gd6497d8
Date: Wed, 07 Apr 2010 12:02:00 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "libgnokii and core programs".

The branch, master has been updated
       via  d6497d8be2d71f6671f1068dd1d691ce7886bab7 (commit)
      from  65da7713d0d2c6079286c283d66a4ba8bd501ad0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/gnokii.git/commit/?id=d6497d8be2d71f6671f1068dd1d691ce7886bab7


commit d6497d8be2d71f6671f1068dd1d691ce7886bab7
Author: Pawel Kot <address@hidden>
Date:   Wed Apr 7 14:01:33 2010 +0200

    Support recurrence when reading and writing ical files.

diff --git a/ChangeLog b/ChangeLog
index c0a1c0a..0fdcbd1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -74,6 +74,7 @@
       separate fields                                   (Paweł Kot)
     o support reading and writing caller grops on Series40 3rd Ed+
       from/to vcard files                               (Paweł Kot)
+    o support recurrence in ical files                  (Paweł Kot)
  * build system updates
     o remove GNOKII_API from the definition of asprinf
                                                       (Jari Turkia)
diff --git a/common/vcal.c b/common/vcal.c
index 8196e5b..43ffae9 100644
--- a/common/vcal.c
+++ b/common/vcal.c
@@ -107,7 +107,7 @@ static void ical_append_printf(ical_string *str, const char 
*fmt, ...)
 /*
        ICALENDAR Reading functions
  */
-GNOKII_API char * gn_calnote2icalstr (gn_calnote *calnote)
+GNOKII_API char *gn_calnote2icalstr(gn_calnote *calnote)
 {
        ical_string str;
 
@@ -198,6 +198,42 @@ GNOKII_API char * gn_calnote2icalstr (gn_calnote *calnote)
                break;
        }
 
+       if (calnote->recurrence) {
+               char rrule[64];
+               char *freq;
+               int interval = 1;
+
+               switch (calnote->recurrence) {
+               case GN_CALNOTE_NEVER:
+                       goto norecurrence;
+               case GN_CALNOTE_DAILY:
+                       freq = "DAILY";
+                       break;
+               case GN_CALNOTE_WEEKLY:
+                       freq = "WEEKLY";
+                       break;
+               case GN_CALNOTE_2WEEKLY:
+                       freq = "WEEKLY";
+                       interval = 2;
+                       break;
+               case GN_CALNOTE_MONTHLY:
+                       freq = "MONTHLY";
+                       break;
+               case GN_CALNOTE_YEARLY:
+                       freq = "YEARLY";
+                       break;
+               default:
+                       freq = "HOURLY";
+                       interval = calnote->recurrence;
+                       break;
+               }
+               if (calnote->occurrences == 0)
+                       snprintf(rrule, sizeof(rrule), "FREQ=%s;INTERVAL=%d", 
freq, interval);
+               else
+                       snprintf(rrule, sizeof(rrule), 
"FREQ=%s;COUNT=%d;INTERVAL=%d", freq, calnote->occurrences, interval);
+               properties[iprop++] = 
icalproperty_new_rrule(icalrecurrencetype_from_string(rrule));
+       }
+norecurrence:
        snprintf(compuid, sizeof(compuid), "guid.gnokii.org_%d_%d", 
calnote->location, rand());
 
        pIcal = icalcomponent_vanew(ICAL_VCALENDAR_COMPONENT,
@@ -374,7 +410,10 @@ static int gn_ical2calnote_real(icalcomponent *comp, 
gn_calnote *calnote, int id
        } else {
                const char *str;
                icalcomponent *alarm = {0};
+               icalproperty *rrule;
+               struct icalrecurrencetype recur;
                retval = GN_ERR_NONE;
+
                calnote->phone_number[0] = 0;
 
                /* type */
@@ -462,6 +501,49 @@ static int gn_ical2calnote_real(icalcomponent *comp, 
gn_calnote *calnote, int id
                        }
                }
 
+               /* recurrence */
+               rrule = icalcomponent_get_first_property(comp, 
ICAL_RRULE_PROPERTY);
+               if (rrule) {
+                       recur = icalproperty_get_rrule(rrule);
+                       calnote->occurrences = recur.count;
+                       switch (recur.freq) {
+                       case ICAL_SECONDLY_RECURRENCE:
+                               dprintf("Not suppported recurrence type. 
Aproximating recurrence\n");
+                               calnote->recurrence = recur.interval / 3600;
+                               if (calnote->recurrence)
+                                       calnote->recurrence = 1;
+                               break;
+                       case ICAL_MINUTELY_RECURRENCE:
+                               dprintf("Not suppported recurrence type. 
Aproximating recurrence\n");
+                               calnote->recurrence = recur.interval / 60;
+                               if (calnote->recurrence)
+                                       calnote->recurrence = 1;
+                               break;
+                       case ICAL_HOURLY_RECURRENCE:
+                               calnote->recurrence = recur.interval;
+                               break;
+                       case ICAL_DAILY_RECURRENCE:
+                               calnote->recurrence = recur.interval * 24;
+                               break;
+                       case ICAL_WEEKLY_RECURRENCE:
+                               calnote->recurrence = recur.interval * 24 * 7;
+                               break;
+                       case ICAL_MONTHLY_RECURRENCE:
+                               calnote->recurrence = GN_CALNOTE_MONTHLY;
+                               break;
+                       case ICAL_YEARLY_RECURRENCE:
+                               calnote->recurrence = GN_CALNOTE_YEARLY;
+                               break;
+                       case ICAL_NO_RECURRENCE:
+                               calnote->recurrence = GN_CALNOTE_NEVER;
+                               break;
+                       default:
+                               dprintf("Not supported recurrence type. 
Assuming never\n");
+                               calnote->recurrence = GN_CALNOTE_NEVER;
+                               break;
+                       }
+               }
+
                str = icalcomponent_get_location(compresult);
                if (!str)
                        str = "";

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog     |    1 +
 common/vcal.c |   84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 84 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
libgnokii and core programs




reply via email to

[Prev in Thread] Current Thread [Next in Thread]