From fc256b51501510509e2291c564bb378109b360ea Mon Sep 17 00:00:00 2001 From: Geoff Lankow Date: Thu, 25 Aug 2022 15:54:49 +1200 Subject: [PATCH] Bug 1787097 - Remove libical. r=leftmostcat Differential Revision: https://phabricator.services.mozilla.com/D155539 --HG-- rename : calendar/base/backend/icaljs/calDateTime.js => calendar/base/src/CalDateTime.jsm rename : calendar/base/backend/icaljs/calDuration.js => calendar/base/src/CalDuration.jsm rename : calendar/base/backend/icaljs/calICSService.js => calendar/base/src/CalICSService.jsm rename : calendar/base/backend/icaljs/calPeriod.js => calendar/base/src/CalPeriod.jsm rename : calendar/base/backend/icaljs/calRecurrenceRule.js => calendar/base/src/CalRecurrenceRule.jsm rename : calendar/base/src/calTimezone.js => calendar/base/src/CalTimezone.jsm rename : calendar/base/backend/icaljs/calICSService-worker.js => calendar/base/src/calICSService-worker.js rename : calendar/test/unit/head_consts.js => calendar/test/unit/head.js rename : calendar/test/unit/xpcshell-shared.ini => calendar/test/unit/xpcshell.ini extra : rebase_source : 8e25080fcc1e792d687e6bb49c69f65d3c8e07ba --- .clang-format-ignore | 1 - calendar/base/backend/CalBackendLoader.jsm | 71 - calendar/base/backend/components.conf | 47 - .../backend/icaljs/calICALJSComponents.js | 51 - calendar/base/backend/icaljs/moz.build | 23 - .../backend/libical/calAttributeHelpers.h | 91 - calendar/base/backend/libical/calDateTime.cpp | 572 ---- calendar/base/backend/libical/calDateTime.h | 51 - calendar/base/backend/libical/calDuration.cpp | 292 -- calendar/base/backend/libical/calDuration.h | 37 - .../base/backend/libical/calICSService.cpp | 1281 -------- calendar/base/backend/libical/calICSService.h | 178 -- calendar/base/backend/libical/calPeriod.cpp | 158 - calendar/base/backend/libical/calPeriod.h | 45 - .../backend/libical/calRecurrenceRule.cpp | 580 ---- .../base/backend/libical/calRecurrenceRule.h | 34 - calendar/base/backend/libical/calTimezone.cpp | 59 - calendar/base/backend/libical/calTimezone.h | 25 - calendar/base/backend/libical/calUtils.cpp | 100 - calendar/base/backend/libical/calUtils.h | 171 -- calendar/base/backend/libical/moz.build | 16 - calendar/base/backend/moz.build | 17 - calendar/base/calendar.js | 3 - calendar/base/modules/calUtils.jsm | 5 - calendar/base/moz.build | 1 - calendar/base/public/calIDateTime.idl | 9 - calendar/base/public/calIDuration.idl | 9 - calendar/base/public/calIICSService.idl | 26 +- calendar/base/public/calIPeriod.idl | 9 - calendar/base/public/calIRecurrenceRule.idl | 4 - .../calDateTime.js => src/CalDateTime.jsm} | 32 +- .../calDuration.js => src/CalDuration.jsm} | 10 +- .../CalICSService.jsm} | 59 +- .../icaljs/calPeriod.js => src/CalPeriod.jsm} | 20 +- calendar/base/src/CalRecurrenceInfo.jsm | 4 - .../CalRecurrenceRule.jsm} | 24 +- .../src/{calTimezone.js => CalTimezone.jsm} | 58 +- calendar/base/src/CalTimezoneService.jsm | 46 +- .../icaljs => src}/calICSService-worker.js | 2 +- calendar/base/src/components.conf | 30 + calendar/base/src/moz.build | 8 +- calendar/libical/AUTHORS | 6 - calendar/libical/LICENSE | 33 - calendar/libical/config.h | 24 - calendar/libical/design-data/components.txt | 22 - calendar/libical/design-data/parameters.csv | 39 - .../libical/design-data/params-in-prop.txt | 57 - calendar/libical/design-data/properties.csv | 122 - calendar/libical/design-data/restrictions.csv | 1420 --------- calendar/libical/design-data/status.txt | 56 - calendar/libical/design-data/value-types.csv | 35 - calendar/libical/moz.build | 9 - .../libical/scripts/mkderivedcomponents.pl | 170 -- .../libical/scripts/mkderivedparameters.pl | 390 --- .../libical/scripts/mkderivedproperties.pl | 384 --- calendar/libical/scripts/mkderivedvalues.pl | 297 -- calendar/libical/scripts/mkinclude.sh | 39 - calendar/libical/scripts/mkneticali.pl | 99 - .../scripts/mkparameterrestrictions.pl | 85 - .../libical/scripts/mkrestrictionrecords.pl | 109 - .../libical/scripts/mkrestrictiontable.pl | 102 - calendar/libical/scripts/readvaluesfile.pl | 135 - calendar/libical/src/libical/Makefile.in | 174 -- calendar/libical/src/libical/astime.h | 65 - calendar/libical/src/libical/caldate.c | 176 -- calendar/libical/src/libical/icalarray.c | 193 -- calendar/libical/src/libical/icalarray.h | 64 - calendar/libical/src/libical/icalattach.c | 151 - calendar/libical/src/libical/icalattach.h | 60 - calendar/libical/src/libical/icalattachimpl.h | 59 - calendar/libical/src/libical/icalcomponent.c | 2660 ---------------- calendar/libical/src/libical/icalcomponent.h | 285 -- .../src/libical/icalderivedparameter.c.in | 216 -- .../src/libical/icalderivedparameter.h.in | 38 - .../src/libical/icalderivedproperty.c.in | 298 -- .../src/libical/icalderivedproperty.h.in | 33 - .../libical/src/libical/icalderivedvalue.c.in | 460 --- .../libical/src/libical/icalderivedvalue.h.in | 77 - calendar/libical/src/libical/icalduration.c | 352 --- calendar/libical/src/libical/icalduration.h | 64 - calendar/libical/src/libical/icalenums.c | 183 -- calendar/libical/src/libical/icalenums.h | 168 -- calendar/libical/src/libical/icalerror.c | 271 -- calendar/libical/src/libical/icalerror.h | 173 -- calendar/libical/src/libical/icallangbind.c | 337 --- calendar/libical/src/libical/icallangbind.h | 56 - calendar/libical/src/libical/icalmemory.c | 375 --- calendar/libical/src/libical/icalmemory.h | 85 - calendar/libical/src/libical/icalmime.c | 411 --- calendar/libical/src/libical/icalmime.h | 44 - calendar/libical/src/libical/icalparameter.c | 448 --- calendar/libical/src/libical/icalparameter.h | 80 - .../libical/src/libical/icalparameterimpl.h | 53 - calendar/libical/src/libical/icalparser.c | 1291 -------- calendar/libical/src/libical/icalparser.h | 97 - calendar/libical/src/libical/icalperiod.c | 179 -- calendar/libical/src/libical/icalperiod.h | 57 - calendar/libical/src/libical/icalproperty.c | 1054 ------- calendar/libical/src/libical/icalproperty.h | 141 - calendar/libical/src/libical/icalrecur.c | 2670 ----------------- calendar/libical/src/libical/icalrecur.h | 217 -- .../libical/src/libical/icalrestriction.c.in | 523 ---- .../libical/src/libical/icalrestriction.h | 64 - calendar/libical/src/libical/icaltime.c | 1241 -------- calendar/libical/src/libical/icaltime.h | 287 -- calendar/libical/src/libical/icaltimezone.c | 2032 ------------- calendar/libical/src/libical/icaltimezone.h | 180 -- .../libical/src/libical/icaltimezoneimpl.h | 88 - calendar/libical/src/libical/icaltypes.c | 241 -- calendar/libical/src/libical/icaltypes.h | 122 - calendar/libical/src/libical/icalvalue.c | 1547 ---------- calendar/libical/src/libical/icalvalue.h | 94 - calendar/libical/src/libical/icalvalueimpl.h | 96 - calendar/libical/src/libical/icalversion.h | 7 - .../libical/src/libical/icalversion.h.cmake | 7 - calendar/libical/src/libical/icalversion.h.in | 7 - calendar/libical/src/libical/icptrholder.h | 104 - calendar/libical/src/libical/libical.dsp | 594 ---- calendar/libical/src/libical/moz.build | 66 - calendar/libical/src/libical/pvl.c | 597 ---- calendar/libical/src/libical/pvl.h | 110 - calendar/libical/src/libical/sspm.c | 1639 ---------- calendar/libical/src/libical/sspm.h | 146 - calendar/libical/src/libical/vcomponent.h | 351 --- calendar/libical/src/libical/vsnprintf.c | 173 -- calendar/libical/src/libical/vsnprintf.h | 33 - calendar/moz.build | 1 - calendar/test/moz.build | 3 +- .../test/unit/{head_consts.js => head.js} | 0 calendar/test/unit/head_icaljs.js | 5 - calendar/test/unit/head_libical.js | 5 - calendar/test/unit/test_freebusy.js | 32 +- calendar/test/unit/test_ics_parser.js | 4 +- calendar/test/unit/test_ics_service.js | 23 +- calendar/test/unit/xpcshell-icaljs.ini | 8 - calendar/test/unit/xpcshell-libical.ini | 8 - .../{xpcshell-shared.ini => xpcshell.ini} | 3 + mail/installer/package-manifest.in | 9 - 138 files changed, 161 insertions(+), 31996 deletions(-) delete mode 100644 calendar/base/backend/CalBackendLoader.jsm delete mode 100644 calendar/base/backend/components.conf delete mode 100644 calendar/base/backend/icaljs/calICALJSComponents.js delete mode 100644 calendar/base/backend/icaljs/moz.build delete mode 100644 calendar/base/backend/libical/calAttributeHelpers.h delete mode 100644 calendar/base/backend/libical/calDateTime.cpp delete mode 100644 calendar/base/backend/libical/calDateTime.h delete mode 100644 calendar/base/backend/libical/calDuration.cpp delete mode 100644 calendar/base/backend/libical/calDuration.h delete mode 100644 calendar/base/backend/libical/calICSService.cpp delete mode 100644 calendar/base/backend/libical/calICSService.h delete mode 100644 calendar/base/backend/libical/calPeriod.cpp delete mode 100644 calendar/base/backend/libical/calPeriod.h delete mode 100644 calendar/base/backend/libical/calRecurrenceRule.cpp delete mode 100644 calendar/base/backend/libical/calRecurrenceRule.h delete mode 100644 calendar/base/backend/libical/calTimezone.cpp delete mode 100644 calendar/base/backend/libical/calTimezone.h delete mode 100644 calendar/base/backend/libical/calUtils.cpp delete mode 100644 calendar/base/backend/libical/calUtils.h delete mode 100644 calendar/base/backend/libical/moz.build delete mode 100644 calendar/base/backend/moz.build rename calendar/base/{backend/icaljs/calDateTime.js => src/CalDateTime.jsm} (79%) rename calendar/base/{backend/icaljs/calDuration.js => src/CalDuration.jsm} (89%) rename calendar/base/{backend/icaljs/calICSService.js => src/CalICSService.jsm} (88%) rename calendar/base/{backend/icaljs/calPeriod.js => src/CalPeriod.jsm} (70%) rename calendar/base/{backend/icaljs/calRecurrenceRule.js => src/CalRecurrenceRule.jsm} (88%) rename calendar/base/src/{calTimezone.js => CalTimezone.jsm} (53%) rename calendar/base/{backend/icaljs => src}/calICSService-worker.js (93%) delete mode 100644 calendar/libical/AUTHORS delete mode 100644 calendar/libical/LICENSE delete mode 100644 calendar/libical/config.h delete mode 100644 calendar/libical/design-data/components.txt delete mode 100644 calendar/libical/design-data/parameters.csv delete mode 100644 calendar/libical/design-data/params-in-prop.txt delete mode 100644 calendar/libical/design-data/properties.csv delete mode 100644 calendar/libical/design-data/restrictions.csv delete mode 100644 calendar/libical/design-data/status.txt delete mode 100644 calendar/libical/design-data/value-types.csv delete mode 100644 calendar/libical/moz.build delete mode 100755 calendar/libical/scripts/mkderivedcomponents.pl delete mode 100755 calendar/libical/scripts/mkderivedparameters.pl delete mode 100755 calendar/libical/scripts/mkderivedproperties.pl delete mode 100755 calendar/libical/scripts/mkderivedvalues.pl delete mode 100644 calendar/libical/scripts/mkinclude.sh delete mode 100755 calendar/libical/scripts/mkneticali.pl delete mode 100755 calendar/libical/scripts/mkparameterrestrictions.pl delete mode 100755 calendar/libical/scripts/mkrestrictionrecords.pl delete mode 100755 calendar/libical/scripts/mkrestrictiontable.pl delete mode 100644 calendar/libical/scripts/readvaluesfile.pl delete mode 100644 calendar/libical/src/libical/Makefile.in delete mode 100644 calendar/libical/src/libical/astime.h delete mode 100644 calendar/libical/src/libical/caldate.c delete mode 100644 calendar/libical/src/libical/icalarray.c delete mode 100644 calendar/libical/src/libical/icalarray.h delete mode 100644 calendar/libical/src/libical/icalattach.c delete mode 100644 calendar/libical/src/libical/icalattach.h delete mode 100644 calendar/libical/src/libical/icalattachimpl.h delete mode 100644 calendar/libical/src/libical/icalcomponent.c delete mode 100644 calendar/libical/src/libical/icalcomponent.h delete mode 100644 calendar/libical/src/libical/icalderivedparameter.c.in delete mode 100644 calendar/libical/src/libical/icalderivedparameter.h.in delete mode 100644 calendar/libical/src/libical/icalderivedproperty.c.in delete mode 100644 calendar/libical/src/libical/icalderivedproperty.h.in delete mode 100644 calendar/libical/src/libical/icalderivedvalue.c.in delete mode 100644 calendar/libical/src/libical/icalderivedvalue.h.in delete mode 100644 calendar/libical/src/libical/icalduration.c delete mode 100644 calendar/libical/src/libical/icalduration.h delete mode 100644 calendar/libical/src/libical/icalenums.c delete mode 100644 calendar/libical/src/libical/icalenums.h delete mode 100644 calendar/libical/src/libical/icalerror.c delete mode 100644 calendar/libical/src/libical/icalerror.h delete mode 100644 calendar/libical/src/libical/icallangbind.c delete mode 100644 calendar/libical/src/libical/icallangbind.h delete mode 100644 calendar/libical/src/libical/icalmemory.c delete mode 100644 calendar/libical/src/libical/icalmemory.h delete mode 100644 calendar/libical/src/libical/icalmime.c delete mode 100644 calendar/libical/src/libical/icalmime.h delete mode 100644 calendar/libical/src/libical/icalparameter.c delete mode 100644 calendar/libical/src/libical/icalparameter.h delete mode 100644 calendar/libical/src/libical/icalparameterimpl.h delete mode 100644 calendar/libical/src/libical/icalparser.c delete mode 100644 calendar/libical/src/libical/icalparser.h delete mode 100644 calendar/libical/src/libical/icalperiod.c delete mode 100644 calendar/libical/src/libical/icalperiod.h delete mode 100644 calendar/libical/src/libical/icalproperty.c delete mode 100644 calendar/libical/src/libical/icalproperty.h delete mode 100644 calendar/libical/src/libical/icalrecur.c delete mode 100644 calendar/libical/src/libical/icalrecur.h delete mode 100644 calendar/libical/src/libical/icalrestriction.c.in delete mode 100644 calendar/libical/src/libical/icalrestriction.h delete mode 100644 calendar/libical/src/libical/icaltime.c delete mode 100644 calendar/libical/src/libical/icaltime.h delete mode 100644 calendar/libical/src/libical/icaltimezone.c delete mode 100644 calendar/libical/src/libical/icaltimezone.h delete mode 100644 calendar/libical/src/libical/icaltimezoneimpl.h delete mode 100644 calendar/libical/src/libical/icaltypes.c delete mode 100644 calendar/libical/src/libical/icaltypes.h delete mode 100644 calendar/libical/src/libical/icalvalue.c delete mode 100644 calendar/libical/src/libical/icalvalue.h delete mode 100644 calendar/libical/src/libical/icalvalueimpl.h delete mode 100644 calendar/libical/src/libical/icalversion.h delete mode 100644 calendar/libical/src/libical/icalversion.h.cmake delete mode 100644 calendar/libical/src/libical/icalversion.h.in delete mode 100644 calendar/libical/src/libical/icptrholder.h delete mode 100644 calendar/libical/src/libical/libical.dsp delete mode 100644 calendar/libical/src/libical/moz.build delete mode 100644 calendar/libical/src/libical/pvl.c delete mode 100644 calendar/libical/src/libical/pvl.h delete mode 100644 calendar/libical/src/libical/sspm.c delete mode 100644 calendar/libical/src/libical/sspm.h delete mode 100644 calendar/libical/src/libical/vcomponent.h delete mode 100644 calendar/libical/src/libical/vsnprintf.c delete mode 100644 calendar/libical/src/libical/vsnprintf.h rename calendar/test/unit/{head_consts.js => head.js} (100%) delete mode 100644 calendar/test/unit/head_icaljs.js delete mode 100644 calendar/test/unit/head_libical.js delete mode 100644 calendar/test/unit/xpcshell-icaljs.ini delete mode 100644 calendar/test/unit/xpcshell-libical.ini rename calendar/test/unit/{xpcshell-shared.ini => xpcshell.ini} (96%) diff --git a/.clang-format-ignore b/.clang-format-ignore index 52fc2819be..f64cb88e04 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -4,7 +4,6 @@ # `mach clang-format` will likely not pick up this file. # Specific modules to exclude. -calendar/libical/.* mailnews/mapi/include/.* suite/.* third_party/.* diff --git a/calendar/base/backend/CalBackendLoader.jsm b/calendar/base/backend/CalBackendLoader.jsm deleted file mode 100644 index 2692b87615..0000000000 --- a/calendar/base/backend/CalBackendLoader.jsm +++ /dev/null @@ -1,71 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const EXPORTED_SYMBOLS = ["CalBackendLoader"]; - -function CalBackendLoader() { - try { - this.loadBackend(); - } catch (e) { - dump(`### Error loading backend:${e.filename || e.fileName}:${e.lineNumber}: ${e}\n`); - } -} - -CalBackendLoader.prototype = { - QueryInterface: ChromeUtils.generateQI(["nsIObserver"]), - - loaded: false, - - observe() { - // Nothing to do here, just need the entry so this is instantiated. - }, - - loadBackend() { - if (this.loaded) { - return; - } - - if (Services.prefs.getBoolPref("calendar.icaljs", false)) { - let contracts = { - "@mozilla.org/calendar/datetime;1": "{36783242-ec94-4d8a-9248-d2679edd55b9}", - "@mozilla.org/calendar/ics-service;1": "{c61cb903-4408-41b3-bc22-da0b27efdfe1}", - "@mozilla.org/calendar/period;1": "{394a281f-7299-45f7-8b1f-cce21258972f}", - "@mozilla.org/calendar/recurrence-rule;1": "{df19281a-5389-4146-b941-798cb93a7f0d}", - "@mozilla.org/calendar/duration;1": "{7436f480-c6fc-4085-9655-330b1ee22288}", - }; - - // Load ical.js backend - let scope = {}; - Services.scriptloader.loadSubScript("resource:///components/calICALJSComponents.js", scope); - - // Register the icaljs components. We used to unregisterFactory, but this caused all - // sorts of problems. Just registering over it seems to work quite fine. - let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); - for (let [contractID, classID] of Object.entries(contracts)) { - let newClassID = Components.ID(classID); - let newFactory = lazyFactoryFor(scope, classID); - registrar.registerFactory(newClassID, "", contractID, newFactory); - } - - // Set up ical.js to use non-strict (lenient) mode. - let { ICAL } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm"); - ICAL.design.strict = false; - - dump("[CalBackendLoader] Using Thunderbird's ical.js backend\n"); - } else { - dump("[CalBackendLoader] Using Thunderbird's libical backend\n"); - } - - this.loaded = true; - }, -}; - -function lazyFactoryFor(backendScope, classID) { - return { - createInstance(interfaceID) { - let componentConstructor = backendScope.getComponentConstructor(classID); - return new componentConstructor().QueryInterface(interfaceID); - }, - }; -} diff --git a/calendar/base/backend/components.conf b/calendar/base/backend/components.conf deleted file mode 100644 index 7c46aed190..0000000000 --- a/calendar/base/backend/components.conf +++ /dev/null @@ -1,47 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -Classes = [ - { - "cid": "{0314c271-7168-40fa-802e-83c8c46a557e}", - "contract_ids": [ - "@mozilla.org/calendar/backend-loader;1", - ], - "jsm": "resource:///modules/CalBackendLoader.jsm", - "constructor": "CalBackendLoader", - "categories": {"profile-after-change": "CalBackendLoader"}, - }, - { - "cid": "{85475b45-110a-443c-af3f-b66398a5a7cd}", - "contract_ids": ["@mozilla.org/calendar/datetime;1"], - "type": "calDateTime", - "headers": ["/comm/calendar/base/backend/libical/calDateTime.h"], - }, - { - "cid": "{63513139-51cb-4f5b-9a52-49accc5cae17}", - "contract_ids": ["@mozilla.org/calendar/duration;1"], - "type": "calDuration", - "headers": ["/comm/calendar/base/backend/libical/calDuration.h"], - }, - { - "cid": "{12fdd72b-c5b6-4720-8166-2deca13382f5}", - "contract_ids": ["@mozilla.org/calendar/period;1"], - "type": "calPeriod", - "headers": ["/comm/calendar/base/backend/libical/calPeriod.h"], - }, - { - "cid": "{ae4ca6c3-981b-4f66-a0ce-2f2c218ad9e3}", - "contract_ids": ["@mozilla.org/calendar/ics-service;1"], - "type": "calICSService", - "headers": ["/comm/calendar/base/backend/libical/calICSService.h"], - }, - { - "cid": "{d9560bf9-3065-404a-904c-c882fc9c9b74}", - "contract_ids": ["@mozilla.org/calendar/recurrence-rule;1"], - "type": "calRecurrenceRule", - "headers": ["/comm/calendar/base/backend/libical/calRecurrenceRule.h"], - }, -] diff --git a/calendar/base/backend/icaljs/calICALJSComponents.js b/calendar/base/backend/icaljs/calICALJSComponents.js deleted file mode 100644 index ed7f209e42..0000000000 --- a/calendar/base/backend/icaljs/calICALJSComponents.js +++ /dev/null @@ -1,51 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* import-globals-from ../../src/calTimezone.js */ -/* import-globals-from calDateTime.js */ -/* import-globals-from calDuration.js */ -/* import-globals-from calICSService.js */ -/* import-globals-from calPeriod.js */ -/* import-globals-from calRecurrenceRule.js */ - -var { ComponentUtils } = ChromeUtils.import("resource://gre/modules/ComponentUtils.jsm"); - -/** - * @param {string} cid - Class ID as string. - * @returns {function} Constructor to create the requested class ID component. - */ -this.getComponentConstructor = cid => { - if (!this.loadedScripts) { - let scriptLoadOrder = [ - "resource:///components/calTimezone.js", - "resource:///components/calDateTime.js", - "resource:///components/calDuration.js", - "resource:///components/calICSService.js", - "resource:///components/calPeriod.js", - "resource:///components/calRecurrenceRule.js", - ]; - - for (let script of scriptLoadOrder) { - Services.scriptloader.loadSubScript(script, this); - } - this.loadedScripts = true; - } - - let components = [ - calDateTime, - calDuration, - calIcalComponent, - calIcalProperty, - calICSService, - calPeriod, - calRecurrenceRule, - ]; - - for (const component of components) { - if (component.prototype.classID.toString() == cid) { - return component; - } - } - throw new Error("No component for cid " + cid); -}; diff --git a/calendar/base/backend/icaljs/moz.build b/calendar/base/backend/icaljs/moz.build deleted file mode 100644 index fc0546929d..0000000000 --- a/calendar/base/backend/icaljs/moz.build +++ /dev/null @@ -1,23 +0,0 @@ -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -# There is no manifest file for the calICALJSComponents component because -# calendar backend components are loaded dynamically. -EXTRA_COMPONENTS += [ - "calICALJSComponents.js", -] - -# These files go in components so they can be packaged correctly. -FINAL_TARGET_FILES.components += [ - "calDateTime.js", - "calDuration.js", - "calICSService-worker.js", - "calICSService.js", - "calPeriod.js", - "calRecurrenceRule.js", -] - -with Files("**"): - BUG_COMPONENT = ("Calendar", "ICAL.js Integration") diff --git a/calendar/base/backend/libical/calAttributeHelpers.h b/calendar/base/backend/libical/calAttributeHelpers.h deleted file mode 100644 index 4e65cf2f52..0000000000 --- a/calendar/base/backend/libical/calAttributeHelpers.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CALATTRIBUTEHELPERS_H_ -#define CALATTRIBUTEHELPERS_H_ - -#ifndef CAL_ATTR_SET_PRE -# define CAL_ATTR_SET_PRE /**/ -#endif - -#ifndef CAL_ATTR_SET_POST -# define CAL_ATTR_SET_POST /**/ -#endif - -/** - ** A few helpers for declaring simple attribute getters and setters in - ** calItemBase derivatives - **/ - -// helpers for string types -#define CAL_STRINGTYPE_ATTR_GETTER(cname, mtype, name) \ - NS_IMETHODIMP \ - cname::Get##name(mtype& _retval) { \ - _retval.Assign(m##name); \ - return NS_OK; \ - } - -#define CAL_STRINGTYPE_ATTR_SETTER(cname, mtype, name) \ - NS_IMETHODIMP \ - cname::Set##name(const mtype& aValue) { \ - CAL_ATTR_SET_PRE; \ - m##name.Assign(aValue); \ - CAL_ATTR_SET_POST; \ - return NS_OK; \ - } - -#define CAL_STRINGTYPE_ATTR(cname, mtype, name) \ - CAL_STRINGTYPE_ATTR_GETTER(cname, mtype, name) \ - CAL_STRINGTYPE_ATTR_SETTER(cname, mtype, name) - -// helpers for value types -#define CAL_VALUETYPE_ATTR_GETTER(cname, mtype, name) \ - NS_IMETHODIMP \ - cname::Get##name(mtype* _retval) { \ - NS_ENSURE_ARG_POINTER(_retval); \ - *_retval = m##name; \ - return NS_OK; \ - } - -#define CAL_VALUETYPE_ATTR_SETTER(cname, mtype, name) \ - NS_IMETHODIMP \ - cname::Set##name(mtype aValue) { \ - CAL_ATTR_SET_PRE; \ - if (m##name != aValue) { \ - m##name = aValue; \ - CAL_ATTR_SET_POST; \ - } \ - return NS_OK; \ - } - -#define CAL_VALUETYPE_ATTR(cname, mtype, name) \ - CAL_VALUETYPE_ATTR_GETTER(cname, mtype, name) \ - CAL_VALUETYPE_ATTR_SETTER(cname, mtype, name) - -// helpers for interface types -#define CAL_ISUPPORTS_ATTR_GETTER(cname, mtype, name) \ - NS_IMETHODIMP \ - cname::Get##name(mtype** _retval) { \ - NS_ENSURE_ARG_POINTER(_retval); \ - NS_IF_ADDREF(*_retval = m##name); \ - return NS_OK; \ - } - -#define CAL_ISUPPORTS_ATTR_SETTER(cname, mtype, name) \ - NS_IMETHODIMP \ - cname::Set##name(mtype* aValue) { \ - CAL_ATTR_SET_PRE; \ - if (m##name != aValue) { \ - m##name = aValue; \ - CAL_ATTR_SET_POST; \ - } \ - return NS_OK; \ - } - -#define CAL_ISUPPORTS_ATTR(cname, mtype, name) \ - CAL_ISUPPORTS_ATTR_GETTER(cname, mtype, name) \ - CAL_ISUPPORTS_ATTR_SETTER(cname, mtype, name) - -#endif diff --git a/calendar/base/backend/libical/calDateTime.cpp b/calendar/base/backend/libical/calDateTime.cpp deleted file mode 100644 index 11df656bb7..0000000000 --- a/calendar/base/backend/libical/calDateTime.cpp +++ /dev/null @@ -1,572 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "calDateTime.h" -#include "calBaseCID.h" - -#include "nsServiceManagerUtils.h" -#include "nsIClassInfoImpl.h" - -#include "calIErrors.h" -#include "calDuration.h" - -#include "jsapi.h" -#include "jsfriendapi.h" -#include "js/Wrapper.h" -#include "prprf.h" - -extern "C" { -#include "ical.h" -} - -#define CAL_ATTR_SET_PRE \ - NS_ENSURE_FALSE(mImmutable, NS_ERROR_OBJECT_IS_IMMUTABLE) -#define CAL_ATTR_SET_POST Normalize() -#include "calAttributeHelpers.h" - -NS_IMPL_CLASSINFO(calDateTime, nullptr, 0, CAL_DATETIME_CID) -NS_IMPL_ISUPPORTS_CI(calDateTime, calIDateTime, calIDateTimeLibical) - -calDateTime::calDateTime() : mImmutable(false) { Reset(); } - -calDateTime::calDateTime(icaltimetype const* atimeptr, calITimezone* tz) - : mImmutable(false) { - FromIcalTime(atimeptr, tz); -} - -NS_IMETHODIMP -calDateTime::GetIsMutable(bool* aResult) { - NS_ENSURE_ARG_POINTER(aResult); - *aResult = !mImmutable; - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::MakeImmutable() { - mImmutable = true; - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::Clone(calIDateTime** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - icaltimetype itt; - ToIcalTime(&itt); - calDateTime* const cdt = new calDateTime(&itt, mTimezone); - CAL_ENSURE_MEMORY(cdt); - NS_ADDREF(*aResult = cdt); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::ResetTo(int16_t year, int16_t month, int16_t day, int16_t hour, - int16_t minute, int16_t second, calITimezone* tz) { - NS_ENSURE_FALSE(mImmutable, NS_ERROR_OBJECT_IS_IMMUTABLE); - NS_ENSURE_ARG_POINTER(tz); - mYear = year; - mMonth = month; - mDay = day; - mHour = hour; - mMinute = minute; - mSecond = second; - mIsDate = false; - mTimezone = tz; - Normalize(); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::Reset() { - NS_ENSURE_FALSE(mImmutable, NS_ERROR_OBJECT_IS_IMMUTABLE); - mYear = 1970; - mMonth = 0; - mDay = 1; - mHour = 0; - mMinute = 0; - mSecond = 0; - mWeekday = 4; - mYearday = 1; - mIsDate = false; - mTimezone = nullptr; - mNativeTime = 0; - mIsValid = true; - return NS_OK; -} - -CAL_VALUETYPE_ATTR(calDateTime, int16_t, Year) -CAL_VALUETYPE_ATTR(calDateTime, int16_t, Month) -CAL_VALUETYPE_ATTR(calDateTime, int16_t, Day) -CAL_VALUETYPE_ATTR(calDateTime, int16_t, Hour) -CAL_VALUETYPE_ATTR(calDateTime, int16_t, Minute) -CAL_VALUETYPE_ATTR(calDateTime, int16_t, Second) -CAL_VALUETYPE_ATTR(calDateTime, bool, IsDate) -CAL_VALUETYPE_ATTR_GETTER(calDateTime, bool, IsValid) -CAL_VALUETYPE_ATTR_GETTER(calDateTime, PRTime, NativeTime) -CAL_VALUETYPE_ATTR_GETTER(calDateTime, int16_t, Weekday) -CAL_VALUETYPE_ATTR_GETTER(calDateTime, int16_t, Yearday) - -NS_IMETHODIMP -calDateTime::GetTimezone(calITimezone** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - ensureTimezone(); - - NS_IF_ADDREF(*aResult = mTimezone); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::SetTimezone(calITimezone* aValue) { - NS_ENSURE_FALSE(mImmutable, NS_ERROR_OBJECT_IS_IMMUTABLE); - NS_ENSURE_ARG_POINTER(aValue); - mTimezone = aValue; - CAL_ATTR_SET_POST; - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::GetTimezoneOffset(int32_t* aResult) { - NS_ENSURE_ARG_POINTER(aResult); - icaltimetype icalt; - ToIcalTime(&icalt); - int dst; - *aResult = icaltimezone_get_utc_offset(const_cast(icalt.zone), - &icalt, &dst); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::SetNativeTime(PRTime aNativeTime) { - icaltimetype icalt; - PRTimeToIcaltime(aNativeTime, false, icaltimezone_get_utc_timezone(), &icalt); - nsCOMPtr ctz = cal::UTC(); - FromIcalTime(&icalt, ctz); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::AddDuration(calIDuration* aDuration) { - NS_ENSURE_FALSE(mImmutable, NS_ERROR_OBJECT_IS_IMMUTABLE); - NS_ENSURE_ARG_POINTER(aDuration); - ensureTimezone(); - - nsresult rv; - nsCOMPtr icaldur = do_QueryInterface(aDuration, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - icaldurationtype idt; - icaldur->ToIcalDuration(&idt); - - icaltimetype itt; - ToIcalTime(&itt); - - icaltimetype const newitt = icaltime_add(itt, idt); - FromIcalTime(&newitt, mTimezone); - - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::SubtractDate(calIDateTime* aDate, calIDuration** aDuration) { - NS_ENSURE_ARG_POINTER(aDate); - NS_ENSURE_ARG_POINTER(aDuration); - - // same as icaltime_subtract(), but minding timezones: - PRTime t2t; - aDate->GetNativeTime(&t2t); - // for a duration, need to convert the difference in microseconds (prtime) - // to seconds (libical), so divide by one million. - icaldurationtype const idt = icaldurationtype_from_int( - static_cast((mNativeTime - t2t) / int64_t(PR_USEC_PER_SEC))); - - calDuration* const dur = new calDuration(&idt); - CAL_ENSURE_MEMORY(dur); - NS_ADDREF(*aDuration = dur); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::ToString(nsACString& aResult) { - nsAutoCString tzid; - char buffer[256]; - - ensureTimezone(); - mTimezone->GetTzid(tzid); - - uint32_t const length = PR_snprintf( - buffer, sizeof(buffer), - "%04hd/%02hd/%02hd %02hd:%02hd:%02hd %s isDate=%01hd nativeTime=%lld", - mYear, mMonth + 1, mDay, mHour, mMinute, mSecond, tzid.get(), - static_cast(mIsDate), mNativeTime); - if (length != static_cast(-1)) aResult.Assign(buffer, length); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::ToJSON(nsACString& aResult) { return ToString(aResult); } - -NS_IMETHODIMP -calDateTime::GetInTimezone(calITimezone* aTimezone, calIDateTime** aResult) { - NS_ENSURE_ARG_POINTER(aTimezone); - NS_ENSURE_ARG_POINTER(aResult); - - if (mIsDate) { - // if it's a date, we really just want to make a copy of this - // and set the timezone. - nsresult rv = Clone(aResult); - if (NS_SUCCEEDED(rv)) { - rv = (*aResult)->SetTimezone(aTimezone); - } - return rv; - } else { - icaltimetype icalt; - ToIcalTime(&icalt); - - icaltimezone* tz = cal::getIcalTimezone(aTimezone); - if (icalt.zone == tz) { - return Clone(aResult); - } - - /* If there's a zone, we need to convert; otherwise, we just - * assign, since this item is floating */ - if (icalt.zone && tz) { - icaltimezone_convert_time(&icalt, const_cast(icalt.zone), - tz); - } - icalt.zone = tz; - icalt.is_utc = (tz && tz == icaltimezone_get_utc_timezone()); - - calDateTime* cdt = new calDateTime(&icalt, aTimezone); - CAL_ENSURE_MEMORY(cdt); - NS_ADDREF(*aResult = cdt); - return NS_OK; - } -} - -NS_IMETHODIMP -calDateTime::GetStartOfWeek(calIDateTime** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - ensureTimezone(); - - icaltimetype icalt; - ToIcalTime(&icalt); - int day_of_week = icaltime_day_of_week(icalt); - if (day_of_week > 1) icaltime_adjust(&icalt, -(day_of_week - 1), 0, 0, 0); - icalt.is_date = 1; - - calDateTime* const cdt = new calDateTime(&icalt, mTimezone); - CAL_ENSURE_MEMORY(cdt); - NS_ADDREF(*aResult = cdt); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::GetEndOfWeek(calIDateTime** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - ensureTimezone(); - - icaltimetype icalt; - ToIcalTime(&icalt); - int day_of_week = icaltime_day_of_week(icalt); - if (day_of_week < 7) icaltime_adjust(&icalt, 7 - day_of_week, 0, 0, 0); - icalt.is_date = 1; - - calDateTime* const cdt = new calDateTime(&icalt, mTimezone); - CAL_ENSURE_MEMORY(cdt); - NS_ADDREF(*aResult = cdt); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::GetStartOfMonth(calIDateTime** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - ensureTimezone(); - - icaltimetype icalt; - ToIcalTime(&icalt); - icalt.day = 1; - icalt.is_date = 1; - - calDateTime* const cdt = new calDateTime(&icalt, mTimezone); - CAL_ENSURE_MEMORY(cdt); - NS_ADDREF(*aResult = cdt); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::GetEndOfMonth(calIDateTime** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - ensureTimezone(); - - icaltimetype icalt; - ToIcalTime(&icalt); - icalt.day = icaltime_days_in_month(icalt.month, icalt.year); - icalt.is_date = 1; - - calDateTime* const cdt = new calDateTime(&icalt, mTimezone); - CAL_ENSURE_MEMORY(cdt); - NS_ADDREF(*aResult = cdt); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::GetStartOfYear(calIDateTime** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - ensureTimezone(); - - icaltimetype icalt; - ToIcalTime(&icalt); - icalt.month = 1; - icalt.day = 1; - icalt.is_date = 1; - - calDateTime* const cdt = new calDateTime(&icalt, mTimezone); - CAL_ENSURE_MEMORY(cdt); - NS_ADDREF(*aResult = cdt); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::GetEndOfYear(calIDateTime** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - ensureTimezone(); - - icaltimetype icalt; - ToIcalTime(&icalt); - icalt.month = 12; - icalt.day = 31; - icalt.is_date = 1; - - calDateTime* const cdt = new calDateTime(&icalt, mTimezone); - CAL_ENSURE_MEMORY(cdt); - NS_ADDREF(*aResult = cdt); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::GetIcalString(nsACString& aResult) { - icaltimetype t; - ToIcalTime(&t); - - // note that ics is owned by libical, so we don't need to free - char const* const ics = icaltime_as_ical_string(t); - CAL_ENSURE_MEMORY(ics); - aResult.Assign(ics); - return NS_OK; -} - -NS_IMETHODIMP -calDateTime::SetIcalString(nsACString const& aIcalString) { - NS_ENSURE_FALSE(mImmutable, NS_ERROR_OBJECT_IS_IMMUTABLE); - icaltimetype icalt; - icalt = icaltime_from_string(PromiseFlatCString(aIcalString).get()); - if (icaltime_is_null_time(icalt)) { - return static_cast(calIErrors::ICS_ERROR_BASE + icalerrno); - } - FromIcalTime(&icalt, nullptr); - return NS_OK; -} - -/** - ** utility/protected methods - **/ - -// internal Normalize(): -void calDateTime::Normalize() { - icaltimetype icalt; - - ensureTimezone(); - ToIcalTime(&icalt); - FromIcalTime(&icalt, mTimezone); -} - -void calDateTime::ensureTimezone() { - if (mTimezone == nullptr) { - mTimezone = cal::UTC(); - } -} - -NS_IMETHODIMP_(void) -calDateTime::ToIcalTime(struct icaltimetype* icalt) { - ensureTimezone(); - - icalt->year = mYear; - icalt->month = mMonth + 1; - icalt->day = mDay; - icalt->hour = mHour; - icalt->minute = mMinute; - icalt->second = mSecond; - - icalt->is_date = mIsDate ? 1 : 0; - icalt->is_daylight = 0; - - icaltimezone* tz = cal::getIcalTimezone(mTimezone); - icalt->zone = tz; - icalt->is_utc = (tz && tz == icaltimezone_get_utc_timezone()); - icalt->is_daylight = 0; - // xxx todo: discuss/investigate is_daylight - // if (tz) { - // icaltimezone_get_utc_offset(tz, icalt, &icalt->is_daylight); - // } -} - -void calDateTime::FromIcalTime(icaltimetype const* icalt, calITimezone* tz) { - icaltimetype t = *icalt; - mIsValid = - (icaltime_is_null_time(t) || icaltime_is_valid_time(t) ? true : false); - - mIsDate = t.is_date ? true : false; - if (mIsDate) { - t.hour = 0; - t.minute = 0; - t.second = 0; - } - - if (mIsValid) { - t = icaltime_normalize(t); - } - - mYear = static_cast(t.year); - mMonth = static_cast(t.month - 1); - mDay = static_cast(t.day); - mHour = static_cast(t.hour); - mMinute = static_cast(t.minute); - mSecond = static_cast(t.second); - - if (tz) { - mTimezone = tz; - } else { - mTimezone = cal::detectTimezone(t, nullptr); - } -#if defined(DEBUG) - if (mTimezone) { - if (t.is_utc) { - nsCOMPtr ctz = cal::UTC(); - NS_ASSERTION(SameCOMIdentity(mTimezone, ctz), "UTC mismatch!"); - } else if (!t.zone) { - nsAutoCString tzid; - mTimezone->GetTzid(tzid); - if (tzid.EqualsLiteral("floating")) { - nsCOMPtr ctz = cal::floating(); - NS_ASSERTION(SameCOMIdentity(mTimezone, ctz), "floating mismatch!"); - } - } else { - nsAutoCString tzid; - mTimezone->GetTzid(tzid); - NS_ASSERTION( - tzid.Equals(icaltimezone_get_tzid(const_cast(t.zone))), - "tzid mismatch!"); - } - } -#endif - - mWeekday = static_cast(icaltime_day_of_week(t) - 1); - mYearday = static_cast(icaltime_day_of_year(t)); - - // mNativeTime: not moving the existing date to UTC, - // but merely representing it a UTC-based way. - t.is_date = 0; - mNativeTime = IcaltimeToPRTime(&t, icaltimezone_get_utc_timezone()); -} - -PRTime calDateTime::IcaltimeToPRTime(icaltimetype const* icalt, - icaltimezone const* tz) { - icaltimetype tt; - PRExplodedTime et; - - /* If the time is the special null time, return 0. */ - if (icaltime_is_null_time(*icalt)) { - return 0; - } - - if (tz) { - // use libical for timezone conversion, as it can handle all ics - // timezones. having nspr do it is much harder. - tt = icaltime_convert_to_zone(*icalt, const_cast(tz)); - } else { - tt = *icalt; - } - - /* Empty the destination */ - memset(&et, 0, sizeof(struct PRExplodedTime)); - - /* Fill the fields */ - if (icaltime_is_date(tt)) { - et.tm_sec = et.tm_min = et.tm_hour = 0; - } else { - et.tm_sec = tt.second; - et.tm_min = tt.minute; - et.tm_hour = tt.hour; - } - et.tm_mday = static_cast(tt.day); - et.tm_month = static_cast(tt.month - 1); - et.tm_year = static_cast(tt.year); - - return PR_ImplodeTime(&et); -} - -void calDateTime::PRTimeToIcaltime(PRTime time, bool isdate, - icaltimezone const* tz, - icaltimetype* icalt) { - PRExplodedTime et; - PR_ExplodeTime(time, PR_GMTParameters, &et); - - icalt->year = et.tm_year; - icalt->month = et.tm_month + 1; - icalt->day = et.tm_mday; - - if (isdate) { - icalt->hour = 0; - icalt->minute = 0; - icalt->second = 0; - icalt->is_date = 1; - } else { - icalt->hour = et.tm_hour; - icalt->minute = et.tm_min; - icalt->second = et.tm_sec; - icalt->is_date = 0; - } - - icalt->zone = tz; - icalt->is_utc = ((tz && tz == icaltimezone_get_utc_timezone()) ? 1 : 0); - icalt->is_daylight = 0; - // xxx todo: discuss/investigate is_daylight - // if (tz) { - // icaltimezone_get_utc_offset(tz, icalt, &icalt->is_daylight); - // } -} - -NS_IMETHODIMP -calDateTime::Compare(calIDateTime* aOther, int32_t* aResult) { - NS_ENSURE_ARG_POINTER(aOther); - NS_ENSURE_ARG_POINTER(aResult); - - nsresult rv; - nsCOMPtr icalother = do_QueryInterface(aOther, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - bool otherIsDate = false; - aOther->GetIsDate(&otherIsDate); - - icaltimetype a, b; - ToIcalTime(&a); - icalother->ToIcalTime(&b); - - // If either this or aOther is floating, both objects are treated - // as floating for the comparison. - if (!a.zone || !b.zone) { - a.zone = nullptr; - a.is_utc = 0; - b.zone = nullptr; - b.is_utc = 0; - } - - if (mIsDate || otherIsDate) { - *aResult = - icaltime_compare_date_only_tz(a, b, cal::getIcalTimezone(mTimezone)); - } else { - *aResult = icaltime_compare(a, b); - } - - return NS_OK; -} diff --git a/calendar/base/backend/libical/calDateTime.h b/calendar/base/backend/libical/calDateTime.h deleted file mode 100644 index dbcc698d88..0000000000 --- a/calendar/base/backend/libical/calDateTime.h +++ /dev/null @@ -1,51 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#if !defined(INCLUDED_CALDATETIME_H) -# define INCLUDED_CALDATETIME_H - -# include "calIDateTime.h" -# include "calITimezoneProvider.h" -# include "calUtils.h" - -struct icaltimetype; -typedef struct _icaltimezone icaltimezone; - -class calDateTime : public calIDateTimeLibical, public cal::XpcomBase { - public: - calDateTime(); - calDateTime(icaltimetype const* icalt, calITimezone* tz); - - NS_DECL_ISUPPORTS - NS_DECL_CALIDATETIME - NS_DECL_CALIDATETIMELIBICAL - - protected: - virtual ~calDateTime() {} - bool mImmutable; - bool mIsValid; - bool mIsDate; - - int16_t mYear; - int16_t mMonth; - int16_t mDay; - int16_t mHour; - int16_t mMinute; - int16_t mSecond; - int16_t mWeekday; - int16_t mYearday; - - PRTime mNativeTime; - nsCOMPtr mTimezone; - - void Normalize(); - void FromIcalTime(icaltimetype const* icalt, calITimezone* tz); - void ensureTimezone(); - - static PRTime IcaltimeToPRTime(icaltimetype const* icalt, - icaltimezone const* tz); - static void PRTimeToIcaltime(PRTime time, bool isdate, icaltimezone const* tz, - icaltimetype* icalt); -}; - -#endif // INCLUDED_CALDATETIME_H diff --git a/calendar/base/backend/libical/calDuration.cpp b/calendar/base/backend/libical/calDuration.cpp deleted file mode 100644 index fee955eb75..0000000000 --- a/calendar/base/backend/libical/calDuration.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "calDuration.h" -#include "calBaseCID.h" - -#include "nsComponentManagerUtils.h" -#include "nsServiceManagerUtils.h" - -#include "nsIClassInfoImpl.h" - -#include "calUtils.h" - -#define SECONDS_PER_WEEK 604800 -#define SECONDS_PER_DAY 86400 -#define SECONDS_PER_HOUR 3600 -#define SECONDS_PER_MINUTE 60 - -NS_IMPL_CLASSINFO(calDuration, nullptr, 0, CAL_DURATION_CID) -NS_IMPL_ISUPPORTS_CI(calDuration, calIDuration, calIDurationLibical) - -calDuration::calDuration() : mImmutable(false) { Reset(); } - -calDuration::calDuration(const calDuration& cdt) { - mDuration.is_neg = cdt.mDuration.is_neg; - mDuration.weeks = cdt.mDuration.weeks; - mDuration.days = cdt.mDuration.days; - mDuration.hours = cdt.mDuration.hours; - mDuration.minutes = cdt.mDuration.minutes; - mDuration.seconds = cdt.mDuration.seconds; - - // copies are always mutable - mImmutable = false; -} - -calDuration::calDuration(const struct icaldurationtype* const aDurationPtr) - : mImmutable(false) { - FromIcalDuration(aDurationPtr); -} - -NS_IMETHODIMP -calDuration::GetIcalDuration(JS::MutableHandle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calDuration::SetIcalDuration(JS::Handle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calDuration::GetIsMutable(bool* aResult) { - NS_ENSURE_ARG_POINTER(aResult); - - *aResult = !mImmutable; - return NS_OK; -} - -NS_IMETHODIMP -calDuration::MakeImmutable() { - mImmutable = true; - return NS_OK; -} - -NS_IMETHODIMP -calDuration::Clone(calIDuration** aResult) { - calDuration* cdt = new calDuration(*this); - if (!cdt) return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(*aResult = cdt); - return NS_OK; -} - -NS_IMETHODIMP -calDuration::Reset() { - if (mImmutable) return NS_ERROR_FAILURE; - - mDuration.is_neg = 0; - mDuration.weeks = 0; - mDuration.days = 0; - mDuration.hours = 0; - mDuration.minutes = 0; - mDuration.seconds = 0; - - return NS_OK; -} - -NS_IMETHODIMP calDuration::GetIsNegative(bool* _retval) { - *_retval = mDuration.is_neg; - return NS_OK; -} -NS_IMETHODIMP calDuration::SetIsNegative(bool aValue) { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - mDuration.is_neg = aValue; - return NS_OK; -} - -NS_IMETHODIMP calDuration::GetWeeks(int16_t* _retval) { - *_retval = (int16_t)mDuration.weeks; - return NS_OK; -} -NS_IMETHODIMP calDuration::SetWeeks(int16_t aValue) { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - mDuration.weeks = aValue; - return NS_OK; -} - -NS_IMETHODIMP calDuration::GetDays(int16_t* _retval) { - *_retval = (int16_t)mDuration.days; - return NS_OK; -} -NS_IMETHODIMP calDuration::SetDays(int16_t aValue) { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - mDuration.days = aValue; - return NS_OK; -} - -NS_IMETHODIMP calDuration::GetHours(int16_t* _retval) { - *_retval = (int16_t)mDuration.hours; - return NS_OK; -} -NS_IMETHODIMP calDuration::SetHours(int16_t aValue) { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - mDuration.hours = aValue; - return NS_OK; -} - -NS_IMETHODIMP calDuration::GetMinutes(int16_t* _retval) { - *_retval = (int16_t)mDuration.minutes; - return NS_OK; -} -NS_IMETHODIMP calDuration::SetMinutes(int16_t aValue) { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - mDuration.minutes = aValue; - return NS_OK; -} - -NS_IMETHODIMP calDuration::GetSeconds(int16_t* _retval) { - *_retval = (int16_t)mDuration.seconds; - return NS_OK; -} -NS_IMETHODIMP calDuration::SetSeconds(int16_t aValue) { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - mDuration.seconds = aValue; - return NS_OK; -} - -NS_IMETHODIMP calDuration::GetInSeconds(int32_t* _retval) { - int32_t retval = - (((int32_t)((int16_t)mDuration.weeks * SECONDS_PER_WEEK)) + - ((int32_t)((int16_t)mDuration.days * SECONDS_PER_DAY)) + - ((int32_t)((int16_t)mDuration.hours * SECONDS_PER_HOUR)) + - ((int32_t)((int16_t)mDuration.minutes * SECONDS_PER_MINUTE)) + - ((int32_t)((int16_t)mDuration.seconds))); - if (mDuration.is_neg) retval = -retval; - *_retval = retval; - - return NS_OK; -} -NS_IMETHODIMP calDuration::SetInSeconds(int32_t aValue) { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - - mDuration.is_neg = (aValue < 0); - if (mDuration.is_neg) aValue = -aValue; - - // set weeks exOR days/hours/... - mDuration.weeks = - ((aValue % SECONDS_PER_WEEK) == 0 ? aValue / SECONDS_PER_WEEK : 0); - aValue -= (mDuration.weeks * SECONDS_PER_WEEK); - - mDuration.days = aValue / SECONDS_PER_DAY; - aValue -= (mDuration.days * SECONDS_PER_DAY); - - mDuration.hours = aValue / SECONDS_PER_HOUR; - aValue -= (mDuration.hours * SECONDS_PER_HOUR); - - mDuration.minutes = aValue / SECONDS_PER_MINUTE; - aValue -= (mDuration.minutes * SECONDS_PER_MINUTE); - - mDuration.seconds = aValue; - - return NS_OK; -} - -NS_IMETHODIMP calDuration::AddDuration(calIDuration* aDuration) { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - - nsresult rv; - nsCOMPtr icaldur = do_QueryInterface(aDuration, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - struct icaldurationtype idt; - icaldur->ToIcalDuration(&idt); - - // Calculate the new absolute value of the duration - // For two negative durations, the abs. value will increase, - // so use + in that case. - // Of course, also use + when both durations are positive. - if (idt.is_neg == mDuration.is_neg) { - mDuration.weeks += idt.weeks; - mDuration.days += idt.days; - mDuration.hours += idt.hours; - mDuration.minutes += idt.minutes; - mDuration.seconds += idt.seconds; - } else { - mDuration.weeks -= idt.weeks; - mDuration.days -= idt.days; - mDuration.hours -= idt.hours; - mDuration.minutes -= idt.minutes; - mDuration.seconds -= idt.seconds; - } - - Normalize(); - - return NS_OK; -} - -NS_IMETHODIMP -calDuration::Normalize() { - if (mImmutable) return NS_ERROR_CALENDAR_IMMUTABLE; - - int32_t totalInSeconds; - GetInSeconds(&totalInSeconds); - SetInSeconds(totalInSeconds); - - return NS_OK; -} - -NS_IMETHODIMP -calDuration::ToString(nsACString& aResult) { return GetIcalString(aResult); } - -NS_IMETHODIMP_(void) -calDuration::ToIcalDuration(struct icaldurationtype* icald) { - icald->is_neg = mDuration.is_neg; - icald->weeks = mDuration.weeks; - icald->days = mDuration.days; - icald->hours = mDuration.hours; - icald->minutes = mDuration.minutes; - icald->seconds = mDuration.seconds; - return; -} - -void calDuration::FromIcalDuration(const struct icaldurationtype* const icald) { - mDuration.is_neg = icald->is_neg; - mDuration.weeks = icald->weeks; - mDuration.days = icald->days; - mDuration.hours = icald->hours; - mDuration.minutes = icald->minutes; - mDuration.seconds = icald->seconds; - return; -} - -NS_IMETHODIMP -calDuration::GetIcalString(nsACString& aResult) { - // note that ics is owned by libical, so we don't need to free - const char* ics = icaldurationtype_as_ical_string(mDuration); - - if (ics) { - aResult.Assign(ics); - return NS_OK; - } - - return NS_ERROR_OUT_OF_MEMORY; -} - -NS_IMETHODIMP -calDuration::SetIcalString(const nsACString& aIcalString) { - mDuration = - icaldurationtype_from_string(PromiseFlatCString(aIcalString).get()); - return NS_OK; -} - -NS_IMETHODIMP -calDuration::Compare(calIDuration* aOther, int32_t* aResult) { - int32_t thisInSeconds, otherInSeconds; - - // cast to void because these calls can't fail - (void)GetInSeconds(&thisInSeconds); - (void)aOther->GetInSeconds(&otherInSeconds); - - if (thisInSeconds < otherInSeconds) { - *aResult = -1; - } else if (thisInSeconds > otherInSeconds) { - *aResult = 1; - } else { - *aResult = 0; - } - - return NS_OK; -} diff --git a/calendar/base/backend/libical/calDuration.h b/calendar/base/backend/libical/calDuration.h deleted file mode 100644 index 4ca21b73b7..0000000000 --- a/calendar/base/backend/libical/calDuration.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CALDURATION_H_ -#define CALDURATION_H_ - -#include "calIDuration.h" - -extern "C" { -#include "ical.h" -} - -class calDuration final : public calIDurationLibical { - public: - calDuration(); - calDuration(const calDuration& cdt); - explicit calDuration(const struct icaldurationtype* const aDurationPtr); - - // nsISupports interface - NS_DECL_ISUPPORTS - - // calIDateTime interface - NS_DECL_CALIDURATION - NS_DECL_CALIDURATIONLIBICAL - - protected: - ~calDuration() {} - bool mImmutable; - - struct icaldurationtype mDuration; - - void FromIcalDuration(const struct icaldurationtype* const icald); -}; - -#endif /* CALDURATION_H_ */ diff --git a/calendar/base/backend/libical/calICSService.cpp b/calendar/base/backend/libical/calICSService.cpp deleted file mode 100644 index f18d9f8eee..0000000000 --- a/calendar/base/backend/libical/calICSService.cpp +++ /dev/null @@ -1,1281 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsStringStream.h" -#include "nsComponentManagerUtils.h" - -#include "calICSService.h" -#include "calTimezone.h" -#include "calDateTime.h" -#include "calDuration.h" -#include "calIErrors.h" -#include "calUtils.h" - -extern "C" { -#include "ical.h" -} - -calIcalProperty::~calIcalProperty() { - if (!mParent) { - icalproperty_free(mProperty); - } -} - -NS_IMPL_CLASSINFO(calIcalProperty, nullptr, 0, CAL_ICALPROPERTY_CID) -NS_IMPL_ISUPPORTS_CI(calIcalProperty, calIIcalProperty, calIIcalPropertyLibical) - -NS_IMETHODIMP_(icalproperty*) -calIcalProperty::GetLibicalProperty() { return mProperty; } - -NS_IMETHODIMP_(icalcomponent*) -calIcalProperty::GetLibicalComponent() { - return mParent->GetLibicalComponent(); -} - -NS_IMETHODIMP -calIcalProperty::GetIcalString(nsACString& str) { - char const* icalstr = icalproperty_as_ical_string(mProperty); - if (icalstr == 0) { -#ifdef DEBUG - fprintf(stderr, "Error getting ical string: %d (%s)\n", icalerrno, - icalerror_strerror(icalerrno)); -#endif - return static_cast(calIErrors::ICS_ERROR_BASE + icalerrno); - } - str.Assign(icalstr); - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::ToString(nsACString& aResult) { - return GetIcalString(aResult); -} - -NS_IMETHODIMP -calIcalProperty::GetValue(nsACString& str) { - icalvalue* value = icalproperty_get_value(mProperty); - icalvalue_kind valuekind = icalvalue_isa(value); - - const char* icalstr; - if (valuekind == ICAL_TEXT_VALUE) { - icalstr = icalvalue_get_text(value); - } else if (valuekind == ICAL_X_VALUE) { - icalstr = icalvalue_get_x(value); - } else if (valuekind == ICAL_ATTACH_VALUE) { - icalattach* attach = icalvalue_get_attach(value); - if (icalattach_get_is_url(attach)) { - icalstr = icalattach_get_url(attach); - } else { - icalstr = (const char*)icalattach_get_data(attach); - } - } else { - icalstr = icalproperty_get_value_as_string(mProperty); - } - - if (!icalstr) { - if (icalerrno == ICAL_BADARG_ERROR) { - str.Truncate(); - // Set string to null, because we don't have a value - // (which is something different then an empty value) - str.SetIsVoid(true); - return NS_OK; - } - - if (icalerrno == ICAL_NO_ERROR) { - str.Truncate(); - return NS_OK; - } - -#ifdef DEBUG - fprintf(stderr, "Error getting string value: %d (%s)\n", icalerrno, - icalerror_strerror(icalerrno)); -#endif - return NS_ERROR_FAILURE; - } - - str.Assign(icalstr); - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::SetValue(const nsACString& str) { - icalvalue_kind kind = - icalproperty_kind_to_value_kind(icalproperty_isa(mProperty)); - if (kind == ICAL_TEXT_VALUE) { - icalvalue* v = icalvalue_new_text(PromiseFlatCString(str).get()); - icalproperty_set_value(mProperty, v); - } else if (kind == ICAL_X_VALUE) { - icalvalue* v = icalvalue_new_x(PromiseFlatCString(str).get()); - icalproperty_set_value(mProperty, v); - } else if (kind == ICAL_ATTACH_VALUE) { - icalattach* v = icalattach_new_from_data(PromiseFlatCString(str).get(), - nullptr, nullptr); - icalproperty_set_attach(mProperty, v); - } else { - icalproperty_set_value_from_string(mProperty, PromiseFlatCString(str).get(), - icalvalue_kind_to_string(kind)); - } - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::GetValueAsIcalString(nsACString& str) { - const char* icalstr = icalproperty_get_value_as_string(mProperty); - if (!icalstr) { - if (icalerrno == ICAL_BADARG_ERROR) { - str.Truncate(); - // Set string to null, because we don't have a value - // (which is something different then an empty value) - str.SetIsVoid(true); - return NS_OK; - } - -#ifdef DEBUG - fprintf(stderr, "Error getting string value: %d (%s)\n", icalerrno, - icalerror_strerror(icalerrno)); -#endif - return NS_ERROR_FAILURE; - } - - str.Assign(icalstr); - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::SetValueAsIcalString(const nsACString& str) { - const char* kindstr = icalvalue_kind_to_string( - icalproperty_kind_to_value_kind(icalproperty_isa(mProperty))); - icalproperty_set_value_from_string(mProperty, PromiseFlatCString(str).get(), - kindstr); - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::GetPropertyName(nsACString& name) { - const char* icalstr = icalproperty_get_property_name(mProperty); - if (!icalstr) { -#ifdef DEBUG - fprintf(stderr, "Error getting property name: %d (%s)\n", icalerrno, - icalerror_strerror(icalerrno)); -#endif - return NS_ERROR_FAILURE; - } - name.Assign(icalstr); - return NS_OK; -} - -static icalparameter* FindParameter(icalproperty* prop, const nsACString& param, - icalparameter_kind kind) { - for (icalparameter* icalparam = icalproperty_get_first_parameter(prop, kind); - icalparam; icalparam = icalproperty_get_next_parameter(prop, kind)) { - if (param.Equals(icalparameter_get_xname(icalparam))) return icalparam; - } - return nullptr; -} - -NS_IMETHODIMP -calIcalProperty::GetParameter(const nsACString& param, nsACString& value) { - // More ridiculous parameter/X-PARAMETER handling. - icalparameter_kind paramkind = - icalparameter_string_to_kind(PromiseFlatCString(param).get()); - - if (paramkind == ICAL_NO_PARAMETER) return NS_ERROR_INVALID_ARG; - - const char* icalstr = nullptr; - if (paramkind == ICAL_X_PARAMETER) { - icalparameter* icalparam = - FindParameter(mProperty, param, ICAL_X_PARAMETER); - if (icalparam) icalstr = icalparameter_get_xvalue(icalparam); - } else if (paramkind == ICAL_IANA_PARAMETER) { - icalparameter* icalparam = - FindParameter(mProperty, param, ICAL_IANA_PARAMETER); - if (icalparam) icalstr = icalparameter_get_iana_value(icalparam); - } else { - icalstr = icalproperty_get_parameter_as_string( - mProperty, PromiseFlatCString(param).get()); - } - - if (!icalstr) { - value.Truncate(); - value.SetIsVoid(true); - } else { - value.Assign(icalstr); - } - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::SetParameter(const nsACString& param, - const nsACString& value) { - icalparameter_kind paramkind = - icalparameter_string_to_kind(PromiseFlatCString(param).get()); - - if (paramkind == ICAL_NO_PARAMETER) return NS_ERROR_INVALID_ARG; - - // Because libical's support for manipulating parameters is weak, and - // X-PARAMETERS doubly so, we walk the list looking for an existing one of - // that name, and reset its value if found. - if (paramkind == ICAL_X_PARAMETER) { - icalparameter* icalparam = - FindParameter(mProperty, param, ICAL_X_PARAMETER); - if (icalparam) { - icalparameter_set_xvalue(icalparam, PromiseFlatCString(value).get()); - return NS_OK; - } - // If not found, fall through to adding a new parameter below. - } else if (paramkind == ICAL_IANA_PARAMETER) { - icalparameter* icalparam = - FindParameter(mProperty, param, ICAL_IANA_PARAMETER); - if (icalparam) { - icalparameter_set_iana_value(icalparam, PromiseFlatCString(value).get()); - return NS_OK; - } - // If not found, fall through to adding a new parameter below. - } else { - // We could try getting an existing parameter here and resetting its - // value, but this is easier and I don't care that much about parameter - // performance at this point. - RemoveParameter(param); - } - - icalparameter* icalparam = icalparameter_new_from_value_string( - paramkind, PromiseFlatCString(value).get()); - if (!icalparam) return NS_ERROR_OUT_OF_MEMORY; - - // You might ask me "why does libical not do this for us?" and I would - // just nod knowingly but sadly at you in return. - // - // You might also, if you were not too distracted by the first question, - // ask why we have icalproperty_set_x_name but icalparameter_set_xname. - // More nodding would ensue. - if (paramkind == ICAL_X_PARAMETER) - icalparameter_set_xname(icalparam, PromiseFlatCString(param).get()); - else if (paramkind == ICAL_IANA_PARAMETER) - icalparameter_set_iana_name(icalparam, PromiseFlatCString(param).get()); - - icalproperty_add_parameter(mProperty, icalparam); - // XXX check ical errno - return NS_OK; -} - -static nsresult FillParameterName(icalparameter* icalparam, nsACString& name) { - const char* propname = nullptr; - if (icalparam) { - icalparameter_kind paramkind = icalparameter_isa(icalparam); - if (paramkind == ICAL_X_PARAMETER) - propname = icalparameter_get_xname(icalparam); - else if (paramkind == ICAL_IANA_PARAMETER) - propname = icalparameter_get_iana_name(icalparam); - else if (paramkind != ICAL_NO_PARAMETER) - propname = icalparameter_kind_to_string(paramkind); - } - - if (propname) { - name.Assign(propname); - } else { - name.Truncate(); - name.SetIsVoid(true); - } - - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::GetFirstParameterName(nsACString& name) { - icalparameter* icalparam = - icalproperty_get_first_parameter(mProperty, ICAL_ANY_PARAMETER); - return FillParameterName(icalparam, name); -} - -NS_IMETHODIMP -calIcalProperty::GetNextParameterName(nsACString& name) { - icalparameter* icalparam = - icalproperty_get_next_parameter(mProperty, ICAL_ANY_PARAMETER); - return FillParameterName(icalparam, name); -} - -NS_IMETHODIMP -calIcalProperty::RemoveParameter(const nsACString& param) { - icalproperty_remove_parameter_by_name(mProperty, - PromiseFlatCString(param).get()); - // XXX check ical errno - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::ClearXParameters() { - int oldcount, paramcount = 0; - do { - oldcount = paramcount; - icalproperty_remove_parameter(mProperty, ICAL_X_PARAMETER); - paramcount = icalproperty_count_parameters(mProperty); - } while (oldcount != paramcount); - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::GetValueAsDatetime(calIDateTime** dtp) { - NS_ENSURE_ARG_POINTER(dtp); - return getDatetime_(toIcalComponent(mParent), mProperty, dtp); -} - -nsresult calIcalProperty::getDatetime_(calIcalComponent* parent, - icalproperty* prop, calIDateTime** dtp) { - icalvalue* const val = icalproperty_get_value(prop); - icalvalue_kind const valkind = icalvalue_isa(val); - if (valkind != ICAL_DATETIME_VALUE && valkind != ICAL_DATE_VALUE) { - return NS_ERROR_UNEXPECTED; - } - icaltimetype itt = icalvalue_get_datetime(val); - - char const* tzid_ = nullptr; - if (!itt.is_utc) { - if (itt.zone) { - tzid_ = icaltimezone_get_tzid(const_cast(itt.zone)); - } else { - // Need to get the tzid param. Unfortunately, libical tends to return raw - // ics strings, with quotes and everything. That's not what we want. Need - // to work around. - icalparameter* const tzparam = - icalproperty_get_first_parameter(prop, ICAL_TZID_PARAMETER); - if (tzparam) { - tzid_ = icalparameter_get_xvalue(tzparam); - } - } - } - - nsCOMPtr tz; - if (tzid_) { - nsDependentCString const tzid(tzid_); - calIcalComponent* comp = nullptr; - if (parent) { - comp = parent->getParentVCalendarOrThis(); - } - // look up parent if timezone is already referenced: - if (comp) { - comp->mReferencedTimezones.Get(tzid, getter_AddRefs(tz)); - } - if (!tz) { - if (parent) { - // passed tz provider has precedence over timezone service: - calITimezoneProvider* const tzProvider = parent->getTzProvider(); - if (tzProvider) { - tzProvider->GetTimezone(tzid, getter_AddRefs(tz)); - NS_ASSERTION(tz, tzid_); - } - } - if (!tz) { - // look up tz in tz service. - // this hides errors from incorrect ics files, which could state - // a TZID that is not present in the ics file. - // The other way round, it makes this product more error tolerant. - nsresult rv = - cal::getTimezoneService()->GetTimezone(tzid, getter_AddRefs(tz)); - - if (NS_FAILED(rv) || !tz) { - icaltimezone const* zone = itt.zone; - if (!zone && comp) { - // look up parent VCALENDAR for VTIMEZONE: - zone = icalcomponent_get_timezone(comp->mComponent, tzid_); - NS_ASSERTION(zone, tzid_); - } - if (zone) { - // We need to decouple this (inner) VTIMEZONE from the parent - // VCALENDAR to avoid running into circular references (referenced - // timezones): - icaltimezone* const clonedZone = icaltimezone_new(); - CAL_ENSURE_MEMORY(clonedZone); - icalcomponent* const clonedZoneComp = icalcomponent_new_clone( - icaltimezone_get_component(const_cast(zone))); - if (!clonedZoneComp) { - icaltimezone_free(clonedZone, 1 /* free struct */); - CAL_ENSURE_MEMORY(clonedZoneComp); - } - if (!icaltimezone_set_component(clonedZone, clonedZoneComp)) { - icaltimezone_free(clonedZone, 1 /* free struct */); - return NS_ERROR_INVALID_ARG; - } - nsCOMPtr const tzComp( - new calIcalComponent(clonedZone, clonedZoneComp)); - CAL_ENSURE_MEMORY(tzComp); - tz = new calTimezone(tzid, tzComp); - CAL_ENSURE_MEMORY(tz); - } else { // install phantom timezone, so the data could be repaired: - tz = new calTimezone(tzid, nullptr); - CAL_ENSURE_MEMORY(tz); - } - } - } - if (comp && tz) { - // assure timezone is known: - comp->AddTimezoneReference(tz); - } - } - if (tz) { - // correct itt which would else appear floating: - itt.zone = cal::getIcalTimezone(tz); - itt.is_utc = 0; - } else { - cal::logMissingTimezone(tzid_); - } - } - *dtp = new calDateTime(&itt, tz); - CAL_ENSURE_MEMORY(*dtp); - NS_ADDREF(*dtp); - return NS_OK; -} - -calIcalComponent::~calIcalComponent() { - if (!mParent) { - // We free either a plain icalcomponent or a icaltimezone. - // In the latter case icaltimezone_free frees the VTIMEZONE component. - if (mTimezone) { - icaltimezone_free(mTimezone, 1 /* free struct */); - } else { - icalcomponent_free(mComponent); - } - } -} -NS_IMETHODIMP -calIcalComponent::GetIcalComponent(JS::MutableHandle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calIcalComponent::SetIcalComponent(JS::Handle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calIcalComponent::GetParent(calIIcalComponent** parent) { - NS_ENSURE_ARG_POINTER(parent); - NS_IF_ADDREF(*parent = mParent); - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::GetIcalTimezone(JS::MutableHandle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calIcalComponent::SetIcalTimezone(JS::Handle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calIcalComponent::AddTimezoneReference(calITimezone* aTimezone) { - NS_ENSURE_ARG_POINTER(aTimezone); - nsAutoCString tzid; - nsresult rv = aTimezone->GetTzid(tzid); - NS_ENSURE_SUCCESS(rv, rv); - mReferencedTimezones.InsertOrUpdate(tzid, aTimezone); - - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::GetReferencedTimezones( - nsTArray>& aTimezones) { - aTimezones.ClearAndRetainStorage(); - uint32_t const count = mReferencedTimezones.Count(); - if (count == 0) { - return NS_OK; - } - aTimezones.SetCapacity(count); - for (auto iter = mReferencedTimezones.ConstIter(); !iter.Done(); - iter.Next()) { - aTimezones.AppendElement(iter.Data()); - } - return NS_OK; -} - -nsresult calIcalComponent::SetPropertyValue(icalproperty_kind kind, - icalvalue* val) { - ClearAllProperties(kind); - if (!val) return NS_OK; - - icalproperty* prop = icalproperty_new(kind); - if (!prop) { - icalvalue_free(val); - return NS_ERROR_OUT_OF_MEMORY; - } - - icalproperty_set_value(prop, val); - icalcomponent_add_property(mComponent, prop); - return NS_OK; -} - -nsresult calIcalComponent::SetProperty(icalproperty_kind kind, - icalproperty* prop) { - ClearAllProperties(kind); - if (!prop) return NS_OK; - icalcomponent_add_property(mComponent, prop); - return NS_OK; -} - -#define COMP_STRING_TO_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname) \ - NS_IMETHODIMP \ - calIcalComponent::Get##Attrname(nsACString& str) { \ - int32_t val; \ - nsresult rv = GetIntProperty(ICAL_##ICALNAME##_PROPERTY, &val); \ - if (NS_FAILED(rv)) return rv; \ - if (val == -1) { \ - str.Truncate(); \ - str.SetIsVoid(true); \ - } else { \ - str.Assign( \ - icalproperty_##lcname##_to_string((icalproperty_##lcname)val)); \ - } \ - return NS_OK; \ - } \ - \ - NS_IMETHODIMP \ - calIcalComponent::Set##Attrname(const nsACString& str) { \ - icalproperty* prop = nullptr; \ - if (!str.IsVoid()) { \ - icalproperty_##lcname val = \ - icalproperty_string_to_##lcname(PromiseFlatCString(str).get()); \ - prop = icalproperty_new_##lcname(val); \ - if (!prop) return NS_ERROR_OUT_OF_MEMORY; /* XXX map errno */ \ - } \ - return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop); \ - } - -#define COMP_GENERAL_STRING_ATTRIBUTE(Attrname, ICALNAME) \ - NS_IMETHODIMP \ - calIcalComponent::Get##Attrname(nsACString& str) { \ - return GetStringProperty(ICAL_##ICALNAME##_PROPERTY, str); \ - } \ - \ - NS_IMETHODIMP \ - calIcalComponent::Set##Attrname(const nsACString& str) { \ - return SetStringProperty(ICAL_##ICALNAME##_PROPERTY, str); \ - } - -#define COMP_STRING_ATTRIBUTE(Attrname, ICALNAME, lcname) \ - NS_IMETHODIMP \ - calIcalComponent::Get##Attrname(nsACString& str) { \ - return GetStringProperty(ICAL_##ICALNAME##_PROPERTY, str); \ - } \ - \ - NS_IMETHODIMP \ - calIcalComponent::Set##Attrname(const nsACString& str) { \ - icalproperty* prop = \ - icalproperty_new_##lcname(PromiseFlatCString(str).get()); \ - return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop); \ - } - -#define COMP_GENERAL_INT_ATTRIBUTE(Attrname, ICALNAME) \ - NS_IMETHODIMP \ - calIcalComponent::Get##Attrname(int32_t* valp) { \ - return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \ - } \ - \ - NS_IMETHODIMP \ - calIcalComponent::Set##Attrname(int32_t val) { \ - return SetIntProperty(ICAL_##ICALNAME##_PROPERTY, val); \ - } - -#define COMP_ENUM_ATTRIBUTE(Attrname, ICALNAME, lcname) \ - NS_IMETHODIMP \ - calIcalComponent::Get##Attrname(int32_t* valp) { \ - return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \ - } \ - \ - NS_IMETHODIMP \ - calIcalComponent::Set##Attrname(int32_t val) { \ - icalproperty* prop = \ - icalproperty_new_##lcname((icalproperty_##lcname)val); \ - return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop); \ - } - -#define COMP_INT_ATTRIBUTE(Attrname, ICALNAME, lcname) \ - NS_IMETHODIMP \ - calIcalComponent::Get##Attrname(int32_t* valp) { \ - return GetIntProperty(ICAL_##ICALNAME##_PROPERTY, valp); \ - } \ - \ - NS_IMETHODIMP \ - calIcalComponent::Set##Attrname(int32_t val) { \ - icalproperty* prop = icalproperty_new_##lcname(val); \ - return SetProperty(ICAL_##ICALNAME##_PROPERTY, prop); \ - } - -nsresult calIcalComponent::GetStringProperty(icalproperty_kind kind, - nsACString& str) { - icalproperty* prop = icalcomponent_get_first_property(mComponent, kind); - if (!prop) { - str.Truncate(); - str.SetIsVoid(true); - } else { - str.Assign(icalvalue_get_string(icalproperty_get_value(prop))); - } - return NS_OK; -} - -nsresult calIcalComponent::SetStringProperty(icalproperty_kind kind, - const nsACString& str) { - icalvalue* val = nullptr; - if (!str.IsVoid()) { - val = icalvalue_new_string(PromiseFlatCString(str).get()); - if (!val) return NS_ERROR_OUT_OF_MEMORY; - } - return SetPropertyValue(kind, val); -} - -nsresult calIcalComponent::GetIntProperty(icalproperty_kind kind, - int32_t* valp) { - icalproperty* prop = icalcomponent_get_first_property(mComponent, kind); - if (!prop) - *valp = calIIcalComponent::INVALID_VALUE; - else - *valp = (int32_t)icalvalue_get_integer(icalproperty_get_value(prop)); - return NS_OK; -} - -nsresult calIcalComponent::SetIntProperty(icalproperty_kind kind, int32_t i) { - icalvalue* val = icalvalue_new_integer(i); - if (!val) return NS_ERROR_OUT_OF_MEMORY; - return SetPropertyValue(kind, val); -} - -nsresult calIcalComponent::GetDateTimeAttribute(icalproperty_kind kind, - calIDateTime** dtp) { - NS_ENSURE_ARG_POINTER(dtp); - icalproperty* prop = icalcomponent_get_first_property(mComponent, kind); - if (!prop) { - *dtp = nullptr; /* invalid date */ - return NS_OK; - } - return calIcalProperty::getDatetime_(this, prop, dtp); -} - -nsresult calIcalComponent::SetDateTimeAttribute(icalproperty_kind kind, - calIDateTime* dt) { - ClearAllProperties(kind); - bool isValid; - if (!dt || NS_FAILED(dt->GetIsValid(&isValid)) || !isValid) { - return NS_OK; - } - icalproperty* prop = icalproperty_new(kind); - CAL_ENSURE_MEMORY(prop); - nsresult rc = calIcalProperty::setDatetime_(this, prop, dt); - if (NS_SUCCEEDED(rc)) - icalcomponent_add_property(mComponent, prop); - else - icalproperty_free(prop); - return rc; -} - -NS_IMETHODIMP -calIcalProperty::GetParent(calIIcalComponent** parent) { - NS_IF_ADDREF(*parent = mParent); - return NS_OK; -} - -NS_IMETHODIMP -calIcalProperty::GetIcalProperty(JS::MutableHandle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calIcalProperty::SetIcalProperty(JS::Handle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calIcalProperty::SetValueAsDatetime(calIDateTime* dt) { - NS_ENSURE_ARG_POINTER(dt); - return setDatetime_(toIcalComponent(mParent), mProperty, dt); -} - -nsresult calIcalProperty::setDatetime_(calIcalComponent* parent, - icalproperty* prop, calIDateTime* dt) { - NS_ENSURE_ARG_POINTER(prop); - NS_ENSURE_ARG_POINTER(dt); - - nsresult rv; - nsCOMPtr icaldt = do_QueryInterface(dt, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - icaltimetype itt; - icaldt->ToIcalTime(&itt); - - if (parent) { - if (!itt.is_utc) { - nsCOMPtr tz; - rv = dt->GetTimezone(getter_AddRefs(tz)); - NS_ENSURE_SUCCESS(rv, rv); - if (itt.zone) { - rv = parent->getParentVCalendarOrThis()->AddTimezoneReference(tz); - NS_ENSURE_SUCCESS(rv, rv); - icalparameter* const param = icalparameter_new_from_value_string( - ICAL_TZID_PARAMETER, - icaltimezone_get_tzid(const_cast(itt.zone))); - icalproperty_set_parameter(prop, param); - } else { // either floating or phantom: - bool b = false; - if (NS_FAILED(tz->GetIsFloating(&b)) || !b) { - // restore the same phantom TZID: - nsAutoCString tzid; - rv = tz->GetTzid(tzid); - NS_ENSURE_SUCCESS(rv, rv); - icalparameter* const param = icalparameter_new_from_value_string( - ICAL_TZID_PARAMETER, tzid.get()); - icalproperty_set_parameter(prop, param); - } - } - } - } else if (!itt.is_date && !itt.is_utc && itt.zone) { - // no parent to add the CTIMEZONE to: coerce DATETIMEs to UTC, DATEs to - // floating - icaltimezone_convert_time(&itt, const_cast(itt.zone), - icaltimezone_get_utc_timezone()); - itt.zone = icaltimezone_get_utc_timezone(); - itt.is_utc = 1; - } - - icalvalue* const val = icalvalue_new_datetime(itt); - CAL_ENSURE_MEMORY(val); - icalproperty_set_value(prop, val); - return NS_OK; -} - -#define RO_COMP_DATE_ATTRIBUTE(Attrname, ICALNAME) \ - NS_IMETHODIMP \ - calIcalComponent::Get##Attrname(calIDateTime** dtp) { \ - return GetDateTimeAttribute(ICAL_##ICALNAME##_PROPERTY, dtp); \ - } - -#define COMP_DATE_ATTRIBUTE(Attrname, ICALNAME) \ - RO_COMP_DATE_ATTRIBUTE(Attrname, ICALNAME) \ - \ - NS_IMETHODIMP \ - calIcalComponent::Set##Attrname(calIDateTime* dt) { \ - return SetDateTimeAttribute(ICAL_##ICALNAME##_PROPERTY, dt); \ - } - -#define RO_COMP_DURATION_ATTRIBUTE(Attrname, ICALNAME) \ - NS_IMETHODIMP \ - calIcalComponent::Get##Attrname(calIDuration** dtp) { \ - icalproperty* prop = icalcomponent_get_first_property( \ - mComponent, ICAL_##ICALNAME##_PROPERTY); \ - if (!prop) { \ - *dtp = nullptr; /* invalid duration */ \ - return NS_OK; \ - } \ - struct icaldurationtype idt = \ - icalvalue_get_duration(icalproperty_get_value(prop)); \ - *dtp = new calDuration(&idt); \ - CAL_ENSURE_MEMORY(*dtp); \ - NS_ADDREF(*dtp); \ - return NS_OK; \ - } - -NS_IMPL_CLASSINFO(calIcalComponent, nullptr, nsIClassInfo::THREADSAFE, - CAL_ICALCOMPONENT_CID) -NS_IMPL_ISUPPORTS_CI(calIcalComponent, calIIcalComponent, - calIIcalComponentLibical) - -NS_IMETHODIMP_(icalcomponent*) -calIcalComponent::GetLibicalComponent() { return mComponent; } - -NS_IMETHODIMP_(icaltimezone*) -calIcalComponent::GetLibicalTimezone() { - NS_ASSERTION(icalcomponent_isa(mComponent) == ICAL_VTIMEZONE_COMPONENT, - "no VTIMEZONE -- unexpected!"); - if (!mTimezone && - (icalcomponent_isa(mComponent) == ICAL_VTIMEZONE_COMPONENT)) { - // xxx todo: libical needs a parent VCALENDAR to retrieve a icaltimezone - NS_ASSERTION(mParent, "VTIMEZONE has no parent!"); - if (mParent) { - icalproperty* const tzidProp = - icalcomponent_get_first_property(mComponent, ICAL_TZID_PROPERTY); - NS_ASSERTION(tzidProp, "no TZID property in VTIMEZONE!?"); - if (tzidProp) { - mTimezone = icalcomponent_get_timezone( - mParent->GetLibicalComponent(), - icalvalue_get_string(icalproperty_get_value(tzidProp))); - } - } - } - return mTimezone; -} - -NS_IMETHODIMP -calIcalComponent::GetFirstSubcomponent(const nsACString& kind, - calIIcalComponent** subcomp) { - NS_ENSURE_ARG_POINTER(subcomp); - - icalcomponent_kind compkind = - icalcomponent_string_to_kind(PromiseFlatCString(kind).get()); - - // Maybe someday I'll support X-COMPONENTs - if (compkind == ICAL_NO_COMPONENT || compkind == ICAL_X_COMPONENT) - return NS_ERROR_INVALID_ARG; - - icalcomponent* ical = icalcomponent_get_first_component(mComponent, compkind); - if (!ical) { - *subcomp = nullptr; - return NS_OK; - } - - *subcomp = new calIcalComponent(ical, this); - CAL_ENSURE_MEMORY(*subcomp); - NS_ADDREF(*subcomp); - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::GetNextSubcomponent(const nsACString& kind, - calIIcalComponent** subcomp) { - NS_ENSURE_ARG_POINTER(subcomp); - - icalcomponent_kind compkind = - icalcomponent_string_to_kind(PromiseFlatCString(kind).get()); - - // Maybe someday I'll support X-COMPONENTs - if (compkind == ICAL_NO_COMPONENT || compkind == ICAL_X_COMPONENT) - return NS_ERROR_INVALID_ARG; - - icalcomponent* ical = icalcomponent_get_next_component(mComponent, compkind); - if (!ical) { - *subcomp = nullptr; - return NS_OK; - } - - *subcomp = new calIcalComponent(ical, this); - CAL_ENSURE_MEMORY(*subcomp); - NS_ADDREF(*subcomp); - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::GetComponentType(nsACString& componentType) { - componentType.Assign( - icalcomponent_kind_to_string(icalcomponent_isa(mComponent))); - return NS_OK; -} - -COMP_STRING_ATTRIBUTE(Uid, UID, uid) -COMP_STRING_ATTRIBUTE(Prodid, PRODID, prodid) -COMP_STRING_ATTRIBUTE(Version, VERSION, version) -COMP_STRING_TO_ENUM_ATTRIBUTE(Method, METHOD, method) -COMP_STRING_TO_ENUM_ATTRIBUTE(Status, STATUS, status) -COMP_STRING_ATTRIBUTE(Summary, SUMMARY, summary) -COMP_STRING_ATTRIBUTE(Description, DESCRIPTION, description) -COMP_STRING_ATTRIBUTE(Location, LOCATION, location) -COMP_STRING_ATTRIBUTE(Categories, CATEGORIES, categories) -COMP_STRING_ATTRIBUTE(URL, URL, url) -COMP_INT_ATTRIBUTE(Priority, PRIORITY, priority) -RO_COMP_DURATION_ATTRIBUTE(Duration, DURATION) -COMP_DATE_ATTRIBUTE(StartTime, DTSTART) -COMP_DATE_ATTRIBUTE(EndTime, DTEND) -COMP_DATE_ATTRIBUTE(DueTime, DUE) -COMP_DATE_ATTRIBUTE(StampTime, DTSTAMP) -COMP_DATE_ATTRIBUTE(LastModified, LASTMODIFIED) -COMP_DATE_ATTRIBUTE(CreatedTime, CREATED) -COMP_DATE_ATTRIBUTE(CompletedTime, COMPLETED) -COMP_DATE_ATTRIBUTE(RecurrenceId, RECURRENCEID) - -void calIcalComponent::ClearAllProperties(icalproperty_kind kind) { - for (icalproperty *prop = icalcomponent_get_first_property(mComponent, kind), - *next; - prop; prop = next) { - next = icalcomponent_get_next_property(mComponent, kind); - icalcomponent_remove_property(mComponent, prop); - icalproperty_free(prop); - } -} - -NS_IMETHODIMP -calIcalComponent::SerializeToICS(nsACString& serialized) { - char* icalstr; - - nsresult rv = Serialize(&icalstr); - if (NS_FAILED(rv)) { - return rv; - } - - serialized.Assign(icalstr); - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::ToString(nsACString& aResult) { - return SerializeToICS(aResult); -} - -NS_IMETHODIMP -calIcalComponent::SerializeToICSStream(nsIInputStream** aStreamResult) { - NS_ENSURE_ARG_POINTER(aStreamResult); - - char* icalstr; - nsresult rv = Serialize(&icalstr); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr aStringStream( - do_CreateInstance(NS_STRINGINPUTSTREAM_CONTRACTID, &rv)); - NS_ENSURE_SUCCESS(rv, rv); - // copies the string into the input stream that's handed back. - // This copy is necessary because we don't really own icalstr; - // it's one of libical's ring buffers - rv = aStringStream->SetData(icalstr, -1); - NS_ENSURE_SUCCESS(rv, rv); - - aStringStream.forget(aStreamResult); - return NS_OK; -} - -nsresult calIcalComponent::Serialize(char** icalstr) { - NS_ENSURE_ARG_POINTER(icalstr); - - // add the timezone bits - if (icalcomponent_isa(mComponent) == ICAL_VCALENDAR_COMPONENT && - mReferencedTimezones.Count() > 0) { - for (auto iter = mReferencedTimezones.ConstIter(); !iter.Done(); - iter.Next()) { - icaltimezone* icaltz = cal::getIcalTimezone(iter.Data()); - if (icaltz) { - icalcomponent* const tzcomp = - icalcomponent_new_clone(icaltimezone_get_component(icaltz)); - icalcomponent_add_component(mComponent, tzcomp); - } - } - } - - *icalstr = icalcomponent_as_ical_string(mComponent); - if (!*icalstr) { - // xxx todo: what about NS_ERROR_OUT_OF_MEMORY? -#ifdef DEBUG - fprintf(stderr, "Error serializing: %d (%s)\n", icalerrno, - icalerror_strerror(icalerrno)); -#endif - // The return values in calIError match with libical errnos, - // so no need for a conversion table or anything. - return static_cast(calIErrors::ICS_ERROR_BASE + icalerrno); - } - - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::Clone(calIIcalComponent** _retval) { - NS_ENSURE_ARG_POINTER(_retval); - icalcomponent* cloned = icalcomponent_new_clone(mComponent); - if (cloned == nullptr) return NS_ERROR_OUT_OF_MEMORY; - calIcalComponent* const comp = - new calIcalComponent(cloned, nullptr, getTzProvider()); - if (comp == nullptr) { - icalcomponent_free(cloned); - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(*_retval = comp); - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::AddSubcomponent(calIIcalComponent* aComp) { - NS_ENSURE_ARG_POINTER(aComp); - - /* XXX mildly unsafe assumption here. - * To fix it, I will: - * - check the object's classinfo to find out if I have one of my - * own objects, and if not - * - use comp->serializeToICS and reparse to create a copy. - * - * I should probably also return the new/reused component so that the - * caller has something it can poke at all live-like. - */ - - nsresult rv; - nsCOMPtr icalcomp = do_QueryInterface(aComp, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - calIcalComponent* const ical = toIcalComponent(icalcomp); - - nsTArray> timezones; - rv = ical->GetReferencedTimezones(timezones); - calIcalComponent* const vcal = getParentVCalendarOrThis(); - for (auto& tz : timezones) { - rv = vcal->AddTimezoneReference(tz); - NS_ENSURE_SUCCESS(rv, rv); - } - - if (ical->mParent) { - ical->mComponent = icalcomponent_new_clone(ical->mComponent); - } - ical->mParent = this; - icalcomponent_add_component(mComponent, ical->mComponent); - return NS_OK; -} - -// NS_IMETHODIMP -// IcalComponent::RemoveSubcomponent(calIIcalComponent *comp) -// { -// NS_ENSURE_ARG_POINTER(comp); -// calIcalComponent *ical = static_cast(comp); -// icalcomponent_remove_component(mComponent, ical->mComponent); -// ical->mParent = nullptr; -// return NS_OK; -// } - -NS_IMETHODIMP -calIcalComponent::GetFirstProperty(const nsACString& kind, - calIIcalProperty** prop) { - NS_ENSURE_ARG_POINTER(prop); - - icalproperty_kind propkind = - icalproperty_string_to_kind(PromiseFlatCString(kind).get()); - - if (propkind == ICAL_NO_PROPERTY) return NS_ERROR_INVALID_ARG; - - icalproperty* icalprop = nullptr; - if (propkind == ICAL_X_PROPERTY) { - for (icalprop = - icalcomponent_get_first_property(mComponent, ICAL_X_PROPERTY); - icalprop; icalprop = icalcomponent_get_next_property( - mComponent, ICAL_X_PROPERTY)) { - if (kind.Equals(icalproperty_get_x_name(icalprop))) break; - } - } else { - icalprop = icalcomponent_get_first_property(mComponent, propkind); - } - - if (!icalprop) { - *prop = nullptr; - return NS_OK; - } - - *prop = new calIcalProperty(icalprop, this); - CAL_ENSURE_MEMORY(*prop); - NS_ADDREF(*prop); - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::GetNextProperty(const nsACString& kind, - calIIcalProperty** prop) { - NS_ENSURE_ARG_POINTER(prop); - - icalproperty_kind propkind = - icalproperty_string_to_kind(PromiseFlatCString(kind).get()); - - if (propkind == ICAL_NO_PROPERTY) return NS_ERROR_INVALID_ARG; - icalproperty* icalprop = nullptr; - if (propkind == ICAL_X_PROPERTY) { - for (icalprop = - icalcomponent_get_next_property(mComponent, ICAL_X_PROPERTY); - icalprop; icalprop = icalcomponent_get_next_property( - mComponent, ICAL_X_PROPERTY)) { - if (kind.Equals(icalproperty_get_x_name(icalprop))) break; - } - } else { - icalprop = icalcomponent_get_next_property(mComponent, propkind); - } - - if (!icalprop) { - *prop = nullptr; - return NS_OK; - } - - *prop = new calIcalProperty(icalprop, this); - CAL_ENSURE_MEMORY(*prop); - NS_ADDREF(*prop); - return NS_OK; -} - -NS_IMETHODIMP -calIcalComponent::AddProperty(calIIcalProperty* aProp) { - NS_ENSURE_ARG_POINTER(aProp); - // We assume a calIcalProperty is passed in (else the cast wouldn't run and - // we are about to crash), so we assume that this ICS service code has created - // the property. - - nsresult rv; - nsCOMPtr icalprop = do_QueryInterface(aProp, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - calIcalProperty* const ical = toIcalProperty(icalprop); - if (ical->mParent) { - ical->mProperty = icalproperty_new_clone(ical->mProperty); - } - ical->mParent = this; - icalcomponent_add_property(mComponent, ical->mProperty); - - nsCOMPtr dt; - if (NS_SUCCEEDED(aProp->GetValueAsDatetime(getter_AddRefs(dt))) && dt) { - // make sure timezone definition will be included: - nsCOMPtr tz; - if (NS_SUCCEEDED(dt->GetTimezone(getter_AddRefs(tz))) && tz) { - getParentVCalendarOrThis()->AddTimezoneReference(tz); - } - } - return NS_OK; -} - -// If you add then remove a property/component, the referenced -// timezones won't get purged out. There's currently no client code. - -// NS_IMETHODIMP -// calIcalComponent::RemoveProperty(calIIcalProperty *prop) -// { -// NS_ENSURE_ARG_POINTER(prop); -// // XXX like AddSubcomponent, this is questionable -// calIcalProperty *ical = static_cast(prop); -// icalcomponent_remove_property(mComponent, ical->mProperty); -// ical->mParent = nullptr; -// return NS_OK; -// } - -NS_IMPL_CLASSINFO(calICSService, nullptr, nsIClassInfo::THREADSAFE, - CAL_ICSSERVICE_CID) -NS_IMPL_ISUPPORTS_CI(calICSService, calIICSService) - -calICSService::calICSService() {} - -NS_IMETHODIMP -calICSService::ParseICS(const nsACString& serialized, - calITimezoneProvider* tzProvider, - calIIcalComponent** component) { - NS_ENSURE_ARG_POINTER(component); - icalcomponent* ical = - icalparser_parse_string(PromiseFlatCString(serialized).get()); - if (!ical) { -#ifdef DEBUG - fprintf(stderr, "Error parsing: '%20s': %d (%s)\n", - PromiseFlatCString(serialized).get(), icalerrno, - icalerror_strerror(icalerrno)); -#endif - // The return values is calIError match with ical errors, - // so no need for a conversion table or anything. - return static_cast(calIErrors::ICS_ERROR_BASE + icalerrno); - } - calIcalComponent* comp = new calIcalComponent(ical, nullptr, tzProvider); - if (!comp) { - icalcomponent_free(ical); - return NS_ERROR_OUT_OF_MEMORY; - } - NS_ADDREF(*component = comp); - return NS_OK; -} - -NS_IMETHODIMP -calICSService::ParserWorker::Run() { - icalcomponent* ical = icalparser_parse_string(mString.get()); - nsresult status = NS_OK; - calIIcalComponent* comp = nullptr; - - if (ical) { - comp = new calIcalComponent(ical, nullptr, mProvider); - if (!comp) { - icalcomponent_free(ical); - status = NS_ERROR_OUT_OF_MEMORY; - } - } else { - status = static_cast(calIErrors::ICS_ERROR_BASE + icalerrno); - } - - nsCOMPtr completer = - new ParserWorkerCompleter(mWorkerThread, status, comp, mListener); - mMainThread->Dispatch(completer, NS_DISPATCH_NORMAL); - - mWorkerThread = nullptr; - mMainThread = nullptr; - return NS_OK; -} - -NS_IMETHODIMP -calICSService::ParserWorker::ParserWorkerCompleter::Run() { - mListener->OnParsingComplete(mStatus, mComp); - - nsresult rv = mWorkerThread->Shutdown(); - NS_ENSURE_SUCCESS(rv, rv); - - mWorkerThread = nullptr; - return NS_OK; -} - -NS_IMETHODIMP -calICSService::ParseICSAsync(const nsACString& serialized, - calITimezoneProvider* tzProvider, - calIIcsComponentParsingListener* listener) { - nsresult rv; - NS_ENSURE_ARG_POINTER(listener); - - nsCOMPtr workerThread; - nsCOMPtr currentThread; - rv = NS_GetCurrentThread(getter_AddRefs(currentThread)); - NS_ENSURE_SUCCESS(rv, rv); - rv = NS_NewNamedThread("ICS parser", getter_AddRefs(workerThread)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr worker = new ParserWorker( - currentThread, workerThread, serialized, tzProvider, listener); - NS_ENSURE_TRUE(worker, NS_ERROR_OUT_OF_MEMORY); - - rv = workerThread->Dispatch(worker, NS_DISPATCH_NORMAL); - NS_ENSURE_SUCCESS(rv, rv); - - return NS_OK; -} - -NS_IMETHODIMP -calICSService::CreateIcalComponent(const nsACString& kind, - calIIcalComponent** comp) { - NS_ENSURE_ARG_POINTER(comp); - icalcomponent_kind compkind = - icalcomponent_string_to_kind(PromiseFlatCString(kind).get()); - - // Maybe someday I'll support X-COMPONENTs - if (compkind == ICAL_NO_COMPONENT || compkind == ICAL_X_COMPONENT) - return NS_ERROR_INVALID_ARG; - - icalcomponent* ical = icalcomponent_new(compkind); - if (!ical) return NS_ERROR_OUT_OF_MEMORY; // XXX translate - - *comp = new calIcalComponent(ical, nullptr); - if (!*comp) { - icalcomponent_free(ical); - return NS_ERROR_OUT_OF_MEMORY; - } - - NS_ADDREF(*comp); - return NS_OK; -} - -NS_IMETHODIMP -calICSService::CreateIcalProperty(const nsACString& kind, - calIIcalProperty** prop) { - NS_ENSURE_ARG_POINTER(prop); - icalproperty_kind propkind = - icalproperty_string_to_kind(PromiseFlatCString(kind).get()); - - if (propkind == ICAL_NO_PROPERTY) return NS_ERROR_INVALID_ARG; - - icalproperty* icalprop = icalproperty_new(propkind); - if (!icalprop) return NS_ERROR_OUT_OF_MEMORY; // XXX translate - - if (propkind == ICAL_X_PROPERTY) - icalproperty_set_x_name(icalprop, PromiseFlatCString(kind).get()); - - *prop = new calIcalProperty(icalprop, nullptr); - CAL_ENSURE_MEMORY(*prop); - NS_ADDREF(*prop); - return NS_OK; -} - -NS_IMETHODIMP -calICSService::CreateIcalPropertyFromString(const nsACString& str, - calIIcalProperty** prop) { - NS_ENSURE_ARG_POINTER(prop); - - icalproperty* icalprop = - icalproperty_new_from_string(PromiseFlatCString(str).get()); - - *prop = new calIcalProperty(icalprop, nullptr); - CAL_ENSURE_MEMORY(*prop); - NS_ADDREF(*prop); - return NS_OK; -} diff --git a/calendar/base/backend/libical/calICSService.h b/calendar/base/backend/libical/calICSService.h deleted file mode 100644 index 6dfda32255..0000000000 --- a/calendar/base/backend/libical/calICSService.h +++ /dev/null @@ -1,178 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#if !defined(INCLUDED_CALICSSERVICE_H) -# define INCLUDED_CALICSSERVICE_H - -# include "nsCOMPtr.h" -# include "calIICSService.h" -# include "calITimezoneProvider.h" -# include "nsInterfaceHashtable.h" -# include "nsProxyRelease.h" -# include "nsThreadUtils.h" -# include "calUtils.h" - -extern "C" { -# include "ical.h" -} - -class calICSService : public calIICSService, public cal::XpcomBase { - protected: - virtual ~calICSService() {} - class ParserWorker : public mozilla::Runnable { - public: - ParserWorker(nsIThread* mainThread, nsIThread* workerThread, - const nsACString& icsString, calITimezoneProvider* tzProvider, - calIIcsComponentParsingListener* listener) - : mozilla::Runnable("ParserWorker"), - mString(icsString), - mProvider(tzProvider), - mMainThread(mainThread), - mWorkerThread(workerThread) { - mListener = new nsMainThreadPtrHolder( - "calICSService::mListener", listener); - } - - NS_DECL_NSIRUNNABLE - - protected: - nsCString mString; - nsCOMPtr mProvider; - nsMainThreadPtrHandle mListener; - nsCOMPtr mMainThread; - nsCOMPtr mWorkerThread; - - class ParserWorkerCompleter : public mozilla::Runnable { - public: - ParserWorkerCompleter( - nsIThread* workerThread, nsresult status, - calIIcalComponent* component, - const nsMainThreadPtrHandle& - listener) - : mozilla::Runnable("ParserWorkerCompleter"), - mWorkerThread(workerThread), - mListener(listener), - mComp(component), - mStatus(status) {} - - NS_DECL_NSIRUNNABLE - protected: - nsCOMPtr mWorkerThread; - nsMainThreadPtrHandle mListener; - nsCOMPtr mComp; - nsresult mStatus; - }; - }; - - public: - calICSService(); - - NS_DECL_THREADSAFE_ISUPPORTS - NS_DECL_CALIICSSERVICE -}; - -class calIcalComponent; - -class calIcalProperty : public calIIcalPropertyLibical, public cal::XpcomBase { - friend class calIcalComponent; - - public: - calIcalProperty(icalproperty* prop, calIIcalComponentLibical* parent) - : mProperty(prop), mParent(parent) {} - - NS_DECL_ISUPPORTS - NS_DECL_CALIICALPROPERTY - NS_DECL_CALIICALPROPERTYLIBICAL - - protected: - virtual ~calIcalProperty(); - - static nsresult getDatetime_(calIcalComponent* parent, icalproperty* prop, - calIDateTime** dtp); - static nsresult setDatetime_(calIcalComponent* parent, icalproperty* prop, - calIDateTime* dt); - - icalproperty* mProperty; - nsCOMPtr mParent; -}; - -class calIcalComponent : public calIIcalComponentLibical, - public cal::XpcomBase { - friend class calIcalProperty; - - public: - calIcalComponent(icalcomponent* ical, calIIcalComponentLibical* parent, - calITimezoneProvider* tzProvider = nullptr) - : mComponent(ical), - mTimezone(nullptr), - mTzProvider(tzProvider), - mParent(parent) {} - - // VTIMEZONE ctor - calIcalComponent(icaltimezone* icaltz, icalcomponent* ical) - : mComponent(ical), mTimezone(icaltz) {} - - NS_DECL_THREADSAFE_ISUPPORTS - NS_DECL_CALIICALCOMPONENT - NS_DECL_CALIICALCOMPONENTLIBICAL - - protected: - virtual ~calIcalComponent(); - - calITimezoneProvider* getTzProvider() const { - // walk up the parents to find a tz provider: - calIcalComponent const* that = this; - while (that) { - calITimezoneProvider* const ret = that->mTzProvider; - if (ret) { - return ret; - } - calIIcalComponentLibical* const p = that->mParent; - that = static_cast(p); - } - return nullptr; - } - - calIcalComponent* getParentVCalendarOrThis() { - // walk up the parents to find a VCALENDAR: - calIcalComponent* that = this; - while (that && - icalcomponent_isa(that->mComponent) != ICAL_VCALENDAR_COMPONENT) { - calIIcalComponentLibical* const p = that->mParent; - that = static_cast(p); - } - if (!that) that = this; - return that; - } - - nsresult GetDateTimeAttribute(icalproperty_kind kind, calIDateTime** dtp); - nsresult SetDateTimeAttribute(icalproperty_kind kind, calIDateTime* dt); - - nsresult SetPropertyValue(icalproperty_kind kind, icalvalue* val); - nsresult SetProperty(icalproperty_kind kind, icalproperty* prop); - - nsresult GetStringProperty(icalproperty_kind kind, nsACString& str); - nsresult SetStringProperty(icalproperty_kind kind, const nsACString& str); - - nsresult GetIntProperty(icalproperty_kind kind, int32_t* valp); - nsresult SetIntProperty(icalproperty_kind kind, int32_t i); - - void ClearAllProperties(icalproperty_kind kind); - - nsresult Serialize(char** icalstr); - - nsInterfaceHashtable mReferencedTimezones; - icalcomponent* mComponent; - icaltimezone* mTimezone; // set iff VTIMEZONE - nsCOMPtr const mTzProvider; - nsCOMPtr mParent; -}; - -inline calIcalProperty* toIcalProperty(calIIcalPropertyLibical* p) { - return static_cast(p); -} -inline calIcalComponent* toIcalComponent(calIIcalComponentLibical* p) { - return static_cast(p); -} - -#endif // INCLUDED_CALICSSERVICE_H diff --git a/calendar/base/backend/libical/calPeriod.cpp b/calendar/base/backend/libical/calPeriod.cpp deleted file mode 100644 index 43b5c4e10d..0000000000 --- a/calendar/base/backend/libical/calPeriod.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "calPeriod.h" -#include "calBaseCID.h" - -#include "nsIClassInfoImpl.h" - -#include "calUtils.h" - -NS_IMPL_CLASSINFO(calPeriod, nullptr, 0, CAL_PERIOD_CID) -NS_IMPL_ISUPPORTS_CI(calPeriod, calIPeriod, calIPeriodLibical) - -calPeriod::calPeriod() : mImmutable(false) {} - -calPeriod::calPeriod(const calPeriod& cpt) : mImmutable(false) { - if (cpt.mStart) { - nsCOMPtr start; - cpt.mStart->Clone(getter_AddRefs(start)); - mStart = do_QueryInterface(start); - } - if (cpt.mEnd) { - nsCOMPtr end; - cpt.mEnd->Clone(getter_AddRefs(end)); - mEnd = do_QueryInterface(end); - } -} - -calPeriod::calPeriod(struct icalperiodtype const* aPeriodPtr) - : mImmutable(false) { - FromIcalPeriod(aPeriodPtr); -} - -NS_IMETHODIMP -calPeriod::GetIcalPeriod(JS::MutableHandle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calPeriod::SetIcalPeriod(JS::Handle) { - return NS_ERROR_NOT_IMPLEMENTED; -} - -NS_IMETHODIMP -calPeriod::GetIsMutable(bool* aResult) { - NS_ENSURE_ARG_POINTER(aResult); - - *aResult = !mImmutable; - return NS_OK; -} - -NS_IMETHODIMP -calPeriod::MakeImmutable() { - mImmutable = true; - return NS_OK; -} - -NS_IMETHODIMP -calPeriod::Clone(calIPeriod** aResult) { - NS_ENSURE_ARG_POINTER(aResult); - calPeriod* cpt = new calPeriod(*this); - if (!cpt) return NS_ERROR_OUT_OF_MEMORY; - - NS_ADDREF(*aResult = cpt); - return NS_OK; -} - -NS_IMETHODIMP calPeriod::GetStart(calIDateTime** _retval) { - NS_ENSURE_ARG_POINTER(_retval); - *_retval = mStart; - NS_IF_ADDREF(*_retval); - return NS_OK; -} -NS_IMETHODIMP calPeriod::SetStart(calIDateTime* aValue) { - NS_ENSURE_ARG_POINTER(aValue); - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - - mStart = do_QueryInterface(aValue); - return mStart->MakeImmutable(); -} - -NS_IMETHODIMP calPeriod::GetEnd(calIDateTime** _retval) { - NS_ENSURE_ARG_POINTER(_retval); - *_retval = mEnd; - NS_IF_ADDREF(*_retval); - return NS_OK; -} -NS_IMETHODIMP calPeriod::SetEnd(calIDateTime* aValue) { - NS_ENSURE_ARG_POINTER(aValue); - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - - mEnd = do_QueryInterface(aValue); - return mEnd->MakeImmutable(); -} - -NS_IMETHODIMP calPeriod::GetDuration(calIDuration** _retval) { - NS_ENSURE_ARG_POINTER(_retval); - if (!mStart || !mEnd) return NS_ERROR_UNEXPECTED; - return mEnd->SubtractDate(mStart, _retval); -} - -NS_IMETHODIMP -calPeriod::ToString(nsACString& aResult) { return GetIcalString(aResult); } - -NS_IMETHODIMP_(void) -calPeriod::ToIcalPeriod(struct icalperiodtype* icalp) { - // makes no sense to create a duration without bath a start and end - if (!mStart || !mEnd) { - *icalp = icalperiodtype_null_period(); - return; - } - - mStart->ToIcalTime(&icalp->start); - mEnd->ToIcalTime(&icalp->end); -} - -void calPeriod::FromIcalPeriod(struct icalperiodtype const* icalp) { - mStart = new calDateTime(&(icalp->start), nullptr); - mStart->MakeImmutable(); - mEnd = new calDateTime(&(icalp->end), nullptr); - mEnd->MakeImmutable(); - return; -} - -NS_IMETHODIMP -calPeriod::GetIcalString(nsACString& aResult) { - struct icalperiodtype ip; - ToIcalPeriod(&ip); - - // note that ics is owned by libical, so we don't need to free - const char* ics = icalperiodtype_as_ical_string(ip); - - if (ics) { - aResult.Assign(ics); - return NS_OK; - } - - return NS_ERROR_OUT_OF_MEMORY; -} - -NS_IMETHODIMP -calPeriod::SetIcalString(const nsACString& aIcalString) { - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - struct icalperiodtype ip; - ip = icalperiodtype_from_string(PromiseFlatCString(aIcalString).get()); - // XXX Shortcut. Assumes nobody tried to overrule our impl. of calIDateTime - mStart = new calDateTime(&ip.start, nullptr); - if (icaltime_is_null_time(ip.end)) { - struct icaltimetype end; - end = icaltime_add(ip.start, ip.duration); - mEnd = new calDateTime(&end, nullptr); - } else { - mEnd = new calDateTime(&ip.end, nullptr); - } - return NS_OK; -} diff --git a/calendar/base/backend/libical/calPeriod.h b/calendar/base/backend/libical/calPeriod.h deleted file mode 100644 index 63f550b07d..0000000000 --- a/calendar/base/backend/libical/calPeriod.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef CALPERIOD_H_ -#define CALPERIOD_H_ - -#include "nsCOMPtr.h" - -#include "calIPeriod.h" -#include "calDateTime.h" -#include "calIDuration.h" - -extern "C" { -#include "ical.h" -} - -class calPeriod final : public calIPeriodLibical { - public: - calPeriod(); - explicit calPeriod(const calPeriod& cpt); - explicit calPeriod(struct icalperiodtype const* aPeriodPtr); - - // nsISupports interface - NS_DECL_ISUPPORTS - - // calIPeriod interface - NS_DECL_CALIPERIOD - NS_DECL_CALIPERIODLIBICAL - - protected: - ~calPeriod() {} - calPeriod const& operator=(calPeriod const&); - - bool mImmutable; - - // struct icaldurationtype mPeriod; - nsCOMPtr mStart; - nsCOMPtr mEnd; - - void FromIcalPeriod(struct icalperiodtype const* icalp); -}; - -#endif /* CALPERIOD_H_ */ diff --git a/calendar/base/backend/libical/calRecurrenceRule.cpp b/calendar/base/backend/libical/calRecurrenceRule.cpp deleted file mode 100644 index b465a1d894..0000000000 --- a/calendar/base/backend/libical/calRecurrenceRule.cpp +++ /dev/null @@ -1,580 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsCOMArray.h" - -#include "calRecurrenceRule.h" - -#include "calDateTime.h" -#include "calIItemBase.h" -#include "calIEvent.h" - -#include "calICSService.h" - -#include "nsIClassInfoImpl.h" - -#include - -NS_IMPL_CLASSINFO(calRecurrenceRule, NULL, 0, CAL_RECURRENCERULE_CID) -NS_IMPL_ISUPPORTS_CI(calRecurrenceRule, calIRecurrenceItem, calIRecurrenceRule) - -calRecurrenceRule::calRecurrenceRule() - : mImmutable(false), mIsNegative(false), mIsByCount(false) { - icalrecurrencetype_clear(&mIcalRecur); -} - -bool calRecurrenceRule::FreqSupported() { - return !((mIcalRecur.freq == ICAL_SECONDLY_RECURRENCE) || - (mIcalRecur.freq == ICAL_MINUTELY_RECURRENCE)); -} - -NS_IMETHODIMP -calRecurrenceRule::GetIsMutable(bool* aResult) { - NS_ENSURE_ARG_POINTER(aResult); - *aResult = !mImmutable; - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::MakeImmutable() { - mImmutable = true; - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::Clone(calIRecurrenceItem** aResult) { - calRecurrenceRule* const crc = new calRecurrenceRule(); - CAL_ENSURE_MEMORY(crc); - - crc->mIsNegative = mIsNegative; - crc->mIsByCount = mIsByCount; - crc->mIcalRecur = mIcalRecur; - - NS_ADDREF(*aResult = crc); - return NS_OK; -} - -/* attribute boolean isNegative; */ -NS_IMETHODIMP -calRecurrenceRule::GetIsNegative(bool* _retval) { - NS_ENSURE_ARG_POINTER(_retval); - *_retval = mIsNegative; - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::SetIsNegative(bool aIsNegative) { - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - mIsNegative = aIsNegative; - return NS_OK; -} - -/* readonly attribute boolean isFinite; */ -NS_IMETHODIMP -calRecurrenceRule::GetIsFinite(bool* _retval) { - NS_ENSURE_ARG_POINTER(_retval); - - if ((mIsByCount && mIcalRecur.count == 0) || - (!mIsByCount && icaltime_is_null_time(mIcalRecur.until))) { - *_retval = false; - } else { - *_retval = true; - } - return NS_OK; -} - -/* attribute long type; */ -NS_IMETHODIMP -calRecurrenceRule::GetType(nsACString& aType) { - switch (mIcalRecur.freq) { -#define RECUR_HELPER(x) \ - case ICAL_##x##_RECURRENCE: \ - aType.AssignLiteral(#x); \ - break - RECUR_HELPER(SECONDLY); - RECUR_HELPER(MINUTELY); - RECUR_HELPER(HOURLY); - RECUR_HELPER(DAILY); - RECUR_HELPER(WEEKLY); - RECUR_HELPER(MONTHLY); - RECUR_HELPER(YEARLY); -#undef RECUR_HELPER - default: - aType.AssignLiteral(""); - } - - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::SetType(const nsACString& aType) { - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; -#define RECUR_HELPER(x) \ - if (aType.EqualsLiteral(#x)) mIcalRecur.freq = ICAL_##x##_RECURRENCE - RECUR_HELPER(SECONDLY); - else RECUR_HELPER(MINUTELY); - else RECUR_HELPER(HOURLY); - else RECUR_HELPER(DAILY); - else RECUR_HELPER(WEEKLY); - else RECUR_HELPER(MONTHLY); - else RECUR_HELPER(YEARLY); -#undef RECUR_HELPER - else if (aType.IsEmpty() || aType.EqualsLiteral("")) mIcalRecur.freq = - ICAL_NO_RECURRENCE; - else return NS_ERROR_FAILURE; - - return NS_OK; -} - -/* attribute long count; */ -NS_IMETHODIMP -calRecurrenceRule::GetCount(int32_t* aRecurCount) { - NS_ENSURE_ARG_POINTER(aRecurCount); - - if (!mIsByCount) return NS_ERROR_FAILURE; - - if (mIcalRecur.count == 0 && icaltime_is_null_time(mIcalRecur.until)) { - *aRecurCount = -1; - } else if (mIcalRecur.count) { - *aRecurCount = mIcalRecur.count; - } else { - // count wasn't set, so we don't know - return NS_ERROR_FAILURE; - } - - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::SetCount(int32_t aRecurCount) { - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - if (aRecurCount != -1) { - if (aRecurCount < 0 || aRecurCount > INT_MAX) return NS_ERROR_ILLEGAL_VALUE; - mIcalRecur.count = static_cast(aRecurCount); - mIsByCount = true; - } else { - mIcalRecur.count = 0; - mIsByCount = false; - } - - mIcalRecur.until = icaltime_null_time(); - - return NS_OK; -} - -/* attribute calIDateTime untilDate; */ -NS_IMETHODIMP -calRecurrenceRule::GetUntilDate(calIDateTime** aRecurEnd) { - NS_ENSURE_ARG_POINTER(aRecurEnd); - - if (mIsByCount) return NS_ERROR_FAILURE; - - if (!icaltime_is_null_time(mIcalRecur.until)) { - *aRecurEnd = new calDateTime(&mIcalRecur.until, nullptr); - CAL_ENSURE_MEMORY(*aRecurEnd); - NS_ADDREF(*aRecurEnd); - } else { - // infinite recurrence - *aRecurEnd = nullptr; - } - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::SetUntilDate(calIDateTime* aRecurEnd) { - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - if (aRecurEnd) { - nsresult rv; - bool b; - nsCOMPtr icaldt; - nsCOMPtr tz; - aRecurEnd->GetTimezone(getter_AddRefs(tz)); - - if (NS_SUCCEEDED(tz->GetIsUTC(&b)) && !b && - NS_SUCCEEDED(tz->GetIsFloating(&b)) && !b) { - // convert to UTC: - nsCOMPtr dt; - nsCOMPtr ctz = cal::UTC(); - aRecurEnd->GetInTimezone(ctz, getter_AddRefs(dt)); - icaldt = do_QueryInterface(dt, &rv); - } else { - icaldt = do_QueryInterface(aRecurEnd, &rv); - } - - NS_ENSURE_SUCCESS(rv, rv); - struct icaltimetype itt; - icaldt->ToIcalTime(&itt); - - mIcalRecur.until = itt; - } else { - mIcalRecur.until = icaltime_null_time(); - } - - mIcalRecur.count = 0; - - mIsByCount = false; - - return NS_OK; -} - -/* readonly attribute boolean isByCount; */ -NS_IMETHODIMP -calRecurrenceRule::GetIsByCount(bool* aIsByCount) { - *aIsByCount = mIsByCount; - return NS_OK; -} - -/* attribute long interval; */ -NS_IMETHODIMP -calRecurrenceRule::GetInterval(int32_t* aInterval) { - NS_ENSURE_ARG_POINTER(aInterval); - *aInterval = mIcalRecur.interval; - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::SetInterval(int32_t aInterval) { - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - if (aInterval < 0 || aInterval > SHRT_MAX) return NS_ERROR_ILLEGAL_VALUE; - mIcalRecur.interval = static_cast(aInterval); - return NS_OK; -} - -// Helper table to encode the size/location of the various arrays in the -// icalrecurrencetype struct. -static const struct { - const char* name; - size_t offset; - size_t maxCount; -} recurrenceTable[] = { - {"BYSECOND", offsetof(icalrecurrencetype, by_second), ICAL_BY_SECOND_SIZE}, - {"BYMINUTE", offsetof(icalrecurrencetype, by_minute), ICAL_BY_MINUTE_SIZE}, - {"BYHOUR", offsetof(icalrecurrencetype, by_hour), ICAL_BY_HOUR_SIZE}, - {"BYDAY", offsetof(icalrecurrencetype, by_day), ICAL_BY_DAY_SIZE}, - {"BYMONTHDAY", offsetof(icalrecurrencetype, by_month_day), - ICAL_BY_MONTHDAY_SIZE}, - {"BYYEARDAY", offsetof(icalrecurrencetype, by_year_day), - ICAL_BY_YEARDAY_SIZE}, - {"BYWEEKNO", offsetof(icalrecurrencetype, by_week_no), ICAL_BY_WEEKNO_SIZE}, - {"BYMONTH", offsetof(icalrecurrencetype, by_month), ICAL_BY_MONTH_SIZE}, - {"BYSETPOS", offsetof(icalrecurrencetype, by_set_pos), ICAL_BY_SETPOS_SIZE}, - {nullptr, 0, 0}}; - -NS_IMETHODIMP -calRecurrenceRule::GetComponent(const nsACString& aComponentType, - nsTArray& aValues) { - aValues.ClearAndRetainStorage(); - // Look up the array for this component type. - for (int i = 0; recurrenceTable[i].name; ++i) { - auto const& row = recurrenceTable[i]; - if (aComponentType.EqualsASCII(row.name)) { - // Found it. - int16_t const* src = (int16_t*)((uint8_t*)&mIcalRecur + row.offset); - size_t count; - for (count = 0; count < row.maxCount; count++) { - if (src[count] == ICAL_RECURRENCE_ARRAY_MAX) break; - } - aValues.ReplaceElementsAt(0, aValues.Length(), src, count); - return NS_OK; - } - } - return NS_ERROR_FAILURE; // Invalid component. -} - -NS_IMETHODIMP -calRecurrenceRule::SetComponent(const nsACString& aComponentType, - nsTArray const& aValues) { - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - - // Look up the array for this component type. - for (int i = 0; recurrenceTable[i].name; ++i) { - auto const& row = recurrenceTable[i]; - if (aComponentType.EqualsASCII(row.name)) { - // Found it. - int16_t* dest = (int16_t*)((uint8_t*)&mIcalRecur + row.offset); - if (aValues.Length() > row.maxCount) return NS_ERROR_FAILURE; - for (int16_t v : aValues) { - *dest++ = v; - } - // Terminate array unless full. - if (aValues.Length() < row.maxCount) { - *dest++ = ICAL_RECURRENCE_ARRAY_MAX; - } - return NS_OK; - } - } - return NS_ERROR_FAILURE; // Invalid component. -} - -/* calIDateTime getNextOccurrence (in calIDateTime aStartTime, in calIDateTime - * aOccurrenceTime); */ -NS_IMETHODIMP -calRecurrenceRule::GetNextOccurrence(calIDateTime* aStartTime, - calIDateTime* aOccurrenceTime, - calIDateTime** _retval) { - NS_ENSURE_ARG_POINTER(aStartTime); - NS_ENSURE_ARG_POINTER(aOccurrenceTime); - NS_ENSURE_ARG_POINTER(_retval); - - if (!FreqSupported()) { - *_retval = nullptr; - return NS_OK; - } - - nsresult rv; - - nsCOMPtr icaldtstart = - do_QueryInterface(aStartTime, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMPtr icaloccurtime = - do_QueryInterface(aOccurrenceTime, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - struct icaltimetype dtstart; - icaldtstart->ToIcalTime(&dtstart); - - struct icaltimetype occurtime; - icaloccurtime->ToIcalTime(&occurtime); - - icalrecur_iterator* recur_iter; - recur_iter = icalrecur_iterator_new(mIcalRecur, dtstart); - if (!recur_iter) return NS_ERROR_OUT_OF_MEMORY; - - struct icaltimetype next = icalrecur_iterator_next(recur_iter); - while (!icaltime_is_null_time(next)) { - if (icaltime_compare(next, occurtime) > 0) break; - - next = icalrecur_iterator_next(recur_iter); - } - - icalrecur_iterator_free(recur_iter); - - if (icaltime_is_null_time(next)) { - *_retval = nullptr; - return NS_OK; - } - - nsCOMPtr tz; - aStartTime->GetTimezone(getter_AddRefs(tz)); - *_retval = new calDateTime(&next, tz); - CAL_ENSURE_MEMORY(*_retval); - NS_ADDREF(*_retval); - return NS_OK; -} - -static inline icaltimetype ensureDateTime(icaltimetype const& icalt) { - if (!icalt.is_date) { - return icalt; - } else { - icaltimetype ret = icalt; - ret.is_date = 0; - ret.hour = 0; - ret.minute = 0; - ret.second = 0; - return ret; - } -} - -NS_IMETHODIMP -calRecurrenceRule::GetOccurrences(calIDateTime* aStartTime, - calIDateTime* aRangeStart, - calIDateTime* aRangeEnd, uint32_t aMaxCount, - nsTArray>& aDates) { - NS_ENSURE_ARG_POINTER(aStartTime); - NS_ENSURE_ARG_POINTER(aRangeStart); - aDates.ClearAndRetainStorage(); - - if (!FreqSupported()) { - return NS_OK; - } - - // make sure the request is sane; infinite recurrence - // with no end time is bad times. - if (!aMaxCount && !aRangeEnd && mIcalRecur.count == 0 && - icaltime_is_null_time(mIcalRecur.until)) - return NS_ERROR_INVALID_ARG; - - nsCOMArray dates; - -#ifdef DEBUG_dbo - { - char const* const ss = icalrecurrencetype_as_string(&mIcalRecur); - nsAutoCString tst, tend; - aRangeStart->ToString(tst); - aRangeEnd->ToString(tend); - printf("RULE: [%s -> %s, %d]: %s\n", tst.get(), tend.get(), - mIcalRecur.count, ss); - } -#endif - - nsresult rv; - - nsCOMPtr icalrangestart = - do_QueryInterface(aRangeStart, &rv); - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr icaldtstart = - do_QueryInterface(aStartTime, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - struct icaltimetype rangestart, dtstart, dtend; - icalrangestart->ToIcalTime(&rangestart); - rangestart = ensureDateTime(rangestart); - icaldtstart->ToIcalTime(&dtstart); - nsCOMPtr tz; - aStartTime->GetTimezone(getter_AddRefs(tz)); - - if (aRangeEnd) { - nsCOMPtr icalrangeend = - do_QueryInterface(aRangeEnd, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - icalrangeend->ToIcalTime(&dtend); - dtend = ensureDateTime(dtend); - - // if the start of the recurrence is past the end, - // we have no dates - if (icaltime_compare(dtstart, dtend) >= 0) { - return NS_OK; - } - } - - icalrecur_iterator* recur_iter; - recur_iter = icalrecur_iterator_new(mIcalRecur, dtstart); - if (!recur_iter) return NS_ERROR_OUT_OF_MEMORY; - - for (icaltimetype next = icalrecur_iterator_next(recur_iter); - !icaltime_is_null_time(next); - next = icalrecur_iterator_next(recur_iter)) { - icaltimetype const dtNext(ensureDateTime(next)); - - // if this thing is before the range start - if (icaltime_compare(dtNext, rangestart) < 0) { - continue; - } - - if (aRangeEnd && icaltime_compare(dtNext, dtend) >= 0) break; - - calIDateTime* cdt = new calDateTime(&next, tz); - aDates.AppendElement(cdt); -#ifdef DEBUG_dbo - { - nsAutoCString str; - cdt->ToString(str); - printf(" occ: %s\n", str.get()); - } -#endif - if (aMaxCount && aMaxCount <= aDates.Length()) break; - } - - icalrecur_iterator_free(recur_iter); - - return NS_OK; -} - -/** - ** ical property getting/setting - **/ -NS_IMETHODIMP -calRecurrenceRule::GetIcalProperty(calIIcalProperty** prop) { - icalproperty* const rrule = icalproperty_new_rrule(mIcalRecur); - CAL_ENSURE_MEMORY(rrule); - *prop = new calIcalProperty(rrule, nullptr); - if (!*prop) { - icalproperty_free(rrule); - return NS_ERROR_FAILURE; - } - - NS_ADDREF(*prop); - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::SetIcalProperty(calIIcalProperty* aProp) { - NS_ENSURE_ARG_POINTER(aProp); - nsresult rv; - - nsCOMPtr icalprop = do_QueryInterface(aProp, &rv); - NS_ENSURE_SUCCESS(rv, rv); - - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - - nsAutoCString propname; - rv = aProp->GetPropertyName(propname); - NS_ENSURE_SUCCESS(rv, rv); - if (propname.EqualsLiteral("RRULE")) { - mIsNegative = false; - } else { - return NS_ERROR_INVALID_ARG; - } - - icalproperty* prop; - struct icalrecurrencetype icalrecur; - - prop = icalprop->GetLibicalProperty(); - - icalrecur = icalproperty_get_rrule(prop); - - // XXX Note that we ignore the dtstart and use the one from the - // event, though I realize now that we shouldn't. Ignoring - // dtstart makes it impossible to have multiple RRULEs on one - // event that start at different times (e.g. every day starting on - // jan 1 for 2 weeks, every other day starting on feb 1 for 2 - // weeks). Neither the server nor the UI supports this now, - // but we really ought to! - // struct icaltimetype icaldtstart; - // icaldtstrat = icalproperty_get_dtstart(prop); - - if (icalrecur.count != 0) - mIsByCount = true; - else - mIsByCount = false; - - mIcalRecur = icalrecur; - - return NS_OK; -} - -NS_IMETHODIMP -calRecurrenceRule::SetIcalString(const nsACString& str) { - if (mImmutable) return NS_ERROR_OBJECT_IS_IMMUTABLE; - - nsresult rv = NS_OK; - nsAutoCString name; - nsCOMPtr icsSvc = cal::getICSService(); - nsCOMPtr prop; - - rv = icsSvc->CreateIcalPropertyFromString(str, getter_AddRefs(prop)); - NS_ENSURE_SUCCESS(rv, rv); - - rv = prop->GetPropertyName(name); - NS_ENSURE_SUCCESS(rv, rv); - - if (!name.EqualsLiteral("RRULE")) { - return NS_ERROR_ILLEGAL_VALUE; - } - - return SetIcalProperty(prop); -} - -NS_IMETHODIMP -calRecurrenceRule::GetIcalString(nsACString& str) { - nsresult rv = NS_OK; - - nsCOMPtr prop; - - rv = this->GetIcalProperty(getter_AddRefs(prop)); - - if (NS_SUCCEEDED(rv)) { - rv = prop->GetIcalString(str); - } - - return rv; -} - -NS_IMETHODIMP -calRecurrenceRule::GetWeekStart(short*) { return NS_ERROR_NOT_IMPLEMENTED; } - -NS_IMETHODIMP -calRecurrenceRule::SetWeekStart(short) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/calendar/base/backend/libical/calRecurrenceRule.h b/calendar/base/backend/libical/calRecurrenceRule.h deleted file mode 100644 index dac5f8183f..0000000000 --- a/calendar/base/backend/libical/calRecurrenceRule.h +++ /dev/null @@ -1,34 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#if !defined(INCLUDED_CAL_RECURRENCERULE_H) -# define INCLUDED_CAL_RECURRENCERULE_H - -# include "calIRecurrenceRule.h" -# include "calUtils.h" - -extern "C" { -# include "ical.h" -} - -class calRecurrenceRule : public calIRecurrenceRule, public cal::XpcomBase { - public: - calRecurrenceRule(); - - NS_DECL_ISUPPORTS - NS_DECL_CALIRECURRENCEITEM - NS_DECL_CALIRECURRENCERULE - protected: - virtual ~calRecurrenceRule() {} - - icalrecurrencetype mIcalRecur; - - bool mImmutable; - bool mIsNegative; - bool mIsByCount; - - private: - bool FreqSupported(); -}; - -#endif // INCLUDED_CAL_RECURRENCERULE_H diff --git a/calendar/base/backend/libical/calTimezone.cpp b/calendar/base/backend/libical/calTimezone.cpp deleted file mode 100644 index 57bf614430..0000000000 --- a/calendar/base/backend/libical/calTimezone.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "calTimezone.h" -#include "calUtils.h" -#include "calAttributeHelpers.h" - -NS_IMPL_ISUPPORTS(calTimezone, calITimezone) - -CAL_ISUPPORTS_ATTR_GETTER(calTimezone, calIIcalComponent, IcalComponent) -CAL_STRINGTYPE_ATTR_GETTER(calTimezone, nsACString, Tzid) - -NS_IMETHODIMP -calTimezone::GetIsFloating(bool* _retval) { - NS_ENSURE_ARG_POINTER(_retval); - *_retval = false; - return NS_OK; -} - -NS_IMETHODIMP -calTimezone::GetIsUTC(bool* _retval) { - NS_ENSURE_ARG_POINTER(_retval); - *_retval = false; - return NS_OK; -} - -NS_IMETHODIMP -calTimezone::GetDisplayName(nsAString& _retval) { - _retval = NS_ConvertUTF8toUTF16(mTzid); - return NS_OK; -} - -NS_IMETHODIMP -calTimezone::GetLatitude(nsACString& _retval) { - _retval.SetIsVoid(true); - return NS_OK; -} - -NS_IMETHODIMP -calTimezone::GetLongitude(nsACString& _retval) { - _retval.SetIsVoid(true); - return NS_OK; -} - -NS_IMETHODIMP -calTimezone::GetProvider(calITimezoneProvider** _retval) { - NS_ENSURE_ARG_POINTER(_retval); - *_retval = nullptr; - return NS_OK; -} - -NS_IMETHODIMP -calTimezone::ToString(nsACString& aResult) { - if (mIcalComponent) { - return mIcalComponent->ToString(aResult); - } else { - return GetTzid(aResult); - } -} diff --git a/calendar/base/backend/libical/calTimezone.h b/calendar/base/backend/libical/calTimezone.h deleted file mode 100644 index d2cb91b1b0..0000000000 --- a/calendar/base/backend/libical/calTimezone.h +++ /dev/null @@ -1,25 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#if !defined(INCLUDED_CAL_TIMEZONE_H) -# define INCLUDED_CAL_TIMEZONE_H - -# include "nsCOMPtr.h" -# include "calITimezone.h" -# include "calUtils.h" - -class calTimezone : public calITimezone, public cal::XpcomBase { - public: - calTimezone(nsCString const& tzid, calIIcalComponent* component) - : mTzid(tzid), mIcalComponent(component) {} - - NS_DECL_ISUPPORTS - NS_DECL_CALITIMEZONE - - protected: - virtual ~calTimezone() {} - nsCString const mTzid; - nsCOMPtr const mIcalComponent; -}; - -#endif // INCLUDED_CAL_TIMEZONE_H diff --git a/calendar/base/backend/libical/calUtils.cpp b/calendar/base/backend/libical/calUtils.cpp deleted file mode 100644 index a499449e27..0000000000 --- a/calendar/base/backend/libical/calUtils.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "nsComponentManagerUtils.h" - -#include "calUtils.h" -#include "nsIScriptError.h" - -extern "C" { -#include "ical.h" -} - -namespace cal { - -nsresult logError(const nsAString& msg) { - nsresult rc; - nsCOMPtr const scriptError( - do_CreateInstance("@mozilla.org/scripterror;1", &rc)); - NS_ENSURE_SUCCESS(rc, rc); - rc = - scriptError->Init(msg, EmptyString(), EmptyString(), 0, 0, - nsIScriptError::errorFlag, "calendar"_ns, false, false); - return getConsoleService()->LogMessage(scriptError); -} - -nsresult logWarning(const nsAString& msg) { - nsresult rc; - nsCOMPtr const scriptError( - do_CreateInstance("@mozilla.org/scripterror;1", &rc)); - NS_ENSURE_SUCCESS(rc, rc); - rc = scriptError->Init(msg, EmptyString(), EmptyString(), 0, 0, - nsIScriptError::warningFlag, "calendar"_ns, false, - false); - return getConsoleService()->LogMessage(scriptError); -} - -nsresult log(char16_t const* msg) { - return getConsoleService()->LogStringMessage(msg); -} - -nsCOMPtr detectTimezone(icaltimetype const& icalt, - calITimezoneProvider* tzProvider) { - if (icalt.is_utc) { - return UTC(); - } - if (icalt.zone) { - char const* const tzid = - icaltimezone_get_tzid(const_cast(icalt.zone)); - if (tzid) { - nsCOMPtr tz; - if (tzProvider) { - tzProvider->GetTimezone(nsDependentCString(tzid), getter_AddRefs(tz)); - } else { - getTimezoneService()->GetTimezone(nsDependentCString(tzid), - getter_AddRefs(tz)); - } - if (tz) { - return tz; - } - NS_ASSERTION(tz, "no timezone found, falling back to floating!"); - logMissingTimezone(tzid); - } - } - return floating(); -} - -void logMissingTimezone(char const* tzid) { - // xxx todo: needs l10n - nsString msg(u"Timezone \""_ns); - msg += NS_ConvertUTF8toUTF16(tzid); - msg += u"\" not found, falling back to floating!"_ns; - logError(msg); -} - -icaltimezone* getIcalTimezone(calITimezone* tz) { - icaltimezone* icaltz = nullptr; - if (!tz) { - NS_ASSERTION(false, "No Timezone passed to getIcalTimezone"); - return nullptr; - } - - bool b; - tz->GetIsUTC(&b); - if (b) { - icaltz = icaltimezone_get_utc_timezone(); - } else { - nsCOMPtr tzComp; - tz->GetIcalComponent(getter_AddRefs(tzComp)); - if (tzComp) { - nsCOMPtr tzCompLibical = - do_QueryInterface(tzComp); - icaltz = tzCompLibical->GetLibicalTimezone(); - } // else floating or phantom timezone - } - return icaltz; -} - -XpcomBase::~XpcomBase() {} - -} // namespace cal diff --git a/calendar/base/backend/libical/calUtils.h b/calendar/base/backend/libical/calUtils.h deleted file mode 100644 index 56b9ff5454..0000000000 --- a/calendar/base/backend/libical/calUtils.h +++ /dev/null @@ -1,171 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#if !defined(INCLUDED_CAL_UTILS_H) -# define INCLUDED_CAL_UTILS_H - -# include "nsCRT.h" -# include "nsString.h" - -# include "nsIStringEnumerator.h" - -# include "calITimezone.h" -# include "calITimezoneProvider.h" -# include "calIICSService.h" -# include "nsIConsoleService.h" -# include "nsServiceManagerUtils.h" -# include "nsIClassInfoImpl.h" -# include "nsCOMPtr.h" - -# include "calBaseCID.h" - -# define CAL_STRLEN_ARGS(x) x, sizeof(x) - 1 -# define CAL_ENSURE_MEMORY(p) NS_ENSURE_TRUE(p, NS_ERROR_OUT_OF_MEMORY) - -typedef struct _icaltimezone icaltimezone; -typedef struct icaltimetype icaltimetype; - -namespace cal { - -/** - * Gets the global console service. - */ -inline nsCOMPtr getConsoleService() { - return do_GetService("@mozilla.org/consoleservice;1"); -} - -/** - * Gets the global ICS service. - */ -inline nsCOMPtr getICSService() { - return do_GetService(CAL_ICSSERVICE_CONTRACTID); -} - -/** - * Gets the global timezone service. - */ -inline nsCOMPtr getTimezoneService() { - nsresult rv; - nsCOMPtr tzs; - - tzs = do_GetService(CAL_TIMEZONESERVICE_CONTRACTID, &rv); - if (NS_FAILED(rv)) { - MOZ_CRASH( - "Could not load timezone service, brace yourself and prepare for " - "crash"); - } - return tzs; -} - -/** - * Logs an error. - */ -nsresult logError(const nsAString& msg); -inline nsresult logError(char const* msg) { - return logError(NS_ConvertASCIItoUTF16(msg)); -} -inline nsresult logError(nsACString const& msg) { - return logError(NS_ConvertASCIItoUTF16(msg)); -} - -/** - * Logs a warning. - */ -nsresult logWarning(const nsAString& msg); -inline nsresult logWarning(char const* msg) { - return logWarning(NS_ConvertASCIItoUTF16(msg)); -} -inline nsresult logWarning(nsACString const& msg) { - return logWarning(NS_ConvertASCIItoUTF16(msg)); -} - -/** - * Just logs. - */ -nsresult log(char16_t const* msg); -inline nsresult log(char const* msg) { - return log(NS_ConvertASCIItoUTF16(msg).get()); -} -inline nsresult log(nsACString const& msg) { - return log(NS_ConvertASCIItoUTF16(msg).get()); -} - -// some timezone helpers - -/** - * Gets the "UTC" timezone. - */ -inline nsCOMPtr UTC() { - nsresult rv; - nsCOMPtr tz; - - rv = getTimezoneService()->GetUTC(getter_AddRefs(tz)); - if (NS_FAILED(rv)) { - MOZ_CRASH( - "Could not load UTC timezone, brace yourself and prepare for crash"); - } - - return tz; -} - -/** - * Gets the "floating" timezone - */ -inline nsCOMPtr floating() { - nsresult rv; - nsCOMPtr tz; - - rv = getTimezoneService()->GetFloating(getter_AddRefs(tz)); - if (NS_FAILED(rv)) { - MOZ_CRASH( - "Could not load floating timezone, brace yourself and prepare for " - "crash"); - } - - return tz; -} - -/** - * Returns the libical VTIMEZONE component, null if floating. - * - * @attention - * Every timezone provider needs to use calICSService for - * creating its timezone components since we need to stick to the - * same libical. - */ -icaltimezone* getIcalTimezone(calITimezone* tz); - -/** - * Detects the timezone icalt refers to, either using the - * passed timezone provider or the global timezone service. - * - * @param icalt an icaltime - * @param tzProvider timezone provider or null which - * defaults to the timezone service - */ -nsCOMPtr detectTimezone(icaltimetype const& icalt, - calITimezoneProvider* tzProvider); - -/** - * Logs a missing timezone into the js console. - */ -void logMissingTimezone(char const* tzid); - -/** - * Common base class for XPCOM object implementations: - * - disallows public deletion (virtual protected dtor) - * - disallows copy semantics (no assignment, no copy ctor) - */ -class XpcomBase { - protected: - XpcomBase() {} - virtual ~XpcomBase(); - - private: - XpcomBase(XpcomBase const&); // left unimplemented - XpcomBase const& operator=(XpcomBase const&); // left unimplemented -}; - -} // namespace cal - -#endif // !defined(INCLUDED_CAL_UTILS_H) diff --git a/calendar/base/backend/libical/moz.build b/calendar/base/backend/libical/moz.build deleted file mode 100644 index 1084773745..0000000000 --- a/calendar/base/backend/libical/moz.build +++ /dev/null @@ -1,16 +0,0 @@ -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -UNIFIED_SOURCES += [ - "calDateTime.cpp", - "calDuration.cpp", - "calICSService.cpp", - "calPeriod.cpp", - "calRecurrenceRule.cpp", - "calTimezone.cpp", - "calUtils.cpp", -] - -FINAL_LIBRARY = "xul" diff --git a/calendar/base/backend/moz.build b/calendar/base/backend/moz.build deleted file mode 100644 index c3be6d5bfa..0000000000 --- a/calendar/base/backend/moz.build +++ /dev/null @@ -1,17 +0,0 @@ -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DIRS = ["libical", "icaljs"] - -EXTRA_JS_MODULES += [ - "CalBackendLoader.jsm", -] - -XPCOM_MANIFESTS += [ - "components.conf", -] - -with Files("**"): - BUG_COMPONENT = ("Calendar", "Internal Components") diff --git a/calendar/base/calendar.js b/calendar/base/calendar.js index abe392f398..475330301f 100644 --- a/calendar/base/calendar.js +++ b/calendar/base/calendar.js @@ -169,9 +169,6 @@ pref("calendar.paste.intoSelectedCalendar", false); pref("calendar.baseview.loglevel", "Warn"); -// Backend to use. false: libical, true: ical.js -pref("calendar.icaljs", true); - // Enables the prompt when deleting from the item views or trees. pref("calendar.item.promptDelete", true); diff --git a/calendar/base/modules/calUtils.jsm b/calendar/base/modules/calUtils.jsm index fb2262e4ae..ce8e42ac37 100644 --- a/calendar/base/modules/calUtils.jsm +++ b/calendar/base/modules/calUtils.jsm @@ -5,11 +5,6 @@ var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); var { ConsoleAPI } = ChromeUtils.import("resource://gre/modules/Console.jsm"); -// Usually the backend loader gets loaded via profile-after-change, but in case -// a calendar component hooks in earlier, its very likely it will use calUtils. -// Getting the service here will load if its not already loaded -Cc["@mozilla.org/calendar/backend-loader;1"].getService(); - // The calendar console instance var gCalendarConsole = new ConsoleAPI({ prefix: "Calendar", diff --git a/calendar/base/moz.build b/calendar/base/moz.build index a9e3c5d8b3..c8f8be24bd 100644 --- a/calendar/base/moz.build +++ b/calendar/base/moz.build @@ -5,7 +5,6 @@ DIRS = [ "public", - "backend", "src", "modules", "themes", diff --git a/calendar/base/public/calIDateTime.idl b/calendar/base/public/calIDateTime.idl index 98faa30e46..e4da295843 100644 --- a/calendar/base/public/calIDateTime.idl +++ b/calendar/base/public/calIDateTime.idl @@ -226,12 +226,3 @@ interface calIDateTime : nsISupports */ attribute ACString icalString; }; - -/** Libical specific interfaces */ - -[ptr] native icaltimetypeptr(struct icaltimetype); -[builtinclass,scriptable,uuid(04139dff-a6f0-446d-9aec-2062df887ef2)] -interface calIDateTimeLibical : calIDateTime -{ - [noscript,notxpcom] void toIcalTime(in icaltimetypeptr itt); -}; diff --git a/calendar/base/public/calIDuration.idl b/calendar/base/public/calIDuration.idl index 65f944aa0a..a6bb00ed79 100644 --- a/calendar/base/public/calIDuration.idl +++ b/calendar/base/public/calIDuration.idl @@ -102,12 +102,3 @@ interface calIDuration : nsISupports */ attribute ACString icalString; }; - -/** Libical specific interfaces */ - -[ptr] native icaldurationtypeptr(struct icaldurationtype); -[builtinclass,scriptable,uuid(f5e1c987-e722-4dec-bf91-93d4062b504a)] -interface calIDurationLibical : calIDuration -{ - [noscript,notxpcom] void toIcalDuration(in icaldurationtypeptr idt); -}; diff --git a/calendar/base/public/calIICSService.idl b/calendar/base/public/calIICSService.idl index 4161e79a85..01aa3a72cf 100644 --- a/calendar/base/public/calIICSService.idl +++ b/calendar/base/public/calIICSService.idl @@ -154,7 +154,7 @@ interface calIIcalProperty : nsISupports { /** * The whole property as an ical string. - * @exception Any libical error will be thrown as an calIError::ICS_ error. + * @exception Any error will be thrown as an calIError::ICS_ error. */ readonly attribute AUTF8String icalString; @@ -251,28 +251,4 @@ interface calIICSService : nsISupports calIIcalComponent createIcalComponent(in AUTF8String kind); calIIcalProperty createIcalProperty(in AUTF8String kind); calIIcalProperty createIcalPropertyFromString(in AUTF8String str); - /* I wish I could write this function atop libical! - boolean isLegalParameterValue(in AUTF8String paramKind, - in AUTF8String paramValue); - */ -}; - -/** Libical specific interfaces */ - -[ptr] native icalpropertyptr(struct icalproperty_impl); -[ptr] native icalcomponentptr(struct icalcomponent_impl); -[ptr] native icaltimezoneptr(struct _icaltimezone); - -[builtinclass,scriptable,uuid(d2fc0264-191e-435e-8ef2-b2ab1fa81ca9)] -interface calIIcalComponentLibical : calIIcalComponent -{ - [noscript,notxpcom] icalcomponentptr getLibicalComponent(); - [noscript,notxpcom] icaltimezoneptr getLibicalTimezone(); -}; - -[builtinclass,scriptable,uuid(e0b9067f-0a53-4724-9c69-63599681877e)] -interface calIIcalPropertyLibical : calIIcalProperty -{ - [noscript,notxpcom] icalpropertyptr getLibicalProperty(); - [noscript,notxpcom] icalcomponentptr getLibicalComponent(); }; diff --git a/calendar/base/public/calIPeriod.idl b/calendar/base/public/calIPeriod.idl index 64de0b8ff1..d11f0ebdb3 100644 --- a/calendar/base/public/calIPeriod.idl +++ b/calendar/base/public/calIPeriod.idl @@ -56,12 +56,3 @@ interface calIPeriod : nsISupports */ attribute ACString icalString; }; - -/** Libical specific interfaces */ - -[ptr] native icalperiodtypeptr(struct icalperiodtype); -[builtinclass,scriptable,uuid(04ee525f-96db-4731-8d61-688e754df24f)] -interface calIPeriodLibical : calIPeriod -{ - [noscript,notxpcom] void toIcalPeriod(in icalperiodtypeptr idt); -}; diff --git a/calendar/base/public/calIRecurrenceRule.idl b/calendar/base/public/calIRecurrenceRule.idl index 701c9859a5..8694036a8c 100644 --- a/calendar/base/public/calIRecurrenceRule.idl +++ b/calendar/base/public/calIRecurrenceRule.idl @@ -24,10 +24,6 @@ interface calIRecurrenceRule : calIRecurrenceItem attribute AUTF8String type; // repeat every N of type - // XXX Please mind an implementation detail: - // the underlying libical currently only supports C short values for interval, - // i.e. commonly 16 bits on most platforms, thus please use only 0 <= interval <= 0x7fff. - // It is open whether we go with IDL short here or tweak libical to support at least 32 bits. attribute long interval; // These two are mutually exclusive; whichever is set diff --git a/calendar/base/backend/icaljs/calDateTime.js b/calendar/base/src/CalDateTime.jsm similarity index 79% rename from calendar/base/backend/icaljs/calDateTime.js rename to calendar/base/src/CalDateTime.jsm index 43a3ce20f7..1f66280557 100644 --- a/calendar/base/backend/icaljs/calDateTime.js +++ b/calendar/base/src/CalDateTime.jsm @@ -2,18 +2,22 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* import-globals-from calICALJSComponents.js */ +var EXPORTED_SYMBOLS = ["CalDateTime"]; -var { ICAL, unwrap, unwrapSetter } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm"); +const { ICAL, unwrap, unwrapSetter } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm"); + +const lazy = {}; +ChromeUtils.defineModuleGetter(lazy, "CalDuration", "resource:///modules/CalDuration.jsm"); +ChromeUtils.defineModuleGetter(lazy, "CalTimezone", "resource:///modules/CalTimezone.jsm"); var UNIX_TIME_TO_PRTIME = 1000000; -function calDateTime(innerObject) { +function CalDateTime(innerObject) { this.wrappedJSObject = this; this.innerObject = innerObject || ICAL.Time.epochTime.clone(); } -calDateTime.prototype = { +CalDateTime.prototype = { QueryInterface: ChromeUtils.generateQI(["calIDateTime"]), classID: Components.ID("{36783242-ec94-4d8a-9248-d2679edd55b9}"), @@ -22,7 +26,7 @@ calDateTime.prototype = { this.isMutable = false; }, clone() { - return new calDateTime(this.innerObject.clone()); + return new CalDateTime(this.innerObject.clone()); }, isValid: true, @@ -78,7 +82,7 @@ calDateTime.prototype = { }, get timezone() { - return new calICALJSTimezone(this.innerObject.zone); + return new lazy.CalTimezone(this.innerObject.zone); }, set timezone(rawval) { unwrapSetter( @@ -134,7 +138,7 @@ calDateTime.prototype = { }, getInTimezone: unwrap(ICAL.Timezone, function(val) { - return new calDateTime(this.innerObject.convertToZone(val)); + return new CalDateTime(this.innerObject.convertToZone(val)); }), addDuration: unwrap(ICAL.Duration, function(val) { @@ -142,7 +146,7 @@ calDateTime.prototype = { }), subtractDate: unwrap(ICAL.Time, function(val) { - return new calDuration(this.innerObject.subtractDateTz(val)); + return new lazy.CalDuration(this.innerObject.subtractDateTz(val)); }), compare: unwrap(ICAL.Time, function(val) { @@ -165,22 +169,22 @@ calDateTime.prototype = { }), get startOfWeek() { - return new calDateTime(this.innerObject.startOfWeek()); + return new CalDateTime(this.innerObject.startOfWeek()); }, get endOfWeek() { - return new calDateTime(this.innerObject.endOfWeek()); + return new CalDateTime(this.innerObject.endOfWeek()); }, get startOfMonth() { - return new calDateTime(this.innerObject.startOfMonth()); + return new CalDateTime(this.innerObject.startOfMonth()); }, get endOfMonth() { - return new calDateTime(this.innerObject.endOfMonth()); + return new CalDateTime(this.innerObject.endOfMonth()); }, get startOfYear() { - return new calDateTime(this.innerObject.startOfYear()); + return new CalDateTime(this.innerObject.startOfYear()); }, get endOfYear() { - return new calDateTime(this.innerObject.endOfYear()); + return new CalDateTime(this.innerObject.endOfYear()); }, get icalString() { diff --git a/calendar/base/backend/icaljs/calDuration.js b/calendar/base/src/CalDuration.jsm similarity index 89% rename from calendar/base/backend/icaljs/calDuration.js rename to calendar/base/src/CalDuration.jsm index 4e43eb6386..fb5cb514d0 100644 --- a/calendar/base/backend/icaljs/calDuration.js +++ b/calendar/base/src/CalDuration.jsm @@ -2,14 +2,16 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -var { ICAL, unwrap } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm"); +var EXPORTED_SYMBOLS = ["CalDuration"]; -function calDuration(innerObject) { +const { ICAL, unwrap } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm"); + +function CalDuration(innerObject) { this.innerObject = innerObject || new ICAL.Duration(); this.wrappedJSObject = this; } -calDuration.prototype = { +CalDuration.prototype = { QueryInterface: ChromeUtils.generateQI(["calIDuration"]), classID: Components.ID("{7436f480-c6fc-4085-9655-330b1ee22288}"), @@ -25,7 +27,7 @@ calDuration.prototype = { this.isMutable = false; }, clone() { - return new calDuration(this.innerObject.clone()); + return new CalDuration(this.innerObject.clone()); }, get isNegative() { diff --git a/calendar/base/backend/icaljs/calICSService.js b/calendar/base/src/CalICSService.jsm similarity index 88% rename from calendar/base/backend/icaljs/calICSService.js rename to calendar/base/src/CalICSService.jsm index 62229731da..3c02f14518 100644 --- a/calendar/base/backend/icaljs/calICSService.js +++ b/calendar/base/src/CalICSService.jsm @@ -2,19 +2,24 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* import-globals-from calICALJSComponents.js */ +var EXPORTED_SYMBOLS = ["CalIcalProperty", "CalICSService"]; -var { ICAL, unwrapSetter, unwrapSingle, wrapGetter } = ChromeUtils.import( +const { ICAL, unwrapSetter, unwrapSingle, wrapGetter } = ChromeUtils.import( "resource:///modules/calendar/Ical.jsm" ); -var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); +const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); -function calIcalProperty(innerObject) { +const lazy = {}; +ChromeUtils.defineModuleGetter(lazy, "CalDateTime", "resource:///modules/CalDateTime.jsm"); +ChromeUtils.defineModuleGetter(lazy, "CalDuration", "resource:///modules/CalDuration.jsm"); +ChromeUtils.defineModuleGetter(lazy, "CalTimezone", "resource:///modules/CalTimezone.jsm"); + +function CalIcalProperty(innerObject) { this.innerObject = innerObject || new ICAL.Property(); this.wrappedJSObject = this; } -calIcalProperty.prototype = { +CalIcalProperty.prototype = { QueryInterface: ChromeUtils.generateQI(["calIIcalProperty"]), classID: Components.ID("{423ac3f0-f612-48b3-953f-47f7f8fd705b}"), @@ -92,7 +97,7 @@ calIcalProperty.prototype = { let val = this.innerObject.getFirstValue(); let isIcalTime = val && typeof val == "object" && "icalclass" in val && val.icalclass == "icaltime"; - return isIcalTime ? new calDateTime(val) : null; + return isIcalTime ? new lazy.CalDateTime(val) : null; }, set valueAsDatetime(rawval) { unwrapSetter( @@ -107,7 +112,7 @@ calIcalProperty.prototype = { ) { this.innerObject.setParameter("TZID", val.zone.tzid); if (this.parent) { - let tzref = wrapGetter(calICALJSTimezone, val.zone); + let tzref = wrapGetter(lazy.CalTimezone, val.zone); this.parent.addTimezoneReference(tzref); } } else { @@ -385,67 +390,67 @@ calIcalComponent.prototype = { val.zone != ICAL.Timezone.localTimezone ) { prop.setParameter("TZID", val.zone.tzid); - this.addTimezoneReference(wrapGetter(calICALJSTimezone, val.zone)); + this.addTimezoneReference(wrapGetter(lazy.CalTimezone, val.zone)); } else { prop.removeParameter("TZID"); } }, get startTime() { - return wrapGetter(calDateTime, this.innerObject.getFirstPropertyValue("dtstart")); + return wrapGetter(lazy.CalDateTime, this.innerObject.getFirstPropertyValue("dtstart")); }, set startTime(val) { unwrapSetter(ICAL.Time, val, this._setTimeAttr.bind(this, "dtstart"), this); }, get endTime() { - return wrapGetter(calDateTime, this.innerObject.getFirstPropertyValue("dtend")); + return wrapGetter(lazy.CalDateTime, this.innerObject.getFirstPropertyValue("dtend")); }, set endTime(val) { unwrapSetter(ICAL.Time, val, this._setTimeAttr.bind(this, "dtend"), this); }, get duration() { - return wrapGetter(calDuration, this.innerObject.getFirstPropertyValue("duration")); + return wrapGetter(lazy.CalDuration, this.innerObject.getFirstPropertyValue("duration")); }, get dueTime() { - return wrapGetter(calDateTime, this.innerObject.getFirstPropertyValue("due")); + return wrapGetter(lazy.CalDateTime, this.innerObject.getFirstPropertyValue("due")); }, set dueTime(val) { unwrapSetter(ICAL.Time, val, this._setTimeAttr.bind(this, "due"), this); }, get stampTime() { - return wrapGetter(calDateTime, this.innerObject.getFirstPropertyValue("dtstamp")); + return wrapGetter(lazy.CalDateTime, this.innerObject.getFirstPropertyValue("dtstamp")); }, set stampTime(val) { unwrapSetter(ICAL.Time, val, this._setTimeAttr.bind(this, "dtstamp"), this); }, get createdTime() { - return wrapGetter(calDateTime, this.innerObject.getFirstPropertyValue("created")); + return wrapGetter(lazy.CalDateTime, this.innerObject.getFirstPropertyValue("created")); }, set createdTime(val) { unwrapSetter(ICAL.Time, val, this._setTimeAttr.bind(this, "created"), this); }, get completedTime() { - return wrapGetter(calDateTime, this.innerObject.getFirstPropertyValue("completed")); + return wrapGetter(lazy.CalDateTime, this.innerObject.getFirstPropertyValue("completed")); }, set completedTime(val) { unwrapSetter(ICAL.Time, val, this._setTimeAttr.bind(this, "completed"), this); }, get lastModified() { - return wrapGetter(calDateTime, this.innerObject.getFirstPropertyValue("last-modified")); + return wrapGetter(lazy.CalDateTime, this.innerObject.getFirstPropertyValue("last-modified")); }, set lastModified(val) { unwrapSetter(ICAL.Time, val, this._setTimeAttr.bind(this, "last-modified"), this); }, get recurrenceId() { - return wrapGetter(calDateTime, this.innerObject.getFirstPropertyValue("recurrence-id")); + return wrapGetter(lazy.CalDateTime, this.innerObject.getFirstPropertyValue("recurrence-id")); }, set recurrenceId(val) { unwrapSetter(ICAL.Time, val, this._setTimeAttr.bind(this, "recurrence-id"), this); @@ -486,10 +491,10 @@ calIcalComponent.prototype = { let thisprop = new ICAL.Property(prop.toJSON(), prop.parent); thisprop.removeAllValues(); thisprop.setValue(devil); - yield new calIcalProperty(thisprop); + yield new CalIcalProperty(thisprop); } } else { - yield new calIcalProperty(prop); + yield new CalIcalProperty(prop); } } })(); @@ -558,11 +563,11 @@ calIcalComponent.prototype = { }, }; -function calICSService() { +function CalICSService() { this.wrappedJSObject = this; } -calICSService.prototype = { +CalICSService.prototype = { QueryInterface: ChromeUtils.generateQI(["calIICSService"]), classID: Components.ID("{c61cb903-4408-41b3-bc22-da0b27efdfe1}"), @@ -585,22 +590,22 @@ calICSService.prototype = { rc = event.data.rc; icalComp = new calIcalComponent(new ICAL.Component(event.data.data)); if (!Components.isSuccessCode(rc)) { - cal.ERROR("[calICSService] Error in parser worker: " + event.data); + cal.ERROR("[CalICSService] Error in parser worker: " + event.data); } } catch (e) { - cal.ERROR("[calICSService] Exception parsing item: " + e); + cal.ERROR("[CalICSService] Exception parsing item: " + e); } listener.onParsingComplete(rc, icalComp); }; worker.onerror = function(event) { - cal.ERROR("[calICSService] Error in parser worker: " + event.message); + cal.ERROR("[CalICSService] Error in parser worker: " + event.message); listener.onParsingComplete(Cr.NS_ERROR_FAILURE, null); }; worker.postMessage(serialized); } catch (e) { // If an error occurs above, the calling code will hang. Catch the exception just in case - cal.ERROR("[calICSService] Error starting parsing worker: " + e); + cal.ERROR("[CalICSService] Error starting parsing worker: " + e); listener.onParsingComplete(Cr.NS_ERROR_FAILURE, null); } }, @@ -610,10 +615,10 @@ calICSService.prototype = { }, createIcalProperty(kind) { - return new calIcalProperty(new ICAL.Property(kind.toLowerCase())); + return new CalIcalProperty(new ICAL.Property(kind.toLowerCase())); }, createIcalPropertyFromString(str) { - return new calIcalProperty(ICAL.Property.fromString(str.trim(), ICAL.design.icalendar)); + return new CalIcalProperty(ICAL.Property.fromString(str.trim(), ICAL.design.icalendar)); }, }; diff --git a/calendar/base/backend/icaljs/calPeriod.js b/calendar/base/src/CalPeriod.jsm similarity index 70% rename from calendar/base/backend/icaljs/calPeriod.js rename to calendar/base/src/CalPeriod.jsm index 59c406e1d4..e93e20e7ef 100644 --- a/calendar/base/backend/icaljs/calPeriod.js +++ b/calendar/base/src/CalPeriod.jsm @@ -2,18 +2,22 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* import-globals-from calICALJSComponents.js */ +var EXPORTED_SYMBOLS = ["CalPeriod"]; -var { ICAL, unwrapSetter, wrapGetter } = ChromeUtils.import( +const { ICAL, unwrapSetter, wrapGetter } = ChromeUtils.import( "resource:///modules/calendar/Ical.jsm" ); -function calPeriod(innerObject) { +const lazy = {}; +ChromeUtils.defineModuleGetter(lazy, "CalDateTime", "resource:///modules/CalDateTime.jsm"); +ChromeUtils.defineModuleGetter(lazy, "CalDuration", "resource:///modules/CalDuration.jsm"); + +function CalPeriod(innerObject) { this.innerObject = innerObject || new ICAL.Period({}); this.wrappedJSObject = this; } -calPeriod.prototype = { +CalPeriod.prototype = { QueryInterface: ChromeUtils.generateQI(["calIPeriod"]), classID: Components.ID("{394a281f-7299-45f7-8b1f-cce21258972f}"), @@ -31,11 +35,11 @@ calPeriod.prototype = { this.isMutable = false; }, clone() { - return new calPeriod(this.innerObject.clone()); + return new CalPeriod(this.innerObject.clone()); }, get start() { - return wrapGetter(calDateTime, this.innerObject.start); + return wrapGetter(lazy.CalDateTime, this.innerObject.start); }, set start(rawval) { unwrapSetter( @@ -49,7 +53,7 @@ calPeriod.prototype = { }, get end() { - return wrapGetter(calDateTime, this.innerObject.getEnd()); + return wrapGetter(lazy.CalDateTime, this.innerObject.getEnd()); }, set end(rawval) { unwrapSetter( @@ -66,7 +70,7 @@ calPeriod.prototype = { }, get duration() { - return wrapGetter(calDuration, this.innerObject.getDuration()); + return wrapGetter(lazy.CalDuration, this.innerObject.getDuration()); }, get icalString() { diff --git a/calendar/base/src/CalRecurrenceInfo.jsm b/calendar/base/src/CalRecurrenceInfo.jsm index 1757d97f2a..f778928f48 100644 --- a/calendar/base/src/CalRecurrenceInfo.jsm +++ b/calendar/base/src/CalRecurrenceInfo.jsm @@ -463,10 +463,6 @@ CalRecurrenceInfo.prototype = { }, getPreviousOccurrence(aTime) { - // TODO libical currently does not provide us with easy means of - // getting the previous occurrence. This could be fixed to improve - // performance greatly. Filed as libical feature request 1944020. - // HACK We never know how early an RDATE might be before the actual // recurrence start. Since rangeStart cannot be null for recurrence // items like calIRecurrenceRule, we need to work around by supplying a diff --git a/calendar/base/backend/icaljs/calRecurrenceRule.js b/calendar/base/src/CalRecurrenceRule.jsm similarity index 88% rename from calendar/base/backend/icaljs/calRecurrenceRule.js rename to calendar/base/src/CalRecurrenceRule.jsm index 19b7784de6..1bbdbcb3d2 100644 --- a/calendar/base/backend/icaljs/calRecurrenceRule.js +++ b/calendar/base/src/CalRecurrenceRule.jsm @@ -2,21 +2,25 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* import-globals-from calICALJSComponents.js */ +var EXPORTED_SYMBOLS = ["CalRecurrenceRule"]; -var { ICAL, unwrapSetter, unwrapSingle, wrapGetter } = ChromeUtils.import( +const { ICAL, unwrapSetter, unwrapSingle, wrapGetter } = ChromeUtils.import( "resource:///modules/calendar/Ical.jsm" ); -var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); +const { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); -function calRecurrenceRule(innerObject) { +const lazy = {}; +ChromeUtils.defineModuleGetter(lazy, "CalDateTime", "resource:///modules/CalDateTime.jsm"); +ChromeUtils.defineModuleGetter(lazy, "CalIcalProperty", "resource:///modules/CalICSService.jsm"); + +function CalRecurrenceRule(innerObject) { this.innerObject = innerObject || new ICAL.Recur(); this.wrappedJSObject = this; } var calRecurrenceRuleInterfaces = [Ci.calIRecurrenceRule, Ci.calIRecurrenceItem]; var calRecurrenceRuleClassID = Components.ID("{df19281a-5389-4146-b941-798cb93a7f0d}"); -calRecurrenceRule.prototype = { +CalRecurrenceRule.prototype = { QueryInterface: cal.generateQI(["calIRecurrenceRule", "calIRecurrenceItem"]), classID: calRecurrenceRuleClassID, classInfo: cal.generateCI({ @@ -38,7 +42,7 @@ calRecurrenceRule.prototype = { } }, clone() { - return new calRecurrenceRule(new ICAL.Recur(this.innerObject)); + return new CalRecurrenceRule(new ICAL.Recur(this.innerObject)); }, isNegative: false, // We don't support EXRULE anymore @@ -69,7 +73,7 @@ calRecurrenceRule.prototype = { } aStartTime = unwrapSingle(ICAL.Time, aStartTime); aRecId = unwrapSingle(ICAL.Time, aRecId); - return wrapGetter(calDateTime, this.innerObject.getNextOccurrence(aStartTime, aRecId)); + return wrapGetter(lazy.CalDateTime, this.innerObject.getNextOccurrence(aStartTime, aRecId)); }, getOccurrences(aStartTime, aRangeStart, aRangeEnd, aMaxCount) { @@ -120,7 +124,7 @@ calRecurrenceRule.prototype = { next.zone = aStartTime.zone; } - occurrences.push(new calDateTime(next)); + occurrences.push(new lazy.CalDateTime(next)); if (aMaxCount && occurrences.length >= aMaxCount) { break; @@ -141,7 +145,7 @@ calRecurrenceRule.prototype = { get icalProperty() { let prop = new ICAL.Property("rrule"); prop.setValue(this.innerObject); - return new calIcalProperty(prop); + return new lazy.CalIcalProperty(prop); }, set icalProperty(rawval) { this.ensureMutable(); @@ -184,7 +188,7 @@ calRecurrenceRule.prototype = { get untilDate() { if (this.innerObject.until) { - return new calDateTime(this.innerObject.until); + return new lazy.CalDateTime(this.innerObject.until); } return null; }, diff --git a/calendar/base/src/calTimezone.js b/calendar/base/src/CalTimezone.jsm similarity index 53% rename from calendar/base/src/calTimezone.js rename to calendar/base/src/CalTimezone.jsm index 1d6e138630..1eb9b57010 100644 --- a/calendar/base/src/calTimezone.js +++ b/calendar/base/src/CalTimezone.jsm @@ -2,15 +2,17 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +var EXPORTED_SYMBOLS = ["CalTimezone"]; + var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); var { ICAL } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm"); -function calICALJSTimezone(innerObject) { +function CalTimezone(innerObject) { this.innerObject = innerObject || new ICAL.Timezone(); this.wrappedJSObject = this; } -calICALJSTimezone.prototype = { +CalTimezone.prototype = { QueryInterface: ChromeUtils.generateQI(["calITimezone"]), classID: Components.ID("{6702eb17-a968-4b43-b562-0d0c5f8e9eb5}"), @@ -62,55 +64,3 @@ calICALJSTimezone.prototype = { return this.innerObject.toString(); }, }; - -function calLibicalTimezone(tzid, component, latitude, longitude) { - this.wrappedJSObject = this; - this.tzid = tzid; - this.mComponent = component; - this.mUTC = false; - this.isFloating = false; - this.latitude = latitude; - this.longitude = longitude; -} -calLibicalTimezone.prototype = { - QueryInterface: ChromeUtils.generateQI(["calITimezone"]), - classID: Components.ID("{6702eb17-a968-4b43-b562-0d0c5f8e9eb5}"), - - toString() { - return this.icalComponent ? this.icalComponent.toString() : this.tzid; - }, - - get isUTC() { - return this.mUTC; - }, - - get icalComponent() { - let comp = this.mComponent; - if (comp && typeof comp == "string") { - this.mComponent = cal.icsService - .parseICS("BEGIN:VCALENDAR\r\n" + comp + "\r\nEND:VCALENDAR\r\n", null) - .getFirstSubcomponent("VTIMEZONE"); - } - return this.mComponent; - }, - - get displayName() { - if (this.mDisplayName === undefined) { - try { - let bundle = cal.timezoneService.wrappedJSObject.stringBundle; - this.mDisplayName = bundle.GetStringFromName( - "pref.timezone." + this.tzid.replace(/\//g, ".") - ); - } catch (exc) { - // don't assert here, but gracefully fall back to TZID: - cal.LOG("Timezone property lookup failed! Falling back to " + this.tzid + "\n" + exc); - this.mDisplayName = this.tzid; - } - } - return this.mDisplayName; - }, - - get provider() { - return cal.timezoneService; - }, -}; diff --git a/calendar/base/src/CalTimezoneService.jsm b/calendar/base/src/CalTimezoneService.jsm index f5f813c00f..028d2ad006 100644 --- a/calendar/base/src/CalTimezoneService.jsm +++ b/calendar/base/src/CalTimezoneService.jsm @@ -2,22 +2,15 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -/* import-globals-from calTimezone.js */ - var EXPORTED_SYMBOLS = ["CalTimezoneService"]; var { AppConstants } = ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); var { NetUtil } = ChromeUtils.import("resource://gre/modules/NetUtil.jsm"); -var { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); var { cal } = ChromeUtils.import("resource:///modules/calendar/calUtils.jsm"); var { ICAL, unwrapSingle } = ChromeUtils.import("resource:///modules/calendar/Ical.jsm"); -const lazy = {}; - -XPCOMUtils.defineLazyPreferenceGetter(lazy, "gUseIcaljs", "calendar.icaljs", false); - -Services.scriptloader.loadSubScript("resource:///components/calTimezone.js"); +const { CalTimezone } = ChromeUtils.import("resource:///modules/CalTimezone.jsm"); const TIMEZONE_CHANGED_TOPIC = "default-timezone-changed"; @@ -170,14 +163,7 @@ CalTimezoneService.prototype = { get UTC() { if (!this.mZones.has("UTC")) { - let utc; - if (lazy.gUseIcaljs) { - utc = new calICALJSTimezone(ICAL.Timezone.utcTimezone); - } else { - utc = new calLibicalTimezone("UTC", null, "", ""); - utc.mUTC = true; - } - + let utc = new CalTimezone(ICAL.Timezone.utcTimezone); this.mZones.set("UTC", { zone: utc }); } @@ -186,13 +172,7 @@ CalTimezoneService.prototype = { get floating() { if (!this.mZones.has("floating")) { - let floating; - if (lazy.gUseIcaljs) { - floating = new calICALJSTimezone(ICAL.Timezone.localTimezone); - } else { - floating = new calLibicalTimezone("floating", null, "", ""); - floating.isFloating = true; - } + let floating = new CalTimezone(ICAL.Timezone.localTimezone); this.mZones.set("floating", { zone: floating }); } @@ -229,18 +209,14 @@ CalTimezoneService.prototype = { "\r\n" + timezone.ics.join("\r\n") + "\r\nEND:VTIMEZONE"; - if (lazy.gUseIcaljs) { - timezone.zone = new calICALJSTimezone( - ICAL.Timezone.fromData({ - tzid, - component: ics, - latitude: timezone.latitude, - longitude: timezone.longitude, - }) - ); - } else { - timezone.zone = new calLibicalTimezone(tzid, ics, timezone.latitude, timezone.longitude); - } + timezone.zone = new CalTimezone( + ICAL.Timezone.fromData({ + tzid, + component: ics, + latitude: timezone.latitude, + longitude: timezone.longitude, + }) + ); } } return timezone.zone; diff --git a/calendar/base/backend/icaljs/calICSService-worker.js b/calendar/base/src/calICSService-worker.js similarity index 93% rename from calendar/base/backend/icaljs/calICSService-worker.js rename to calendar/base/src/calICSService-worker.js index 74c9c9dccd..9f0fd8375a 100644 --- a/calendar/base/backend/icaljs/calICSService-worker.js +++ b/calendar/base/src/calICSService-worker.js @@ -7,7 +7,7 @@ */ /* eslint-env worker */ -/* import-globals-from ../../modules/Ical.jsm */ +/* import-globals-from ../modules/Ical.jsm */ var NS_OK = 0; var NS_ERROR_FAILURE = 2147500037; diff --git a/calendar/base/src/components.conf b/calendar/base/src/components.conf index af2bc835fe..d5bd284e79 100644 --- a/calendar/base/src/components.conf +++ b/calendar/base/src/components.conf @@ -53,6 +53,12 @@ Classes = [ "jsm": "resource:///modules/CalCalendarManager.jsm", "constructor": "CalCalendarManager", }, + { + "cid": "{36783242-ec94-4d8a-9248-d2679edd55b9}", + "contract_ids": ["@mozilla.org/calendar/datetime;1"], + "jsm": "resource:///modules/CalDateTime.jsm", + "constructor": "CalDateTime", + }, { "cid": "{8e6799af-e7e9-4e6c-9a82-a2413e86d8c3}", "contract_ids": ["@mozilla.org/calendar/deleted-items-manager;1"], @@ -60,6 +66,12 @@ Classes = [ "constructor": "CalDeletedItems", "categories": {"profile-after-change": "deleted-items-manager"}, }, + { + "cid": "{7436f480-c6fc-4085-9655-330b1ee22288}", + "contract_ids": ["@mozilla.org/calendar/duration;1"], + "jsm": "resource:///modules/CalDuration.jsm", + "constructor": "CalDuration", + }, { "cid": "{974339d5-ab86-4491-aaaf-2b2ca177c12b}", "contract_ids": ["@mozilla.org/calendar/event;1"], @@ -84,12 +96,24 @@ Classes = [ "jsm": "resource:///modules/CalIcsSerializer.jsm", "constructor": "CalIcsSerializer", }, + { + "cid": "{c61cb903-4408-41b3-bc22-da0b27efdfe1}", + "contract_ids": ["@mozilla.org/calendar/ics-service;1"], + "jsm": "resource:///modules/CalICSService.jsm", + "constructor": "CalICSService", + }, { "cid": "{f41392ab-dcad-4bad-818f-b3d1631c4d93}", "contract_ids": ["@mozilla.org/calendar/itip-item;1"], "jsm": "resource:///modules/CalItipItem.jsm", "constructor": "CalItipItem", }, + { + "cid": "{394a281f-7299-45f7-8b1f-cce21258972f}", + "contract_ids": ["@mozilla.org/calendar/period;1"], + "jsm": "resource:///modules/CalPeriod.jsm", + "constructor": "CalPeriod", + }, { "cid": "{1153c73a-39be-46aa-9ba9-656d188865ca}", "contract_ids": ["@mozilla.org/network/protocol;1?name=webcal"], @@ -114,6 +138,12 @@ Classes = [ "jsm": "resource:///modules/CalRecurrenceInfo.jsm", "constructor": "CalRecurrenceInfo", }, + { + "cid": "{df19281a-5389-4146-b941-798cb93a7f0d}", + "contract_ids": ["@mozilla.org/calendar/recurrence-rule;1"], + "jsm": "resource:///modules/CalRecurrenceRule.jsm", + "constructor": "CalRecurrenceRule", + }, { "cid": "{76810fae-abad-4019-917a-08e95d5bbd68}", "contract_ids": ["@mozilla.org/calendar/relation;1"], diff --git a/calendar/base/src/moz.build b/calendar/base/src/moz.build index c773ba8c1d..eadef7b08d 100644 --- a/calendar/base/src/moz.build +++ b/calendar/base/src/moz.build @@ -16,21 +16,27 @@ EXTRA_JS_MODULES += [ "CalAttachment.jsm", "CalAttendee.jsm", "CalCalendarManager.jsm", + "CalDateTime.jsm", "CalDefaultACLManager.jsm", "CalDeletedItems.jsm", + "CalDuration.jsm", "CalEvent.jsm", "CalFreeBusyService.jsm", "CalIcsParser.jsm", "CalIcsSerializer.jsm", + "CalICSService.jsm", "CalItipItem.jsm", "CalMetronome.jsm", "CalMimeConverter.jsm", + "CalPeriod.jsm", "CalProtocolHandler.jsm", "CalReadableStreamFactory.jsm", "CalRecurrenceDate.jsm", "CalRecurrenceInfo.jsm", + "CalRecurrenceRule.jsm", "CalRelation.jsm", "CalStartupService.jsm", + "CalTimezone.jsm", "CalTimezoneService.jsm", "CalTodo.jsm", "CalTransactionManager.jsm", @@ -44,8 +50,8 @@ XPCOM_MANIFESTS += [ # These files go in components so they can be packaged correctly. FINAL_TARGET_FILES.components += [ "calCachedCalendar.js", + "calICSService-worker.js", "calItemBase.js", - "calTimezone.js", ] with Files("**"): diff --git a/calendar/libical/AUTHORS b/calendar/libical/AUTHORS deleted file mode 100644 index 40d3b11e98..0000000000 --- a/calendar/libical/AUTHORS +++ /dev/null @@ -1,6 +0,0 @@ -Eric Busboom -Andrea Campi -Art Cancro [http://www.citadel.org] -Wilfried Goesgens [http://www.citadel.org] -John Gray -Omar Kilani [http://www.rememberthemilk.com] diff --git a/calendar/libical/LICENSE b/calendar/libical/LICENSE deleted file mode 100644 index 9ed264adf9..0000000000 --- a/calendar/libical/LICENSE +++ /dev/null @@ -1,33 +0,0 @@ -Libical is distributed under both the LGPL and the MPL. The MPL -notice, reproduced below, covers the use of either of the licenses. - ----------------------------------------------------------------------- - -The contents of this file are subject to the Mozilla Public License -Version 1.1 (the "License"); you may not use this file except in -compliance with the License. You may obtain a copy of the License at -http://www.mozilla.org/MPL/ - -Software distributed under the License is distributed on an "AS -IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or -implied. See the License for the specific language governing rights -and limitations under the License. - - The Original Code is libical. - - The Initial Developer of the Original Code is Eric Busboom - - All Rights Reserved. - - Contributor(s): See individual source files. - -Alternatively, the contents of this file may be used under the terms -of the LGPL license, in which case the provisions of LGPL License are -applicable instead of those above. If you wish to allow use of your -version of this file only under the terms of the LGPL License and not -to allow others to use your version of this file under the MPL, -indicate your decision by deleting the provisions above and replace -them with the notice and other provisions required by the LGPL -License. If you do not delete the provisions above, a recipient may -use your version of this file under either the MPL or the LGPL -License." diff --git a/calendar/libical/config.h b/calendar/libical/config.h deleted file mode 100644 index 6bbb75817f..0000000000 --- a/calendar/libical/config.h +++ /dev/null @@ -1,24 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* most of the settings will be properly included from mozilla-config.h */ - -/* Define to make icalerror_* calls abort instead of internally signalling an - error */ -#undef ICAL_ERRORS_ARE_FATAL - -/* Define if we want _REENTRANT */ -#define ICAL_REENTRANT - -/* Define to terminate lines with "\n" instead of "\r\n" */ -#undef ICAL_UNIX_NEWLINE - -/* Define to 1 if you DO NOT WANT to see deprecated messages */ -#define NO_WARN_DEPRECATED - -#define PACKAGE_DATA_DIR - -/* Define if you DO NOT WANT to use any zones.tab, neither builtin nor system. - Only UTC will be available then. */ -#define NO_ZONES_TAB diff --git a/calendar/libical/design-data/components.txt b/calendar/libical/design-data/components.txt deleted file mode 100644 index c4736e72b2..0000000000 --- a/calendar/libical/design-data/components.txt +++ /dev/null @@ -1,22 +0,0 @@ -ANY -VAGENDA -VALARM -VCALENDAR -VCAR -VCOMMAND -VEVENT -VFREEBUSY -VJOURNAL -VQUERY -VSCHEDULE -VTIMEZONE -VTODO -X -XAUDIOALARM -XDAYLIGHTSAVINGSTIME -XDISPLAYALARM -XEMAILALARM -XLICINVALID -XMIMEPART -XPROCEDUREALARM -XSTANDARDTIME diff --git a/calendar/libical/design-data/parameters.csv b/calendar/libical/design-data/parameters.csv deleted file mode 100644 index d01647587f..0000000000 --- a/calendar/libical/design-data/parameters.csv +++ /dev/null @@ -1,39 +0,0 @@ -"#Name ","C icalparameter_kind Enum","C Type","Enumeration Values" -"ALTREP","2","const char*", -"CHARSET","3","const char*", -"CN","4","const char*", -"CUTYPE","5","icalparameter_cutype","INDIVIDUAL;GROUP;RESOURCE;ROOM;UNKNOWN" -"DELEGATED-FROM","6","const char*", -"DELEGATED-TO","7","const char*", -"DIR","8","const char*", -"ENCODING","10","icalparameter_encoding","8BIT;BASE64" -"FBTYPE","11","icalparameter_fbtype","FREE;BUSY;BUSY-UNAVAILABLE;BUSY-TENTATIVE" -"FMTTYPE","12","const char*", -"LANGUAGE","14","const char*", -"MEMBER","18","const char*", -"PARTSTAT","20","icalparameter_partstat","NEEDS-ACTION;ACCEPTED;DECLINED;TENTATIVE;DELEGATED;COMPLETED;INPROCESS" -"RANGE","21","icalparameter_range","THISANDPRIOR;THISANDFUTURE" -"RELATED","22","icalparameter_related","START;END" -"RELTYPE","23","icalparameter_reltype","PARENT;CHILD;SIBLING" -"ROLE","24","icalparameter_role","CHAIR;REQ-PARTICIPANT;OPT-PARTICIPANT;NON-PARTICIPANT" -"RSVP","25","icalparameter_rsvp","TRUE;FALSE" -"SENT-BY","26","const char*", -"TZID","27","const char*", -"VALUE","28","icalparameter_value","BINARY;BOOLEAN;DATE;DURATION;FLOAT;INTEGER;PERIOD;RECUR;TEXT;URI;ERROR;DATE-TIME;UTC-OFFSET;CAL-ADDRESS" -"X","29","const char*", -"X-LIC-ERRORTYPE","31","icalparameter_xlicerrortype","COMPONENT-PARSE-ERROR;PROPERTY-PARSE-ERROR;PARAMETER-NAME-PARSE-ERROR;PARAMETER-VALUE-PARSE-ERROR;VALUE-PARSE-ERROR;INVALID-ITIP;UNKNOWN-VCAL-PROP-ERROR;MIME-PARSE-ERROR;VCAL-PROP-PARSE-ERROR" -"X-LIC-COMPARETYPE","30","icalparameter_xliccomparetype","EQUAL;NOTEQUAL;LESS;GREATER;LESSEQUAL;GREATEREQUAL;REGEX;ISNULL;ISNOTNULL" -"#CAP Parameters","Draft 8", -"#this parameter should really be called ACTION, but this conflicts with the ACTION property" -"ACTIONPARAM","1","icalparameter_action","ASK;ABORT" -"ID","13","const char*", -"ENABLE","9","icalparameter_enable","TRUE;FALSE" -"LATENCY","15","const char*", -"LOCAL","16","icalparameter_local","TRUE;FALSE" -"LOCALIZE","17","const char*", -"OPTIONS","19","const char*", -"NO","32",, -"#In practice any unknown paramater that is not an xparam is treated as an ianaparam" -"IANA","33","const char*", -"ANY","0",, -"#NOTE for updaters. Preserve the icalparameter_kind Enum values to aid forward compatibility" diff --git a/calendar/libical/design-data/params-in-prop.txt b/calendar/libical/design-data/params-in-prop.txt deleted file mode 100644 index 8a50e2877f..0000000000 --- a/calendar/libical/design-data/params-in-prop.txt +++ /dev/null @@ -1,57 +0,0 @@ -ACTION VALUE X -ATTACH FMTTYPE ENCODING VALUE X -ATTENDEE CN CUTYPE DELEGATED-FROM DELEGATED-TO DIR LANGUAGE MEMBER PARTSTAT ROLE RSVP SENT-BY RECEIVED-SEQUENCE RECEIVED-DTSTAMP SCHEDULE-STATUS SCHEDULE-AGENT SCHEDULE-FORCE-SEND X -CALSCALE X -CATEGORIES LANGUAGE X -CLASS X -CMD ACTIONPARAM ID LATENCY LOCALIZE OPTIONS X -COMMENT ALTREP LANGUAGE X -COMPLETED X -CONTACT ALTREP LANGUAGE X -CREATED X -DESCRIPTION ALTREP LANGUAGE X -DTEND VALUE TZID X -DTSTAMP X -DTSTART VALUE TZID X -DUE VALUE TZID X -DURATION X -EXDATE VALUE TZID X -EXRULE X -FREEBUSY FBTYPE X -GEO X -LAST-MODIFIED X -LOCATION ALTREP LANGUAGE X -METHOD X -ORGANIZER CN DIR LANGUAGE SENT-BY SCHEDULE-STATUS SCHEDULE-AGENT SCHEDULE-FORCE-SEND X -PERCENT-COMPLETE X -PRIORITY X -PRODID X -RDATE VALUE TZID X -RECURRENCE-ID VALUE RANGE TZID X -RELATED-TO RELTYPE X -REPEAT X -REQUEST-STATUS LANGUAGE X -RESOURCES ALTREP LANGUAGE X -RRULE X -SEQUENCE LOCAL X -STATUS X -SUMMARY ALTREP LANGUAGE X -TRANSP X -TRIGGER ENABLE VALUE RELATED X -TZID X -TZNAME LANGUAGE X -TZOFFSETFROM X -TZOFFSETTO X -TZURL X -UID X -URL X -VERSION X -XPROP LANGUAGE X -X-LIC-ERROR XLICEERRORTYPE X -SCOPE X -MAXRESULTS X -MAXRESULTSSIZE X -QUERY X -QUERYNAME X -TARGET X -EXPAND X diff --git a/calendar/libical/design-data/properties.csv b/calendar/libical/design-data/properties.csv deleted file mode 100644 index 1febb0b313..0000000000 --- a/calendar/libical/design-data/properties.csv +++ /dev/null @@ -1,122 +0,0 @@ -,, -"#Property Name","libical Value type","iCalendar default value" -"ACTION","ACTION","ACTION" -"ALLOW-CONFLICT","TEXT","TEXT" -"ATTACH","ATTACH","URI" -"ATTENDEE","CAL-ADDRESS","CAL-ADDRESS" -"CALSCALE","TEXT","TEXT" -"CATEGORIES","TEXT","TEXT" -"CALID","TEXT","TEXT" -"CARID","TEXT","TEXT" -"CLASS","CLASS","CLASS" -"COMMENT","TEXT","TEXT" -"COMPLETED","DATE-TIME","DATE-TIME" -"CONTACT","TEXT","TEXT" -"CREATED","DATE-TIME","DATE-TIME" -"DECREED","TEXT","TEXT" -"DEFAULT-CHARSET","TEXT","TEXT" -"DEFAULT-LOCALE","TEXT","TEXT" -"DEFAULT-TZID","TEXT","TEXT" -"DESCRIPTION","TEXT","TEXT" -"DTEND","DATE-TIME","DATE-TIME" -"DTSTAMP","DATE-TIME","DATE-TIME" -"DTSTART","DATE-TIME","DATE-TIME" -"DUE","DATE-TIME","DATE-TIME" -"DURATION","DURATION","DURATION" -"EXDATE","DATE-TIME","DATE-TIME" -"EXRULE","RECUR","RECUR" -"FREEBUSY","PERIOD","PERIOD" -"GEO","GEO","GEO" -"LAST-MODIFIED","DATE-TIME","DATE-TIME" -"LOCATION","TEXT","TEXT" -"METHOD","METHOD","METHOD" -"ORGANIZER","CAL-ADDRESS","CAL-ADDRESS" -"OWNER","TEXT","TEXT" -"PERCENT-COMPLETE","INTEGER","INTEGER" -"PRIORITY","INTEGER","INTEGER" -"PRODID","TEXT","TEXT" -"RDATE","DATE-TIME-PERIOD","DATE-TIME" -"RECURRENCE-ID","DATE-TIME","DATE-TIME" -"RELATED-TO","TEXT","TEXT" -"RELCALID","TEXT","TEXT" -"REPEAT","INTEGER","INTEGER" -"REQUEST-STATUS","REQUEST-STATUS","REQUEST-STATUS" -"RESOURCES","TEXT","TEXT" -"RRULE","RECUR","RECUR" -"SEQUENCE","INTEGER","INTEGER" -"STATUS","STATUS","STATUS" -"SUMMARY","TEXT","TEXT" -"TRANSP","TRANSP","TRANSP" -"TRIGGER","TRIGGER","DURATION" -"TZID","TEXT","TEXT" -"TZNAME","TEXT","TEXT" -"TZOFFSETFROM","UTC-OFFSET","UTC-OFFSET" -"TZOFFSETTO","UTC-OFFSET","UTC-OFFSET" -"TZURL","URI","URI" -"UID","TEXT","TEXT" -"URL","URI","URI" -"VERSION","TEXT","TEXT" -"X","X","X" -"SCOPE","TEXT","TEXT" -"MAXRESULTS","INTEGER","INTEGER" -"MAXRESULTSSIZE","INTEGER","INTEGER" -"QUERY","QUERY","QUERY" -"QUERYNAME","TEXT","TEXT" -"EXPAND","INTEGER","INTEGER" -"TARGET","CAL-ADDRESS","CAL-ADDRESS" -"X-LIC-ERROR","TEXT","TEXT" -"X-LIC-CLUSTERCOUNT","STRING","STRING" -"X-LIC-MIMECONTENTTYPE","STRING","STRING" -"X-LIC-MIMECHARSET","STRING","STRING" -"X-LIC-MIMEENCODING","STRING","STRING" -"X-LIC-MIMEOPTINFO","STRING","STRING" -"X-LIC-MIMECID","STRING","STRING" -"X-LIC-MIMEFILENAME","STRING","STRING" -"CALMASTER","TEXT","TEXT" -"X-LIC-CLASS","X-LIC-CLASS","X-LIC-CLASS" -"ANY","NO","NO" -"NO","NO","NO" -"#CAP Properties",, -,"FIXME","Should be BOOLEAN" -"ALLOW-CONFLICT","TEXT","TEXT" -"CALID","TEXT","TEXT" -"CALMASTER","TEXT","TEXT" -"CARID","TEXT","TEXT" -"CMD","CMD","CMD" -"CSID","URI","URI" -"DECREED","TEXT","TEXT" -"DEFAULT-CHARSET","TEXT","TEXT" -"DEFAULT-LOCALE","TEXT","TEXT" -"DEFAULT-TZID","TEXT","TEXT" -"DEFAULT-VCARS","TEXT","TEXT" -,"FIXME","Should be UPN-FILTER" -"DENY","TEXT","TEXT" -,"FIXME","Should be BOOLEAN" -"EXPAND","INTEGER","INTEGER" -,"FIXME","Should be UPN-FILTER" -"GRANT","TEXT","TEXT" -"MAXDATE","DATE-TIME","DATE-TIME" -"MINDATE","DATE-TIME","DATE-TIME" -"NAME","TEXT","TEXT" -"OWNER","TEXT","TEXT" -"PERMISSION","TEXT","TEXT" -"QUERY","QUERY","QUERY" -"QUERYID","TEXT","TEXT" -"RELCALID","TEXT","TEXT" -"RESTRICTION","QUERY","QUERY" -"SCOPE","TEXT","TEXT" -"TARGET","CAL-ADDRESS","CAL-ADDRESS" -"#CAP Properties","These are only allowed in VREPLY", -"CAP-VERSION","TEXT","TEXT" -"CAR-LEVEL","CAR-LEVEL","CAR-LEVEL" -"COMPONENTS","TEXT","TEXT" -"STORES-EXPANDED","TEXT","TEXT" -"DATE-MAX","DATE-TIME","DATE-TIME" -"DATE-MIN","DATE-TIME","DATE-TIME" -"ITIP-VERSION","TEXT","TEXT" -"MAX-COMPONENT-SIZE","INTEGER","INTEGER" -"MULTIPART","TEXT","TEXT" -"QUERY-LEVEL","QUERY-LEVEL","QUERY-LEVEL" -"RECUR-ACCEPTED","TEXT","TEXT" -"RECUR-EXPAND","TEXT","TEXT" -"RECUR-LIMIT","TEXT","TEXT" diff --git a/calendar/libical/design-data/restrictions.csv b/calendar/libical/design-data/restrictions.csv deleted file mode 100644 index bded850694..0000000000 --- a/calendar/libical/design-data/restrictions.csv +++ /dev/null @@ -1,1420 +0,0 @@ -# Method, Target component, Property, Sub-component, Restriction -PUBLISH,VEVENT,NONE,NONE,ONEPLUS -PUBLISH,VEVENT,DTSTAMP,NONE,ONE -PUBLISH,VEVENT,DTSTART,NONE,ONE -PUBLISH,VEVENT,ORGANIZER,NONE,ONE -PUBLISH,VEVENT,SUMMARY,NONE,ONE -PUBLISH,VEVENT,UID,NONE,ONE -PUBLISH,VEVENT,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -PUBLISH,VEVENT,SEQUENCE,NONE,ZEROORONE -PUBLISH,VEVENT,ATTACH,NONE,ZEROPLUS -PUBLISH,VEVENT,CATEGORIES,NONE,ZEROPLUS #Non-standard -PUBLISH,VEVENT,CLASS,NONE,ZEROORONE -PUBLISH,VEVENT,COMMENT,NONE,ZEROORONE -PUBLISH,VEVENT,CONTACT,NONE,ZEROPLUS -PUBLISH,VEVENT,CREATED,NONE,ZEROORONE -PUBLISH,VEVENT,DESCRIPTION,NONE,ZEROORONE -PUBLISH,VEVENT,DTEND,NONE,ONEEXCLUSIVE,no_duration -PUBLISH,VEVENT,DURATION,NONE,ONEEXCLUSIVE,no_dtend -PUBLISH,VEVENT,EXDATE,NONE,ZEROPLUS -PUBLISH,VEVENT,EXRULE,NONE,ZEROPLUS -PUBLISH,VEVENT,GEO,NONE,ZEROORONE -PUBLISH,VEVENT,LASTMODIFIED,NONE,ZEROORONE -PUBLISH,VEVENT,LOCATION,NONE,ZEROORONE -PUBLISH,VEVENT,PRIORITY,NONE,ZEROORONE -PUBLISH,VEVENT,RDATE,NONE,ZEROPLUS -PUBLISH,VEVENT,RELATEDTO,NONE,ZEROPLUS -PUBLISH,VEVENT,RESOURCES,NONE,ZEROORONE -PUBLISH,VEVENT,RRULE,NONE,ZEROPLUS -PUBLISH,VEVENT,STATUS,NONE,ZEROORONE,may_be_tent_conf_cancel -PUBLISH,VEVENT,TRANSP,NONE,ZEROORONE -PUBLISH,VEVENT,URL,NONE,ZEROORONE -PUBLISH,VEVENT,X,NONE,ZEROPLUS -PUBLISH,VEVENT,ATTENDEE,NONE,ZERO -PUBLISH,VEVENT,REQUESTSTATUS,NONE,ZERO -PUBLISH,VEVENT,NONE,VALARM,ZEROPLUS -PUBLISH,VEVENT,NONE,VFREEBUSY,ZERO -PUBLISH,VEVENT,NONE,VJOURNAL,ZERO -PUBLISH,VEVENT,NONE,VTODO,ZERO -PUBLISH,VEVENT,NONE,VTIMEZONE,ZEROPLUS,must_if_tz_ref -PUBLISH,VEVENT,NONE,X,ZEROPLUS -PUBLISH,VEVENT,RELCALID,NONE,ZEROORONE -REQUEST,VEVENT,NONE,NONE,ONEPLUS -REQUEST,VEVENT,ATTENDEE,NONE,ONEPLUS -REQUEST,VEVENT,DTSTAMP,NONE,ONE -REQUEST,VEVENT,DTSTART,NONE,ONE -REQUEST,VEVENT,ORGANIZER,NONE,ONE -REQUEST,VEVENT,SEQUENCE,NONE,ZEROORONE -REQUEST,VEVENT,SUMMARY,NONE,ONE -REQUEST,VEVENT,UID,NONE,ONE -REQUEST,VEVENT,ATTACH,NONE,ZEROPLUS -REQUEST,VEVENT,CATEGORIES,NONE,ZEROPLUS #Non-standard -REQUEST,VEVENT,CLASS,NONE,ZEROORONE -REQUEST,VEVENT,COMMENT,NONE,ZEROORONE -REQUEST,VEVENT,CONTACT,NONE,ZEROPLUS -REQUEST,VEVENT,CREATED,NONE,ZEROORONE -REQUEST,VEVENT,DESCRIPTION,NONE,ZEROORONE -REQUEST,VEVENT,DTEND,NONE,ONEEXCLUSIVE,no_duration -REQUEST,VEVENT,DURATION,NONE,ONEEXCLUSIVE,no_dtend -REQUEST,VEVENT,EXDATE,NONE,ZEROPLUS -REQUEST,VEVENT,EXRULE,NONE,ZEROPLUS -REQUEST,VEVENT,GEO,NONE,ZEROORONE -REQUEST,VEVENT,LASTMODIFIED,NONE,ZEROORONE -REQUEST,VEVENT,LOCATION,NONE,ZEROORONE -REQUEST,VEVENT,PRIORITY,NONE,ZEROORONE -REQUEST,VEVENT,RDATE,NONE,ZEROPLUS -REQUEST,VEVENT,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -REQUEST,VEVENT,RELATEDTO,NONE,ZEROPLUS -REQUEST,VEVENT,REQUESTSTATUS,NONE,ZEROPLUS -REQUEST,VEVENT,RESOURCES,NONE,ZEROORONE -REQUEST,VEVENT,RRULE,NONE,ZEROPLUS -REQUEST,VEVENT,STATUS,NONE,ZEROORONE,may_be_tent_conf -REQUEST,VEVENT,TRANSP,NONE,ZEROORONE -REQUEST,VEVENT,URL,NONE,ZEROORONE -REQUEST,VEVENT,X,NONE,ZEROPLUS -REQUEST,VEVENT,NONE,VALARM,ZEROPLUS -REQUEST,VEVENT,NONE,VTIMEZONE,ZEROPLUS,must_if_tz_ref -REQUEST,VEVENT,NONE,X,ZEROPLUS -REQUEST,VEVENT,NONE,VFREEBUSY,ZERO -REQUEST,VEVENT,NONE,VJOURNAL,ZERO -REQUEST,VEVENT,NONE,VTODO,ZERO -REQUEST,VEVENT,RELCALID,NONE,ZEROORONE -REPLY,VEVENT,NONE,NONE,ONEPLUS -REPLY,VEVENT,ATTENDEE,NONE,ONE -REPLY,VEVENT,DTSTAMP,NONE,ONE -REPLY,VEVENT,ORGANIZER,NONE,ONE -REPLY,VEVENT,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -REPLY,VEVENT,UID,NONE,ONE -REPLY,VEVENT,SEQUENCE,NONE,ZEROORONE -REPLY,VEVENT,ATTACH,NONE,ZEROPLUS -REPLY,VEVENT,CATEGORIES,NONE,ZEROPLUS #Non-standard -REPLY,VEVENT,CLASS,NONE,ZEROORONE -REPLY,VEVENT,COMMENT,NONE,ZEROORONE -REPLY,VEVENT,CONTACT,NONE,ZEROPLUS -REPLY,VEVENT,CREATED,NONE,ZEROORONE -REPLY,VEVENT,DESCRIPTION,NONE,ZEROORONE -REPLY,VEVENT,DTEND,NONE,ONEEXCLUSIVE,no_duration -REPLY,VEVENT,DTSTART,NONE,ZEROORONE -REPLY,VEVENT,DURATION,NONE,ONEEXCLUSIVE,no_dtend -REPLY,VEVENT,EXDATE,NONE,ZEROPLUS -REPLY,VEVENT,EXRULE,NONE,ZEROPLUS -REPLY,VEVENT,GEO,NONE,ZEROORONE -REPLY,VEVENT,LASTMODIFIED,NONE,ZEROORONE -REPLY,VEVENT,LOCATION,NONE,ZEROORONE -REPLY,VEVENT,PRIORITY,NONE,ZEROORONE -REPLY,VEVENT,RDATE,NONE,ZEROPLUS -REPLY,VEVENT,RELATEDTO,NONE,ZEROPLUS -REPLY,VEVENT,RESOURCES,NONE,ZEROORONE -REPLY,VEVENT,REQUESTSTATUS,NONE,ZEROPLUS -REPLY,VEVENT,RRULE,NONE,ZEROPLUS -REPLY,VEVENT,STATUS,NONE,ZEROORONE -REPLY,VEVENT,SUMMARY,NONE,ZEROORONE -REPLY,VEVENT,TRANSP,NONE,ZEROORONE -REPLY,VEVENT,URL,NONE,ZEROORONE -REPLY,VEVENT,X,NONE,ZEROPLUS -REPLY,VEVENT,NONE,VTIMEZONE,ZEROORONE,must_if_tz_ref -REPLY,VEVENT,NONE,X,ZEROPLUS -REPLY,VEVENT,NONE,VALARM,ZERO -REPLY,VEVENT,NONE,VFREEBUSY,ZERO -REPLY,VEVENT,NONE,VJOURNAL,ZERO -REPLY,VEVENT,NONE,VTODO,ZERO -REPLY,VEVENT,RELCALID,NONE,ZEROORONE -ADD,VEVENT,NONE,NONE,ONE -ADD,VEVENT,DTSTAMP,NONE,ONE -ADD,VEVENT,DTSTART,NONE,ONE -ADD,VEVENT,ORGANIZER,NONE,ONE -ADD,VEVENT,SEQUENCE,NONE,ONE -ADD,VEVENT,SUMMARY,NONE,ONE -ADD,VEVENT,UID,NONE,ONE -ADD,VEVENT,ATTACH,NONE,ZEROPLUS -ADD,VEVENT,ATTENDEE,NONE,ZEROPLUS -ADD,VEVENT,CATEGORIES,NONE,ZEROPLUS #Non-standard -ADD,VEVENT,CLASS,NONE,ZEROORONE -ADD,VEVENT,COMMENT,NONE,ZEROORONE -ADD,VEVENT,CONTACT,NONE,ZEROPLUS -ADD,VEVENT,CREATED,NONE,ZEROORONE -ADD,VEVENT,DESCRIPTION,NONE,ZEROORONE -ADD,VEVENT,DTEND,NONE,ONEEXCLUSIVE,no_duration -ADD,VEVENT,DURATION,NONE,ONEEXCLUSIVE,no_dtend -ADD,VEVENT,EXDATE,NONE,ZEROPLUS -ADD,VEVENT,EXRULE,NONE,ZEROPLUS -ADD,VEVENT,GEO,NONE,ZEROORONE -ADD,VEVENT,LASTMODIFIED,NONE,ZEROORONE -ADD,VEVENT,LOCATION,NONE,ZEROORONE -ADD,VEVENT,PRIORITY,NONE,ZEROORONE -ADD,VEVENT,RDATE,NONE,ZEROPLUS -ADD,VEVENT,RELATEDTO,NONE,ZEROPLUS -ADD,VEVENT,RESOURCES,NONE,ZEROORONE -ADD,VEVENT,RRULE,NONE,ZEROPLUS -ADD,VEVENT,STATUS,NONE,ZEROORONE,may_be_tent_conf -ADD,VEVENT,TRANSP,NONE,ZEROORONE -ADD,VEVENT,URL,NONE,ZEROORONE -ADD,VEVENT,X,NONE,ZEROPLUS -ADD,VEVENT,RECURRENCEID,NONE,ZERO,must_be_recurring -ADD,VEVENT,REQUESTSTATUS,NONE,ZERO -ADD,VEVENT,NONE,VALARM,ZEROPLUS -ADD,VEVENT,NONE,VTIMEZONE,ZEROPLUS,must_if_tz_ref -ADD,VEVENT,NONE,X,ZEROPLUS -ADD,VEVENT,NONE,VFREEBUSY,ZERO -ADD,VEVENT,NONE,VTODO,ZERO -ADD,VEVENT,NONE,VJOURNAL,ZERO -ADD,VEVENT,RELCALID,NONE,ZEROORONE -CANCEL,VEVENT,NONE,NONE,ONEPLUS -CANCEL,VEVENT,ATTENDEE,NONE,ZEROPLUS -CANCEL,VEVENT,DTSTAMP,NONE,ONE -CANCEL,VEVENT,ORGANIZER,NONE,ONE -CANCEL,VEVENT,SEQUENCE,NONE,ONE -CANCEL,VEVENT,UID,NONE,ONE -CANCEL,VEVENT,COMMENT,NONE,ZEROORONE -CANCEL,VEVENT,ATTACH,NONE,ZEROPLUS -CANCEL,VEVENT,CATEGORIES,NONE,ZEROPLUS #Non-standard -CANCEL,VEVENT,CLASS,NONE,ZEROORONE -CANCEL,VEVENT,CONTACT,NONE,ZEROPLUS -CANCEL,VEVENT,CREATED,NONE,ZEROORONE -CANCEL,VEVENT,DESCRIPTION,NONE,ZEROORONE -CANCEL,VEVENT,DTEND,NONE,ONEEXCLUSIVE ,no_duration -CANCEL,VEVENT,DTSTART,NONE,ZEROORONE -CANCEL,VEVENT,DURATION,NONE,ONEEXCLUSIVE,no_dtend -CANCEL,VEVENT,EXDATE,NONE,ZEROPLUS -CANCEL,VEVENT,EXRULE,NONE,ZEROPLUS -CANCEL,VEVENT,GEO,NONE,ZEROORONE -CANCEL,VEVENT,LASTMODIFIED,NONE,ZEROORONE -CANCEL,VEVENT,LOCATION,NONE,ZEROORONE -CANCEL,VEVENT,PRIORITY,NONE,ZEROORONE -CANCEL,VEVENT,RDATE,NONE,ZEROPLUS -CANCEL,VEVENT,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -CANCEL,VEVENT,RELATEDTO,NONE,ZEROPLUS -CANCEL,VEVENT,RESOURCES,NONE,ZEROORONE -CANCEL,VEVENT,RRULE,NONE,ZEROPLUS -CANCEL,VEVENT,STATUS,NONE,ZEROORONE,must_be_canceled_no_attendee -CANCEL,VEVENT,SUMMARY,NONE,ZEROORONE -CANCEL,VEVENT,TRANSP,NONE,ZEROORONE -CANCEL,VEVENT,URL,NONE,ZEROORONE -CANCEL,VEVENT,X,NONE,ZEROPLUS -CANCEL,VEVENT,REQUESTSTATUS,NONE,ZERO -CANCEL,VEVENT,NONE,VTIMEZONE,ZEROPLUS,must_if_tz_ref -CANCEL,VEVENT,NONE,X,ZEROPLUS -CANCEL,VEVENT,NONE,VTODO,ZERO -CANCEL,VEVENT,NONE,VJOURNAL,ZERO -CANCEL,VEVENT,NONE,VFREEBUSY,ZERO -CANCEL,VEVENT,NONE,VALARM,ZERO -CANCEL,VEVENT,RELCALID,NONE,ZEROORONE -REFRESH,VEVENT,NONE,NONE,ONE -REFRESH,VEVENT,ATTENDEE,NONE,ONE -REFRESH,VEVENT,DTSTAMP,NONE,ONE -REFRESH,VEVENT,ORGANIZER,NONE,ONE -REFRESH,VEVENT,UID,NONE,ONE -REFRESH,VEVENT,COMMENT,NONE,ZEROORONE -REFRESH,VEVENT,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -REFRESH,VEVENT,X,NONE,ZEROPLUS -REFRESH,VEVENT,ATTACH,NONE,ZERO -REFRESH,VEVENT,CATEGORIES,NONE,ZERO -REFRESH,VEVENT,CLASS,NONE,ZERO -REFRESH,VEVENT,CONTACT,NONE,ZERO -REFRESH,VEVENT,CREATED,NONE,ZERO -REFRESH,VEVENT,DESCRIPTION,NONE,ZERO -REFRESH,VEVENT,DTEND,NONE,ZERO -REFRESH,VEVENT,DTSTART,NONE,ZERO -REFRESH,VEVENT,DURATION,NONE,ZERO -REFRESH,VEVENT,EXDATE,NONE,ZERO -REFRESH,VEVENT,EXRULE,NONE,ZERO -REFRESH,VEVENT,GEO,NONE,ZERO -REFRESH,VEVENT,LASTMODIFIED,NONE,ZERO -REFRESH,VEVENT,LOCATION,NONE,ZERO -REFRESH,VEVENT,PRIORITY,NONE,ZERO -REFRESH,VEVENT,RDATE,NONE,ZERO -REFRESH,VEVENT,RELATEDTO,NONE,ZERO -REFRESH,VEVENT,REQUESTSTATUS,NONE,ZERO -REFRESH,VEVENT,RESOURCES,NONE,ZERO -REFRESH,VEVENT,RRULE,NONE,ZERO -REFRESH,VEVENT,SEQUENCE,NONE,ZERO -REFRESH,VEVENT,STATUS,NONE,ZERO -REFRESH,VEVENT,SUMMARY,NONE,ZERO -REFRESH,VEVENT,TRANSP,NONE,ZERO -REFRESH,VEVENT,URL,NONE,ZERO -REFRESH,VEVENT,NONE,X,ZEROPLUS -REFRESH,VEVENT,NONE,VTODO,ZERO -REFRESH,VEVENT,NONE,VJOURNAL,ZERO -REFRESH,VEVENT,NONE,VFREEBUSY,ZERO -REFRESH,VEVENT,NONE,VTIMEZONE,ZERO,must_if_tz_ref -REFRESH,VEVENT,NONE,VALARM,ZERO -REFRESH,VEVENT,RELCALID,NONE,ZEROORONE -COUNTER,VEVENT,NONE,NONE,ONE -COUNTER,VEVENT,DTSTAMP,NONE,ONE -COUNTER,VEVENT,DTSTART,NONE,ONE -COUNTER,VEVENT,ORGANIZER,NONE,ONE -COUNTER,VEVENT,SEQUENCE,NONE,ONE -COUNTER,VEVENT,SUMMARY,NONE,ONE -COUNTER,VEVENT,UID,NONE,ONE -COUNTER,VEVENT,ATTACH,NONE,ZEROPLUS -COUNTER,VEVENT,ATTENDEE,NONE,ZEROPLUS -COUNTER,VEVENT,CATEGORIES,NONE,ZEROPLUS #Non-standard -COUNTER,VEVENT,CLASS,NONE,ZEROORONE -COUNTER,VEVENT,COMMENT,NONE,ZEROORONE -COUNTER,VEVENT,CONTACT,NONE,ZEROPLUS -COUNTER,VEVENT,CREATED,NONE,ZEROORONE -COUNTER,VEVENT,DESCRIPTION,NONE,ZEROORONE -COUNTER,VEVENT,DTEND,NONE,ONEEXCLUSIVE,no_duration -COUNTER,VEVENT,DURATION,NONE,ONEEXCLUSIVE,no_dtend -COUNTER,VEVENT,EXDATE,NONE,ZEROPLUS -COUNTER,VEVENT,EXRULE,NONE,ZEROPLUS -COUNTER,VEVENT,GEO,NONE,ZEROORONE -COUNTER,VEVENT,LASTMODIFIED,NONE,ZEROORONE -COUNTER,VEVENT,LOCATION,NONE,ZEROORONE -COUNTER,VEVENT,PRIORITY,NONE,ZEROORONE -COUNTER,VEVENT,RDATE,NONE,ZEROPLUS -COUNTER,VEVENT,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -COUNTER,VEVENT,RELATEDTO,NONE,ZEROPLUS -COUNTER,VEVENT,REQUESTSTATUS,NONE,ZEROPLUS -COUNTER,VEVENT,RESOURCES,NONE,ZEROORONE -COUNTER,VEVENT,RRULE,NONE,ZEROPLUS -COUNTER,VEVENT,STATUS,NONE,ZEROORONE,may_be_tent_conf_cancel -COUNTER,VEVENT,TRANSP,NONE,ZEROORONE -COUNTER,VEVENT,URL,NONE,ZEROORONE -COUNTER,VEVENT,X,NONE,ZEROPLUS -COUNTER,VEVENT,NONE,VALARM,ZEROPLUS -COUNTER,VEVENT,NONE,VTIMEZONE,ZEROPLUS,must_if_tz_ref -COUNTER,VEVENT,NONE,X,ZEROPLUS -COUNTER,VEVENT,NONE,VTODO,ZERO -COUNTER,VEVENT,NONE,VJOURNAL,ZERO -COUNTER,VEVENT,NONE,VFREEBUSY,ZERO -COUNTER,VEVENT,RELCALID,NONE,ZEROORONE -DECLINECOUNTER,VEVENT,NONE,NONE,ONE -DECLINECOUNTER,VEVENT,DTSTAMP,NONE,ONE -DECLINECOUNTER,VEVENT,ORGANIZER,NONE,ONE -DECLINECOUNTER,VEVENT,UID,NONE,ONE -DECLINECOUNTER,VEVENT,COMMENT,NONE,ZEROORONE -DECLINECOUNTER,VEVENT,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -DECLINECOUNTER,VEVENT,REQUESTSTATUS,NONE,ZEROPLUS -DECLINECOUNTER,VEVENT,SEQUENCE,NONE,ZERO -DECLINECOUNTER,VEVENT,X,NONE,ZEROPLUS -DECLINECOUNTER,VEVENT,ATTACH,NONE,ZERO -DECLINECOUNTER,VEVENT,ATTENDEE,NONE,ZERO -DECLINECOUNTER,VEVENT,CATEGORIES,NONE,ZERO -DECLINECOUNTER,VEVENT,CLASS,NONE,ZERO -DECLINECOUNTER,VEVENT,CONTACT,NONE,ZERO -DECLINECOUNTER,VEVENT,CREATED,NONE,ZERO -DECLINECOUNTER,VEVENT,DESCRIPTION,NONE,ZERO -DECLINECOUNTER,VEVENT,DTEND,NONE,ZERO -DECLINECOUNTER,VEVENT,DTSTART,NONE,ZERO -DECLINECOUNTER,VEVENT,DURATION,NONE,ZERO -DECLINECOUNTER,VEVENT,EXDATE,NONE,ZERO -DECLINECOUNTER,VEVENT,EXRULE,NONE,ZERO -DECLINECOUNTER,VEVENT,GEO,NONE,ZERO -DECLINECOUNTER,VEVENT,LASTMODIFIED,NONE,ZERO -DECLINECOUNTER,VEVENT,LOCATION,NONE,ZERO -DECLINECOUNTER,VEVENT,PRIORITY,NONE,ZERO -DECLINECOUNTER,VEVENT,RDATE,NONE,ZERO -DECLINECOUNTER,VEVENT,RELATEDTO,NONE,ZERO -DECLINECOUNTER,VEVENT,RESOURCES,NONE,ZERO -DECLINECOUNTER,VEVENT,RRULE,NONE,ZERO -DECLINECOUNTER,VEVENT,STATUS,NONE,ZERO -DECLINECOUNTER,VEVENT,SUMMARY,NONE,ZERO -DECLINECOUNTER,VEVENT,TRANSP,NONE,ZERO -DECLINECOUNTER,VEVENT,URL,NONE,ZERO -DECLINECOUNTER,VEVENT,NONE,X,ZEROPLUS -DECLINECOUNTER,VEVENT,NONE,VTODO,ZERO -DECLINECOUNTER,VEVENT,NONE,VJOURNAL,ZERO -DECLINECOUNTER,VEVENT,NONE,VFREEBUSY,ZERO -DECLINECOUNTER,VEVENT,NONE,VTIMEZONE,ZERO,must_if_tz_ref -DECLINECOUNTER,VEVENT,NONE,VALARM,ZERO -DECLINECOUNTER,VEVENT,RELCALID,NONE,ZEROORONE -PUBLISH,VFREEBUSY,NONE,NONE,ONEPLUS -PUBLISH,VFREEBUSY,DTSTAMP,NONE,ONE -PUBLISH,VFREEBUSY,DTSTART,NONE,ONE -PUBLISH,VFREEBUSY,DTEND,NONE,ONE -PUBLISH,VFREEBUSY,FREEBUSY,NONE,ONEPLUS -PUBLISH,VFREEBUSY,ORGANIZER,NONE,ONE -PUBLISH,VFREEBUSY,COMMENT,NONE,ZEROORONE -PUBLISH,VFREEBUSY,CONTACT,NONE,ZEROPLUS -PUBLISH,VFREEBUSY,X,NONE,ZEROPLUS -PUBLISH,VFREEBUSY,URL,NONE,ZEROORONE -PUBLISH,VFREEBUSY,ATTENDEE,NONE,ZERO -PUBLISH,VFREEBUSY,DURATION,NONE,ZERO -PUBLISH,VFREEBUSY,REQUESTSTATUS,NONE,ZERO -PUBLISH,VFREEBUSY,UID,NONE,ZERO -PUBLISH,VFREEBUSY,NONE,X,ZEROPLUS -PUBLISH,VFREEBUSY,NONE,VEVENT,ZERO -PUBLISH,VFREEBUSY,NONE,VTODO,ZERO -PUBLISH,VFREEBUSY,NONE,VJOURNAL,ZERO -PUBLISH,VFREEBUSY,NONE,VTIMEZONE,ZERO,must_if_tz_ref -PUBLISH,VFREEBUSY,NONE,VALARM,ZERO -REQUEST,VFREEBUSY,NONE,NONE,ONE -REQUEST,VFREEBUSY,ATTENDEE,NONE,ONEPLUS -REQUEST,VFREEBUSY,DTEND,NONE,ONE -REQUEST,VFREEBUSY,DTSTAMP,NONE,ONE -REQUEST,VFREEBUSY,DTSTART,NONE,ONE -REQUEST,VFREEBUSY,ORGANIZER,NONE,ONE -REQUEST,VFREEBUSY,UID,NONE,ONE -REQUEST,VFREEBUSY,COMMENT,NONE,ZEROORONE -REQUEST,VFREEBUSY,CONTACT,NONE,ZEROPLUS -REQUEST,VFREEBUSY,X,NONE,ZEROPLUS -REQUEST,VFREEBUSY,FREEBUSY,NONE,ZERO -REQUEST,VFREEBUSY,DURATION,NONE,ZERO -REQUEST,VFREEBUSY,REQUESTSTATUS,NONE,ZERO -REQUEST,VFREEBUSY,URL,NONE,ZERO -REQUEST,VFREEBUSY,NONE,X,ZEROPLUS -REQUEST,VFREEBUSY,NONE,VALARM,ZERO -REQUEST,VFREEBUSY,NONE,VEVENT,ZERO -REQUEST,VFREEBUSY,NONE,VTODO,ZERO -REQUEST,VFREEBUSY,NONE,VJOURNAL,ZERO -REQUEST,VFREEBUSY,NONE,VTIMEZONE,ZERO -REPLY,VFREEBUSY,NONE,NONE,ONE -REPLY,VFREEBUSY,ATTENDEE,NONE,ONE -REPLY,VFREEBUSY,DTSTAMP,NONE,ONE -REPLY,VFREEBUSY,DTEND,NONE,ONE -REPLY,VFREEBUSY,DTSTART,NONE,ONE -REPLY,VFREEBUSY,FREEBUSY,NONE,ONEPLUS -REPLY,VFREEBUSY,ORGANIZER,NONE,ONE -REPLY,VFREEBUSY,UID,NONE,ONE -REPLY,VFREEBUSY,COMMENT,NONE,ZEROORONE -REPLY,VFREEBUSY,CONTACT,NONE,ZEROPLUS -REPLY,VFREEBUSY,REQUESTSTATUS,NONE,ZEROPLUS -REPLY,VFREEBUSY,URL,NONE,ZEROORONE -REPLY,VFREEBUSY,X,NONE,ZEROPLUS -REPLY,VFREEBUSY,DURATION,NONE,ZERO -REPLY,VFREEBUSY,SEQUENCE,NONE,ZERO -REPLY,VFREEBUSY,NONE,X,ZEROPLUS -REPLY,VFREEBUSY,NONE,VALARM,ZERO -REPLY,VFREEBUSY,NONE,VEVENT,ZERO -REPLY,VFREEBUSY,NONE,VTODO,ZERO -REPLY,VFREEBUSY,NONE,VJOURNAL,ZERO -REPLY,VFREEBUSY,NONE,VTIMEZONE,ZERO -PUBLISH,VTODO,NONE,NONE,ONEPLUS -PUBLISH,VTODO,DTSTAMP,NONE,ONE -PUBLISH,VTODO,DTSTART,NONE,ONE -PUBLISH,VTODO,ORGANIZER,NONE,ONE -PUBLISH,VTODO,PRIORITY,NONE,ONE -PUBLISH,VTODO,SEQUENCE,NONE,ZEROORONE -PUBLISH,VTODO,SUMMARY,NONE,ONE -PUBLISH,VTODO,UID,NONE,ONE -PUBLISH,VTODO,ATTACH,NONE,ZEROPLUS -PUBLISH,VTODO,CATEGORIES,NONE,ZEROPLUS #Non-Standard -PUBLISH,VTODO,CLASS,NONE,ZEROORONE -PUBLISH,VTODO,COMMENT,NONE,ZEROORONE -PUBLISH,VTODO,CONTACT,NONE,ZEROPLUS -PUBLISH,VTODO,CREATED,NONE,ZEROORONE -PUBLISH,VTODO,DESCRIPTION,NONE,ZEROORONE -PUBLISH,VTODO,DUE,NONE,ZEROORONE -PUBLISH,VTODO,DURATION,NONE,ZEROORONE -PUBLISH,VTODO,EXDATE,NONE,ZEROPLUS -PUBLISH,VTODO,EXRULE,NONE,ZEROPLUS -PUBLISH,VTODO,GEO,NONE,ZEROORONE -PUBLISH,VTODO,LASTMODIFIED,NONE,ZEROORONE -PUBLISH,VTODO,LOCATION,NONE,ZEROORONE -PUBLISH,VTODO,PERCENTCOMPLETE,NONE,ZEROORONE -PUBLISH,VTODO,RDATE,NONE,ZEROPLUS -PUBLISH,VTODO,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -PUBLISH,VTODO,RELATEDTO,NONE,ZEROPLUS -PUBLISH,VTODO,RESOURCES,NONE,ZEROORONE -PUBLISH,VTODO,RRULE,NONE,ZEROPLUS -PUBLISH,VTODO,STATUS,NONE,ZEROORONE -PUBLISH,VTODO,URL,NONE,ZEROORONE -PUBLISH,VTODO,X,NONE,ZEROPLUS -PUBLISH,VTODO,ATTENDEE,NONE,ZERO -PUBLISH,VTODO,REQUESTSTATUS,NONE,ZERO -PUBLISH,VTODO,NONE,VTIMEZONE,ZEROPLUS -PUBLISH,VTODO,NONE,VALARM,ZEROPLUS -PUBLISH,VTODO,NONE,X,ZEROPLUS -PUBLISH,VTODO,NONE,VFREEBUSY,ZERO -PUBLISH,VTODO,NONE,VEVENT,ZERO -PUBLISH,VTODO,NONE,VJOURNAL,ZERO -PUBLISH,VTODO,RELCALID,NONE,ZEROORONE -REQUEST,VTODO,NONE,NONE,ONEPLUS -REQUEST,VTODO,ATTENDEE,NONE,ONEPLUS -REQUEST,VTODO,DTSTAMP,NONE,ONE -REQUEST,VTODO,DTSTART,NONE,ONE -REQUEST,VTODO,ORGANIZER,NONE,ONE -REQUEST,VTODO,PRIORITY,NONE,ONE -REQUEST,VTODO,SEQUENCE,NONE,ZEROORONE -REQUEST,VTODO,SUMMARY,NONE,ONE -REQUEST,VTODO,UID,NONE,ONE -REQUEST,VTODO,ATTACH,NONE,ZEROPLUS -REQUEST,VTODO,CATEGORIES,NONE,ZEROPLUS #Non-Standard -REQUEST,VTODO,CLASS,NONE,ZEROORONE -REQUEST,VTODO,COMMENT,NONE,ZEROORONE -REQUEST,VTODO,CONTACT,NONE,ZEROPLUS -REQUEST,VTODO,CREATED,NONE,ZEROORONE -REQUEST,VTODO,DESCRIPTION,NONE,ZEROORONE -REQUEST,VTODO,DUE,NONE,ZEROORONE -REQUEST,VTODO,DURATION,NONE,ZEROORONE -REQUEST,VTODO,EXDATE,NONE,ZEROPLUS -REQUEST,VTODO,EXRULE,NONE,ZEROPLUS -REQUEST,VTODO,GEO,NONE,ZEROORONE -REQUEST,VTODO,LASTMODIFIED,NONE,ZEROORONE -REQUEST,VTODO,LOCATION,NONE,ZEROORONE -REQUEST,VTODO,PERCENTCOMPLETE,NONE,ZEROORONE -REQUEST,VTODO,RDATE,NONE,ZEROPLUS -REQUEST,VTODO,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -REQUEST,VTODO,RELATEDTO,NONE,ZEROPLUS -REQUEST,VTODO,RESOURCES,NONE,ZEROORONE -REQUEST,VTODO,RRULE,NONE,ZEROPLUS -REQUEST,VTODO,STATUS,NONE,ZEROORONE,may_be_comp_need_process -REQUEST,VTODO,URL,NONE,ZEROORONE -REQUEST,VTODO,X,NONE,ZEROPLUS -REQUEST,VTODO,REQUESTSTATUS,NONE,ZERO -REQUEST,VTODO,NONE,VALARM,ZEROPLUS -REQUEST,VTODO,NONE,VTIMEZONE,ZEROPLUS -REQUEST,VTODO,NONE,X,ZEROPLUS -REQUEST,VTODO,NONE,VEVENT,ZERO -REQUEST,VTODO,NONE,VFREEBUSY,ZERO -REQUEST,VTODO,NONE,VJOURNAL,ZERO -REQUEST,VTODO,RELCALID,NONE,ZEROORONE -REPLY,VTODO,NONE,NONE,ONEPLUS -REPLY,VTODO,ATTENDEE,NONE,ONEPLUS -REPLY,VTODO,DTSTAMP,NONE,ONE -REPLY,VTODO,ORGANIZER,NONE,ONE -REPLY,VTODO,REQUESTSTATUS,NONE,ONEPLUS -REPLY,VTODO,UID,NONE,ONE -REPLY,VTODO,ATTACH,NONE,ZEROPLUS -REPLY,VTODO,CATEGORIES,NONE,ZEROPLUS #Non-Standard -REPLY,VTODO,CLASS,NONE,ZEROORONE -REPLY,VTODO,COMMENT,NONE,ZEROORONE -REPLY,VTODO,CONTACT,NONE,ZEROPLUS -REPLY,VTODO,CREATED,NONE,ZEROORONE -REPLY,VTODO,DESCRIPTION,NONE,ZEROORONE -REPLY,VTODO,DTSTART,NONE,ZEROORONE -REPLY,VTODO,DUE,NONE,ZEROORONE -REPLY,VTODO,DURATION,NONE,ZEROORONE -REPLY,VTODO,EXDATE,NONE,ZEROPLUS -REPLY,VTODO,EXRULE,NONE,ZEROPLUS -REPLY,VTODO,GEO,NONE,ZEROORONE -REPLY,VTODO,LASTMODIFIED,NONE,ZEROORONE -REPLY,VTODO,LOCATION,NONE,ZEROORONE -REPLY,VTODO,PERCENTCOMPLETE,NONE,ZEROORONE -REPLY,VTODO,PRIORITY,NONE,ZEROORONE -REPLY,VTODO,RDATE,NONE,ZEROPLUS -REPLY,VTODO,RELATEDTO,NONE,ZEROPLUS -REPLY,VTODO,RESOURCES,NONE,ZEROORONE -REPLY,VTODO,RRULE,NONE,ZEROPLUS -REPLY,VTODO,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -REPLY,VTODO,SEQUENCE,NONE,ZEROORONE -REPLY,VTODO,STATUS,NONE,ZEROORONE -REPLY,VTODO,SUMMARY,NONE,ZEROORONE -REPLY,VTODO,URL,NONE,ZEROORONE -REPLY,VTODO,X,NONE,ZEROPLUS -REPLY,VTODO,NONE,VTIMEZONE,ZEROORONE -REPLY,VTODO,NONE,X,ZEROPLUS -REPLY,VTODO,NONE,VALARM,ZERO -REPLY,VTODO,NONE,VEVENT,ZERO -REPLY,VTODO,NONE,VFREEBUSY,ZERO -REPLY,VTODO,RELCALID,NONE,ZEROORONE -ADD,VTODO,NONE,NONE,ONE -ADD,VTODO,DTSTAMP,NONE,ONE -ADD,VTODO,ORGANIZER,NONE,ONE -ADD,VTODO,PRIORITY,NONE,ONE -ADD,VTODO,SEQUENCE,NONE,ONE -ADD,VTODO,SUMMARY,NONE,ONE -ADD,VTODO,UID,NONE,ONE -ADD,VTODO,ATTACH,NONE,ZEROPLUS -ADD,VTODO,ATTENDEE,NONE,ZEROPLUS -ADD,VTODO,CATEGORIES,NONE,ZEROPLUS -ADD,VTODO,CLASS,NONE,ZEROORONE -ADD,VTODO,COMMENT,NONE,ZEROORONE -ADD,VTODO,CONTACT,NONE,ZEROPLUS -ADD,VTODO,CREATED,NONE,ZEROORONE -ADD,VTODO,DESCRIPTION,NONE,ZEROORONE -ADD,VTODO,DTSTART,NONE,ZEROORONE -ADD,VTODO,DUE,NONE,ZEROORONE -ADD,VTODO,DURATION,NONE,ZEROORONE -ADD,VTODO,EXDATE,NONE,ZEROPLUS -ADD,VTODO,EXRULE,NONE,ZEROPLUS -ADD,VTODO,GEO,NONE,ZEROORONE -ADD,VTODO,LASTMODIFIED,NONE,ZEROORONE -ADD,VTODO,LOCATION,NONE,ZEROORONE -ADD,VTODO,PERCENTCOMPLETE,NONE,ZEROORONE -ADD,VTODO,RDATE,NONE,ZEROPLUS -ADD,VTODO,RELATEDTO,NONE,ZEROPLUS -ADD,VTODO,RESOURCES,NONE,ZEROORONE -ADD,VTODO,RRULE,NONE,ZEROPLUS -ADD,VTODO,STATUS,NONE,ZEROORONE,may_be_comp_need_process -ADD,VTODO,URL,NONE,ZEROORONE -ADD,VTODO,X,NONE,ZEROPLUS -ADD,VTODO,RECURRENCEID,NONE,ZERO,must_be_recurring -ADD,VTODO,REQUESTSTATUS,NONE,ZERO -ADD,VTODO,NONE,VALARM,ZEROPLUS -ADD,VTODO,NONE,VTIMEZONE,ZEROPLUS -ADD,VTODO,NONE,X,ZEROPLUS -ADD,VTODO,NONE,VEVENT,ZERO -ADD,VTODO,NONE,VJOURNAL,ZERO -ADD,VTODO,NONE,VFREEBUSY,ZERO -ADD,VTODO,RELCALID,NONE,ZEROORONE -CANCEL,VTODO,NONE,NONE,ONE -CANCEL,VTODO,ATTENDEE,NONE,ZEROPLUS -CANCEL,VTODO,UID,NONE,ONE -CANCEL,VTODO,DTSTAMP,NONE,ONE -CANCEL,VTODO,ORGANIZER,NONE,ONE -CANCEL,VTODO,SEQUENCE,NONE,ONE -CANCEL,VTODO,ATTACH,NONE,ZEROPLUS -CANCEL,VTODO,CATEGORIES,NONE,ZEROPLUS #Non-Standard -CANCEL,VTODO,CLASS,NONE,ZEROORONE -CANCEL,VTODO,COMMENT,NONE,ZEROORONE -CANCEL,VTODO,CONTACT,NONE,ZEROPLUS -CANCEL,VTODO,CREATED,NONE,ZEROORONE -CANCEL,VTODO,DESCRIPTION,NONE,ZEROORONE -CANCEL,VTODO,DTSTART,NONE,ZEROORONE -CANCEL,VTODO,DUE,NONE,ZEROORONE -CANCEL,VTODO,DURATION,NONE,ZEROORONE -CANCEL,VTODO,EXDATE,NONE,ZEROPLUS -CANCEL,VTODO,EXRULE,NONE,ZEROPLUS -CANCEL,VTODO,GEO,NONE,ZEROORONE -CANCEL,VTODO,LASTMODIFIED,NONE,ZEROORONE -CANCEL,VTODO,LOCATION,NONE,ZEROORONE -CANCEL,VTODO,PERCENTCOMPLETE,NONE,ZEROORONE -CANCEL,VTODO,RDATE,NONE,ZEROPLUS -CANCEL,VTODO,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -CANCEL,VTODO,RELATEDTO,NONE,ZEROPLUS -CANCEL,VTODO,RESOURCES,NONE,ZEROORONE -CANCEL,VTODO,RRULE,NONE,ZEROPLUS -CANCEL,VTODO,PRIORITY,NONE,ZEROORONE -CANCEL,VTODO,STATUS,NONE,ZEROORONE,must_be_canceled_no_attendee -CANCEL,VTODO,URL,NONE,ZEROORONE -CANCEL,VTODO,X,NONE,ZEROPLUS -CANCEL,VTODO,REQUESTSTATUS,NONE,ZERO -CANCEL,VTODO,NONE,VTIMEZONE,ZEROORONE -CANCEL,VTODO,NONE,X,ZEROPLUS -CANCEL,VTODO,NONE,VALARM,ZERO -CANCEL,VTODO,NONE,VEVENT,ZERO -CANCEL,VTODO,NONE,VFREEBUSY,ZERO -CANCEL,VTODO,RELCALID,NONE,ZEROORONE -REFRESH,VTODO,NONE,NONE,ONE -REFRESH,VTODO,ATTENDEE,NONE,ONE -REFRESH,VTODO,DTSTAMP,NONE,ONE -REFRESH,VTODO,UID,NONE,ONE -REFRESH,VTODO,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -REFRESH,VTODO,X,NONE,ZEROPLUS -REFRESH,VTODO,ATTACH,NONE,ZERO -REFRESH,VTODO,CATEGORIES,NONE,ZERO -REFRESH,VTODO,CLASS,NONE,ZERO -REFRESH,VTODO,COMMENT,NONE,ZERO -REFRESH,VTODO,CONTACT,NONE,ZERO -REFRESH,VTODO,CREATED,NONE,ZERO -REFRESH,VTODO,DESCRIPTION,NONE,ZERO -REFRESH,VTODO,DTSTART,NONE,ZERO -REFRESH,VTODO,DUE,NONE,ZERO -REFRESH,VTODO,DURATION,NONE,ZERO -REFRESH,VTODO,EXDATE,NONE,ZERO -REFRESH,VTODO,EXRULE,NONE,ZERO -REFRESH,VTODO,GEO,NONE,ZERO -REFRESH,VTODO,LASTMODIFIED,NONE,ZERO -REFRESH,VTODO,LOCATION,NONE,ZERO -REFRESH,VTODO,ORGANIZER,NONE,ZERO -REFRESH,VTODO,PERCENTCOMPLETE,NONE,ZERO -REFRESH,VTODO,PRIORITY,NONE,ZERO -REFRESH,VTODO,RDATE,NONE,ZERO -REFRESH,VTODO,RELATEDTO,NONE,ZERO -REFRESH,VTODO,REQUESTSTATUS,NONE,ZERO -REFRESH,VTODO,RESOURCES,NONE,ZERO -REFRESH,VTODO,RRULE,NONE,ZERO -REFRESH,VTODO,SEQUENCE,NONE,ZERO -REFRESH,VTODO,STATUS,NONE,ZERO -REFRESH,VTODO,URL,NONE,ZERO -REFRESH,VTODO,NONE,X,ZEROPLUS -REFRESH,VTODO,NONE,VALARM,ZERO -REFRESH,VTODO,NONE,VEVENT,ZERO -REFRESH,VTODO,NONE,VFREEBUSY,ZERO -REFRESH,VTODO,NONE,VTIMEZONE,ZERO -REFRESH,VTODO,RELCALID,NONE,ZEROORONE -COUNTER,VTODO,NONE,NONE,ONE -COUNTER,VTODO,ATTENDEE,NONE,ONEPLUS -COUNTER,VTODO,DTSTAMP,NONE,ONE -COUNTER,VTODO,ORGANIZER,NONE,ONE -COUNTER,VTODO,PRIORITY,NONE,ONE -COUNTER,VTODO,SUMMARY,NONE,ONE -COUNTER,VTODO,UID,NONE,ONE -COUNTER,VTODO,ATTACH,NONE,ZEROPLUS -COUNTER,VTODO,CATEGORIES,NONE,ZEROPLUS #Non-standard -COUNTER,VTODO,CLASS,NONE,ZEROORONE -COUNTER,VTODO,COMMENT,NONE,ZEROORONE -COUNTER,VTODO,CONTACT,NONE,ZEROPLUS -COUNTER,VTODO,CREATED,NONE,ZEROORONE -COUNTER,VTODO,DESCRIPTION,NONE,ZEROORONE -COUNTER,VTODO,DTSTART,NONE,ZEROORONE -COUNTER,VTODO,DUE,NONE,ZEROORONE -COUNTER,VTODO,DURATION,NONE,ZEROORONE -COUNTER,VTODO,EXDATE,NONE,ZEROPLUS -COUNTER,VTODO,EXRULE,NONE,ZEROPLUS -COUNTER,VTODO,GEO,NONE,ZEROORONE -COUNTER,VTODO,LASTMODIFIED,NONE,ZEROORONE -COUNTER,VTODO,LOCATION,NONE,ZEROORONE -COUNTER,VTODO,PERCENTCOMPLETE,NONE,ZEROORONE -COUNTER,VTODO,RDATE,NONE,ZEROPLUS -COUNTER,VTODO,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -COUNTER,VTODO,RELATEDTO,NONE,ZEROPLUS -COUNTER,VTODO,REQUESTSTATUS,NONE,ZEROPLUS -COUNTER,VTODO,RESOURCES,NONE,ZEROORONE -COUNTER,VTODO,RRULE,NONE,ZEROORONE -COUNTER,VTODO,SEQUENCE,NONE,ZEROORONE -COUNTER,VTODO,STATUS,NONE,ZEROORONE,may_be_comp_need_process -COUNTER,VTODO,URL,NONE,ZEROORONE -COUNTER,VTODO,X,NONE,ZEROPLUS -COUNTER,VTODO,NONE,VALARM,ZEROPLUS -COUNTER,VTODO,NONE,VTIMEZONE,ZEROORONE -COUNTER,VTODO,NONE,X,ZEROPLUS -COUNTER,VTODO,NONE,VEVENT,ZERO -COUNTER,VTODO,NONE,VFREEBUSY,ZERO -COUNTER,VTODO,RELCALID,NONE,ZEROORONE -DECLINECOUNTER,VTODO,NONE,NONE,ONE -DECLINECOUNTER,VTODO,ATTENDEE,NONE,ONEPLUS -DECLINECOUNTER,VTODO,DTSTAMP,NONE,ONE -DECLINECOUNTER,VTODO,ORGANIZER,NONE,ONE -DECLINECOUNTER,VTODO,SEQUENCE,NONE,ONE -DECLINECOUNTER,VTODO,UID,NONE,ONE -DECLINECOUNTER,VTODO,ATTACH,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,CATEGORIES,NONE,ZEROPLUS #Non-standard -DECLINECOUNTER,VTODO,CLASS,NONE,ZEROORONE -DECLINECOUNTER,VTODO,COMMENT,NONE,ZEROORONE -DECLINECOUNTER,VTODO,CONTACT,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,CREATED,NONE,ZEROORONE -DECLINECOUNTER,VTODO,DESCRIPTION,NONE,ZEROORONE -DECLINECOUNTER,VTODO,DTSTART,NONE,ZEROORONE -DECLINECOUNTER,VTODO,DUE,NONE,ZEROORONE -DECLINECOUNTER,VTODO,DURATION,NONE,ZEROORONE -DECLINECOUNTER,VTODO,EXDATE,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,EXRULE,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,GEO,NONE,ZEROORONE -DECLINECOUNTER,VTODO,LASTMODIFIED,NONE,ZEROORONE -DECLINECOUNTER,VTODO,LOCATION,NONE,ZEROORONE -DECLINECOUNTER,VTODO,PERCENTCOMPLETE,NONE,ZEROORONE -DECLINECOUNTER,VTODO,PRIORITY,NONE,ZEROORONE -DECLINECOUNTER,VTODO,RDATE,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -DECLINECOUNTER,VTODO,RELATEDTO,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,REQUESTSTATUS,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,RESOURCES,NONE,ZEROORONE -DECLINECOUNTER,VTODO,RRULE,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,STATUS,NONE,ZEROORONE -DECLINECOUNTER,VTODO,URL,NONE,ZEROORONE -DECLINECOUNTER,VTODO,X,NONE,ZEROPLUS -DECLINECOUNTER,VTODO,NONE,VTIMEZONE,ZEROPLUS -DECLINECOUNTER,VTODO,NONE,X,ZEROPLUS -DECLINECOUNTER,VTODO,NONE,VALARM,ZERO -DECLINECOUNTER,VTODO,NONE,VEVENT,ZERO -DECLINECOUNTER,VTODO,NONE,VFREEBUSY,ZERO -DECLINECOUNTER,VTODO,RELCALID,NONE,ZEROORONE -PUBLISH,VJOURNAL,NONE,NONE,ONEPLUS -PUBLISH,VJOURNAL,DESCRIPTION,NONE,ONE -PUBLISH,VJOURNAL,DTSTAMP,NONE,ONE -PUBLISH,VJOURNAL,DTSTART,NONE,ONE -PUBLISH,VJOURNAL,ORGANIZER,NONE,ONE -PUBLISH,VJOURNAL,UID,NONE,ONE -PUBLISH,VJOURNAL,ATTACH,NONE,ZEROPLUS -PUBLISH,VJOURNAL,CATEGORIES,NONE,ZEROPLUS #Non-standard -PUBLISH,VJOURNAL,CLASS,NONE,ZEROORONE -PUBLISH,VJOURNAL,COMMENT,NONE,ZEROORONE -PUBLISH,VJOURNAL,CONTACT,NONE,ZEROPLUS -PUBLISH,VJOURNAL,CREATED,NONE,ZEROORONE -PUBLISH,VJOURNAL,EXDATE,NONE,ZEROPLUS -PUBLISH,VJOURNAL,EXRULE,NONE,ZEROPLUS -PUBLISH,VJOURNAL,LASTMODIFIED,NONE,ZEROORONE -PUBLISH,VJOURNAL,RDATE,NONE,ZEROPLUS -PUBLISH,VJOURNAL,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -PUBLISH,VJOURNAL,RELATEDTO,NONE,ZEROPLUS -PUBLISH,VJOURNAL,RRULE,NONE,ZEROPLUS -PUBLISH,VJOURNAL,SEQUENCE,NONE,ZEROORONE -PUBLISH,VJOURNAL,STATUS,NONE,ZEROORONE,may_be_draft_final_canceled -PUBLISH,VJOURNAL,SUMMARY,NONE,ZEROORONE -PUBLISH,VJOURNAL,URL,NONE,ZEROORONE -PUBLISH,VJOURNAL,X,NONE,ZEROPLUS -PUBLISH,VJOURNAL,ATTENDEE,NONE,ZERO -PUBLISH,VJOURNAL,NONE,VALARM,ZEROPLUS -PUBLISH,VJOURNAL,NONE,VTIMEZONE,ZEROPLUS -PUBLISH,VJOURNAL,NONE,X,ZEROPLUS -PUBLISH,VJOURNAL,NONE,VEVENT,ZERO -PUBLISH,VJOURNAL,NONE,VFREEBUSY,ZERO -PUBLISH,VJOURNAL,NONE,VTODO,ZERO -ADD,VJOURNAL,NONE,NONE,ONE -ADD,VJOURNAL,DESCRIPTION,NONE,ONE -ADD,VJOURNAL,DTSTAMP,NONE,ONE -ADD,VJOURNAL,DTSTART,NONE,ONE -ADD,VJOURNAL,ORGANIZER,NONE,ONE -ADD,VJOURNAL,SEQUENCE,NONE,ONE -ADD,VJOURNAL,UID,NONE,ONE -ADD,VJOURNAL,ATTACH,NONE,ZEROPLUS -ADD,VJOURNAL,CATEGORIES,NONE,ZEROPLUS #Non-standard -ADD,VJOURNAL,CLASS,NONE,ZEROORONE -ADD,VJOURNAL,COMMENT,NONE,ZEROORONE -ADD,VJOURNAL,CONTACT,NONE,ZEROPLUS -ADD,VJOURNAL,CREATED,NONE,ZEROORONE -ADD,VJOURNAL,EXDATE,NONE,ZEROPLUS -ADD,VJOURNAL,EXRULE,NONE,ZEROPLUS -ADD,VJOURNAL,LASTMODIFIED,NONE,ZEROORONE -ADD,VJOURNAL,RDATE,NONE,ZEROPLUS -ADD,VJOURNAL,RELATEDTO,NONE,ZEROPLUS -ADD,VJOURNAL,RRULE,NONE,ZEROPLUS -ADD,VJOURNAL,STATUS,NONE,ZEROORONE -ADD,VJOURNAL,SUMMARY,NONE,ZEROORONE -ADD,VJOURNAL,URL,NONE,ZEROORONE -ADD,VJOURNAL,X,NONE,ZEROPLUS -ADD,VJOURNAL,ATTENDEE,NONE,ZERO -ADD,VJOURNAL,RECURRENCEID,NONE,ZERO -ADD,VJOURNAL,NONE,VALARM,ZEROPLUS -ADD,VJOURNAL,NONE,VTIMEZONE,ZEROORONE -ADD,VJOURNAL,NONE,X,ZEROPLUS -ADD,VJOURNAL,NONE,VEVENT,ZERO -ADD,VJOURNAL,NONE,VFREEBUSY,ZERO -ADD,VJOURNAL,NONE,VTODO,ZERO -CANCEL,VJOURNAL,NONE,NONE,ONEPLUS -CANCEL,VJOURNAL,DTSTAMP,NONE,ONE -CANCEL,VJOURNAL,ORGANIZER,NONE,ONE -CANCEL,VJOURNAL,SEQUENCE,NONE,ONE -CANCEL,VJOURNAL,UID,NONE,ONE -CANCEL,VJOURNAL,ATTACH,NONE,ZEROPLUS -CANCEL,VJOURNAL,ATTENDEE,NONE,ZEROPLUS -CANCEL,VJOURNAL,CATEGORIES,NONE,ZEROPLUS #Non-standard -CANCEL,VJOURNAL,CLASS,NONE,ZEROORONE -CANCEL,VJOURNAL,COMMENT,NONE,ZEROORONE -CANCEL,VJOURNAL,CONTACT,NONE,ZEROPLUS -CANCEL,VJOURNAL,CREATED,NONE,ZEROORONE -CANCEL,VJOURNAL,DESCRIPTION,NONE,ZEROORONE -CANCEL,VJOURNAL,DTSTART,NONE,ZEROORONE -CANCEL,VJOURNAL,EXDATE,NONE,ZEROPLUS -CANCEL,VJOURNAL,EXRULE,NONE,ZEROPLUS -CANCEL,VJOURNAL,LASTMODIFIED,NONE,ZEROORONE -CANCEL,VJOURNAL,RDATE,NONE,ZEROPLUS -CANCEL,VJOURNAL,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -CANCEL,VJOURNAL,RELATEDTO,NONE,ZEROPLUS -CANCEL,VJOURNAL,RRULE,NONE,ZEROPLUS -CANCEL,VJOURNAL,STATUS,NONE,ZEROORONE,must_be_cancel_if_present -CANCEL,VJOURNAL,SUMMARY,NONE,ZEROORONE -CANCEL,VJOURNAL,URL,NONE,ZEROORONE -CANCEL,VJOURNAL,X,NONE,ZEROPLUS -CANCEL,VJOURNAL,REQUESTSTATUS,NONE,ZERO -CANCEL,VJOURNAL,NONE,VTIMEZONE,ZEROPLUS -CANCEL,VJOURNAL,NONE,X,ZEROPLUS -CANCEL,VJOURNAL,NONE,VALARM,ZERO -CANCEL,VJOURNAL,NONE,VEVENT,ZERO -CANCEL,VJOURNAL,NONE,VFREEBUSY,ZERO -CANCEL,VJOURNAL,NONE,VTODO,ZERO -PUBLISH,VAGENDA,NONE,NONE,ONEPLUS -PUBLISH,VAGENDA,CALMASTER,NONE,ONE -PUBLISH,VAGENDA,OWNER,NONE,ZEROORONE -PUBLISH,VAGENDA,RELCALID,NONE,ZEROORONE -PUBLISH,VAGENDA,TZID,NONE,ONE -REQUEST,VAGENDA,NONE,NONE,ONEPLUS -REQUEST,VAGENDA,CALMASTER,NONE,ONE -REQUEST,VAGENDA,OWNER,NONE,ZEROORONE -REQUEST,VAGENDA,RELCALID,NONE,ZEROORONE -REQUEST,VAGENDA,TZID,NONE,ONE -REPLY,VAGENDA,NONE,NONE,ONEPLUS -REPLY,VAGENDA,CALMASTER,NONE,ONE -REPLY,VAGENDA,OWNER,NONE,ZEROORONE -REPLY,VAGENDA,RELCALID,NONE,ZEROORONE -REPLY,VAGENDA,TZID,NONE,ONE -ADD,VAGENDA,NONE,NONE,ONEPLUS -ADD,VAGENDA,CALMASTER,NONE,ONE -ADD,VAGENDA,OWNER,NONE,ZEROORONE -ADD,VAGENDA,RELCALID,NONE,ZEROORONE -ADD,VAGENDA,TZID,NONE,ONE -CANCEL,VAGENDA,NONE,NONE,ONEPLUS -CANCEL,VAGENDA,CALMASTER,NONE,ONE -CANCEL,VAGENDA,OWNER,NONE,ZEROORONE -CANCEL,VAGENDA,RELCALID,NONE,ZEROORONE -CANCEL,VAGENDA,TZID,NONE,ONE -REFRESH,VAGENDA,NONE,NONE,ONEPLUS -REFRESH,VAGENDA,CALMASTER,NONE,ONE -REFRESH,VAGENDA,OWNER,NONE,ZEROORONE -REFRESH,VAGENDA,RELCALID,NONE,ZEROORONE -REFRESH,VAGENDA,TZID,NONE,ONE -COUNTER,VAGENDA,NONE,NONE,ONEPLUS -COUNTER,VAGENDA,CALMASTER,NONE,ONE -COUNTER,VAGENDA,OWNER,NONE,ZEROORONE -COUNTER,VAGENDA,RELCALID,NONE,ZEROORONE -COUNTER,VAGENDA,TZID,NONE,ONE -DECLINECOUNTER,VAGENDA,NONE,NONE,ONEPLUS -DECLINECOUNTER,VAGENDA,CALMASTER,NONE,ONE -DECLINECOUNTER,VAGENDA,OWNER,NONE,ZEROORONE -DECLINECOUNTER,VAGENDA,RELCALID,NONE,ZEROORONE -DECLINECOUNTER,VAGENDA,TZID,NONE,ONE -NONE,VAGENDA,ALLOWCONFLICT,NONE,ONE -NONE,VAGENDA,CALMASTER,NONE,ONE -NONE,VAGENDA,OWNER,NONE,ZEROORONE -NONE,VAGENDA,RELCALID,NONE,ZEROORONE -NONE,VAGENDA,TZID,NONE,ONE -NONE,VAGENDA,DEFAULTCHARSET,NONE,ONE -NONE,VAGENDA,DEFAULTLOCALE,NONE,ONE -NONE,VAGENDA,DEFAULTTZID,NONE,ONE -NONE,VCALENDAR,ACTION,NONE,ZERO -NONE,VCALENDAR,ATTACH,NONE,ZERO -NONE,VCALENDAR,ATTENDEE,NONE,ZERO -NONE,VCALENDAR,RELCALID,NONE,ZEROORONE -NONE,VCALENDAR,CALSCALE,NONE,ZEROORONE -NONE,VCALENDAR,CATEGORIES,NONE,ZERO -NONE,VCALENDAR,CLASS,NONE,ZERO -NONE,VCALENDAR,COMMENT,NONE,ZERO -NONE,VCALENDAR,COMPLETED,NONE,ZERO -NONE,VCALENDAR,CONTACT,NONE,ZERO -NONE,VCALENDAR,CREATED,NONE,ZERO -NONE,VCALENDAR,DESCRIPTION,NONE,ZERO -NONE,VCALENDAR,DTEND,NONE,ZERO -NONE,VCALENDAR,DTSTAMP,NONE,ZERO -NONE,VCALENDAR,DTSTART,NONE,ZERO -NONE,VCALENDAR,DUE,NONE,ZERO -NONE,VCALENDAR,DURATION,NONE,ZERO -NONE,VCALENDAR,EXDATE,NONE,ZERO -NONE,VCALENDAR,EXRULE,NONE,ZERO -NONE,VCALENDAR,FREEBUSY,NONE,ZERO -NONE,VCALENDAR,GEO,NONE,ZERO -NONE,VCALENDAR,LASTMODIFIED,NONE,ZERO -NONE,VCALENDAR,LOCATION,NONE,ZERO -NONE,VCALENDAR,METHOD,NONE,ZEROORONE -NONE,VCALENDAR,ORGANIZER,NONE,ZERO -NONE,VCALENDAR,PERCENTCOMPLETE,NONE,ZERO -NONE,VCALENDAR,PRIORITY,NONE,ZERO -NONE,VCALENDAR,PRODID,NONE,ONE -NONE,VCALENDAR,RDATE,NONE,ZERO -NONE,VCALENDAR,RECURRENCEID,NONE,ZERO -NONE,VCALENDAR,RELATEDTO,NONE,ZERO -NONE,VCALENDAR,REPEAT,NONE,ZERO -NONE,VCALENDAR,REQUESTSTATUS,NONE,ZERO -NONE,VCALENDAR,RESOURCES,NONE,ZERO -NONE,VCALENDAR,RRULE,NONE,ZERO -NONE,VCALENDAR,SEQUENCE,NONE,ZERO -NONE,VCALENDAR,STATUS,NONE,ZERO -NONE,VCALENDAR,SUMMARY,NONE,ZERO -NONE,VCALENDAR,TRANSP,NONE,ZERO -NONE,VCALENDAR,TRIGGER,NONE,ZERO -NONE,VCALENDAR,TZID,NONE,ZERO -NONE,VCALENDAR,TZNAME,NONE,ZERO -NONE,VCALENDAR,TZOFFSETFROM,NONE,ZERO -NONE,VCALENDAR,TZOFFSETTO,NONE,ZERO -NONE,VCALENDAR,TZURL,NONE,ZERO -NONE,VCALENDAR,UID,NONE,ZERO -NONE,VCALENDAR,URL,NONE,ZERO -NONE,VCALENDAR,VERSION,NONE,ONE -NONE,VCALENDAR,X,NONE,ZEROPLUS -NONE,VEVENT,ACTION,NONE,ZERO -NONE,VEVENT,ATTACH,NONE,ZEROPLUS -NONE,VEVENT,ATTENDEE,NONE,ZEROPLUS -NONE,VEVENT,CALSCALE,NONE,ZERO -NONE,VEVENT,CATEGORIES,NONE,ZEROPLUS -NONE,VEVENT,CLASS,NONE,ZEROORONE -NONE,VEVENT,COMMENT,NONE,ZEROPLUS -NONE,VEVENT,COMPLETED,NONE,ZERO -NONE,VEVENT,CONTACT,NONE,ZEROPLUS -NONE,VEVENT,CREATED,NONE,ZEROORONE -NONE,VEVENT,DESCRIPTION,NONE,ZEROORONE -NONE,VEVENT,DTEND,NONE,ONEEXCLUSIVE,no_duration -NONE,VEVENT,DTSTAMP,NONE,ZEROORONE -NONE,VEVENT,DTSTART,NONE,ZEROORONE -NONE,VEVENT,DUE,NONE,ZERO -NONE,VEVENT,DURATION,NONE,ONEEXCLUSIVE,no_dtend -NONE,VEVENT,EXDATE,NONE,ZEROPLUS -NONE,VEVENT,EXRULE,NONE,ZEROPLUS -NONE,VEVENT,FREEBUSY,NONE,ZERO -NONE,VEVENT,GEO,NONE,ZEROORONE -NONE,VEVENT,LASTMODIFIED,NONE,ZEROORONE -NONE,VEVENT,LOCATION,NONE,ZEROORONE -NONE,VEVENT,METHOD,NONE,ZERO -NONE,VEVENT,ORGANIZER,NONE,ZEROORONE -NONE,VEVENT,PERCENTCOMPLETE,NONE,ZERO -NONE,VEVENT,PRIORITY,NONE,ZEROORONE -NONE,VEVENT,PRODID,NONE,ZERO -NONE,VEVENT,RDATE,NONE,ZEROPLUS -NONE,VEVENT,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -NONE,VEVENT,RELATEDTO,NONE,ZEROPLUS -NONE,VEVENT,REPEAT,NONE,ZERO -NONE,VEVENT,REQUESTSTATUS,NONE,ZEROPLUS -NONE,VEVENT,RESOURCES,NONE,ZEROPLUS -NONE,VEVENT,RRULE,NONE,ZEROPLUS -NONE,VEVENT,SEQUENCE,NONE,ZEROORONE -NONE,VEVENT,STATUS,NONE,ZEROORONE -NONE,VEVENT,SUMMARY,NONE,ZEROORONE -NONE,VEVENT,TRANSP,NONE,ZEROORONE -NONE,VEVENT,TRIGGER,NONE,ZERO -NONE,VEVENT,TZID,NONE,ZERO -NONE,VEVENT,TZNAME,NONE,ZERO -NONE,VEVENT,TZOFFSETFROM,NONE,ZERO -NONE,VEVENT,TZOFFSETTO,NONE,ZERO -NONE,VEVENT,TZURL,NONE,ZERO -NONE,VEVENT,UID,NONE,ZEROORONE -NONE,VEVENT,URL,NONE,ZEROORONE -NONE,VEVENT,VERSION,NONE,ZERO -NONE,VEVENT,X,NONE,ZEROPLUS -NONE,VEVENT,RELCALID,NONE,ZEROORONE -NONE,VTODO,ACTION,NONE,ZERO -NONE,VTODO,ATTACH,NONE,ZEROPLUS -NONE,VTODO,ATTENDEE,NONE,ZEROPLUS -NONE,VTODO,CALSCALE,NONE,ZERO -NONE,VTODO,CATEGORIES,NONE,ZEROPLUS -NONE,VTODO,CLASS,NONE,ZEROORONE -NONE,VTODO,COMMENT,NONE,ZEROPLUS -NONE,VTODO,COMPLETED,NONE,ZEROORONE -NONE,VTODO,CONTACT,NONE,ZEROPLUS -NONE,VTODO,CREATED,NONE,ZEROORONE -NONE,VTODO,DESCRIPTION,NONE,ZEROORONE -NONE,VTODO,DTEND,NONE,ZERO -NONE,VTODO,DTSTAMP,NONE,ZEROORONE -NONE,VTODO,DTSTART,NONE,ZEROORONE -NONE,VTODO,DUE,NONE,ONEEXCLUSIVE -NONE,VTODO,DURATION,NONE,ONEEXCLUSIVE -NONE,VTODO,EXDATE,NONE,ZEROPLUS -NONE,VTODO,EXRULE,NONE,ZEROPLUS -NONE,VTODO,FREEBUSY,NONE,ZERO -NONE,VTODO,GEO,NONE,ZEROORONE -NONE,VTODO,LASTMODIFIED,NONE,ZEROORONE -NONE,VTODO,LOCATION,NONE,ZEROORONE -NONE,VTODO,METHOD,NONE,ZERO -NONE,VTODO,ORGANIZER,NONE,ZEROORONE -NONE,VTODO,PERCENTCOMPLETE,NONE,ZEROORONE -NONE,VTODO,PRIORITY,NONE,ZEROORONE -NONE,VTODO,PRODID,NONE,ZERO -NONE,VTODO,RDATE,NONE,ZEROPLUS -NONE,VTODO,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -NONE,VTODO,RELATEDTO,NONE,ZEROPLUS -NONE,VTODO,REPEAT,NONE,ZERO -NONE,VTODO,REQUESTSTATUS,NONE,ZEROPLUS -NONE,VTODO,RESOURCES,NONE,ZEROPLUS -NONE,VTODO,RRULE,NONE,ZEROPLUS -NONE,VTODO,SEQUENCE,NONE,ZEROORONE -NONE,VTODO,STATUS,NONE,ZEROORONE -NONE,VTODO,SUMMARY,NONE,ZEROORONE -NONE,VTODO,TRANSP,NONE,ZERO -NONE,VTODO,TRIGGER,NONE,ZERO -NONE,VTODO,TZID,NONE,ZERO -NONE,VTODO,TZNAME,NONE,ZERO -NONE,VTODO,TZOFFSETFROM,NONE,ZERO -NONE,VTODO,TZOFFSETTO,NONE,ZERO -NONE,VTODO,TZURL,NONE,ZERO -NONE,VTODO,UID,NONE,ZEROORONE -NONE,VTODO,URL,NONE,ZEROORONE -NONE,VTODO,VERSION,NONE,ZERO -NONE,VTODO,X,NONE,ZEROPLUS -NONE,VTODO,RELCALID,NONE,ZEROORONE -NONE,VJOURNAL,ACTION,NONE,ZERO -NONE,VJOURNAL,ATTACH,NONE,ZEROPLUS -NONE,VJOURNAL,ATTENDEE,NONE,ZEROPLUS -NONE,VJOURNAL,CALSCALE,NONE,ZERO -NONE,VJOURNAL,CATEGORIES,NONE,ZEROPLUS -NONE,VJOURNAL,CLASS,NONE,ZEROORONE -NONE,VJOURNAL,COMMENT,NONE,ZEROPLUS -NONE,VJOURNAL,COMPLETED,NONE,ZERO -NONE,VJOURNAL,CONTACT,NONE,ZEROPLUS -NONE,VJOURNAL,CREATED,NONE,ZEROORONE -NONE,VJOURNAL,DESCRIPTION,NONE,ZEROORONE -NONE,VJOURNAL,DTEND,NONE,ZERO -NONE,VJOURNAL,DTSTAMP,NONE,ZEROORONE -NONE,VJOURNAL,DTSTART,NONE,ZEROORONE -NONE,VJOURNAL,DUE,NONE,ONEEXCLUSIVE -NONE,VJOURNAL,DURATION,NONE,ONEEXCLUSIVE -NONE,VJOURNAL,EXDATE,NONE,ZEROPLUS -NONE,VJOURNAL,EXRULE,NONE,ZEROPLUS -NONE,VJOURNAL,FREEBUSY,NONE,ZERO -NONE,VJOURNAL,GEO,NONE,ZERO -NONE,VJOURNAL,LASTMODIFIED,NONE,ZEROORONE -NONE,VJOURNAL,LOCATION,NONE,ZERO -NONE,VJOURNAL,METHOD,NONE,ZERO -NONE,VJOURNAL,ORGANIZER,NONE,ZEROORONE -NONE,VJOURNAL,PERCENTCOMPLETE,NONE,ZERO -NONE,VJOURNAL,PRIORITY,NONE,ZERO -NONE,VJOURNAL,PRODID,NONE,ZERO -NONE,VJOURNAL,RDATE,NONE,ZEROPLUS -NONE,VJOURNAL,RECURRENCEID,NONE,ZEROORONE,must_be_recurring -NONE,VJOURNAL,RELATEDTO,NONE,ZEROPLUS -NONE,VJOURNAL,REPEAT,NONE,ZERO -NONE,VJOURNAL,REQUESTSTATUS,NONE,ZEROPLUS -NONE,VJOURNAL,RESOURCES,NONE,ZERO -NONE,VJOURNAL,RRULE,NONE,ZEROPLUS -NONE,VJOURNAL,SEQUENCE,NONE,ZEROORONE -NONE,VJOURNAL,STATUS,NONE,ZEROORONE -NONE,VJOURNAL,SUMMARY,NONE,ZEROORONE -NONE,VJOURNAL,TRANSP,NONE,ZERO -NONE,VJOURNAL,TRIGGER,NONE,ZERO -NONE,VJOURNAL,TZID,NONE,ZERO -NONE,VJOURNAL,TZNAME,NONE,ZERO -NONE,VJOURNAL,TZOFFSETFROM,NONE,ZERO -NONE,VJOURNAL,TZOFFSETTO,NONE,ZERO -NONE,VJOURNAL,TZURL,NONE,ZERO -NONE,VJOURNAL,UID,NONE,ZEROORONE -NONE,VJOURNAL,URL,NONE,ZEROORONE -NONE,VJOURNAL,VERSION,NONE,ZERO -NONE,VJOURNAL,X,NONE,ZEROPLUS -NONE,VFREEBUSY,ACTION,NONE,ZERO -NONE,VFREEBUSY,ATTACH,NONE,ZERO -NONE,VFREEBUSY,ATTENDEE,NONE,ZEROPLUS -NONE,VFREEBUSY,CALSCALE,NONE,ZERO -NONE,VFREEBUSY,CATEGORIES,NONE,ZERO -NONE,VFREEBUSY,CLASS,NONE,ZERO -NONE,VFREEBUSY,COMMENT,NONE,ZEROPLUS -NONE,VFREEBUSY,COMPLETED,NONE,ZERO -NONE,VFREEBUSY,CONTACT,NONE,ZEROORONE -NONE,VFREEBUSY,CREATED,NONE,ZERO -NONE,VFREEBUSY,DESCRIPTION,NONE,ZERO -NONE,VFREEBUSY,DTEND,NONE,ZEROORONE -NONE,VFREEBUSY,DTSTAMP,NONE,ZERO -NONE,VFREEBUSY,DTSTART,NONE,ZEROORONE -NONE,VFREEBUSY,DUE,NONE,ZERO -NONE,VFREEBUSY,DURATION,NONE,ZEROORONE -NONE,VFREEBUSY,EXDATE,NONE,ZERO -NONE,VFREEBUSY,EXRULE,NONE,ZERO -NONE,VFREEBUSY,FREEBUSY,NONE,ZEROPLUS -NONE,VFREEBUSY,GEO,NONE,ZERO -NONE,VFREEBUSY,LASTMODIFIED,NONE,ZERO -NONE,VFREEBUSY,LOCATION,NONE,ZERO -NONE,VFREEBUSY,METHOD,NONE,ZERO -NONE,VFREEBUSY,ORGANIZER,NONE,ZEROORONE -NONE,VFREEBUSY,PERCENTCOMPLETE,NONE,ZERO -NONE,VFREEBUSY,PRIORITY,NONE,ZERO -NONE,VFREEBUSY,PRODID,NONE,ZERO -NONE,VFREEBUSY,RDATE,NONE,ZERO -NONE,VFREEBUSY,RECURRENCEID,NONE,ZERO -NONE,VFREEBUSY,RELATEDTO,NONE,ZERO -NONE,VFREEBUSY,REPEAT,NONE,ZERO -NONE,VFREEBUSY,REQUESTSTATUS,NONE,ZEROPLUS -NONE,VFREEBUSY,RESOURCES,NONE,ZERO -NONE,VFREEBUSY,RRULE,NONE,ZERO -NONE,VFREEBUSY,SEQUENCE,NONE,ZERO -NONE,VFREEBUSY,STATUS,NONE,ZERO -NONE,VFREEBUSY,SUMMARY,NONE,ZERO -NONE,VFREEBUSY,TRANSP,NONE,ZERO -NONE,VFREEBUSY,TRIGGER,NONE,ZERO -NONE,VFREEBUSY,TZID,NONE,ZERO -NONE,VFREEBUSY,TZNAME,NONE,ZERO -NONE,VFREEBUSY,TZOFFSETFROM,NONE,ZERO -NONE,VFREEBUSY,TZOFFSETTO,NONE,ZERO -NONE,VFREEBUSY,TZURL,NONE,ZERO -NONE,VFREEBUSY,UID,NONE,ZEROORONE -NONE,VFREEBUSY,URL,NONE,ZEROORONE -NONE,VFREEBUSY,VERSION,NONE,ZERO -NONE,VFREEBUSY,X,NONE,ZEROPLUS -NONE,VTIMEZONE,ACTION,NONE,ZERO -NONE,VTIMEZONE,ATTACH,NONE,ZERO -NONE,VTIMEZONE,ATTENDEE,NONE,ZERO -NONE,VTIMEZONE,CALSCALE,NONE,ZERO -NONE,VTIMEZONE,CATEGORIES,NONE,ZERO -NONE,VTIMEZONE,CLASS,NONE,ZERO -NONE,VTIMEZONE,COMMENT,NONE,ZERO -NONE,VTIMEZONE,COMPLETED,NONE,ZERO -NONE,VTIMEZONE,CONTACT,NONE,ZERO -NONE,VTIMEZONE,CREATED,NONE,ZERO -NONE,VTIMEZONE,DESCRIPTION,NONE,ZERO -NONE,VTIMEZONE,DTEND,NONE,ZERO -NONE,VTIMEZONE,DTSTAMP,NONE,ZERO -NONE,VTIMEZONE,DTSTART,NONE,ZERO -NONE,VTIMEZONE,DUE,NONE,ZERO -NONE,VTIMEZONE,DURATION,NONE,ZERO -NONE,VTIMEZONE,EXDATE,NONE,ZERO -NONE,VTIMEZONE,EXRULE,NONE,ZERO -NONE,VTIMEZONE,FREEBUSY,NONE,ZERO -NONE,VTIMEZONE,GEO,NONE,ZERO -NONE,VTIMEZONE,LASTMODIFIED,NONE,ZEROORONE -NONE,VTIMEZONE,LOCATION,NONE,ZERO -NONE,VTIMEZONE,METHOD,NONE,ZERO -NONE,VTIMEZONE,ORGANIZER,NONE,ZERO -NONE,VTIMEZONE,PERCENTCOMPLETE,NONE,ZERO -NONE,VTIMEZONE,PRIORITY,NONE,ZERO -NONE,VTIMEZONE,PRODID,NONE,ZERO -NONE,VTIMEZONE,RDATE,NONE,ZERO -NONE,VTIMEZONE,RECURRENCEID,NONE,ZERO -NONE,VTIMEZONE,RELATEDTO,NONE,ZERO -NONE,VTIMEZONE,REPEAT,NONE,ZERO -NONE,VTIMEZONE,REQUESTSTATUS,NONE,ZERO -NONE,VTIMEZONE,RESOURCES,NONE,ZERO -NONE,VTIMEZONE,RRULE,NONE,ZERO -NONE,VTIMEZONE,SEQUENCE,NONE,ZERO -NONE,VTIMEZONE,STATUS,NONE,ZERO -NONE,VTIMEZONE,SUMMARY,NONE,ZERO -NONE,VTIMEZONE,TRANSP,NONE,ZERO -NONE,VTIMEZONE,TRIGGER,NONE,ZERO -NONE,VTIMEZONE,TZID,NONE,ONE -NONE,VTIMEZONE,TZNAME,NONE,ZERO -NONE,VTIMEZONE,TZOFFSETFROM,NONE,ZERO -NONE,VTIMEZONE,TZOFFSETTO,NONE,ZERO -NONE,VTIMEZONE,TZURL,NONE,ZEROPLUS -NONE,VTIMEZONE,UID,NONE,ZERO -NONE,VTIMEZONE,URL,NONE,ZERO -NONE,VTIMEZONE,VERSION,NONE,ZERO -NONE,VTIMEZONE,X,NONE,ZEROORONE -NONE,VTIMEZONE,NONE,XSTANDARD,ZEROPLUS -NONE,VTIMEZONE,NONE,XDAYLIGHT,ZEROPLUS -NONE,XSTANDARD,ACTION,NONE,ZERO -NONE,XSTANDARD,ATTACH,NONE,ZERO -NONE,XSTANDARD,ATTENDEE,NONE,ZERO -NONE,XSTANDARD,CALSCALE,NONE,ZERO -NONE,XSTANDARD,CATEGORIES,NONE,ZERO -NONE,XSTANDARD,CLASS,NONE,ZERO -NONE,XSTANDARD,COMMENT,NONE,ZEROPLUS -NONE,XSTANDARD,COMPLETED,NONE,ZERO -NONE,XSTANDARD,CONTACT,NONE,ZERO -NONE,XSTANDARD,CREATED,NONE,ZERO -NONE,XSTANDARD,DESCRIPTION,NONE,ZERO -NONE,XSTANDARD,DTEND,NONE,ZERO -NONE,XSTANDARD,DTSTAMP,NONE,ZERO -NONE,XSTANDARD,DTSTART,NONE,ONE -NONE,XSTANDARD,DUE,NONE,ZERO -NONE,XSTANDARD,DURATION,NONE,ZERO -NONE,XSTANDARD,EXDATE,NONE,ZERO -NONE,XSTANDARD,EXRULE,NONE,ZERO -NONE,XSTANDARD,FREEBUSY,NONE,ZERO -NONE,XSTANDARD,GEO,NONE,ZERO -NONE,XSTANDARD,LASTMODIFIED,NONE,ZERO -NONE,XSTANDARD,LOCATION,NONE,ZERO -NONE,XSTANDARD,METHOD,NONE,ZERO -NONE,XSTANDARD,ORGANIZER,NONE,ZERO -NONE,XSTANDARD,PERCENTCOMPLETE,NONE,ZERO -NONE,XSTANDARD,PRIORITY,NONE,ZERO -NONE,XSTANDARD,PRODID,NONE,ZERO -NONE,XSTANDARD,RDATE,NONE,ZEROPLUS -NONE,XSTANDARD,RECURRENCEID,NONE,ZERO -NONE,XSTANDARD,RELATEDTO,NONE,ZERO -NONE,XSTANDARD,REPEAT,NONE,ZERO -NONE,XSTANDARD,REQUESTSTATUS,NONE,ZERO -NONE,XSTANDARD,RESOURCES,NONE,ZERO -NONE,XSTANDARD,RRULE,NONE,ZEROPLUS -NONE,XSTANDARD,SEQUENCE,NONE,ZERO -NONE,XSTANDARD,STATUS,NONE,ZERO -NONE,XSTANDARD,SUMMARY,NONE,ZERO -NONE,XSTANDARD,TRANSP,NONE,ZERO -NONE,XSTANDARD,TRIGGER,NONE,ZERO -NONE,XSTANDARD,TZID,NONE,ZERO -NONE,XSTANDARD,TZNAME,NONE,ZEROPLUS -NONE,XSTANDARD,TZOFFSETFROM,NONE,ONE -NONE,XSTANDARD,TZOFFSETTO,NONE,ONE -NONE,XSTANDARD,TZURL,NONE,ZERO -NONE,XSTANDARD,UID,NONE,ZERO -NONE,XSTANDARD,URL,NONE,ZERO -NONE,XSTANDARD,VERSION,NONE,ZERO -NONE,XSTANDARD,X,NONE,ZEROPLUS -NONE,XDAYLIGHT,ACTION,NONE,ZERO -NONE,XDAYLIGHT,ATTACH,NONE,ZERO -NONE,XDAYLIGHT,ATTENDEE,NONE,ZERO -NONE,XDAYLIGHT,CALSCALE,NONE,ZERO -NONE,XDAYLIGHT,CATEGORIES,NONE,ZERO -NONE,XDAYLIGHT,CLASS,NONE,ZERO -NONE,XDAYLIGHT,COMMENT,NONE,ZEROPLUS -NONE,XDAYLIGHT,COMPLETED,NONE,ZERO -NONE,XDAYLIGHT,CONTACT,NONE,ZERO -NONE,XDAYLIGHT,CREATED,NONE,ZERO -NONE,XDAYLIGHT,DESCRIPTION,NONE,ZERO -NONE,XDAYLIGHT,DTEND,NONE,ZERO -NONE,XDAYLIGHT,DTSTAMP,NONE,ZERO -NONE,XDAYLIGHT,DTSTART,NONE,ONE -NONE,XDAYLIGHT,DUE,NONE,ZERO -NONE,XDAYLIGHT,DURATION,NONE,ZERO -NONE,XDAYLIGHT,EXDATE,NONE,ZERO -NONE,XDAYLIGHT,EXRULE,NONE,ZERO -NONE,XDAYLIGHT,FREEBUSY,NONE,ZERO -NONE,XDAYLIGHT,GEO,NONE,ZERO -NONE,XDAYLIGHT,LASTMODIFIED,NONE,ZERO -NONE,XDAYLIGHT,LOCATION,NONE,ZERO -NONE,XDAYLIGHT,METHOD,NONE,ZERO -NONE,XDAYLIGHT,ORGANIZER,NONE,ZERO -NONE,XDAYLIGHT,PERCENTCOMPLETE,NONE,ZERO -NONE,XDAYLIGHT,PRIORITY,NONE,ZERO -NONE,XDAYLIGHT,PRODID,NONE,ZERO -NONE,XDAYLIGHT,RDATE,NONE,ZEROPLUS -NONE,XDAYLIGHT,RECURRENCEID,NONE,ZERO -NONE,XDAYLIGHT,RELATEDTO,NONE,ZERO -NONE,XDAYLIGHT,REPEAT,NONE,ZERO -NONE,XDAYLIGHT,REQUESTSTATUS,NONE,ZERO -NONE,XDAYLIGHT,RESOURCES,NONE,ZERO -NONE,XDAYLIGHT,RRULE,NONE,ZEROPLUS -NONE,XDAYLIGHT,SEQUENCE,NONE,ZERO -NONE,XDAYLIGHT,STATUS,NONE,ZERO -NONE,XDAYLIGHT,SUMMARY,NONE,ZERO -NONE,XDAYLIGHT,TRANSP,NONE,ZERO -NONE,XDAYLIGHT,TRIGGER,NONE,ZERO -NONE,XDAYLIGHT,TZID,NONE,ZERO -NONE,XDAYLIGHT,TZNAME,NONE,ZEROPLUS -NONE,XDAYLIGHT,TZOFFSETFROM,NONE,ONE -NONE,XDAYLIGHT,TZOFFSETTO,NONE,ONE -NONE,XDAYLIGHT,TZURL,NONE,ZERO -NONE,XDAYLIGHT,UID,NONE,ZERO -NONE,XDAYLIGHT,URL,NONE,ZERO -NONE,XDAYLIGHT,VERSION,NONE,ZERO -NONE,XDAYLIGHT,X,NONE,ZEROPLUS -NONE,XAUDIOALARM,ACTION,NONE,ONE -NONE,XAUDIOALARM,ATTACH,NONE,ZEROORONE -NONE,XAUDIOALARM,ATTENDEE,NONE,ZERO -NONE,XAUDIOALARM,CALSCALE,NONE,ZERO -NONE,XAUDIOALARM,CATEGORIES,NONE,ZERO -NONE,XAUDIOALARM,CLASS,NONE,ZERO -NONE,XAUDIOALARM,COMMENT,NONE,ZERO -NONE,XAUDIOALARM,COMPLETED,NONE,ZERO -NONE,XAUDIOALARM,CONTACT,NONE,ZERO -NONE,XAUDIOALARM,CREATED,NONE,ZERO -NONE,XAUDIOALARM,DESCRIPTION,NONE,ZERO -NONE,XAUDIOALARM,DTEND,NONE,ZERO -NONE,XAUDIOALARM,DTSTAMP,NONE,ZERO -NONE,XAUDIOALARM,DTSTART,NONE,ZERO -NONE,XAUDIOALARM,DUE,NONE,ZERO -NONE,XAUDIOALARM,DURATION,NONE,ONEMUTUAL,must_have_repeat -NONE,XAUDIOALARM,REPEAT,NONE,ONEMUTUAL,must_have_duration -NONE,XAUDIOALARM,EXDATE,NONE,ZERO -NONE,XAUDIOALARM,EXRULE,NONE,ZERO -NONE,XAUDIOALARM,FREEBUSY,NONE,ZERO -NONE,XAUDIOALARM,GEO,NONE,ZERO -NONE,XAUDIOALARM,LASTMODIFIED,NONE,ZERO -NONE,XAUDIOALARM,LOCATION,NONE,ZERO -NONE,XAUDIOALARM,METHOD,NONE,ZERO -NONE,XAUDIOALARM,ORGANIZER,NONE,ZERO -NONE,XAUDIOALARM,PERCENTCOMPLETE,NONE,ZERO -NONE,XAUDIOALARM,PRIORITY,NONE,ZERO -NONE,XAUDIOALARM,PRODID,NONE,ZERO -NONE,XAUDIOALARM,RDATE,NONE,ZERO -NONE,XAUDIOALARM,RECURRENCEID,NONE,ZERO -NONE,XAUDIOALARM,RELATEDTO,NONE,ZERO -NONE,XAUDIOALARM,REQUESTSTATUS,NONE,ZERO -NONE,XAUDIOALARM,RESOURCES,NONE,ZERO -NONE,XAUDIOALARM,RRULE,NONE,ZERO -NONE,XAUDIOALARM,SEQUENCE,NONE,ZERO -NONE,XAUDIOALARM,STATUS,NONE,ZERO -NONE,XAUDIOALARM,SUMMARY,NONE,ZERO -NONE,XAUDIOALARM,TRANSP,NONE,ZERO -NONE,XAUDIOALARM,TRIGGER,NONE,ONE -NONE,XAUDIOALARM,TZID,NONE,ZERO -NONE,XAUDIOALARM,TZNAME,NONE,ZERO -NONE,XAUDIOALARM,TZOFFSETFROM,NONE,ZERO -NONE,XAUDIOALARM,TZOFFSETTO,NONE,ZERO -NONE,XAUDIOALARM,TZURL,NONE,ZERO -NONE,XAUDIOALARM,UID,NONE,ZERO -NONE,XAUDIOALARM,URL,NONE,ZERO -NONE,XAUDIOALARM,VERSION,NONE,ZERO -NONE,XAUDIOALARM,X,NONE,ZEROPLUS -NONE,XDISPLAYALARM,ACTION,NONE,ONE -NONE,XDISPLAYALARM,ATTACH,NONE,ZERO -NONE,XDISPLAYALARM,ATTENDEE,NONE,ZERO -NONE,XDISPLAYALARM,CALSCALE,NONE,ZERO -NONE,XDISPLAYALARM,CATEGORIES,NONE,ZERO -NONE,XDISPLAYALARM,CLASS,NONE,ZERO -NONE,XDISPLAYALARM,COMMENT,NONE,ZERO -NONE,XDISPLAYALARM,COMPLETED,NONE,ZERO -NONE,XDISPLAYALARM,CONTACT,NONE,ZERO -NONE,XDISPLAYALARM,CREATED,NONE,ZERO -NONE,XDISPLAYALARM,DESCRIPTION,NONE,ONE -NONE,XDISPLAYALARM,DTEND,NONE,ZERO -NONE,XDISPLAYALARM,DTSTAMP,NONE,ZERO -NONE,XDISPLAYALARM,DTSTART,NONE,ZERO -NONE,XDISPLAYALARM,DUE,NONE,ZERO -NONE,XDISPLAYALARM,DURATION,NONE,ONEMUTUAL,must_have_repeat -NONE,XDISPLAYALARM,REPEAT,NONE,ONEMUTUAL,must_have_duration -NONE,XDISPLAYALARM,EXDATE,NONE,ZERO -NONE,XDISPLAYALARM,EXRULE,NONE,ZERO -NONE,XDISPLAYALARM,FREEBUSY,NONE,ZERO -NONE,XDISPLAYALARM,GEO,NONE,ZERO -NONE,XDISPLAYALARM,LASTMODIFIED,NONE,ZERO -NONE,XDISPLAYALARM,LOCATION,NONE,ZERO -NONE,XDISPLAYALARM,METHOD,NONE,ZERO -NONE,XDISPLAYALARM,ORGANIZER,NONE,ZERO -NONE,XDISPLAYALARM,PERCENTCOMPLETE,NONE,ZERO -NONE,XDISPLAYALARM,PRIORITY,NONE,ZERO -NONE,XDISPLAYALARM,PRODID,NONE,ZERO -NONE,XDISPLAYALARM,RDATE,NONE,ZERO -NONE,XDISPLAYALARM,RECURRENCEID,NONE,ZERO -NONE,XDISPLAYALARM,RELATEDTO,NONE,ZERO -NONE,XDISPLAYALARM,REQUESTSTATUS,NONE,ZERO -NONE,XDISPLAYALARM,RESOURCES,NONE,ZERO -NONE,XDISPLAYALARM,RRULE,NONE,ZERO -NONE,XDISPLAYALARM,SEQUENCE,NONE,ZERO -NONE,XDISPLAYALARM,STATUS,NONE,ZERO -NONE,XDISPLAYALARM,SUMMARY,NONE,ZERO -NONE,XDISPLAYALARM,TRANSP,NONE,ZERO -NONE,XDISPLAYALARM,TRIGGER,NONE,ONE -NONE,XDISPLAYALARM,TZID,NONE,ZERO -NONE,XDISPLAYALARM,TZNAME,NONE,ZERO -NONE,XDISPLAYALARM,TZOFFSETFROM,NONE,ZERO -NONE,XDISPLAYALARM,TZOFFSETTO,NONE,ZERO -NONE,XDISPLAYALARM,TZURL,NONE,ZERO -NONE,XDISPLAYALARM,UID,NONE,ZERO -NONE,XDISPLAYALARM,URL,NONE,ZERO -NONE,XDISPLAYALARM,VERSION,NONE,ZERO -NONE,XDISPLAYALARM,X,NONE,ZEROPLUS -NONE,XEMAILALARM,ACTION,NONE,ONE,must_be_email -NONE,XEMAILALARM,ATTACH,NONE,ZEROPLUS -NONE,XEMAILALARM,ATTENDEE,NONE,ONEPLUS -NONE,XEMAILALARM,CALSCALE,NONE,ZERO -NONE,XEMAILALARM,CATEGORIES,NONE,ZERO -NONE,XEMAILALARM,CLASS,NONE,ZERO -NONE,XEMAILALARM,COMMENT,NONE,ZERO -NONE,XEMAILALARM,COMPLETED,NONE,ZERO -NONE,XEMAILALARM,CONTACT,NONE,ZERO -NONE,XEMAILALARM,CREATED,NONE,ZERO -NONE,XEMAILALARM,DESCRIPTION,NONE,ONE -NONE,XEMAILALARM,DTEND,NONE,ZERO -NONE,XEMAILALARM,DTSTAMP,NONE,ZERO -NONE,XEMAILALARM,DTSTART,NONE,ZERO -NONE,XEMAILALARM,DUE,NONE,ZERO -NONE,XEMAILALARM,DURATION,NONE,ONEMUTUAL,must_have_repeat -NONE,XEMAILALARM,REPEAT,NONE,ONEMUTUAL,must_have_duration -NONE,XEMAILALARM,EXDATE,NONE,ZERO -NONE,XEMAILALARM,EXRULE,NONE,ZERO -NONE,XEMAILALARM,FREEBUSY,NONE,ZERO -NONE,XEMAILALARM,GEO,NONE,ZERO -NONE,XEMAILALARM,LASTMODIFIED,NONE,ZERO -NONE,XEMAILALARM,LOCATION,NONE,ZERO -NONE,XEMAILALARM,METHOD,NONE,ZERO -NONE,XEMAILALARM,ORGANIZER,NONE,ZERO -NONE,XEMAILALARM,PERCENTCOMPLETE,NONE,ZERO -NONE,XEMAILALARM,PRIORITY,NONE,ZERO -NONE,XEMAILALARM,PRODID,NONE,ZERO -NONE,XEMAILALARM,RDATE,NONE,ZERO -NONE,XEMAILALARM,RECURRENCEID,NONE,ZERO -NONE,XEMAILALARM,RELATEDTO,NONE,ZERO -NONE,XEMAILALARM,REQUESTSTATUS,NONE,ZERO -NONE,XEMAILALARM,RESOURCES,NONE,ZERO -NONE,XEMAILALARM,RRULE,NONE,ZERO -NONE,XEMAILALARM,SEQUENCE,NONE,ZERO -NONE,XEMAILALARM,STATUS,NONE,ZERO -NONE,XEMAILALARM,SUMMARY,NONE,ONE -NONE,XEMAILALARM,TRANSP,NONE,ZERO -NONE,XEMAILALARM,TRIGGER,NONE,ONE -NONE,XEMAILALARM,TZID,NONE,ZERO -NONE,XEMAILALARM,TZNAME,NONE,ZERO -NONE,XEMAILALARM,TZOFFSETFROM,NONE,ZERO -NONE,XEMAILALARM,TZOFFSETTO,NONE,ZERO -NONE,XEMAILALARM,TZURL,NONE,ZERO -NONE,XEMAILALARM,UID,NONE,ZERO -NONE,XEMAILALARM,URL,NONE,ZERO -NONE,XEMAILALARM,VERSION,NONE,ZERO -NONE,XEMAILALARM,X,NONE,ZEROPLUS -NONE,XPROCEDUREALARM,ACTION,NONE,ONE -NONE,XPROCEDUREALARM,ATTACH,NONE,ZEROORONE -NONE,XPROCEDUREALARM,ATTENDEE,NONE,ZERO -NONE,XPROCEDUREALARM,CALSCALE,NONE,ZERO -NONE,XPROCEDUREALARM,CATEGORIES,NONE,ZERO -NONE,XPROCEDUREALARM,CLASS,NONE,ZERO -NONE,XPROCEDUREALARM,COMMENT,NONE,ZERO -NONE,XPROCEDUREALARM,COMPLETED,NONE,ZERO -NONE,XPROCEDUREALARM,CONTACT,NONE,ZERO -NONE,XPROCEDUREALARM,CREATED,NONE,ZERO -NONE,XPROCEDUREALARM,DESCRIPTION,NONE,ZEROORONE -NONE,XPROCEDUREALARM,DTEND,NONE,ZERO -NONE,XPROCEDUREALARM,DTSTAMP,NONE,ZERO -NONE,XPROCEDUREALARM,DTSTART,NONE,ZERO -NONE,XPROCEDUREALARM,DUE,NONE,ZERO -NONE,XPROCEDUREALARM,DURATION,NONE,ONEMUTUAL,must_have_repeat -NONE,XPROCEDUREALARM,REPEAT,NONE,ONEMUTUAL,must_have_duration -NONE,XPROCEDUREALARM,EXDATE,NONE,ZERO -NONE,XPROCEDUREALARM,EXRULE,NONE,ZERO -NONE,XPROCEDUREALARM,FREEBUSY,NONE,ZERO -NONE,XPROCEDUREALARM,GEO,NONE,ZERO -NONE,XPROCEDUREALARM,LASTMODIFIED,NONE,ZERO -NONE,XPROCEDUREALARM,LOCATION,NONE,ZERO -NONE,XPROCEDUREALARM,METHOD,NONE,ZERO -NONE,XPROCEDUREALARM,ORGANIZER,NONE,ZERO -NONE,XPROCEDUREALARM,PERCENTCOMPLETE,NONE,ZERO -NONE,XPROCEDUREALARM,PRIORITY,NONE,ZERO -NONE,XPROCEDUREALARM,PRODID,NONE,ZERO -NONE,XPROCEDUREALARM,RDATE,NONE,ZERO -NONE,XPROCEDUREALARM,RECURRENCEID,NONE,ZERO -NONE,XPROCEDUREALARM,RELATEDTO,NONE,ZERO -NONE,XPROCEDUREALARM,REQUESTSTATUS,NONE,ZERO -NONE,XPROCEDUREALARM,RESOURCES,NONE,ZERO -NONE,XPROCEDUREALARM,RRULE,NONE,ZERO -NONE,XPROCEDUREALARM,SEQUENCE,NONE,ZERO -NONE,XPROCEDUREALARM,STATUS,NONE,ZERO -NONE,XPROCEDUREALARM,SUMMARY,NONE,ZERO -NONE,XPROCEDUREALARM,TRANSP,NONE,ZERO -NONE,XPROCEDUREALARM,TRIGGER,NONE,ONE -NONE,XPROCEDUREALARM,TZID,NONE,ZERO -NONE,XPROCEDUREALARM,TZNAME,NONE,ZERO -NONE,XPROCEDUREALARM,TZOFFSETFROM,NONE,ZERO -NONE,XPROCEDUREALARM,TZOFFSETTO,NONE,ZERO -NONE,XPROCEDUREALARM,TZURL,NONE,ZERO -NONE,XPROCEDUREALARM,UID,NONE,ZERO -NONE,XPROCEDUREALARM,URL,NONE,ZERO -NONE,XPROCEDUREALARM,VERSION,NONE,ZERO -NONE,XPROCEDUREALARM,X,NONE,ZEROPLUS -NONE,VQUERY,QUERY,NONE,ZEROORONE -NONE,VQUERY,QUERYNAME,NONE,ONE -NONE,VQUERY,EXPAND,NONE,ONE diff --git a/calendar/libical/design-data/status.txt b/calendar/libical/design-data/status.txt deleted file mode 100644 index 9e7bbf83a7..0000000000 --- a/calendar/libical/design-data/status.txt +++ /dev/null @@ -1,56 +0,0 @@ -2.0 STATOK Operation was successfully performed. -2.0.1 STARTSENDATA Start ICAL input; end with . -2.0.11 OKDATAFOLLOWS The request was processed successfully. Reply data follows on the next line and terminates with . -2.0.2 REPLYPENDING A timeout has occurred. The server is still working on the reply. Use CONTINUE to continue waiting for the reply or ABORT to terminate the command. -2.0.3 ABORTED The command currently underway was successsfully aborted. -2.0.4 WILLATTEMPT The specified Calendar is not here but an attempt will be made to deliver the request or reply to the Calendar anyway. -2.0.5 TRUSTEDWILLQUEUE The request or reply will be queued and delivered to the target calendar when its iRIP server contacts this server and issues the SWITCH command. -2.0.6 WILLATTEMPT The specified Calendar is not here but an attempt will be made to deliver the request or reply to the Calendar anyway. -2.0.7 QUEUED The message has been queued for delivery. -2.0.8 QUEUEEMPTY There are no more queued messages. -2.1 FALLBACK Success. Fallback taken on one or more property values. -2.2 NOCOMMANDINPROGRESS An ABORT or CONTINUE was received when no command was in progress -2.2 IGPROP Success. Invalid property ignored. -2.3 IGPARAM Success. invalid property parameter ignored. -2.4 IGXPROP Success. Unknown non-standard property ignored. -2.5 IGXPARAM Success. Unknown non standard property value ignored. -2.6 IGCOMP Success. Invalid calendar component ignored. -2.7 FORWARD Success. Request forwarded to Calendar User. -2.8 ONEEVENT Success. Repeating event ignored. Scheduled as a single component. -2.9 TRUNC Success. Truncated end date time to date boundary. -2.10 ONETODO Success. Repeating VTODO ignored. Scheduled as a single VTODO. -2.11 TRUNCRRULE Success. Unbounded RRULE clipped at some finite number of instances -3.0 INVPROPNAME Invalid property name. -3.1 INVPROPVAL Invalid property value. -3.2 INVPARAM Invalid property parameter. -3.3 INVPARAMVAL Invalid property parameter value. -3.4 INVCOMP Invalid calendar component sequence. -3.5 INVTIME Invalid date or time. -3.6 INVRULE Invalid rule. -3.7 INVCU Invalid Calendar User. -3.8 NOAUTH No authority. -3.9 BADVERSION Unsupported version. -3.10 TOOBIG Request entity too large. -3.11 MISSREQCOMP Required component or property missing. -3.12 UNKCOMP Unknown component or property found. -3.13 BADCOMP Unsupported component or property found -3.14 NOCAP Unsupported capability. -4.0 BUSY Event conflict. Date/time is busy. -5.0 MAYBE Request MAY supported. -5.1 UNAVAIL Service unavailable. -5.2 NOSERVICE Invalid calendar service. -5.3 NOSCHED No scheduling support for user. -6.1 AUTHENTICATEFAILURE Unsupported authentication mechanism, credentials rejected -6.2 AUTHENTICATIONABORTED Sender aborted authentication, authentication exchange cancelled -8.0 GENERALFAILURE A failure has occurred in the Receiver that prevents the operation from succeeding. -8.1 SERVERTOOBUSY The iRIP Receiver is too busy. -8.2 ICALOBJECTTOOBIG Object has exceeded the server's size limit. -8.3 DATETOOLARGE A DATETIME value was too far in the future to be represented on this Calendar. -8.4 DATETOOSMALL A DATETIME value was too far in the past to be represented on this Calendar. -9.0 INVALIDIRIPCOMMAND An unrecongnized command was received. -9.1 UNEXPECTEDCOMMAND The command is not allowed for the server's current state. -10.1 REFERRAL Accompanied by an alternate address. -10.2 SERVERSHUTDOWN The server is shutting down. -10.3 SERVERSTOPPING FLOOD 2 -10.4 EXCEEDEDQUOTAS The operation would cause a resource to exceed the allocated quota -10.5 QUEUEDTOOLONG The ITIP message has been queued too long. Delivery has been aborted. diff --git a/calendar/libical/design-data/value-types.csv b/calendar/libical/design-data/value-types.csv deleted file mode 100644 index 4e9f157ea2..0000000000 --- a/calendar/libical/design-data/value-types.csv +++ /dev/null @@ -1,35 +0,0 @@ -"#Name","C type& gen flag","Python","Component Values","Enum Values" -"BINARY","(a)const char*","file","unitary", -"BOOLEAN","(a)int","integer","unitary", -"CAL-ADDRESS","(a)const char*","string","unitary", -"DATE","(a)struct icaltimetype","Time","unitary", -"DATE-TIME","(m)struct icaltimetype","Time","unitary", -"DURATION","(a)struct icaldurationtype","Duration","unitary", -"FLOAT","(a)float","float","unitary", -"INTEGER","(a)int","integer","unitary", -"PERIOD","(a)struct icalperiodtype","Period","unitary", -"RECUR","(m)struct icalrecurrencetype","RecurrenceSet","unitary", -"TEXT","(a)const char*","string","unitary", -"URI","(a)const char*","string","unitary", -"UTC-OFFSET","(a)int","integer","unitary", -"QUERY","(a)const char*","string","unitary", -"#Non-standard multi-valued types",,,, -"ATTACH","(m)icalattach *","none","URI;BINARY", -"DATE-TIME-PERIOD","(m)struct icaldatetimeperiodtype","none","DATE-TIME;PERIOD", -"TRIGGER","(m)struct icaltriggertype","string","DURATION;DATE-TIME", -"#Non-standard property enumeration types",,,, -"METHOD","(a)enum icalproperty_method","string","unitary","PUBLISH;REQUEST;REPLY;ADD;CANCEL;REFRESH;COUNTER;DECLINECOUNTER;CREATE;READ;RESPONSE;MOVE;MODIFY;GENERATEUID;DELETE" -"X-LIC-CLASS","(a)enum icalproperty_xlicclass","string","unitary","PUBLISH-NEW;PUBLISH-UPDATE;PUBLISH-FREEBUSY;REQUEST-NEW;REQUEST-UPDATE;REQUEST-RESCHEDULE;REQUEST-DELEGATE;REQUEST-NEW-ORGANIZER;REQUEST-FORWARD;REQUEST-STATUS;REQUEST-FREEBUSY;REPLY-ACCEPT;REPLY-DECLINE;REPLY-DELEGATE;REPLY-CRASHER-ACCEPT;REPLY-CRASHER-DECLINE;ADD-INSTANCE;CANCEL-EVENT;CANCEL-INSTANCE;CANCEL-ALL;REFRESH;COUNTER;DECLINECOUNTER;MALFORMED;OBSOLETE;MISSEQUENCED;UNKNOWN" -"ACTION","(a)enum icalproperty_action","string","unitary","AUDIO;DISPLAY;EMAIL;PROCEDURE" -"STATUS","(a)enum icalproperty_status","string","unitary","TENTATIVE;CONFIRMED;COMPLETED;NEEDS-ACTION;CANCELLED;IN-PROCESS;DRAFT;FINAL" -"TRANSP","(a)enum icalproperty_transp","string","unitary","OPAQUE;OPAQUE-NOCONFLICT;TRANSPARENT;TRANSPARENT-NOCONFLICT" -"CLASS","(m)enum icalproperty_class","string","unitary","PUBLIC;PRIVATE;CONFIDENTIAL" -"#Other non-standard",,,, -"REQUEST-STATUS","(a)struct icalreqstattype","string","unitary" -"GEO","(m)struct icalgeotype","tuple","unitary", -"STRING","(a)const char*","string","unitary", -"X","(m)const char*","string","unitary", -"#CAP enumeration types",,,, -"CMD","(a)enum icalproperty_cmd","string","unitary","ABORT;CONTINUE;CREATE;DELETE;GENERATE-UID;GET-CAPABILITY;IDENTIFY;MODIFY;MOVE;REPLY;SEARCH;SET-LOCALE" -"QUERY-LEVEL","(a)enum icalproperty_querylevel","string","unitary","CAL-QL-1;CAL-QL-NONE" -"CAR-LEVEL","(a)enum icalproperty_carlevel","string","unitary","CAR-NONE;CAR-MIN;CAR-FULL-1" diff --git a/calendar/libical/moz.build b/calendar/libical/moz.build deleted file mode 100644 index e8e6750e4f..0000000000 --- a/calendar/libical/moz.build +++ /dev/null @@ -1,9 +0,0 @@ -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DIRS += ["src/libical"] - -with Files("**"): - BUG_COMPONENT = ("Calendar", "Internal Components") diff --git a/calendar/libical/scripts/mkderivedcomponents.pl b/calendar/libical/scripts/mkderivedcomponents.pl deleted file mode 100755 index 31743c3ba3..0000000000 --- a/calendar/libical/scripts/mkderivedcomponents.pl +++ /dev/null @@ -1,170 +0,0 @@ -#!/usr/bin/env perl - -use Getopt::Std; -getopts('chspi:'); - - -# ARG 0 is components.txt -open(PV,"$ARGV[0]") || die "Can't open components file $ARGV[0]:$!"; - -my @components; - -while (){ - - s/#.*//; - - chop; - - push(@components,$_); - -} - -close PV; - -# Write the file inline by copying everything before a demarcation -# line, and putting the generated data after the demarcation - -if ($opt_i) { - - open(IN,$opt_i) || die "Can't open input file \"$opt_i\""; - - while(){ - - if (/Do not edit/){ - last; - } - - print; - - } - - if($opt_i){ - print "# Everything below this line is machine generated. Do not edit. \n"; - } else { - print "/* Everything below this line is machine generated. Do not edit. */\n"; - } - -} - -if ($opt_c or $opt_h and !$opt_i){ - -print < /* for va_arg functions */ - -EOM - -} - -if ($opt_p and !$opt_i){ - -print <){ - - chop; - - s/#.*$//g; - s/\"//g; - s/\r//g; - - next if ! $_; - - @column = split(/\,/,$_); - - my $parameter_name = $column[0]; - - my $enumConst = $column[1]; - my $data_type = $column[2]; - my $enum_string = $column[3]; - - my @enums; - if($enum_string){ - @enums = split(/;/,$enum_string); - } - - $h{$parameter_name} = { C => $data_type, - kindEnum => $enumConst, - enums => [@enums] - }; - } - - close(F); - - return %h; -} -### END ### -# End of temporary fix. -### - -use Getopt::Std; -getopts('chspi:'); - -%no_xname = (RELATED=>1,RANGE=>1,RSVP=>1,XLICERRORTYPE=>1,XLICCOMPARETYPE=>1); - -%params = read_parameters_file($ARGV[0]); - - -# Write the file inline by copying everything before a demarcation -# line, and putting the generated data after the demarcation - -if ($opt_i) { - - open(IN,$opt_i) || die "Can't open input file $opt_i"; - - while(){ - if (//){ - $autogenMsg = "of section of machine generated code (mkderivedparameters.pl). Do not edit."; - if($opt_p){ - $startComment = "#"; - $endComment = ""; - } else { - $startComment = "/*"; - $endComment = " */"; - } - print $startComment." START ".$autogenMsg.$endComment."\n\n"; - - insert_code(); - - print $startComment." END ".$autogenMsg.$endComment."\n\n"; - } else { - print; - } - - } - -} - -sub insert_code -{ - -# Write parameter enumerations and datatypes - -if($opt_h){ - my $enumConst = $params{'ANY'}->{"kindEnum"}; - print "typedef enum icalparameter_kind {\n ICAL_ANY_PARAMETER = ".$enumConst.",\n"; - $enumVal = 1; - foreach $param (sort keys %params) { - - next if !$param; - - next if $param eq 'NO' or $param eq 'ANY'; - - my $uc = join("",map {uc($_);} split(/-/,$param)); - - $enumConst = $params{$param}->{"kindEnum"}; - - print " ICAL_${uc}_PARAMETER = ".$enumConst.", \n"; - - } - $enumConst = $params{'NO'}->{"kindEnum"}; - print " ICAL_NO_PARAMETER = ".$enumConst."\n} icalparameter_kind;\n\n"; - - # Now create enumerations for parameter values - $idx = 20000; - - print "#define ICALPARAMETER_FIRST_ENUM $idx\n\n"; - - foreach $param (sort keys %params) { - - next if !$param; - - next if $param eq 'NO' or $param eq 'ANY'; - - my $type = $params{$param}->{"C"}; - my $ucv = join("",map {uc(lc($_));} split(/-/,$param)); - my @enums = @{$params{$param}->{'enums'}}; - - if(@enums){ - - print "typedef enum $type {\n"; - my $first = 1; - - unshift(@enums,"X"); - - push(@enums,"NONE"); - - foreach $e (@enums) { - if (!$first){ - print ",\n"; - } else { - $first = 0; - } - - my $uce = join("",map {uc(lc($_));} split(/-/,$e)); - - print " ICAL_${ucv}_${uce} = $idx"; - - $idx++; - } - $c_type =~ s/enum //; - - print "\n} $type;\n\n"; - } - } - - print "#define ICALPARAMETER_LAST_ENUM $idx\n\n"; - -} - -if ($opt_c){ - - - # Create the icalparameter_value to icalvalue_kind conversion table - my $count = 0; - my $out; - - foreach $enum (@{$params{'VALUE'}->{'enums'}}){ - next if $enum eq 'NO' or $enum eq 'ERROR'; - $uc = join("",map {uc(lc($_));} split(/-/,$enum)); - $out.=" {ICAL_VALUE_${uc},ICAL_${uc}_VALUE},\n"; - $count++; - } - - $count+=2; - print "static const struct icalparameter_value_kind_map value_kind_map[$count] = {\n"; - print $out; - print " {ICAL_VALUE_X,ICAL_X_VALUE},\n"; - print " {ICAL_VALUE_NONE,ICAL_NO_VALUE}\n};\n\n"; - - #Create the parameter Name map - - $out=""; - $count=0; - foreach $param (sort keys %params) { - - next if !$param; - - next if $param eq 'NO' or $param eq 'ANY'; - - my $lc = join("",map {lc($_);} split(/-/,$param)); - my $uc = join("",map {uc(lc($_));} split(/-/,$param)); - - $count++; - $out.=" {ICAL_${uc}_PARAMETER,\"$param\"},\n"; - - } - $count+=1; - print "static const struct icalparameter_kind_map parameter_map[$count] = { \n"; - print $out; - print " { ICAL_NO_PARAMETER, \"\"}\n};\n\n"; - - # Create the parameter value map - $out =""; - $count=0; - foreach $param (sort keys %params) { - - next if !$param; - - next if $param eq 'NO' or $param eq 'ANY'; - - my $type = $params{$param}->{"C"}; - my $uc = join("",map {uc(lc($_));} split(/-/,$param)); - my @enums = @{$params{$param}->{'enums'}}; - - if(@enums){ - - foreach $e (@enums){ - my $uce = join("",map {uc(lc($_));} split(/-/,$e)); - - $count++; - $out.=" {ICAL_${uc}_PARAMETER,ICAL_${uc}_${uce},\"$e\"},\n"; - } - - } - } - - $count+=3; - print "static const struct icalparameter_map icalparameter_map[] = {\n"; - print "{ICAL_ANY_PARAMETER,0,\"\"},\n"; - print $out; - print " {ICAL_NO_PARAMETER,0,\"\"}};\n\n"; - -} - -foreach $param (sort keys %params){ - - next if $param eq 'NO' or $param eq 'ANY'; - - my $type = $params{$param}->{'C'}; - - my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$param)); - - my $lc = lc($ucf); - my $uc = uc($lc); - - my $charorenum; - my $set_code; - my $pointer_check; - my $pointer_check_v; - my $xrange; - - if ($type=~/char/ ) { - - $charorenum = " icalerror_check_arg_rz( (param!=0), \"param\");\n return param->string;"; - - $set_code = "((struct icalparameter_impl*)param)->string = icalmemory_strdup(v);"; - - $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");"; - $pointer_check_v = "icalerror_check_arg_rv( (v!=0),\"v\");"; - - } else { - - $xrange =" if (param->string != 0){\n return ICAL_${uc}_X;\n }\n" if !exists $no_xname{$uc}; - - $charorenum= "icalerror_check_arg( (param!=0), \"param\");\n$xrange\nreturn ($type)(param->data);"; - - $pointer_check = "icalerror_check_arg_rz(v >= ICAL_${uc}_X,\"v\");\n icalerror_check_arg_rz(v < ICAL_${uc}_NONE,\"v\");"; - - $pointer_check_v = "icalerror_check_arg_rv(v >= ICAL_${uc}_X,\"v\");\n icalerror_check_arg_rv(v < ICAL_${uc}_NONE,\"v\");"; - - $set_code = "((struct icalparameter_impl*)param)->data = (int)v;"; - - } - - - - if ($opt_c) { - - print <string != NULL) - free ((void*)param->string); - $set_code -} - -EOM - - } elsif( $opt_h) { - - print <[0] = \$p; - - return \$self; -} - -sub get -{ - my \$self = shift; - my \$impl = \$self->_impl(); - - return Net::ICal::icalparameter_as_ical_string(\$impl); - -} - -sub set -{ - # This is hard to implement, so I've punted for now. - die "Set is not implemented"; -} - -EOM - -} - -} - -if ($opt_h){ - -print <){ - - chop; - - s/#.*$//g; - s/\"//g; - s/\r//g; - - next if ! $_; - - @column = split(/,/,$_); - - my $value_name = $column[0]; - - my $c_type_str = $column[1]; - my $c_autogen = ($c_type_str =~ /\(a\)/); - - my $c_type = $c_type_str; - $c_type =~ s/\(.\)//; - - my $python_type = $column[2]; - my $components = $column[3]; - my $enum_values = $column[4]; - - my @components; - if($components ne "unitary"){ - @components = split(/;/,$components); - } else { - @components = (); - } - - my @enums; - if($enum_values) { - @enums = split(/;/,$enum_values); - - } else { - @enums = (); - } - - $h{$value_name} = { C => [$c_autogen,$c_type], - perl => $perl_type, - python => $python_type, - components=>[@components], - enums=>[@enums] - }; - } - - return %h; -} - -sub read_properties_file { - - my $path = shift; - my %h; - - open(F,$path) || die "Can't open properties file $path"; - - while(){ - - chop; - - s/#.*$//g; - s/\"//g; - s/\r//g; - - next if ! $_; - - @column = split(/,/,$_); - - my $property_name = $column[0]; - - my $lic_value = $column[1]; - my $default_value = $column[2]; - - $h{$property_name} = { lic_value => $lic_value, - default_value => $default_value - }; - } - - return %h; -} -### END ### -# End of temporary fix. -### - -use Getopt::Std; -getopts('chspmi:'); - -# ARG 0 is properties.csv -%propmap = read_properties_file($ARGV[0]); - -# ARG 1 is value-types.txt -%valuemap = read_values_file($ARGV[1]); - - -$include_vanew = 1; - -# Write the file inline by copying everything before a demarcation -# line, and putting the generated data after the demarcation - -if ($opt_i) { - - open(IN,$opt_i) || die "Can't open input file $opt_i"; - - while(){ - - if (//){ - insert_code(); - } else { - print; - } - - } - -} - -sub fudge_data { - my $prop = shift; - - my $value = $propmap{$prop}->{'lic_value'}; - - if (!$value){ - die "Can't find value for property \"$prop\"\n"; - } - my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$prop)); - my $lc = lc($ucf); - my $uc = uc($lc); - - my $ucfvalue = join("",map {ucfirst(lc($_));} split(/-/,$value)); - my $lcvalue = lc($ucfvalue); - my $ucvalue = uc($lcvalue); - - my $type = $valuemap{$value}->{C}->[1]; - - return ($uc,$lc,$lcvalue,$ucvalue,$type); - -} - -sub insert_code { - -# Create the property map data -if($opt_c){ - - - my @props = sort keys %propmap; - my $count = scalar(@props); - - - print "static const struct icalproperty_map property_map[$count] = {\n"; - - foreach $prop (@props) { - - next if !$prop; - - next if $prop eq 'NO'; - - my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop); - - print "{ICAL_${uc}_PROPERTY,\"$prop\",ICAL_${ucvalue}_VALUE},\n"; - - } - - $prop = "NO"; - - my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop); - - print "{ICAL_${uc}_PROPERTY,\"\",ICAL_NO_VALUE}};\n\n"; - - $idx = 10000; - $count = 1; - my $out = ""; - - foreach $value (sort keys %valuemap) { - - next if !$value; - next if $value eq 'NO' or $prop eq 'ANY'; - - my $ucv = join("",map {uc(lc($_));} split(/-/,$value)); - my @enums = @{$valuemap{$value}->{'enums'}}; - - if(@enums){ - - my ($c_autogen,$c_type) = @{$valuemap{$value}->{'C'}}; - - unshift(@enums,"X"); - push(@enums,"NONE"); - - foreach $e (@enums) { - - my $uce = join("",map {uc(lc($_));} split(/-/,$e)); - - if($e ne "X" and $e ne "NONE"){ - $str = $e; - } else { - $str = ""; - } - - $out.=" {ICAL_${ucv}_PROPERTY,ICAL_${ucv}_${uce},\"$str\" }, /*$idx*/\n"; - - $idx++; - $count++; - } - - } - } - - $count++; - print "static const struct icalproperty_enum_map enum_map[$count] = {\n"; - print $out; - print " {ICAL_NO_PROPERTY,0,\"\"}\n};\n\n"; - - - -} - - -if($opt_h){ - - # Create the property enumerations list - print "typedef enum icalproperty_kind {\n ICAL_ANY_PROPERTY = 0,\n"; - foreach $prop (sort keys %propmap) { - - next if !$prop; - - next if $prop eq 'NO' or $prop eq 'ANY'; - - my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop); - - print " ICAL_${uc}_PROPERTY, \n"; - - } - print " ICAL_NO_PROPERTY\n} icalproperty_kind;\n\n"; - - -} - - -foreach $prop (sort keys %propmap) { - - next if !$prop; - - next if $prop eq 'NO' or $prop eq 'ANY'; - - my ($uc,$lc,$lcvalue,$ucvalue,$type) = fudge_data($prop); - - - my $pointer_check; - if ($type =~ /\*/){ - $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");\n" if $type =~ /\*/; - } elsif ( $type eq "void" ){ - $pointer_check = "icalerror_check_arg_rv( (v!=0),\"v\");\n" if $type =~ /\*/; - - } - - my $set_pointer_check = "icalerror_check_arg_rv( (v!=0),\"v\");\n" if $type =~ /\*/; - - if($opt_c) { # Generate C source - - if ($include_vanew) { - print<){ - - chop; - - s/#.*$//g; - s/\"//g; - s/\r//g; - - next if ! $_; - - @column = split(/,/,$_); - - my $value_name = $column[0]; - - my $c_type_str = $column[1]; - my $c_autogen = ($c_type_str =~ /\(a\)/); - - my $c_type = $c_type_str; - $c_type =~ s/\(.\)//; - - my $python_type = $column[2]; - my $components = $column[3]; - my $enum_values = $column[4]; - - my @components; - if($components ne "unitary"){ - @components = split(/;/,$components); - } else { - @components = (); - } - - my @enums; - if($enum_values) { - @enums = split(/;/,$enum_values); - - } else { - @enums = (); - } - - $h{$value_name} = { C => [$c_autogen,$c_type], - perl => $perl_type, - python => $python_type, - components=>[@components], - enums=>[@enums] - }; - } - - return %h; -} -### END ### -# End of temporary fix. -### - -use Getopt::Std; -getopts('chi:'); - - #Options - # c -> generate c code file - # h-> generate header file - - # Open with value-types.txt - -my %h = read_values_file($ARGV[0]); - - - # Write the file inline by copying everything before a demarcation - # line, and putting the generated data after the demarcation - -if ($opt_i) { - - open(IN,$opt_i) || die "Can't open input file $opt_i"; - - while(){ - if (//){ - insert_code(); - } else { - print; - } - - - } -} - -sub insert_code -{ - # Map type names to the value in the icalvalue_impl data union */ - -%union_map = ( - BOOLEAN => 'int', - CALADDRESS=>'string', - DATE=>'time', - DATETIME=>'time', - DATETIMEDATE=>'time', - DATETIMEPERIOD=>'period', - DURATION=>'duration', - INTEGER=>'int', - TEXT=>'string', - URI=>'string', - UTCOFFSET=>'int', - QUERY=>'string', - BINARY=>'string', - X=>'string' - ); - - -if($opt_h){ - - # First print out the value enumerations - $idx = 5000; - print "typedef enum icalvalue_kind {\n"; - print " ICAL_ANY_VALUE=$idx,\n"; - - foreach $value (sort keys %h) { - - $idx++; - my $ucv = join("",map {uc(lc($_));} split(/-/,$value)); - - next if $value eq "NO"; - - print " ICAL_${ucv}_VALUE=$idx,\n"; - } - - $idx++; - print " ICAL_NO_VALUE=$idx\n} icalvalue_kind ;\n\n"; - - # Now create enumerations for property values - $idx = 10000; - - print "#define ICALPROPERTY_FIRST_ENUM $idx\n\n"; - - foreach $value (sort keys %h) { - - next if !$value; - - next if $value eq 'NO' or $prop eq 'ANY'; - - my $ucv = join("",map {uc(lc($_));} split(/-/,$value)); - my @enums = @{$h{$value}->{'enums'}}; - - if(@enums){ - - my ($c_autogen,$c_type) = @{$h{$value}->{'C'}}; - print "typedef $c_type {\n"; - my $first = 1; - - unshift(@enums,"X"); - - push(@enums,"NONE"); - - foreach $e (@enums) { - if (!$first){ - print ",\n"; - } else { - $first = 0; - } - - my $uce = join("",map {uc(lc($_));} split(/-/,$e)); - - print " ICAL_${ucv}_${uce} = $idx"; - - $idx++; - } - - $c_type =~ s/enum //; - - print "\n} $c_type;\n\n"; - } - } - - print "#define ICALPROPERTY_LAST_ENUM $idx\n\n"; - -} - - -if($opt_c){ - - # print out the value to string map - - my $count = scalar(keys %h) + 1; - print "static const struct icalvalue_kind_map value_map[$count]={\n"; - - foreach $value (sort keys %h) { - - $idx++; - my $ucv = join("",map {uc(lc($_));} split(/-/,$value)); - - next if $value eq "NO"; - - print " {ICAL_${ucv}_VALUE,\"$value\"},\n"; - } - - - print " {ICAL_NO_VALUE,\"\"}\n};"; - -} - - -foreach $value (sort keys %h) { - - my $autogen = $h{$value}->{C}->[0]; - my $type = $h{$value}->{C}->[1]; - - my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$value)); - - my $lc = lc($ucf); - my $uc = uc($lc); - - my $pointer_check = "icalerror_check_arg_rz( (v!=0),\"v\");\n" if $type =~ /\*/; - my $pointer_check_rv = "icalerror_check_arg_rv( (v!=0),\"v\");\n" if $type =~ /\*/; - - my $assign; - - if ($type =~ /char/){ - $assign = "icalmemory_strdup(v);\n\n if (impl->data.v_string == 0){\n errno = ENOMEM;\n }\n"; - } else { - $assign = "v;"; - } - - my $union_data; - - if(@{$h{$value}->{'enums'}}){ - $union_data = 'enum'; - - } elsif (exists $union_map{$uc} ){ - $union_data=$union_map{$uc}; - } else { - $union_data = $lc; - } - - if ($opt_c && $autogen) { - - print "\n\n\ -icalvalue* icalvalue_new_${lc} ($type v){\ - struct icalvalue_impl* impl;\ - $pointer_check\ - impl = icalvalue_new_impl(ICAL_${uc}_VALUE);\ - icalvalue_set_${lc}((icalvalue*)impl,v);\ - return (icalvalue*)impl;\ -}\ -void icalvalue_set_${lc}(icalvalue* value, $type v) {\ - struct icalvalue_impl* impl; \ - icalerror_check_arg_rv( (value!=0),\"value\");\ - $pointer_check_rv\ - icalerror_check_value_type(value, ICAL_${uc}_VALUE);\ - impl = (struct icalvalue_impl*)value;\n"; - - if( $union_data eq 'string') { - - print " if(impl->data.v_${union_data}!=0) {free((void*)impl->data.v_${union_data});}\n"; - } - - - print "\n\ - impl->data.v_$union_data = $assign \n\ - icalvalue_reset_kind(impl);\n}\n"; - - print "$type\ icalvalue_get_${lc} (const icalvalue* value) {\n\n"; - if( $union_data eq 'string') { - print " icalerror_check_arg_rz ((value!=0),\"value\");\n"; - } - else { - print " icalerror_check_arg ((value!=0),\"value\");\n"; - } - print " icalerror_check_value_type (value, ICAL_${uc}_VALUE);\ - return ((struct icalvalue_impl*)value)->data.v_${union_data};\n}\n"; - - - } elsif($opt_h && $autogen) { - - print "\n /* $value */ \ -icalvalue* icalvalue_new_${lc}($type v); \ -$type icalvalue_get_${lc}(const icalvalue* value); \ -void icalvalue_set_${lc}(icalvalue* value, ${type} v);\n\n"; - - } - -} - - -if ($opt_h){ - print "#endif /*ICALVALUE_H*/\n"; - } - - -} diff --git a/calendar/libical/scripts/mkinclude.sh b/calendar/libical/scripts/mkinclude.sh deleted file mode 100644 index a77c8d74a8..0000000000 --- a/calendar/libical/scripts/mkinclude.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -# -# Given a list of headers, combine them into one, excluding certain lines -# -OUTFILE="/dev/stdout" -COMBINEDHEADERS="" -EXCLUDES="" - -while [ $# -gt 0 ] -do - case $1 in - -o) OUTFILE=$2; shift;; - -e) EXCLUDES="$EXCLUDES $2"; shift;; - *) COMBINEDHEADERS="$COMBINEDHEADERS $1"; - esac - shift -done - -echo '#ifdef __cplusplus' > $OUTFILE -echo 'extern "C" {' >> $OUTFILE -echo '#endif' >> $OUTFILE -echo '/*' >> $OUTFILE -echo " \$Id\$" >> $OUTFILE -echo '*/' >> $OUTFILE -cat $COMBINEDHEADERS >> file.temp1 -for exclude in $EXCLUDES -do - cp file.temp1 file.temp2 - egrep -v "$exclude" file.temp2 > file.temp1 -done -cat file.temp1 >> $OUTFILE -rm -f file.temp1 -rm -f file.temp2 -echo '#ifdef __cplusplus' >> $OUTFILE -echo '};' >> $OUTFILE -echo '#endif' >> $OUTFILE - - diff --git a/calendar/libical/scripts/mkneticali.pl b/calendar/libical/scripts/mkneticali.pl deleted file mode 100755 index 937de49908..0000000000 --- a/calendar/libical/scripts/mkneticali.pl +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/local/bin/perl - -$pr = 1; -$ignore = 0; - - -print< /* for size_t */ -#include - -%} - -EOM - -foreach $f (@ARGV) -{ - @f = split(/\//,$f); - $fn = pop(@f); - - $fn=~/pvl/ && next; - $fn=~/sspm/ && next; - $fn=~/cstp/ && next; - $fn=~/csdb/ && next; - $fn=~/vcal/ && next; - $fn=~/yacc/ && next; - $fn=~/lex/ && next; - - print "\n/**********************************************************************\n"; - - print "\t$fn\n"; - print "**********************************************************************/\n\n"; - - - open F, $f; - - while(){ - - s/^#.*//; - - s/\/\*.*\*\///; - - /^\/\// && next; - - next if /^$/; - - if(/\/\*/){ $pr = 0;} - - /icalparser_parse\(/ and $ignore = 1; - /vanew/ and $ignore = 1; - /_stub/ and $ignore = 1; - /_response/ and $ignore = 1; - /line_gen_func/ and $ignore = 1; - /extern/ and $ignore = 1; - /sspm/ and $ignore = 1; - /icalrecur/ and $ignore = 1; - - if ($pr == 1 && $ignore == 0){ - print ; - } - - - if(/\*\//){ $pr = 1;} - - if (/\;/){ $ignore = 0; } - - } - -} - - diff --git a/calendar/libical/scripts/mkparameterrestrictions.pl b/calendar/libical/scripts/mkparameterrestrictions.pl deleted file mode 100755 index 2c57eb4ca5..0000000000 --- a/calendar/libical/scripts/mkparameterrestrictions.pl +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/perl - -# Version: 1.0 -# Script last updated: 30May1999 GMD -# Change log: -# - - -# usually open params-in-prop.txt -open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!"; - -print <) -{ - chop; - - # split line by whitespace - my @v = split(/\s+/,$_); - # property is first item on line - my $prop = shift @v; - my $prop_name = $prop; - if (substr($prop,0,1) eq "X") { $prop = "X"; } - $prop = join("",split(/-/,$prop)); - -print < - -# usually open restrictions.csv -open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!"; - -print <) -{ - chop; - - # split line at commas - my ($method,$component,$property,$subcomponent,$restriction)=split(/\,/,$_); - - # - #put in code to generate comments here! - # - if ($method ne $last_method) - { - $need_header = 1; - $last_method = $method; - } - if ($component ne $last_component) - { - $need_header = 1; - $last_component = $component; - } - - if ($need_header) - { - print "\n\t/* METHOD: ${method}, COMPONENT: ${component} */\n"; - $need_header = 0; - } - - foreach $item ($component,$property,$subcomponent,$restriction) - { - # handle special cases. - if ($item eq "NONE") - { $item = "NO"; } - else { if (substr($item,0,1) eq "X") - { $item = "X"; }} - - # strip out dashes - $item = join("",split(/-/,$item)); - } - # strip leading V from component names - $component =~ s/^(V?)(\w+?)((SAVINGS)?)((TIME)?)$/$2/; - $subcomponent =~ s/^V(\w+)/$1/; - - print "\t\{ICAL_METHOD_${method},ICAL_${component}_COMPONENT,"; - print "ICAL_${property}_PROPERTY,ICAL_${subcomponent}_COMPONENT,"; - print "ICAL_RESTRICTION_${restriction}\},\n"; - -} - -print <){ - - if (//){ - insert_code(); - } - - if (/Do not edit/){ - last; - } - - print; - - } - - close IN; -} - -sub insert_code { -# First build the property restriction table -print "static const icalrestriction_property_record icalrestriction_property_records[] = {\n"; - -while() -{ - - chop; - - s/\#.*$//; - - my($method,$targetcomp,$prop,$subcomp,$restr,$sub) = split(/,/,$_); - - next if !$method; - - if(!$sub) { - $sub = "0"; - } else { - $sub = "icalrestriction_".$sub; - } - - if($prop ne "NONE"){ - print(" \{ICAL_METHOD_${method},ICAL_${targetcomp}_COMPONENT,ICAL_${prop}_PROPERTY,ICAL_RESTRICTION_${restr},$sub},\n"); - } - -} - - -# Print the terminating line -print " {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_NONE}\n"; - -print "};\n"; - -print "static const icalrestriction_component_record icalrestriction_component_records[] = {\n"; - - -# Go back through the entire file and build the component restriction table -close(F); -open(F,"$ARGV[0]") || die "Can't open restriction data file $ARGV[0]:$!"; - -while() -{ - - chop; - - s/\#.*$//; - - my($method,$targetcomp,$prop,$subcomp,$restr,$sub) = split(/,/,$_); - - next if !$method; - - if(!$sub) { - $sub = "0"; - } else { - $sub = "icalrestriction_".$sub; - } - - - if($subcomp ne "NONE"){ - print(" \{ICAL_METHOD_${method},ICAL_${targetcomp}_COMPONENT,ICAL_${subcomp}_COMPONENT,ICAL_RESTRICTION_${restr},$sub\},\n"); - } - -} - -# print the terminating line -print " {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE}\n"; -print "};\n"; -} - diff --git a/calendar/libical/scripts/readvaluesfile.pl b/calendar/libical/scripts/readvaluesfile.pl deleted file mode 100644 index b3eee98a37..0000000000 --- a/calendar/libical/scripts/readvaluesfile.pl +++ /dev/null @@ -1,135 +0,0 @@ - - -sub read_values_file { - - my $path = shift; - my %h; - - open(F,$path) || die "Can't open values file $path"; - - while(){ - - chop; - - s/#.*$//g; - s/\"//g; - s/\r//g; - - next if ! $_; - - @column = split(/,/,$_); - - my $value_name = $column[0]; - - my $c_type_str = $column[1]; - my $c_autogen = ($c_type_str =~ /\(a\)/); - - my $c_type = $c_type_str; - $c_type =~ s/\(.\)//; - - my $python_type = $column[2]; - my $components = $column[3]; - my $enum_values = $column[4]; - - my @components; - if($components ne "unitary"){ - @components = split(/;/,$components); - } else { - @components = (); - } - - my @enums; - if($enum_values) { - @enums = split(/;/,$enum_values); - - } else { - @enums = (); - } - - $h{$value_name} = { C => [$c_autogen,$c_type], - perl => $perl_type, - python => $python_type, - components=>[@components], - enums=>[@enums] - }; - } - - return %h; -} - -sub read_properties_file { - - my $path = shift; - my %h; - - open(F,$path) || die "Can't open properties file $path"; - - while(){ - - chop; - - s/#.*$//g; - s/\"//g; - s/\r//g; - - next if ! $_; - - @column = split(/,/,$_); - - my $property_name = $column[0]; - - my $lic_value = $column[1]; - my $default_value = $column[2]; - - $h{$property_name} = { lic_value => $lic_value, - default_value => $default_value - }; - } - - return %h; -} - -sub read_parameters_file { - - my $path = shift; - my %h; - - open(F,$path) || die "Can't open parameters file $path"; - - while(){ - - chop; - - s/#.*$//g; - s/\"//g; - s/\r//g; - - next if ! $_; - - @column = split(/\,/,$_); - - my $parameter_name = $column[0]; - - my $enumConst = $column[1]; - my $data_type = $column[2]; - my $enum_string = $column[3]; - - my @enums; - if($enum_string){ - @enums = split(/;/,$enum_string); - } - - $h{$parameter_name} = { C => $data_type, - kindEnum => $enumConst, - enums => [@enums] - }; - } - - close(F); - - return %h; -} - - - -1; diff --git a/calendar/libical/src/libical/Makefile.in b/calendar/libical/src/libical/Makefile.in deleted file mode 100644 index adefb93814..0000000000 --- a/calendar/libical/src/libical/Makefile.in +++ /dev/null @@ -1,174 +0,0 @@ -# ***** BEGIN LICENSE BLOCK ***** -# Version: MPL 1.1/GPL 2.0/LGPL 2.1 -# -# The contents of this file are subject to the Mozilla Public License Version -# 1.1 (the "License"); you may not use this file except in compliance with -# the License. You may obtain a copy of the License at -# http://www.mozilla.org/MPL/ -# -# Software distributed under the License is distributed on an "AS IS" basis, -# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License -# for the specific language governing rights and limitations under the -# License. -# -# The Original Code is libical code. -# -# The Initial Developer of the Original Code is -# Eric Busboom -# Portions created by the Initial Developer are Copyright (C) 2000 -# the Initial Developer. All Rights Reserved. -# -# Contributor(s): -# Michiel van Leeuwen -# -# Alternatively, the contents of this file may be used under the terms of -# either the GNU General Public License Version 2 or later (the "GPL"), or -# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), -# in which case the provisions of the GPL or the LGPL are applicable instead -# of those above. If you wish to allow use of your version of this file only -# under the terms of either the GPL or the LGPL, and not to allow others to -# use your version of this file under the terms of the MPL, indicate your -# decision by deleting the provisions above and replace them with the notice -# and other provisions required by the GPL or the LGPL. If you do not delete -# the provisions above, a recipient may use your version of this file under -# the terms of any one of the MPL, the GPL or the LGPL. -# -# ***** END LICENSE BLOCK ***** - -include $(moztopsrcdir)/config/rules.mk - -###################################################################### -# -# Generate files that are automatically generated (*.h.in and *.c.in) -# and ical.h -# - -DESIGNDATA = $(srcdir)/../../design-data -ICALSCRIPTS = $(srcdir)/../../scripts - -# ORDERING OF HEADERS IS SIGNIFICANT. Don't change this ordering. It -# is required to make the combined header ical.h properly -COMBINEDHEADERS = \ - $(srcdir)/../../config.h \ - $(srcdir)/icalversion.h \ - $(srcdir)/icaltime.h \ - $(srcdir)/icalduration.h \ - $(srcdir)/icalperiod.h \ - $(srcdir)/icalenums.h \ - $(srcdir)/icaltypes.h \ - $(srcdir)/icalrecur.h \ - $(srcdir)/icalattach.h \ - icalderivedvalue.h \ - icalderivedparameter.h \ - $(srcdir)/icalvalue.h \ - $(srcdir)/icalparameter.h \ - icalderivedproperty.h \ - $(srcdir)/icalproperty.h \ - $(srcdir)/pvl.h \ - $(srcdir)/icalarray.h \ - $(srcdir)/icalcomponent.h \ - $(srcdir)/icaltimezone.h \ - $(srcdir)/icalparser.h \ - $(srcdir)/icalmemory.h \ - $(srcdir)/icalerror.h \ - $(srcdir)/icalrestriction.h \ - $(srcdir)/sspm.h \ - $(srcdir)/icalmime.h \ - $(srcdir)/icallangbind.h \ - $(NULL) - -BUILT_COMBINEDHEADERS = \ - icalderivedparameter.h \ - icalderivedproperty.h \ - icalderivedvalue.h - -BUILT_SOURCES = \ - $(BUILT_COMBINEDHEADERS)\ - icalderivedparameter.c \ - icalderivedproperty.c \ - icalrestriction.c \ - icalderivedvalue.c - -GARBAGE += $(BUILT_SOURCES) - -ical.h: $(COMBINEDHEADERS) - echo '#ifndef LIBICAL_ICAL_H' > ical.h - echo '#define LIBICAL_ICAL_H' >> ical.h - echo '#ifdef __cplusplus' >> ical.h - echo 'extern "C" {' >> ical.h - echo '#endif' >> ical.h - echo '/*' >> ical.h - echo ' $$''Id''$$' >> ical.h - echo '*/' >> ical.h - cat $(COMBINEDHEADERS) \ - | egrep -v "#include.*\"ical" \ - | egrep -v "#include.*\"config" \ - | egrep -v "#include.*\"pvl\.h\"" \ - | egrep -v '\$$(Id|Locker): .+\$$'>> ical.h - echo '#ifdef __cplusplus' >> ical.h - echo '}' >> ical.h - echo '#endif' >> ical.h - echo '#endif' >> ical.h - -GARBAGE += ical.h - -# parameters - -PARAMETERDEPS = \ - $(ICALSCRIPTS)/mkderivedparameters.pl \ - $(DESIGNDATA)/parameters.csv \ - $(srcdir)/icalderivedparameter.c.in \ - $(srcdir)/icalderivedparameter.h.in - -icalderivedparameter.h: $(PARAMETERDEPS) - $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedparameters.pl -i $(srcdir)/icalderivedparameter.h.in -h $(DESIGNDATA)/parameters.csv > icalderivedparameter.h - -icalderivedparameter.c: $(PARAMETERDEPS) $(BUILT_COMBINEDHEADERS) - $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedparameters.pl -i $(srcdir)/icalderivedparameter.c.in -c $(DESIGNDATA)/parameters.csv > icalderivedparameter.c - -# properties - -PROPERTYDEPS = \ - $(ICALSCRIPTS)/mkderivedproperties.pl \ - $(DESIGNDATA)/properties.csv \ - $(DESIGNDATA)/value-types.csv \ - $(srcdir)/icalderivedproperty.c.in \ - $(srcdir)/icalderivedproperty.h.in - - -icalderivedproperty.h: $(PROPERTYDEPS) - $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedproperties.pl \ - -i $(srcdir)/icalderivedproperty.h.in -h $(DESIGNDATA)/properties.csv\ - ${DESIGNDATA}/value-types.csv > icalderivedproperty.h - -icalderivedproperty.c: $(PROPERTYDEPS) $(BUILT_COMBINEDHEADERS) - $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedproperties.pl \ - -i $(srcdir)/icalderivedproperty.c.in -c $(DESIGNDATA)/properties.csv \ - ${DESIGNDATA}/value-types.csv > icalderivedproperty.c - -# restrictions - -RESTRICTIONDEPS = \ - $(ICALSCRIPTS)/mkrestrictiontable.pl \ - $(DESIGNDATA)/restrictions.csv \ - $(srcdir)/icalrestriction.c.in - -icalrestriction.c: $(RESTRICTIONDEPS) - $(PERL) $(ICALSCRIPTS)/mkrestrictiontable.pl -i $(srcdir)/icalrestriction.c.in \ - $(DESIGNDATA)/restrictions.csv > icalrestriction.c - -# values - -VALUEDEPS = \ - $(ICALSCRIPTS)/mkderivedvalues.pl \ - $(DESIGNDATA)/value-types.csv \ - $(srcdir)/icalderivedvalue.c.in \ - $(srcdir)/icalderivedvalue.h.in - -icalderivedvalue.h: $(VALUEDEPS) - $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedvalues.pl \ - -i $(srcdir)/icalderivedvalue.h.in -h $(DESIGNDATA)/value-types.csv > icalderivedvalue.h - -icalderivedvalue.c: $(VALUEDEPS) $(BUILT_COMBINEDHEADERS) - $(PERL) -I$(ICALSCRIPTS) $(ICALSCRIPTS)/mkderivedvalues.pl \ - -i $(srcdir)/icalderivedvalue.c.in -c $(DESIGNDATA)/value-types.csv > icalderivedvalue.c diff --git a/calendar/libical/src/libical/astime.h b/calendar/libical/src/libical/astime.h deleted file mode 100644 index 6962c060a8..0000000000 --- a/calendar/libical/src/libical/astime.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1986-2000, Hiram Clawson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * - * Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither name of The Museum of Hiram nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -/** - * @file astime.h - * @brief contains definitions of structures used for time calculations. - */ - -#ifndef _astime_h_ -#define _astime_h_ - -typedef struct ut_instant { - double j_date; /**< julian decimal date, 0 = 01 Jan 4713 BC 12 HR UT */ - long year; /**< year, valid range [-4,713, +2,147,483,647] */ - int month; /**< [1-12] */ - int day; /**< [1-31] */ - int i_hour; /**< [0-23] */ - int i_minute; /**< [0-59] */ - int i_second; /**< [0-59] */ - double d_hour; /**< [0.0-23.9999] includes minute and second */ - double d_minute; /**< [0.0-59.9999] includes second */ - double d_second; /**< [0.0-59.9999] */ - int weekday; /**< [0-6] */ - int day_of_year; /**< [1-366] */ -} UTinstant, * UTinstantPtr; - -/* Functions in caldate.c */ - -long caldat( UTinstantPtr ); /** converts julian date to year,mo,da */ -double juldat( UTinstantPtr ); /** returns julian day from year,mo,da */ - -#endif /* _astime_h_ */ diff --git a/calendar/libical/src/libical/caldate.c b/calendar/libical/src/libical/caldate.c deleted file mode 100644 index 1ce9178651..0000000000 --- a/calendar/libical/src/libical/caldate.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 1986-2000, Hiram Clawson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * - * Redistributions in binary form must reproduce the - * above copyright notice, this list of conditions and - * the following disclaimer in the documentation and/or - * other materials provided with the distribution. - * - * Neither name of The Museum of Hiram nor the names of - * its contributors may be used to endorse or promote products - * derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "astime.h" /* time structures */ - -/** - * caldat computes the day of the week, the day of the year - * the gregorian (or julian) calendar date and the universal - * time from the julian decimal date. - * for astronomical purposes, The Gregorian calendar reform occurred - * on 15 Oct. 1582. This is 05 Oct 1582 by the julian calendar. - - * Input: a ut_instant structure pointer, where the j_date element - * has been set. ( = 0 for 01 Jan 4713 B.C. 12 HR UT ) - * - * output: will set all the other elements of the structure. - * As a convienence, the function will also return the year. - * - * Reference: Astronomial formulae for calculators, meeus, p 23 - * from fortran program by F. Espenak - April 1982 Page 277, - * 50 Year canon of solar eclipses: 1986-2035 - * - */ - -long caldat( date ) -struct ut_instant * date; -{ - double frac; - long jd; - long ka; - long kb; - long kc; - long kd; - long ke; - long ialp; - - jd = (long) (date->j_date + 0.5); /* integer julian date */ - frac = date->j_date + 0.5 - (double) jd + 1.0e-10; /* day fraction */ - ka = (long) jd; - if ( jd >= 2299161L ) - { - ialp = (long) (((double) jd) - 1867216.25 ) / 36524.25; - ka = jd + 1L + ialp - ( ialp >> 2 ); - } - kb = ka + 1524L; - kc = (long) ((double) kb - 122.1 ) / 365.25; - kd = (long) (double) kc * 365.25; - ke = (long) (double) ( kb - kd ) / 30.6001; - date->day = kb - kd - ((long) ( (double) ke * 30.6001 )); - if ( ke > 13L ) - date->month = ke - 13L; - else - date->month = ke - 1L; - if ( (date->month == 2) && (date->day > 28) ) - date->day = 29; - if ( (date->month == 2) && (date->day == 29) && (ke == 3L) ) - date->year = kc - 4716L; - else if ( date->month > 2 ) - date->year = kc - 4716L; - else - date->year = kc - 4715L; - date->i_hour = date->d_hour = frac * 24.0; /* hour */ - date->i_minute = date->d_minute = (long) - ( date->d_hour - (double) date->i_hour ) * 60.0; /* minute */ - date->i_second = date->d_second = (long) - ( date->d_minute - (double) date->i_minute ) * 60.0;/* second */ - date->weekday = (jd + 1L) % 7L; /* day of week */ - if ( date->year == ((date->year >> 2) << 2) ) - date->day_of_year = - ( ( 275 * date->month ) / 9) - - ((date->month + 9) / 12) - + date->day - 30; - else - date->day_of_year = - ( ( 275 * date->month ) / 9) - - (((date->month + 9) / 12) << 1) - + date->day - 30; - return( date->year ); -} - -/** - * juldat computes the julian decimal date (j_date) from - * the gregorian (or Julian) calendar date. - * for astronomical purposes, The Gregorian calendar reform occurred - * on 15 Oct. 1582. This is 05 Oct 1582 by the julian calendar. - * Input: a ut_instant structure pointer where Day, Month, Year and - * i_hour, i_minute, d_second have been set for the date - * in question. - * - * Output: the j_date and weekday elements of the structure will be set. - * Also, the return value of the function will be the j_date too. - * - * Reference: Astronomial formulae for calculators, meeus, p 23 - * from fortran program by F. Espenak - April 1982 Page 276, - * 50 Year canon of solar eclipses: 1986-2035 - */ - -double juldat( date ) -struct ut_instant * date; -{ - double frac, gyr; - long iy0, im0; - long ia, ib; - long jd; - - /* decimal day fraction */ - frac = (( double)date->i_hour/ 24.0) - + ((double) date->i_minute / 1440.0) - + (date->d_second / 86400.0); - /* convert date to format YYYY.MMDDdd */ - gyr = (double) date->year - + (0.01 * (double) date->month) - + (0.0001 * (double) date->day) - + (0.0001 * frac) + 1.0e-9; - /* conversion factors */ - if ( date->month <= 2 ) - { - iy0 = date->year - 1L; - im0 = date->month + 12; - } - else - { - iy0 = date->year; - im0 = date->month; - } - ia = iy0 / 100L; - ib = 2L - ia + (ia >> 2); - /* calculate julian date */ - if ( date->year < 0L ) - jd = (long) ((365.25 * (double) iy0) - 0.75) - + (long) (30.6001 * (im0 + 1L) ) - + (long) date->day + 1720994L; - else - jd = (long) (365.25 * (double) iy0) - + (long) (30.6001 * (double) (im0 + 1L)) - + (long) date->day + 1720994L; - if ( gyr >= 1582.1015 ) /* on or after 15 October 1582 */ - jd += ib; - date->j_date = (double) jd + frac + 0.5; - jd = (long) (date->j_date + 0.5); - date->weekday = (jd + 1L) % 7L; - return( date->j_date ); -} /* end of double juldat( date ) */ diff --git a/calendar/libical/src/libical/icalarray.c b/calendar/libical/src/libical/icalarray.c deleted file mode 100644 index e432b7f2f8..0000000000 --- a/calendar/libical/src/libical/icalarray.c +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- - ====================================================================== - FILE: icalarray.c - CREATOR: Damon Chaplin 07 March 2001 - - $Id: icalarray.c,v 1.7 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2001, Ximian, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - - ======================================================================*/ - -/** @file icalarray.c - * - * @brief An array of arbitrarily-sized elements which grows - * dynamically as elements are added. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include - -#include "icalarray.h" -#include "icalerror.h" - - -static void icalarray_expand (icalarray *array, - int space_needed); - -/** @brief Constructor - */ - -icalarray* -icalarray_new (int element_size, - int increment_size) -{ - icalarray *array; - - array = (icalarray*) malloc (sizeof (icalarray)); - if (!array) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return NULL; - } - - array->element_size = element_size; - array->increment_size = increment_size; - array->num_elements = 0; - array->space_allocated = 0; - array->data = NULL; - - return array; -} - - -icalarray *icalarray_copy (icalarray *originalarray) -{ - icalarray *array = icalarray_new(originalarray->element_size, originalarray->increment_size); - - if (!array) - return NULL; - - array->num_elements = originalarray->num_elements; - array->space_allocated = originalarray->space_allocated; - - array->data = malloc(array->space_allocated * array->element_size); - - if (array->data) { - memcpy(array->data, originalarray->data, - array->element_size*array->space_allocated); - } else { - icalerror_set_errno(ICAL_ALLOCATION_ERROR); - } - - return array; -} - - -/** @brief Destructor - */ - -void -icalarray_free (icalarray *array) -{ - if (array->data) { - free (array->data); - array->data = 0; - } - free (array); - array = 0; -} - - -void -icalarray_append (icalarray *array, - const void *element) -{ - if (array->num_elements >= array->space_allocated) - icalarray_expand (array, 1); - - memcpy ((char *)(array->data) + ( array->num_elements * array->element_size ), element, - array->element_size); - array->num_elements++; -} - - -void* -icalarray_element_at (icalarray *array, - int position) -{ - assert (position >= 0); - assert ((unsigned int)position < array->num_elements); - - return (char *)(array->data) + (position * array->element_size); -} - - -void -icalarray_remove_element_at (icalarray *array, - int position) -{ - void *dest; - int elements_to_move; - - assert (position >= 0); - assert ((unsigned int)position < array->num_elements); - - dest = (char *)array->data + (position * array->element_size); - elements_to_move = array->num_elements - position - 1; - - if (elements_to_move > 0) - memmove (dest, (char *)dest + array->element_size, - elements_to_move * array->element_size); - - array->num_elements--; -} - - -void -icalarray_sort (icalarray *array, - int (*compare) (const void *, - const void *)) -{ - qsort (array->data, array->num_elements, array->element_size, compare); -} - - -static void -icalarray_expand (icalarray *array, - int space_needed) -{ - int new_space_allocated; - void *new_data; - - new_space_allocated = array->space_allocated + array->increment_size; - - if ((unsigned int)space_needed > array->increment_size) - new_space_allocated += space_needed; - - /* - new_data = realloc (array->data, - new_space_allocated * array->element_size); - */ - new_data = malloc(new_space_allocated * array->element_size); - - if (new_data) { - memcpy(new_data,array->data,array->element_size*array->space_allocated); - if (array->data) { - free(array->data); - array->data = 0; - } - array->data = new_data; - array->space_allocated = new_space_allocated; - } else { - icalerror_set_errno(ICAL_ALLOCATION_ERROR); - } -} - - diff --git a/calendar/libical/src/libical/icalarray.h b/calendar/libical/src/libical/icalarray.h deleted file mode 100644 index 1d9369b116..0000000000 --- a/calendar/libical/src/libical/icalarray.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/*====================================================================== - FILE: icalarray.h - CREATOR: Damon Chaplin 07 March 2001 - - - $Id: icalarray.h,v 1.5 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2001, Ximian, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - -======================================================================*/ - - -#ifndef ICALARRAY_H -#define ICALARRAY_H - -/** @file icalarray.h - * - * @brief An array of arbitrarily-sized elements which grows - * dynamically as elements are added. - */ - -typedef struct _icalarray icalarray; -struct _icalarray { - unsigned int element_size; - unsigned int increment_size; - unsigned int num_elements; - unsigned int space_allocated; - void *data; -}; - - - -icalarray *icalarray_new (int element_size, - int increment_size); -icalarray *icalarray_copy (icalarray *array); -void icalarray_free (icalarray *array); - -void icalarray_append (icalarray *array, - const void *element); -void icalarray_remove_element_at (icalarray *array, - int position); - -void *icalarray_element_at (icalarray *array, - int position); - -void icalarray_sort (icalarray *array, - int (*compare) (const void *, const void *)); - - -#endif /* ICALARRAY_H */ diff --git a/calendar/libical/src/libical/icalattach.c b/calendar/libical/src/libical/icalattach.c deleted file mode 100644 index 2c5e22540d..0000000000 --- a/calendar/libical/src/libical/icalattach.c +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalattach.c - CREATOR: acampi 28 May 02 - - $Id: icalattach.c,v 1.3 2007-04-30 13:57:47 artcancro Exp $ - $Locker: $ - - - (C) COPYRIGHT 2000, Andrea Campi - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icaltypes.c - - ======================================================================*/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icaltypes.h" -#include "icalerror.h" -#include "icalmemory.h" -#include "icalattachimpl.h" -#include /* for malloc and abs() */ -#include /* for errno */ -#include /* for icalmemory_strdup */ -#include - -icalattach * -icalattach_new_from_url (const char *url) -{ - icalattach *attach; - char *url_copy; - - icalerror_check_arg_rz ((url != NULL), "url"); - - if ((attach = malloc (sizeof (icalattach))) == NULL) { - errno = ENOMEM; - return NULL; - } - - if ((url_copy = strdup (url)) == NULL) { - free (attach); - errno = ENOMEM; - return NULL; - } - - attach->refcount = 1; - attach->is_url = 1; - attach->u.url.url = url_copy; - - return attach; -} - -icalattach * -icalattach_new_from_data (const char *data, icalattach_free_fn_t free_fn, - void *free_fn_data) -{ - icalattach *attach; - char *data_copy; - - icalerror_check_arg_rz ((data != NULL), "data"); - - if ((attach = malloc (sizeof (icalattach))) == NULL) { - errno = ENOMEM; - return NULL; - } - - if ((data_copy = strdup (data)) == NULL) { - free (attach); - errno = ENOMEM; - return NULL; - } - - attach->refcount = 1; - attach->is_url = 0; - attach->u.data.data = data_copy; - attach->u.data.free_fn = free_fn; - attach->u.data.free_fn_data = free_fn_data; - - return attach; -} - -void -icalattach_ref (icalattach *attach) -{ - icalerror_check_arg_rv ((attach != NULL), "attach"); - icalerror_check_arg_rv ((attach->refcount > 0), "attach->refcount > 0"); - - attach->refcount++; -} - -void -icalattach_unref (icalattach *attach) -{ - icalerror_check_arg_rv ((attach != NULL), "attach"); - icalerror_check_arg_rv ((attach->refcount > 0), "attach->refcount > 0"); - - attach->refcount--; - - if (attach->refcount != 0) - return; - - if (attach->is_url) { - free (attach->u.url.url); - } else { - free (attach->u.data.data); -/* unused for now - if (attach->u.data.free_fn) - (* attach->u.data.free_fn) (attach->u.data.data, attach->u.data.free_fn_data); -*/ - } - - free (attach); -} - -int -icalattach_get_is_url (icalattach *attach) -{ - icalerror_check_arg_rz ((attach != NULL), "attach"); - - return attach->is_url ? 1 : 0; -} - -const char * -icalattach_get_url (icalattach *attach) -{ - icalerror_check_arg_rz ((attach != NULL), "attach"); - icalerror_check_arg_rz ((attach->is_url), "attach->is_url"); - - return attach->u.url.url; -} - -unsigned char * -icalattach_get_data (icalattach *attach) -{ - icalerror_check_arg_rz ((attach != NULL), "attach"); - icalerror_check_arg_rz ((!attach->is_url), "!attach->is_url"); - - return (unsigned char*)attach->u.data.data; -} diff --git a/calendar/libical/src/libical/icalattach.h b/calendar/libical/src/libical/icalattach.h deleted file mode 100644 index 5a82ab889a..0000000000 --- a/calendar/libical/src/libical/icalattach.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalattach.h - CREATOR: acampi 28 May 02 - - - (C) COPYRIGHT 2002, Andrea Campi - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalattach.h - -======================================================================*/ - -#ifndef ICALATTACH_H -#define ICALATTACH_H - - -typedef struct icalattach_impl icalattach; - -typedef void (* icalattach_free_fn_t) (unsigned char *data, void *user_data); - -icalattach *icalattach_new_from_url (const char *url); -icalattach *icalattach_new_from_data (const char *data, - icalattach_free_fn_t free_fn, void *free_fn_data); - -void icalattach_ref (icalattach *attach); -void icalattach_unref (icalattach *attach); - -int icalattach_get_is_url (icalattach *attach); -const char *icalattach_get_url (icalattach *attach); -unsigned char *icalattach_get_data (icalattach *attach); - -struct icalattachtype* icalattachtype_new(void); -void icalattachtype_add_reference(struct icalattachtype* v); -void icalattachtype_free(struct icalattachtype* v); - -void icalattachtype_set_url(struct icalattachtype* v, char* url); -char* icalattachtype_get_url(struct icalattachtype* v); - -void icalattachtype_set_base64(struct icalattachtype* v, char* base64, - int owns); -char* icalattachtype_get_base64(struct icalattachtype* v); - -void icalattachtype_set_binary(struct icalattachtype* v, char* binary, - int owns); -void* icalattachtype_get_binary(struct icalattachtype* v); - - - -#endif /* !ICALATTACH_H */ diff --git a/calendar/libical/src/libical/icalattachimpl.h b/calendar/libical/src/libical/icalattachimpl.h deleted file mode 100644 index 952b849632..0000000000 --- a/calendar/libical/src/libical/icalattachimpl.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalattachimpl.h - CREATOR: acampi 28 May 02 - - $Id: icalattachimpl.h,v 1.3 2008-01-15 23:17:40 dothebart Exp $ - - - (C) COPYRIGHT 2000, Andrea Campi - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalattachimpl.h - - -======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifndef ICALATTACHIMPL_H -#define ICALATTACHIMPL_H - -#include "icalattach.h" - -/* Private structure for ATTACH values */ -struct icalattach_impl { - /* Reference count */ - int refcount; - - union { - /* URL attachment data */ - struct { - char *url; - } url; - - /* Inline data */ - struct { - char *data; - icalattach_free_fn_t free_fn; - void *free_fn_data; - } data; - } u; - - /* TRUE if URL, FALSE if inline data */ - unsigned int is_url : 1; -}; - -#endif diff --git a/calendar/libical/src/libical/icalcomponent.c b/calendar/libical/src/libical/icalcomponent.c deleted file mode 100644 index d3ad43e0e9..0000000000 --- a/calendar/libical/src/libical/icalcomponent.c +++ /dev/null @@ -1,2660 +0,0 @@ -/*====================================================================== - FILE: icalcomponent.c - CREATOR: eric 28 April 1999 - - $Id: icalcomponent.c,v 1.64 2008-01-30 20:28:42 dothebart Exp $ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalcomponent.c - -======================================================================*/ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icalcomponent.h" -#include "pvl.h" /* "Pointer-to-void list" */ -#include "icalerror.h" -#include "icalmemory.h" -#include "icalenums.h" -#include "icaltime.h" -#include "icalarray.h" -#include "icaltimezone.h" -#include "icalduration.h" -#include "icalperiod.h" -#include "icalparser.h" -#include "icalrestriction.h" - -#include /* for malloc */ -#include /* for va_list, etc */ -#include -#include -#include /* for fprintf */ -#include /* for strdup */ -#include /* for INT_MAX */ - -#ifdef WIN32 -#define strncasecmp strnicmp -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#endif - -struct icalcomponent_impl -{ - char id[5]; - icalcomponent_kind kind; - char* x_name; - pvl_list properties; - pvl_elem property_iterator; - pvl_list components; - pvl_elem component_iterator; - icalcomponent* parent; - - /** An array of icaltimezone structs. We use this so we can do fast - lookup of timezones using binary searches. timezones_sorted is - set to 0 whenever we add a timezone, so we remember to sort the - array before doing a binary search. */ - icalarray* timezones; - int timezones_sorted; -}; - -/* icalproperty functions that only components get to use */ -void icalproperty_set_parent(icalproperty* property, - icalcomponent* component); -icalcomponent* icalproperty_get_parent(const icalproperty* property); -void icalcomponent_add_children(icalcomponent *impl,va_list args); -static icalcomponent* icalcomponent_new_impl (icalcomponent_kind kind); - -static void icalcomponent_merge_vtimezone (icalcomponent *comp, - icalcomponent *vtimezone, - icalarray *tzids_to_rename); -static void icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp, - icalcomponent *vtimezone, - icalproperty *tzid_prop, - const char *tzid, - icalarray *tzids_to_rename); -static unsigned int icalcomponent_get_tzid_prefix_len (const char *tzid); -static void icalcomponent_rename_tzids(icalcomponent* comp, - icalarray* rename_table); -static void icalcomponent_rename_tzids_callback(icalparameter *param, - void *data); -static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1, - icalcomponent *vtimezone2); -static int icalcomponent_compare_timezone_fn (const void *elem1, - const void *elem2); -static struct icaltimetype -icalcomponent_get_datetime(icalcomponent *comp, icalproperty *prop); - - -void icalcomponent_add_children(icalcomponent *impl, va_list args) -{ - void* vp; - - while((vp = va_arg(args, void*)) != 0) { - - assert (icalcomponent_isa_component(vp) != 0 || - icalproperty_isa_property(vp) != 0 ) ; - - if (icalcomponent_isa_component(vp) != 0 ){ - icalcomponent_add_component(impl, (icalcomponent*)vp); - - } else if (icalproperty_isa_property(vp) != 0 ){ - icalcomponent_add_property(impl, (icalproperty*)vp); - } - } -} - -static icalcomponent* -icalcomponent_new_impl (icalcomponent_kind kind) -{ - icalcomponent* comp; - - if (!icalcomponent_kind_is_valid(kind)) - return NULL; - - if ( ( comp = (icalcomponent*) malloc(sizeof(icalcomponent))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - strcpy(comp->id,"comp"); - - comp->kind = kind; - comp->properties = pvl_newlist(); - comp->property_iterator = 0; - comp->components = pvl_newlist(); - comp->component_iterator = 0; - comp->x_name = 0; - comp->parent = 0; - comp->timezones = NULL; - comp->timezones_sorted = 1; - - return comp; -} - -/** @brief Constructor - */ -icalcomponent* -icalcomponent_new (icalcomponent_kind kind) -{ - return icalcomponent_new_impl(kind); -} - -/** @brief Constructor - */ -icalcomponent* -icalcomponent_vanew (icalcomponent_kind kind, ...) -{ - va_list args; - - icalcomponent *impl = icalcomponent_new_impl(kind); - - if (impl == 0){ - return 0; - } - - va_start(args,kind); - icalcomponent_add_children(impl, args); - va_end(args); - - return impl; -} - -/** @brief Constructor - */ -icalcomponent* icalcomponent_new_from_string(const char* str) -{ - return icalparser_parse_string(str); -} - -/** @brief Constructor - */ -icalcomponent* icalcomponent_new_clone(icalcomponent* old) -{ - icalcomponent *new; - icalproperty *p; - icalcomponent *c; - pvl_elem itr; - - icalerror_check_arg_rz( (old!=0), "component"); - - new = icalcomponent_new_impl(old->kind); - - if (new == 0){ - return 0; - } - - - for( itr = pvl_head(old->properties); - itr != 0; - itr = pvl_next(itr)) - { - p = (icalproperty*)pvl_data(itr); - icalcomponent_add_property(new,icalproperty_new_clone(p)); - } - - - for( itr = pvl_head(old->components); - itr != 0; - itr = pvl_next(itr)) - { - c = (icalcomponent*)pvl_data(itr); - icalcomponent_add_component(new,icalcomponent_new_clone(c)); - } - - return new; - -} - -/** @brief Constructor - */ -icalcomponent* -icalcomponent_new_x (const char* x_name) -{ - icalcomponent* comp = icalcomponent_new_impl(ICAL_X_COMPONENT); - if (!comp) { - return 0; - } - comp->x_name = icalmemory_strdup(x_name); - return comp; -} - -/*** @brief Destructor - */ -void -icalcomponent_free (icalcomponent* c) -{ - icalproperty* prop; - icalcomponent* comp; - - icalerror_check_arg_rv( (c!=0), "component"); - -#ifdef ICAL_FREE_ON_LIST_IS_ERROR - icalerror_assert( (c->parent ==0),"Tried to free a component that is still attached to a parent component"); -#else - if(c->parent != 0){ - return; - } -#endif - - if(c != 0 ){ - - if ( c->properties != 0 ) - { - while( (prop=pvl_pop(c->properties)) != 0){ - assert(prop != 0); - icalproperty_set_parent(prop,0); - icalproperty_free(prop); - } - pvl_free(c->properties); - } - - - while( (comp=pvl_data(pvl_head(c->components))) != 0){ - assert(comp!=0); - icalcomponent_remove_component(c,comp); - icalcomponent_free(comp); - } - - pvl_free(c->components); - - if (c->x_name != 0) { - free(c->x_name); - } - - if (c->timezones) - icaltimezone_array_free (c->timezones); - - c->kind = ICAL_NO_COMPONENT; - c->properties = 0; - c->property_iterator = 0; - c->components = 0; - c->component_iterator = 0; - c->x_name = 0; - c->id[0] = 'X'; - c->timezones = NULL; - - free(c); - } -} - - -char* -icalcomponent_as_ical_string (icalcomponent* impl) -{ - char *buf; - buf = icalcomponent_as_ical_string_r(impl); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* -icalcomponent_as_ical_string_r (icalcomponent* impl) -{ - char* buf; - char* tmp_buf; - size_t buf_size = 1024; - char* buf_ptr = 0; - pvl_elem itr; - /* RFC 2445 explicitly says that the newline is *ALWAYS* a \r\n (CRLF)!!!! */ - const char newline[] = "\r\n"; - - icalcomponent *c; - icalproperty *p; - icalcomponent_kind kind = icalcomponent_isa(impl); - - const char* kind_string; - - icalerror_check_arg_rz( (impl!=0), "component"); - icalerror_check_arg_rz( (kind!=ICAL_NO_COMPONENT), "component kind is ICAL_NO_COMPONENT"); - - if (kind != ICAL_X_COMPONENT) { - kind_string = icalcomponent_kind_to_string(kind); - } else { - kind_string = impl->x_name; - } - - icalerror_check_arg_rz( (kind_string!=0),"Unknown kind of component"); - - buf = icalmemory_new_buffer(buf_size); - buf_ptr = buf; - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:"); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); - - - - for( itr = pvl_head(impl->properties); - itr != 0; - itr = pvl_next(itr)) - { - p = (icalproperty*)pvl_data(itr); - - icalerror_assert((p!=0),"Got a null property"); - tmp_buf = icalproperty_as_ical_string_r(p); - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); - free(tmp_buf); - } - - - for( itr = pvl_head(impl->components); - itr != 0; - itr = pvl_next(itr)) - { - c = (icalcomponent*)pvl_data(itr); - - tmp_buf = icalcomponent_as_ical_string_r(c); - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, tmp_buf); - free(tmp_buf); - - } - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:"); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, - icalcomponent_kind_to_string(kind)); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); - - return buf; -} - - -int -icalcomponent_is_valid (icalcomponent* component) -{ - if ( (strcmp(component->id,"comp") == 0) && - component->kind != ICAL_NO_COMPONENT){ - return 1; - } else { - return 0; - } - -} - - -icalcomponent_kind -icalcomponent_isa (const icalcomponent* component) -{ - icalerror_check_arg_rx( (component!=0), "component", ICAL_NO_COMPONENT); - - if(component != 0) - { - return component->kind; - } - return ICAL_NO_COMPONENT; -} - - -int -icalcomponent_isa_component (void* component) -{ - icalcomponent *impl = component; - - icalerror_check_arg_rz( (component!=0), "component"); - - if (strcmp(impl->id,"comp") == 0) { - return 1; - } else { - return 0; - } - -} - -void -icalcomponent_add_property (icalcomponent* component, icalproperty* property) -{ - icalerror_check_arg_rv( (component!=0), "component"); - icalerror_check_arg_rv( (property!=0), "property"); - - icalerror_assert( (!icalproperty_get_parent(property)),"The property has already been added to a component. Remove the property with icalcomponent_remove_property before calling icalcomponent_add_property"); - - icalproperty_set_parent(property,component); - - pvl_push(component->properties,property); -} - - -void -icalcomponent_remove_property (icalcomponent* component, icalproperty* property) -{ - pvl_elem itr, next_itr; - - icalerror_check_arg_rv( (component!=0), "component"); - icalerror_check_arg_rv( (property!=0), "property"); - - icalerror_assert( (icalproperty_get_parent(property)),"The property is not a member of a component"); - - - for( itr = pvl_head(component->properties); - itr != 0; - itr = next_itr) - { - next_itr = pvl_next(itr); - - if( pvl_data(itr) == (void*)property ){ - - if (component->property_iterator == itr){ - component->property_iterator = pvl_next(itr); - } - - pvl_remove( component->properties, itr); - icalproperty_set_parent(property,0); - } - } -} - -int -icalcomponent_count_properties (icalcomponent* component, - icalproperty_kind kind) -{ - int count=0; - pvl_elem itr; - - icalerror_check_arg_rz( (component!=0), "component"); - - for( itr = pvl_head(component->properties); - itr != 0; - itr = pvl_next(itr)) - { - if(kind == icalproperty_isa((icalproperty*)pvl_data(itr)) || - kind == ICAL_ANY_PROPERTY){ - count++; - } - } - - - return count; - -} - -icalproperty* icalcomponent_get_current_property (icalcomponent* component) -{ - icalerror_check_arg_rz( (component!=0),"component"); - - if ((component->property_iterator==0)){ - return 0; - } - - return (icalproperty*) pvl_data(component->property_iterator); -} - -icalproperty* -icalcomponent_get_first_property (icalcomponent* c, icalproperty_kind kind) -{ - icalerror_check_arg_rz( (c!=0),"component"); - - for( c->property_iterator = pvl_head(c->properties); - c->property_iterator != 0; - c->property_iterator = pvl_next(c->property_iterator)) { - - icalproperty *p = (icalproperty*) pvl_data(c->property_iterator); - - if (icalproperty_isa(p) == kind || kind == ICAL_ANY_PROPERTY) { - - return p; - } - } - return 0; -} - -icalproperty* -icalcomponent_get_next_property (icalcomponent* c, icalproperty_kind kind) -{ - icalerror_check_arg_rz( (c!=0),"component"); - - if (c->property_iterator == 0){ - return 0; - } - - for( c->property_iterator = pvl_next(c->property_iterator); - c->property_iterator != 0; - c->property_iterator = pvl_next(c->property_iterator)) { - - icalproperty *p = (icalproperty*) pvl_data(c->property_iterator); - - if (icalproperty_isa(p) == kind || kind == ICAL_ANY_PROPERTY) { - - return p; - } - } - - return 0; -} - - -icalproperty** -icalcomponent_get_properties (icalcomponent* component, icalproperty_kind kind); - - -void -icalcomponent_add_component (icalcomponent* parent, icalcomponent* child) -{ - icalerror_check_arg_rv( (parent!=0), "parent"); - icalerror_check_arg_rv( (child!=0), "child"); - - if (child->parent !=0) { - icalerror_set_errno(ICAL_USAGE_ERROR); - } - - child->parent = parent; - - /* Fix for Mozilla - bug 327602 */ - if (child->kind != ICAL_VTIMEZONE_COMPONENT) { - pvl_push(parent->components, child); - } else { - /* VTIMEZONES should be first in the resulting VCALENDAR. */ - pvl_unshift(parent->components, child); - - /* Add the VTIMEZONE to our array. */ - /* FIXME: Currently we are also creating this array when loading in - a builtin VTIMEZONE, when we don't need it. */ - if (!parent->timezones) - parent->timezones = icaltimezone_array_new (); - - icaltimezone_array_append_from_vtimezone (parent->timezones, child); - - /* Flag that we need to sort it before doing any binary searches. */ - parent->timezones_sorted = 0; - } -} - - -void -icalcomponent_remove_component (icalcomponent* parent, icalcomponent* child) -{ - pvl_elem itr, next_itr; - - icalerror_check_arg_rv( (parent!=0), "parent"); - icalerror_check_arg_rv( (child!=0), "child"); - - /* If the component is a VTIMEZONE, remove it from our array as well. */ - if (child->kind == ICAL_VTIMEZONE_COMPONENT) { - icaltimezone *zone; - int i, num_elements; - - num_elements = parent->timezones ? parent->timezones->num_elements : 0; - for (i = 0; i < num_elements; i++) { - zone = icalarray_element_at (parent->timezones, i); - if (icaltimezone_get_component (zone) == child) { - icaltimezone_free (zone, 0); - icalarray_remove_element_at (parent->timezones, i); - break; - } - } - } - - for( itr = pvl_head(parent->components); - itr != 0; - itr = next_itr) - { - next_itr = pvl_next(itr); - - if( pvl_data(itr) == (void*)child ){ - - if (parent->component_iterator == itr){ - /* Don't let the current iterator become invalid */ - - /* HACK. The semantics for this are troubling. */ - parent->component_iterator = - pvl_next(parent->component_iterator); - - } - pvl_remove( parent->components, itr); - child->parent = 0; - break; - } - } -} - - -int -icalcomponent_count_components (icalcomponent* component, - icalcomponent_kind kind) -{ - int count=0; - pvl_elem itr; - - icalerror_check_arg_rz( (component!=0), "component"); - - for( itr = pvl_head(component->components); - itr != 0; - itr = pvl_next(itr)) - { - if(kind == icalcomponent_isa((icalcomponent*)pvl_data(itr)) || - kind == ICAL_ANY_COMPONENT){ - count++; - } - } - - return count; -} - -icalcomponent* -icalcomponent_get_current_component(icalcomponent* component) -{ - icalerror_check_arg_rz( (component!=0),"component"); - - if (component->component_iterator == 0){ - return 0; - } - - return (icalcomponent*) pvl_data(component->component_iterator); -} - -icalcomponent* -icalcomponent_get_first_component (icalcomponent* c, - icalcomponent_kind kind) -{ - icalerror_check_arg_rz( (c!=0),"component"); - - for( c->component_iterator = pvl_head(c->components); - c->component_iterator != 0; - c->component_iterator = pvl_next(c->component_iterator)) { - - icalcomponent *p = (icalcomponent*) pvl_data(c->component_iterator); - - if (icalcomponent_isa(p) == kind || kind == ICAL_ANY_COMPONENT) { - - return p; - } - } - - return 0; -} - - -icalcomponent* -icalcomponent_get_next_component (icalcomponent* c, icalcomponent_kind kind) -{ - icalerror_check_arg_rz( (c!=0),"component"); - - if (c->component_iterator == 0){ - return 0; - } - - for( c->component_iterator = pvl_next(c->component_iterator); - c->component_iterator != 0; - c->component_iterator = pvl_next(c->component_iterator)) { - - icalcomponent *p = (icalcomponent*) pvl_data(c->component_iterator); - - if (icalcomponent_isa(p) == kind || kind == ICAL_ANY_COMPONENT) { - - return p; - } - } - - return 0; -} - -icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c) -{ - icalcomponent *comp; - - for(comp = icalcomponent_get_first_component(c,ICAL_ANY_COMPONENT); - comp != 0; - comp = icalcomponent_get_next_component(c,ICAL_ANY_COMPONENT)){ - - icalcomponent_kind kind = icalcomponent_isa(comp); - - if(kind == ICAL_VEVENT_COMPONENT || - kind == ICAL_VTODO_COMPONENT || - kind == ICAL_VJOURNAL_COMPONENT || - kind == ICAL_VFREEBUSY_COMPONENT || - kind == ICAL_VQUERY_COMPONENT || - kind == ICAL_VAGENDA_COMPONENT){ - return comp; - } - } - return 0; -} - - -/** @brief Get the timespan covered by this component, in UTC - * (deprecated) - * - * see icalcomponent_foreach_recurrence() for a better way to - * extract spans from an component. - * - * This method can be called on either a VCALENDAR or any real - * component. If the VCALENDAR contains no real component, but - * contains a VTIMEZONE, we return that span instead. - * This might not be a desirable behavior; we keep it for now - * for backward compatibility, but it might be deprecated at a - * future time. - * - * FIXME this API needs to be clarified. DTEND is defined as the - * first available time after the end of this event, so the span - * should actually end 1 second before DTEND. - */ - -icaltime_span icalcomponent_get_span(icalcomponent* comp) -{ - icalcomponent *inner; - icalcomponent_kind kind; - icaltime_span span; - struct icaltimetype start, end; - - span.start = 0; - span.end = 0; - span.is_busy= 1; - - /* initial Error checking */ - if (comp == NULL) { - return span; - } - - /* FIXME this might go away */ - kind = icalcomponent_isa(comp); - if(kind == ICAL_VCALENDAR_COMPONENT){ - inner = icalcomponent_get_first_real_component(comp); - - /* Maybe there is a VTIMEZONE in there */ - if (inner == 0){ - inner = icalcomponent_get_first_component(comp, - ICAL_VTIMEZONE_COMPONENT); - } - - } else { - inner = comp; - } - - if (inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - /*icalerror_warn("icalcomponent_get_span: no component specified, or empty VCALENDAR component");*/ - return span; - } - - kind = icalcomponent_isa(inner); - - if( !( kind == ICAL_VEVENT_COMPONENT || - kind == ICAL_VJOURNAL_COMPONENT || - kind == ICAL_VTODO_COMPONENT || - kind == ICAL_VFREEBUSY_COMPONENT )) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - /*icalerror_warn("icalcomponent_get_span: no component specified, or empty VCALENDAR component");*/ - return span; - - } - - /* Get to work. starting with DTSTART */ - start = icalcomponent_get_dtstart(comp); - if (icaltime_is_null_time(start)) { - return span; - } - span.start = icaltime_as_timet_with_zone(start, - icaltimezone_get_utc_timezone()); - - /* The end time could be specified as either a DTEND or a DURATION */ - /* icalcomponent_get_dtend takes care of these cases. */ - end = icalcomponent_get_dtend(comp); - if (icaltime_is_null_time(end)) { - if (!icaltime_is_date(start)) { - /* If dtstart is a DATE-TIME and there is no DTEND nor DURATION - it takes no time */ - span.start = 0; - return span; - } else { - end = start; - } - } - - span.end = icaltime_as_timet_with_zone(end, - icaltimezone_get_utc_timezone()); - if (icaltime_is_date(start)) { - /* Until the end of the day*/ - span.end += 60*60*24 - 1; - } - - return span; - -} - -/** - * Decide if this recurrance is acceptable - * - * @param comp A valid icalcomponent. - * @param dtstart The base dtstart value for this component. - * @param recurtime The time to test against. - * - * @return true if the recurrence value is excluded, false otherwise. - * - * This function decides if a specific recurrence value is - * excluded by EXRULE or EXDATE properties. - * - * It's not the most efficient code. You might get better performance - * if you assume that recurtime is always increasing for each - * call. Then you could: - * - * - sort the EXDATE values - * - save the state of each EXRULE iterator for the next call. - * - * In this case though you don't need to worry how you call this - * function. It will always return the correct result. - */ - -int icalproperty_recurrence_is_excluded(icalcomponent *comp, - struct icaltimetype *dtstart, - struct icaltimetype *recurtime) { - icalproperty *exdate, *exrule; - pvl_elem property_iterator; - - if (comp == NULL || - dtstart == NULL || - recurtime == NULL || - icaltime_is_null_time(*recurtime)) - /* BAD DATA */ - return 1; - - property_iterator = comp->property_iterator; - - /** first test against the exdate values **/ - for (exdate = icalcomponent_get_first_property(comp,ICAL_EXDATE_PROPERTY); - exdate != NULL; - exdate = icalcomponent_get_next_property(comp,ICAL_EXDATE_PROPERTY)) { - - struct icaltimetype exdatetime = icalcomponent_get_datetime(comp, exdate); - - if (icaltime_compare(*recurtime, exdatetime) == 0) { - /** MATCHED **/ - - comp->property_iterator = property_iterator; - return 1; - } - } - - /** Now test against the EXRULEs **/ - for (exrule = icalcomponent_get_first_property(comp,ICAL_EXRULE_PROPERTY); - exrule != NULL; - exrule = icalcomponent_get_next_property(comp,ICAL_EXRULE_PROPERTY)) { - - struct icalrecurrencetype recur = icalproperty_get_exrule(exrule); - icalrecur_iterator *exrule_itr = icalrecur_iterator_new(recur, *dtstart); - struct icaltimetype exrule_time; - - while (exrule_itr) { - int result; - exrule_time = icalrecur_iterator_next(exrule_itr); - - if (icaltime_is_null_time(exrule_time)) - break; - - result = icaltime_compare(*recurtime, exrule_time); - if (result == 0) { - icalrecur_iterator_free(exrule_itr); - comp->property_iterator = property_iterator; - return 1; /** MATCH **/ - } - if (result == 1) - break; /** exrule_time > recurtime **/ - } - - icalrecur_iterator_free(exrule_itr); - } - comp->property_iterator = property_iterator; - - return 0; /** no matches **/ -} - -/** - * @brief Return the busy status based on the TRANSP property. - * - * @param comp A valid icalcomponent. - * - * @return 1 if the event is a busy item, 0 if it is not. - */ - -static int icalcomponent_is_busy(icalcomponent *comp) { - icalproperty *transp; - enum icalproperty_status status; - int ret = 1; - - /** @todo check access control here, converting busy->free if the - permissions do not allow access... */ - - /* Is this a busy time? Check the TRANSP property */ - transp = icalcomponent_get_first_property(comp, ICAL_TRANSP_PROPERTY); - - if (transp) { - icalvalue *transp_val = icalproperty_get_value(transp); - - switch (icalvalue_get_transp(transp_val)) { - case ICAL_TRANSP_OPAQUE: - case ICAL_TRANSP_OPAQUENOCONFLICT: - case ICAL_TRANSP_NONE: - ret = 1; - break; - case ICAL_TRANSP_TRANSPARENT: - case ICAL_TRANSP_TRANSPARENTNOCONFLICT: - ret = 0; - break; - default: - ret = 0; - break; - } - } - status = icalcomponent_get_status(comp); - if (ret && status) { - switch (status) { - case ICAL_STATUS_CANCELLED: - case ICAL_STATUS_TENTATIVE: - ret = 0; - break; - default: - break; - } - } - return(ret); -} - - - - -/** - * @brief cycle through all recurrances of an event - * - * @param comp A valid VEVENT component - * @param start Ignore timespans before this - * @param end Ignore timespans after this - * @param callback Function called for each timespan within the range - * @param callback_data Pointer passed back to the callback function - * - * This function will call the specified callback function for once - * for the base value of DTSTART, and foreach recurring date/time - * value. - * - * It will filter out events that are specified as an EXDATE or an EXRULE. - * - * @todo We do not filter out duplicate RRULES/RDATES - * @todo We do not handle RDATEs with explicit periods - */ - -void icalcomponent_foreach_recurrence(icalcomponent* comp, - struct icaltimetype start, - struct icaltimetype end, - void (*callback)(icalcomponent *comp, - struct icaltime_span *span, - void *data), - void *callback_data) -{ - struct icaltimetype dtstart, dtend; - icaltime_span recurspan, basespan, limit_span; - time_t limit_start, limit_end; - int dtduration; - icalproperty *rrule, *rdate; - struct icaldurationtype dur; - pvl_elem property_iterator; /* for saving the iterator */ - - if (comp == NULL || callback == NULL) - return; - - dtstart = icalcomponent_get_dtstart(comp); - - if (icaltime_is_null_time(dtstart)) - return; - - - /* The end time could be specified as either a DTEND or a DURATION */ - /* icalcomponent_get_dtend takes care of these cases. */ - dtend = icalcomponent_get_dtend(comp); - - /* Now set up the base span for this item, corresponding to the - base DTSTART and DTEND */ - basespan = icaltime_span_new(dtstart, dtend, 1); - - basespan.is_busy = icalcomponent_is_busy(comp); - - - /** Calculate the ceiling and floor values.. **/ - limit_start = icaltime_as_timet_with_zone(start, icaltimezone_get_utc_timezone()); - if (!icaltime_is_null_time(end)) - limit_end = icaltime_as_timet_with_zone(end, icaltimezone_get_utc_timezone()); - else - limit_end = INT_MAX; /* max 32 bit time_t */ - - limit_span.start = limit_start; - limit_span.end = limit_end; - - - /* Do the callback for the initial DTSTART entry */ - - if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &dtstart)) { - /** call callback action **/ - if (icaltime_span_overlaps(&basespan, &limit_span)) - (*callback) (comp, &basespan, callback_data); - } - - recurspan = basespan; - dtduration = basespan.end - basespan.start; - - /* Now cycle through the rrule entries */ - for (rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY); - rrule != NULL; - rrule = icalcomponent_get_next_property(comp,ICAL_RRULE_PROPERTY)) { - - struct icalrecurrencetype recur = icalproperty_get_rrule(rrule); - icalrecur_iterator *rrule_itr = icalrecur_iterator_new(recur, dtstart); - struct icaltimetype rrule_time; - if(rrule_itr) - rrule_time = icalrecur_iterator_next(rrule_itr); - /** note that icalrecur_iterator_next always returns dtstart - the first time.. **/ - - while (rrule_itr) { - rrule_time = icalrecur_iterator_next(rrule_itr); - - if (icaltime_is_null_time(rrule_time)) - break; - - dur = icaltime_subtract(rrule_time, dtstart); - - recurspan.start = basespan.start + icaldurationtype_as_int(dur); - recurspan.end = recurspan.start + dtduration; - - /** save the iterator ICK! **/ - property_iterator = comp->property_iterator; - - if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &rrule_time)) { - /** call callback action **/ - if (icaltime_span_overlaps(&recurspan, &limit_span)) - (*callback) (comp, &recurspan, callback_data); - } - comp->property_iterator = property_iterator; - } /* end of iteration over a specific RRULE */ - - icalrecur_iterator_free(rrule_itr); - } /* end of RRULE loop */ - - - /** Now process RDATE entries **/ - for (rdate = icalcomponent_get_first_property(comp,ICAL_RDATE_PROPERTY); - rdate != NULL; - rdate = icalcomponent_get_next_property(comp,ICAL_RDATE_PROPERTY)) { - - struct icaldatetimeperiodtype rdate_period = icalproperty_get_rdate(rdate); - - /** RDATES can specify raw datetimes, periods, or dates. - we only support raw datetimes for now.. - - @todo Add support for other types **/ - - if (icaltime_is_null_time(rdate_period.time)) - continue; - - dur = icaltime_subtract(rdate_period.time, dtstart); - - recurspan.start = basespan.start + icaldurationtype_as_int(dur); - recurspan.end = recurspan.start + dtduration; - - /** save the iterator ICK! **/ - property_iterator = comp->property_iterator; - - if (!icalproperty_recurrence_is_excluded(comp, &dtstart, &rdate_period.time)) { - /** call callback action **/ - (*callback) (comp, &recurspan, callback_data); - } - comp->property_iterator = property_iterator; - } -} - - - -int icalcomponent_check_restrictions(icalcomponent* comp){ - icalerror_check_arg_rz(comp!=0,"comp"); - return icalrestriction_check(comp); -} - -/** @brief returns the number of errors encountered parsing the data - * - * This function counts the number times the X-LIC-ERROR occurs - * in the data structure. - */ - -int icalcomponent_count_errors(icalcomponent* component) -{ - int errors = 0; - icalproperty *p; - icalcomponent *c; - pvl_elem itr; - - for( itr = pvl_head(component->properties); - itr != 0; - itr = pvl_next(itr)) - { - p = (icalproperty*)pvl_data(itr); - - if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY) - { - errors++; - } - } - - - for( itr = pvl_head(component->components); - itr != 0; - itr = pvl_next(itr)) - { - c = (icalcomponent*)pvl_data(itr); - - errors += icalcomponent_count_errors(c); - - } - - return errors; -} - - -void icalcomponent_strip_errors(icalcomponent* component) -{ - icalproperty *p; - icalcomponent *c; - pvl_elem itr, next_itr; - - for( itr = pvl_head(component->properties); - itr != 0; - itr = next_itr) - { - p = (icalproperty*)pvl_data(itr); - next_itr = pvl_next(itr); - - if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY) - { - icalcomponent_remove_property(component,p); - icalproperty_free(p); - p = NULL; - } - } - - for( itr = pvl_head(component->components); - itr != 0; - itr = pvl_next(itr)) - { - c = (icalcomponent*)pvl_data(itr); - icalcomponent_strip_errors(c); - } -} - -/* Hack. This will change the state of the iterators */ -void icalcomponent_convert_errors(icalcomponent* component) -{ - icalproperty *p, *next_p; - icalcomponent *c; - - for(p = icalcomponent_get_first_property(component,ICAL_ANY_PROPERTY); - p != 0; - p = next_p){ - - next_p = icalcomponent_get_next_property(component,ICAL_ANY_PROPERTY); - - if(icalproperty_isa(p) == ICAL_XLICERROR_PROPERTY) - { - struct icalreqstattype rst; - icalparameter *param = icalproperty_get_first_parameter - (p,ICAL_XLICERRORTYPE_PARAMETER); - - rst.code = ICAL_UNKNOWN_STATUS; - rst.desc = 0; - - switch(icalparameter_get_xlicerrortype(param)){ - - case ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR: { - rst.code = ICAL_3_2_INVPARAM_STATUS; - break; - } - case ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR: { - rst.code = ICAL_3_3_INVPARAMVAL_STATUS; - break; - } - case ICAL_XLICERRORTYPE_PROPERTYPARSEERROR: { - rst.code = ICAL_3_0_INVPROPNAME_STATUS; - break; - } - case ICAL_XLICERRORTYPE_VALUEPARSEERROR: { - rst.code = ICAL_3_1_INVPROPVAL_STATUS; - break; - } - case ICAL_XLICERRORTYPE_COMPONENTPARSEERROR: { - rst.code = ICAL_3_4_INVCOMP_STATUS; - break; - } - - default: { - break; - } - } - if (rst.code != ICAL_UNKNOWN_STATUS){ - - rst.debug = icalproperty_get_xlicerror(p); - icalcomponent_add_property(component, - icalproperty_new_requeststatus(rst)); - - icalcomponent_remove_property(component,p); - icalproperty_free(p); - p = NULL; - } - } - } - - for(c = icalcomponent_get_first_component(component,ICAL_ANY_COMPONENT); - c != 0; - c = icalcomponent_get_next_component(component,ICAL_ANY_COMPONENT)){ - - icalcomponent_convert_errors(c); - } -} - - -icalcomponent* icalcomponent_get_parent(icalcomponent* component) -{ - return component->parent; -} - -void icalcomponent_set_parent(icalcomponent* component, icalcomponent* parent) -{ - component->parent = parent; -} - -icalcompiter icalcompiter_null = {ICAL_NO_COMPONENT,0}; - - -struct icalcomponent_kind_map { - icalcomponent_kind kind; - char name[20]; -}; - - - -static const struct icalcomponent_kind_map component_map[] = -{ - { ICAL_VEVENT_COMPONENT, "VEVENT" }, - { ICAL_VTODO_COMPONENT, "VTODO" }, - { ICAL_VJOURNAL_COMPONENT, "VJOURNAL" }, - { ICAL_VCALENDAR_COMPONENT, "VCALENDAR" }, - { ICAL_VAGENDA_COMPONENT, "VAGENDA" }, - { ICAL_VFREEBUSY_COMPONENT, "VFREEBUSY" }, - { ICAL_VTIMEZONE_COMPONENT, "VTIMEZONE" }, - { ICAL_VALARM_COMPONENT, "VALARM" }, - { ICAL_XSTANDARD_COMPONENT, "STANDARD" }, /*These are part of RFC2445 */ - { ICAL_XDAYLIGHT_COMPONENT, "DAYLIGHT" }, /*but are not really components*/ - { ICAL_X_COMPONENT, "X" }, - { ICAL_VSCHEDULE_COMPONENT, "SCHEDULE" }, - - /* CAP components */ - { ICAL_VCAR_COMPONENT, "VCAR" }, - { ICAL_VCOMMAND_COMPONENT, "VCOMMAND" }, - { ICAL_VQUERY_COMPONENT, "VQUERY" }, - { ICAL_VREPLY_COMPONENT, "VREPLY" }, - - /* libical private components */ - { ICAL_XLICINVALID_COMPONENT, "X-LIC-UNKNOWN" }, - { ICAL_XLICMIMEPART_COMPONENT, "X-LIC-MIME-PART" }, - { ICAL_ANY_COMPONENT, "ANY" }, - { ICAL_XROOT_COMPONENT, "XROOT" }, - - /* End of list */ - { ICAL_NO_COMPONENT, "" }, -}; - - -int icalcomponent_kind_is_valid(const icalcomponent_kind kind) -{ - int i = 0; - do { - if (component_map[i].kind == kind) - return 1; - } while (component_map[i++].kind != ICAL_NO_COMPONENT); - - return 0; -} - -const char* icalcomponent_kind_to_string(icalcomponent_kind kind) -{ - int i; - - for (i=0; component_map[i].kind != ICAL_NO_COMPONENT; i++) { - if (component_map[i].kind == kind) { - return component_map[i].name; - } - } - - return 0; - -} - -icalcomponent_kind icalcomponent_string_to_kind(const char* string) -{ - int i; - - if (string ==0 ) { - return ICAL_NO_COMPONENT; - } - - for (i=0; component_map[i].kind != ICAL_NO_COMPONENT; i++) { - if (strncasecmp(string, component_map[i].name, strlen(component_map[i].name)) == 0) { - return component_map[i].kind; - } - } - - return ICAL_NO_COMPONENT; -} - - - -icalcompiter -icalcomponent_begin_component(icalcomponent* component,icalcomponent_kind kind) -{ - icalcompiter itr; - pvl_elem i; - - itr.kind = kind; - itr.iter = NULL; - - icalerror_check_arg_re(component!=0,"component",icalcompiter_null); - - for( i = pvl_head(component->components); i != 0; i = pvl_next(i)) { - - icalcomponent *c = (icalcomponent*) pvl_data(i); - - if (icalcomponent_isa(c) == kind || kind == ICAL_ANY_COMPONENT) { - - itr.iter = i; - - return itr; - } - } - - return icalcompiter_null; -} - -icalcompiter -icalcomponent_end_component(icalcomponent* component,icalcomponent_kind kind) -{ - icalcompiter itr; - pvl_elem i; - - itr.kind = kind; - - icalerror_check_arg_re(component!=0,"component",icalcompiter_null); - - for( i = pvl_tail(component->components); i != 0; i = pvl_prior(i)) { - - icalcomponent *c = (icalcomponent*) pvl_data(i); - - if (icalcomponent_isa(c) == kind || kind == ICAL_ANY_COMPONENT) { - - itr.iter = pvl_next(i); - - return itr; - } - } - - return icalcompiter_null;; -} - - -icalcomponent* icalcompiter_next(icalcompiter* i) -{ - if (i->iter == 0){ - return 0; - } - - icalerror_check_arg_rz( (i!=0),"i"); - - for( i->iter = pvl_next(i->iter); - i->iter != 0; - i->iter = pvl_next(i->iter)) { - - icalcomponent *c = (icalcomponent*) pvl_data(i->iter); - - if (icalcomponent_isa(c) == i->kind - || i->kind == ICAL_ANY_COMPONENT) { - - return icalcompiter_deref(i);; - } - } - - return 0; - -} - -icalcomponent* icalcompiter_prior(icalcompiter* i) -{ - if (i->iter == 0){ - return 0; - } - - for( i->iter = pvl_prior(i->iter); - i->iter != 0; - i->iter = pvl_prior(i->iter)) { - - icalcomponent *c = (icalcomponent*) pvl_data(i->iter); - - if (icalcomponent_isa(c) == i->kind - || i->kind == ICAL_ANY_COMPONENT) { - - return icalcompiter_deref(i);; - } - } - - return 0; - -} -icalcomponent* icalcompiter_deref(icalcompiter* i) -{ - if(i->iter ==0){ - return 0; - } - - return pvl_data(i->iter); -} - -icalcomponent* icalcomponent_get_inner(icalcomponent* comp) -{ - if (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT){ - return icalcomponent_get_first_real_component(comp); - } else { - return comp; - } -} - -/** @brief sets the METHOD property to the given method - */ - -void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method) -{ - icalproperty *prop - = icalcomponent_get_first_property(comp, ICAL_METHOD_PROPERTY); - - - if (prop == 0){ - prop = icalproperty_new_method(method); - icalcomponent_add_property(comp, prop); - } - - icalproperty_set_method(prop,method); - -} - -/** @brief returns the METHOD property - */ - -icalproperty_method icalcomponent_get_method(icalcomponent* comp) -{ - icalproperty *prop - = icalcomponent_get_first_property(comp,ICAL_METHOD_PROPERTY); - - if (prop == 0){ - return ICAL_METHOD_NONE; - } - - return icalproperty_get_method(prop); -} - -#define ICALSETUPSET(p_kind) \ - icalcomponent *inner; \ - icalproperty *prop; \ - icalerror_check_arg_rv(comp!=0,"comp");\ - inner = icalcomponent_get_inner(comp); \ - if(inner == 0){\ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR);\ - return;\ - }\ - prop = icalcomponent_get_first_property(inner, p_kind); - - -/** @brief Set DTSTART property to given icaltime - * - * This method respects the icaltime type (DATE vs DATE-TIME) and - * timezone (or lack thereof). - */ -void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v) -{ - const char *tzid; - ICALSETUPSET(ICAL_DTSTART_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_dtstart(v); - icalcomponent_add_property(inner, prop); - } else { - icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER); - } - - icalproperty_set_dtstart(prop,v); - - if ((tzid = icaltime_get_tzid(v)) != NULL && !icaltime_is_utc(v)) { - icalproperty_add_parameter(prop, icalparameter_new_tzid(tzid)); - } -} - -/** @brief Get a DATE or DATE-TIME property as an icaltime - * - * If the property is a DATE-TIME with a timezone parameter and a - * corresponding VTIMEZONE is present in the component, the - * returned component will already be in the correct timezone; - * otherwise the caller is responsible for converting it. - * - * FIXME this is useless until we can flag the failure - */ -static struct icaltimetype -icalcomponent_get_datetime(icalcomponent *comp, icalproperty *prop) { - - icalcomponent *c; - icalparameter *param; - struct icaltimetype ret; - - ret = icalvalue_get_datetime(icalproperty_get_value(prop)); - - if ((param = icalproperty_get_first_parameter(prop, ICAL_TZID_PARAMETER)) - != NULL) { - const char *tzid = icalparameter_get_tzid(param); - icaltimezone *tz = NULL; - - for (c = comp; c != NULL; c = icalcomponent_get_parent(c)) { - tz = icalcomponent_get_timezone(c, tzid); - if (tz != NULL) - break; - } - - if (tz == NULL) - tz = icaltimezone_get_builtin_timezone_from_tzid(tzid); - - if (tz != NULL) - ret = icaltime_set_timezone(&ret, tz); - } - - return ret; -} - -/** @brief Get DTSTART property as an icaltime - * - * If DTSTART is a DATE-TIME with a timezone parameter and a - * corresponding VTIMEZONE is present in the component, the - * returned component will already be in the correct timezone; - * otherwise the caller is responsible for converting it. - * - * FIXME this is useless until we can flag the failure - */ -struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp) -{ - icalcomponent *inner = icalcomponent_get_inner(comp); - icalproperty *prop; - - prop = icalcomponent_get_first_property(inner,ICAL_DTSTART_PROPERTY); - if (prop == 0){ - return icaltime_null_time(); - } - - return icalcomponent_get_datetime(comp, prop); -} - -/** @brief Get DTEND property as an icaltime - * - * If a DTEND property is not present but a DURATION is, we use - * that to determine the proper end. - * - * If DTSTART is a DATE-TIME with a timezone parameter and a - * corresponding VTIMEZONE is present in the component, the - * returned component will already be in the correct timezone; - * otherwise the caller is responsible for converting it. - * - * FIXME this is useless until we can flag the failure - */ -struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp) -{ - icalcomponent *inner = icalcomponent_get_inner(comp); - icalproperty *end_prop - = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY); - icalproperty *dur_prop - = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); - struct icaltimetype ret = icaltime_null_time(); - - if ( end_prop != 0) { - ret = icalcomponent_get_datetime(comp, end_prop); - } else if ( dur_prop != 0) { - - struct icaltimetype start = - icalcomponent_get_dtstart(inner); - struct icaldurationtype duration = - icalproperty_get_duration(dur_prop); - - struct icaltimetype end = icaltime_add(start,duration); - - ret = end; - } - - return ret; -} - -/** @brief Set DTEND property to given icaltime - * - * This method respects the icaltime type (DATE vs DATE-TIME) and - * timezone (or lack thereof). - * - * This also checks that a DURATION property isn't already there, - * and returns an error if it is. It's the caller's responsibility - * to remove it. - */ -void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v) -{ - const char *tzid; - ICALSETUPSET(ICAL_DTEND_PROPERTY); - - if (icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY) - != NULL) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return; - } - - if (prop == 0) { - prop = icalproperty_new_dtend(v); - icalcomponent_add_property(inner, prop); - } else { - icalproperty_remove_parameter_by_kind(prop, ICAL_TZID_PARAMETER); - } - - icalproperty_set_dtend(prop,v); - - if ((tzid = icaltime_get_tzid(v)) != NULL && !icaltime_is_utc(v)) { - icalproperty_add_parameter(prop, icalparameter_new_tzid(tzid)); - } -} - -/** @brief Set DURATION property to given icalduration - * - * This method respects the icaltime type (DATE vs DATE-TIME) and - * timezone (or lack thereof). - * - * This also checks that a DTEND property isn't already there, - * and returns an error if it is. It's the caller's responsibility - * to remove it. - */ -void icalcomponent_set_duration(icalcomponent* comp, - struct icaldurationtype v) -{ - ICALSETUPSET(ICAL_DURATION_PROPERTY); - - if (icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY) != NULL) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return; - } - - if (prop == 0) { - prop = icalproperty_new_duration(v); - icalcomponent_add_property(inner, prop); - } else { - icalproperty_set_duration(prop,v); - } -} - -/** @brief Get DURATION property as an icalduration - * - * If a DURATION property is not present but a DTEND is, we use - * that to determine the proper end. - */ -struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp) -{ - icalcomponent *inner = icalcomponent_get_inner(comp); - - icalproperty *end_prop - = icalcomponent_get_first_property(inner,ICAL_DTEND_PROPERTY); - - icalproperty *dur_prop - = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY); - - struct icaldurationtype ret = icaldurationtype_null_duration(); - - if ( dur_prop != 0 && end_prop == 0) { - ret = icalproperty_get_duration(dur_prop); - - } else if ( end_prop != 0 && dur_prop == 0) { - /** - * FIXME - * We assume DTSTART and DTEND are not in different time zones. - * Does the standard actually guarantee this? - */ - struct icaltimetype start = - icalcomponent_get_dtstart(inner); - struct icaltimetype end = - icalcomponent_get_dtend(inner); - - ret = icaltime_subtract(end, start); - } else { - /* Error, both duration and dtend have been specified */ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - } - return ret; -} - -void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v) -{ - - ICALSETUPSET(ICAL_DTSTAMP_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_dtstamp(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_dtstamp(prop,v); - -} - - -struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp) -{ - icalcomponent *inner = icalcomponent_get_inner(comp); - icalproperty *prop - = icalcomponent_get_first_property(inner,ICAL_DTSTAMP_PROPERTY); - - if (prop == 0){ - return icaltime_null_time(); - } - - return icalproperty_get_dtstamp(prop); -} - - -void icalcomponent_set_summary(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_SUMMARY_PROPERTY) - - if (prop == 0){ - prop = icalproperty_new_summary(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_summary(prop,v); -} - - -const char* icalcomponent_get_summary(icalcomponent* comp) -{ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_SUMMARY_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_summary(prop); - -} - -void icalcomponent_set_comment(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_COMMENT_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_comment(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_summary(prop,v); - -} -const char* icalcomponent_get_comment(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_COMMENT_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_comment(prop); -} - -void icalcomponent_set_uid(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_UID_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_uid(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_summary(prop,v); - -} -const char* icalcomponent_get_uid(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_UID_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_uid(prop); -} - -void icalcomponent_set_recurrenceid(icalcomponent* comp, struct icaltimetype v) -{ - ICALSETUPSET(ICAL_RECURRENCEID_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_recurrenceid(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_recurrenceid(prop,v); -} -struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp) -{ - icalcomponent *inner; - icalproperty *prop; - if (comp == 0) { - icalerror_set_errno(ICAL_BADARG_ERROR); - return icaltime_null_time(); - } - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return icaltime_null_time(); - } - - prop= icalcomponent_get_first_property(inner, ICAL_RECURRENCEID_PROPERTY); - - if (prop == 0){ - return icaltime_null_time(); - } - - return icalproperty_get_recurrenceid(prop); -} - -void icalcomponent_set_description(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_DESCRIPTION_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_description(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_description(prop,v); -} -const char* icalcomponent_get_description(icalcomponent* comp) -{ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_DESCRIPTION_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_description(prop); -} - -void icalcomponent_set_location(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_LOCATION_PROPERTY) - - if (prop == 0){ - prop = icalproperty_new_location(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_location(prop,v); -} -const char* icalcomponent_get_location(icalcomponent* comp) -{ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_LOCATION_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_location(prop); -} - -void icalcomponent_set_sequence(icalcomponent* comp, int v) -{ - ICALSETUPSET(ICAL_SEQUENCE_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_sequence(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_sequence(prop,v); - -} -int icalcomponent_get_sequence(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_SEQUENCE_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_sequence(prop); -} - - -void icalcomponent_set_status(icalcomponent* comp, enum icalproperty_status v) -{ - ICALSETUPSET(ICAL_STATUS_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_status(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_status(prop,v); - -} -enum icalproperty_status icalcomponent_get_status(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_STATUS_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_status(prop); -} - -icalcomponent* icalcomponent_new_vcalendar(void) -{ - return icalcomponent_new(ICAL_VCALENDAR_COMPONENT); -} -icalcomponent* icalcomponent_new_vevent(void) -{ - return icalcomponent_new(ICAL_VEVENT_COMPONENT); -} -icalcomponent* icalcomponent_new_vtodo(void) -{ - return icalcomponent_new(ICAL_VTODO_COMPONENT); -} -icalcomponent* icalcomponent_new_vjournal(void) -{ - return icalcomponent_new(ICAL_VJOURNAL_COMPONENT); -} -icalcomponent* icalcomponent_new_valarm(void) -{ - return icalcomponent_new(ICAL_VALARM_COMPONENT); -} -icalcomponent* icalcomponent_new_vfreebusy(void) -{ - return icalcomponent_new(ICAL_VFREEBUSY_COMPONENT); -} -icalcomponent* icalcomponent_new_vtimezone(void) -{ - return icalcomponent_new(ICAL_VTIMEZONE_COMPONENT); -} -icalcomponent* icalcomponent_new_xstandard(void) -{ - return icalcomponent_new(ICAL_XSTANDARD_COMPONENT); -} -icalcomponent* icalcomponent_new_xdaylight(void) -{ - return icalcomponent_new(ICAL_XDAYLIGHT_COMPONENT); -} -icalcomponent* icalcomponent_new_vagenda(void) -{ - return icalcomponent_new(ICAL_VAGENDA_COMPONENT); -} -icalcomponent* icalcomponent_new_vquery(void) -{ - return icalcomponent_new(ICAL_VQUERY_COMPONENT); -} -icalcomponent* icalcomponent_new_vreply(void) -{ - return icalcomponent_new(ICAL_VREPLY_COMPONENT); -} - -/* - * Timezone stuff. - */ - - -/** - * This takes 2 VCALENDAR components and merges the second one into the first, - * resolving any problems with conflicting TZIDs. comp_to_merge will no - * longer exist after calling this function. - */ -void icalcomponent_merge_component(icalcomponent* comp, - icalcomponent* comp_to_merge) -{ - icalcomponent *subcomp, *next_subcomp; - icalarray *tzids_to_rename; - unsigned int i; - - /* Check that both components are VCALENDAR components. */ - assert (icalcomponent_isa(comp) == ICAL_VCALENDAR_COMPONENT); - assert (icalcomponent_isa(comp_to_merge) == ICAL_VCALENDAR_COMPONENT); - - /* Step through each subcomponent of comp_to_merge, looking for VTIMEZONEs. - For each VTIMEZONE found, check if we need to add it to comp and if we - need to rename it and all TZID references to it. */ - tzids_to_rename = icalarray_new (sizeof (char*), 16); - subcomp = icalcomponent_get_first_component (comp_to_merge, - ICAL_VTIMEZONE_COMPONENT); - while (subcomp) { - next_subcomp = icalcomponent_get_next_component (comp_to_merge, - ICAL_VTIMEZONE_COMPONENT); - /* This will add the VTIMEZONE to comp, if necessary, and also update - the array of TZIDs we need to rename. */ - icalcomponent_merge_vtimezone (comp, subcomp, tzids_to_rename); - /* FIXME: Handle possible NEWFAILED error. */ - - subcomp = next_subcomp; - } - - /* If we need to do any renaming of TZIDs, do it now. */ - if (tzids_to_rename->num_elements != 0) { - icalcomponent_rename_tzids (comp_to_merge, tzids_to_rename); - - /* Now free the tzids_to_rename array. */ - for (i = 0; i < tzids_to_rename->num_elements; i++) { - free (icalarray_element_at (tzids_to_rename, i)); - } - } - icalarray_free (tzids_to_rename); - /* Now move all the components from comp_to_merge to comp, excluding - VTIMEZONE components. */ - subcomp = icalcomponent_get_first_component (comp_to_merge, - ICAL_ANY_COMPONENT); - while (subcomp) { - next_subcomp = icalcomponent_get_next_component (comp_to_merge, - ICAL_ANY_COMPONENT); - if (icalcomponent_isa(subcomp) != ICAL_VTIMEZONE_COMPONENT) { - icalcomponent_remove_component (comp_to_merge, subcomp); - icalcomponent_add_component (comp, subcomp); - } - subcomp = next_subcomp; - } - - /* Free comp_to_merge. We have moved most of the subcomponents over to - comp now. */ - icalcomponent_free (comp_to_merge); -} - - -static void icalcomponent_merge_vtimezone (icalcomponent *comp, - icalcomponent *vtimezone, - icalarray *tzids_to_rename) -{ - icalproperty *tzid_prop; - const char *tzid; - char *tzid_copy; - icaltimezone *existing_vtimezone; - - /* Get the TZID of the VTIMEZONE. */ - tzid_prop = icalcomponent_get_first_property (vtimezone, ICAL_TZID_PROPERTY); - if (!tzid_prop) - return; - - tzid = icalproperty_get_tzid (tzid_prop); - if (!tzid) - return; - - /* See if there is already a VTIMEZONE in comp with the same TZID. */ - existing_vtimezone = icalcomponent_get_timezone (comp, tzid); - - /* If there is no existing VTIMEZONE with the same TZID, we can just move - the VTIMEZONE to comp and return. */ - if (!existing_vtimezone) { - icalcomponent_remove_component (icalcomponent_get_parent (vtimezone), - vtimezone); - icalcomponent_add_component (comp, vtimezone); - return; - } - - /* If the TZID has a '/' prefix, then we don't have to worry about the - clashing TZIDs, as they are supposed to be exactly the same VTIMEZONE. */ - if (tzid[0] == '/') - return; - - /* Now we have two VTIMEZONEs with the same TZID (which isn't a globally - unique one), so we compare the VTIMEZONE components to see if they are - the same. If they are, we don't need to do anything. We make a copy of - the tzid, since the parameter may get modified in these calls. */ - tzid_copy = strdup (tzid); - if (!tzid_copy) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } - - if (!icalcomponent_compare_vtimezones (comp, vtimezone)) { - /* FIXME: Handle possible NEWFAILED error. */ - - /* Now we have two different VTIMEZONEs with the same TZID. */ - icalcomponent_handle_conflicting_vtimezones (comp, vtimezone, tzid_prop, - tzid_copy, tzids_to_rename); - } - free (tzid_copy); -} - - -static void -icalcomponent_handle_conflicting_vtimezones (icalcomponent *comp, - icalcomponent *vtimezone, - icalproperty *tzid_prop, - const char *tzid, - icalarray *tzids_to_rename) -{ - int i, suffix, max_suffix = 0, num_elements; - unsigned int tzid_len; - char *tzid_copy, *new_tzid, suffix_buf[32]; - (void)tzid_prop; /* hack to stop unused variable warning */ - - /* Find the length of the TZID without any trailing digits. */ - tzid_len = icalcomponent_get_tzid_prefix_len (tzid); - - /* Step through each of the VTIMEZONEs in comp. We may already have the - clashing VTIMEZONE in the calendar, but it may have been renamed - (i.e. a unique number added on the end of the TZID, e.g. 'London2'). - So we compare the new VTIMEZONE with any VTIMEZONEs that have the - same prefix (e.g. 'London'). If it matches any of those, we have to - rename the TZIDs to that TZID, else we rename to a new TZID, using - the biggest numeric suffix found + 1. */ - num_elements = comp->timezones ? comp->timezones->num_elements : 0; - for (i = 0; i < num_elements; i++) { - icaltimezone *zone; - const char *existing_tzid; - const char *existing_tzid_copy; - unsigned int existing_tzid_len; - - zone = icalarray_element_at (comp->timezones, i); - existing_tzid = icaltimezone_get_tzid (zone); - - /* Find the length of the TZID without any trailing digits. */ - existing_tzid_len = icalcomponent_get_tzid_prefix_len (existing_tzid); - - /* Check if we have the same prefix. */ - if (tzid_len == existing_tzid_len - && !strncmp (tzid, existing_tzid, tzid_len)) { - /* Compare the VTIMEZONEs. */ - if (icalcomponent_compare_vtimezones (icaltimezone_get_component (zone), - vtimezone)) { - /* The VTIMEZONEs match, so we can use the existing VTIMEZONE. But - we have to rename TZIDs to this TZID. */ - tzid_copy = strdup (tzid); - if(!tzid_copy) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } - existing_tzid_copy = strdup (existing_tzid); - if (!existing_tzid_copy) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(tzid_copy); - } else { - icalarray_append (tzids_to_rename, tzid_copy); - free(tzid_copy); - icalarray_append (tzids_to_rename, existing_tzid_copy); - } - return; - } else { - /* FIXME: Handle possible NEWFAILED error. */ - - /* Convert the suffix to an integer and remember the maximum numeric - suffix found. */ - suffix = atoi (existing_tzid + existing_tzid_len); - if (max_suffix < suffix) - max_suffix = suffix; - } - } - } - - /* We didn't find a VTIMEZONE that matched, so we have to rename the TZID, - using the maximum numerical suffix found + 1. */ - tzid_copy = strdup (tzid); - if(!tzid_copy) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } - - snprintf (suffix_buf, sizeof(suffix_buf), "%i", max_suffix + 1); - new_tzid = malloc (tzid_len + strlen (suffix_buf) + 1); - if (!new_tzid) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(tzid_copy); - return; - } - - strncpy (new_tzid, tzid, tzid_len); - strcpy (new_tzid + tzid_len, suffix_buf); - icalarray_append (tzids_to_rename, tzid_copy); - icalarray_append (tzids_to_rename, new_tzid); - free(tzid_copy); - free(new_tzid); -} - - -/* Returns the length of the TZID, without any trailing digits. */ -static unsigned int icalcomponent_get_tzid_prefix_len (const char *tzid) -{ - int len; - const char *p; - - len = strlen (tzid); - p = tzid + len - 1; - while (len > 0 && *p >= '0' && *p <= '9') { - p--; - len--; - } - - return len; -} - - -/** - * Renames all references to the given TZIDs to a new name. rename_table - * contains pairs of strings - a current TZID, and the new TZID to rename it - * to. - */ -static void icalcomponent_rename_tzids(icalcomponent* comp, - icalarray* rename_table) -{ - icalcomponent_foreach_tzid (comp, icalcomponent_rename_tzids_callback, - rename_table); -} - - -static void icalcomponent_rename_tzids_callback(icalparameter *param, void *data) -{ - icalarray *rename_table = data; - const char *tzid; - int i; - - tzid = icalparameter_get_tzid (param); - if (!tzid) - return; - - /* Step through the rename table to see if the current TZID matches - any of the ones we want to rename. */ - for (i = 0; (unsigned int)i < rename_table->num_elements - 1; i += 2) { - if (!strcmp (tzid, icalarray_element_at (rename_table, i))) { - icalparameter_set_tzid (param, icalarray_element_at (rename_table, i + 1)); - break; - } - } -} - - -/** - * Calls the given function for each TZID parameter found in the component. - */ -void icalcomponent_foreach_tzid(icalcomponent* comp, - void (*callback)(icalparameter *param, void *data), - void *callback_data) -{ - icalproperty *prop; - icalproperty_kind kind; - icalparameter *param; - icalcomponent *subcomp; - - /* First look for any TZID parameters used in this component itself. */ - prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY); - while (prop) { - kind = icalproperty_isa (prop); - - /* These are the only properties that can have a TZID. Note that - COMPLETED, CREATED, DTSTAMP & LASTMODIFIED must be in UTC. */ - if (kind == ICAL_DTSTART_PROPERTY || kind == ICAL_DTEND_PROPERTY - || kind == ICAL_DUE_PROPERTY || kind == ICAL_EXDATE_PROPERTY - || kind == ICAL_RDATE_PROPERTY) { - param = icalproperty_get_first_parameter (prop, ICAL_TZID_PARAMETER); - if (param) - (*callback) (param, callback_data); - } - - prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY); - } - - /* Now recursively check child components. */ - subcomp = icalcomponent_get_first_component (comp, ICAL_ANY_COMPONENT); - while (subcomp) { - icalcomponent_foreach_tzid (subcomp, callback, callback_data); - subcomp = icalcomponent_get_next_component (comp, ICAL_ANY_COMPONENT); - } -} - - - -/** - * Returns the icaltimezone from the component corresponding to the given - * TZID, or NULL if the component does not have a corresponding VTIMEZONE. - */ -icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, const char *tzid) -{ - icaltimezone *zone; - int lower, upper, middle, cmp; - const char *zone_tzid; - - if (!comp->timezones) - return NULL; - - /* Sort the array if necessary (by the TZID string). */ - if (!comp->timezones_sorted) { - icalarray_sort (comp->timezones, icalcomponent_compare_timezone_fn); - comp->timezones_sorted = 1; - } - - /* Do a simple binary search. */ - lower = middle = 0; - upper = comp->timezones->num_elements; - - while (lower < upper) { - middle = (lower + upper) >> 1; - zone = icalarray_element_at (comp->timezones, middle); - zone_tzid = icaltimezone_get_tzid (zone); - if (zone_tzid != NULL) { - cmp = strcmp (tzid, zone_tzid); - if (cmp == 0) - return zone; - else if (cmp < 0) - upper = middle; - else - lower = middle + 1; - } - } - - return NULL; -} - - -/** - * A function to compare 2 icaltimezone elements, used for qsort(). - */ -static int icalcomponent_compare_timezone_fn (const void *elem1, - const void *elem2) -{ - icaltimezone *zone1, *zone2; - const char *zone1_tzid, *zone2_tzid; - - zone1 = (icaltimezone*) elem1; - zone2 = (icaltimezone*) elem2; - - zone1_tzid = icaltimezone_get_tzid (zone1); - zone2_tzid = icaltimezone_get_tzid (zone2); - - return strcmp (zone1_tzid, zone2_tzid); -} - - -/** - * Compares 2 VTIMEZONE components to see if they match, ignoring their TZIDs. - * It returns 1 if they match, 0 if they don't, or -1 on error. - */ -static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1, - icalcomponent *vtimezone2) -{ - icalproperty *prop1, *prop2; - const char *tzid1, *tzid2; - char *tzid2_copy, *string1, *string2; - int cmp; - - /* Get the TZID property of the first VTIMEZONE. */ - prop1 = icalcomponent_get_first_property (vtimezone1, ICAL_TZID_PROPERTY); - if (!prop1) - return -1; - - tzid1 = icalproperty_get_tzid (prop1); - if (!tzid1) - return -1; - - /* Get the TZID property of the second VTIMEZONE. */ - prop2 = icalcomponent_get_first_property (vtimezone2, ICAL_TZID_PROPERTY); - if (!prop2) - return -1; - - tzid2 = icalproperty_get_tzid (prop2); - if (!tzid2) - return -1; - - /* Copy the second TZID, and set the property to the same as the first - TZID, since we don't care if these match of not. */ - tzid2_copy = strdup (tzid2); - if (!tzid2_copy) { - icalerror_set_errno (ICAL_NEWFAILED_ERROR); - return 0; - } - - icalproperty_set_tzid (prop2, tzid1); - - /* Now convert both VTIMEZONEs to strings and compare them. */ - string1 = icalcomponent_as_ical_string_r (vtimezone1); - if (!string1) { - free (tzid2_copy); - return -1; - } - - string2 = icalcomponent_as_ical_string_r (vtimezone2); - if (!string2) { - free (string1); - free (tzid2_copy); - return -1; - } - - cmp = strcmp (string1, string2); - - free (string1); - free (string2); - - /* Now reset the second TZID. */ - icalproperty_set_tzid (prop2, tzid2_copy); - free (tzid2_copy); - - return (cmp == 0) ? 1 : 0; -} - - - - - - -/** - * @brief set the RELCALID property of a component. - * - * @param comp Valid calendar component. - * @param v Relcalid URL value - */ - -void icalcomponent_set_relcalid(icalcomponent* comp, const char* v) -{ - ICALSETUPSET(ICAL_RELCALID_PROPERTY); - - if (prop == 0){ - prop = icalproperty_new_relcalid(v); - icalcomponent_add_property(inner, prop); - } - - icalproperty_set_relcalid(prop,v); - -} - - -/** - * @brief get the RELCALID property of a component. - * - * @param comp Valid calendar component. - */ - -const char* icalcomponent_get_relcalid(icalcomponent* comp){ - icalcomponent *inner; - icalproperty *prop; - icalerror_check_arg_rz(comp!=0,"comp"); - - inner = icalcomponent_get_inner(comp); - - if(inner == 0){ - return 0; - } - - prop= icalcomponent_get_first_property(inner,ICAL_RELCALID_PROPERTY); - - if (prop == 0){ - return 0; - } - - return icalproperty_get_relcalid(prop); -} - - -/** @brief Return the time a TODO task is DUE. - * - * @param comp Valid calendar component. - * - * Uses the DUE: property if it exists, otherwise we calculate the DUE - * value by adding the task's duration to the DTSTART time - */ - -struct icaltimetype icalcomponent_get_due(icalcomponent* comp) -{ - icalcomponent *inner = icalcomponent_get_inner(comp); - - icalproperty *due_prop - = icalcomponent_get_first_property(inner,ICAL_DUE_PROPERTY); - - icalproperty *dur_prop - = icalcomponent_get_first_property(inner, ICAL_DURATION_PROPERTY); - - if ( due_prop != 0) { - return icalproperty_get_due(due_prop); - } else if ( dur_prop != 0) { - - struct icaltimetype start = - icalcomponent_get_dtstart(inner); - struct icaldurationtype duration = - icalproperty_get_duration(dur_prop); - - struct icaltimetype due = icaltime_add(start,duration); - - return due; - - } - return icaltime_null_time(); -} - -/** @brief Set the due date of a VTODO task. - * - * @param comp Valid VTODO component. - * @param v Valid due date time. - * - * - If no duration or due properties then set the DUE property. - * - If a DUE property is already set, then reset it to the value v. - * - If a DURATION property is already set, then calculate the new - * duration based on the supplied value of v. - */ - -void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v) -{ - icalcomponent *inner = icalcomponent_get_inner(comp); - - icalproperty *due_prop - = icalcomponent_get_first_property(inner,ICAL_DUE_PROPERTY); - - icalproperty *dur_prop - = icalcomponent_get_first_property(inner,ICAL_DURATION_PROPERTY); - - - if( due_prop == 0 && dur_prop == 0){ - due_prop = icalproperty_new_due(v); - icalcomponent_add_property(inner,due_prop); - } else if ( due_prop != 0) { - icalproperty_set_due(due_prop,v); - } else if ( dur_prop != 0) { - struct icaltimetype start = - icalcomponent_get_dtstart(inner); - - struct icaltimetype due = - icalcomponent_get_due(inner); - - struct icaldurationtype dur - = icaltime_subtract(due,start); - - icalproperty_set_duration(dur_prop,dur); - - } -} diff --git a/calendar/libical/src/libical/icalcomponent.h b/calendar/libical/src/libical/icalcomponent.h deleted file mode 100644 index 338dac1103..0000000000 --- a/calendar/libical/src/libical/icalcomponent.h +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalcomponent.h - CREATOR: eric 20 March 1999 - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalcomponent.h - -======================================================================*/ - -#ifndef ICALCOMPONENT_H -#define ICALCOMPONENT_H - -#include "icalproperty.h" -#include "icalvalue.h" -#include "icalenums.h" /* defines icalcomponent_kind */ -#include "pvl.h" - -typedef struct icalcomponent_impl icalcomponent; - -#ifndef ICALTIMEZONE_DEFINED -#define ICALTIMEZONE_DEFINED -/** @brief An opaque struct representing a timezone. - * We declare this here to avoid a circular dependancy. - */ -typedef struct _icaltimezone icaltimezone; -#endif - - -/* This is exposed so that callers will not have to allocate and - deallocate iterators. Pretend that you can't see it. */ -typedef struct icalcompiter -{ - icalcomponent_kind kind; - pvl_elem iter; - -} icalcompiter; - -icalcomponent* icalcomponent_new(icalcomponent_kind kind); -icalcomponent* icalcomponent_new_clone(icalcomponent* component); -icalcomponent* icalcomponent_new_from_string(const char* str); -icalcomponent* icalcomponent_vanew(icalcomponent_kind kind, ...); -icalcomponent* icalcomponent_new_x(const char* x_name); -void icalcomponent_free(icalcomponent* component); - -char* icalcomponent_as_ical_string(icalcomponent* component); -char* icalcomponent_as_ical_string_r(icalcomponent* component); - -int icalcomponent_is_valid(icalcomponent* component); - -icalcomponent_kind icalcomponent_isa(const icalcomponent* component); - -int icalcomponent_isa_component (void* component); - -/* - * Working with properties - */ - -void icalcomponent_add_property(icalcomponent* component, - icalproperty* property); - -void icalcomponent_remove_property(icalcomponent* component, - icalproperty* property); - -int icalcomponent_count_properties(icalcomponent* component, - icalproperty_kind kind); - -/* Iterate through the properties */ -icalproperty* icalcomponent_get_current_property(icalcomponent* component); - -icalproperty* icalcomponent_get_first_property(icalcomponent* component, - icalproperty_kind kind); -icalproperty* icalcomponent_get_next_property(icalcomponent* component, - icalproperty_kind kind); - - -/* - * Working with components - */ - - -/* Return the first VEVENT, VTODO or VJOURNAL sub-component of cop, or - comp if it is one of those types */ - -icalcomponent* icalcomponent_get_inner(icalcomponent* comp); - - -void icalcomponent_add_component(icalcomponent* parent, - icalcomponent* child); - -void icalcomponent_remove_component(icalcomponent* parent, - icalcomponent* child); - -int icalcomponent_count_components(icalcomponent* component, - icalcomponent_kind kind); - -/** - This takes 2 VCALENDAR components and merges the second one into the first, - resolving any problems with conflicting TZIDs. comp_to_merge will no - longer exist after calling this function. */ -void icalcomponent_merge_component(icalcomponent* comp, - icalcomponent* comp_to_merge); - - -/* Iteration Routines. There are two forms of iterators, internal and -external. The internal ones came first, and are almost completely -sufficient, but they fail badly when you want to construct a loop that -removes components from the container.*/ - - -/* Iterate through components */ -icalcomponent* icalcomponent_get_current_component (icalcomponent* component); - -icalcomponent* icalcomponent_get_first_component(icalcomponent* component, - icalcomponent_kind kind); -icalcomponent* icalcomponent_get_next_component(icalcomponent* component, - icalcomponent_kind kind); - -/* Using external iterators */ -icalcompiter icalcomponent_begin_component(icalcomponent* component, - icalcomponent_kind kind); -icalcompiter icalcomponent_end_component(icalcomponent* component, - icalcomponent_kind kind); -icalcomponent* icalcompiter_next(icalcompiter* i); -icalcomponent* icalcompiter_prior(icalcompiter* i); -icalcomponent* icalcompiter_deref(icalcompiter* i); - - -/* Working with embedded error properties */ - - -/* Check the component against itip rules and insert error properties*/ -/* Working with embedded error properties */ -int icalcomponent_check_restrictions(icalcomponent* comp); - -/** Count embedded errors. */ -int icalcomponent_count_errors(icalcomponent* component); - -/** Remove all X-LIC-ERROR properties*/ -void icalcomponent_strip_errors(icalcomponent* component); - -/** Convert some X-LIC-ERROR properties into RETURN-STATUS properties*/ -void icalcomponent_convert_errors(icalcomponent* component); - -/* Internal operations. They are private, and you should not be using them. */ -icalcomponent* icalcomponent_get_parent(icalcomponent* component); -void icalcomponent_set_parent(icalcomponent* component, - icalcomponent* parent); - -/* Kind conversion routines */ - -int icalcomponent_kind_is_valid(const icalcomponent_kind kind); - -icalcomponent_kind icalcomponent_string_to_kind(const char* string); - -const char* icalcomponent_kind_to_string(icalcomponent_kind kind); - - -/************* Derived class methods. **************************** - -If the code was in an OO language, the remaining routines would be -members of classes derived from icalcomponent. Don't call them on the -wrong component subtypes. */ - -/** For VCOMPONENT: Return a reference to the first VEVENT, VTODO or - VJOURNAL */ -icalcomponent* icalcomponent_get_first_real_component(icalcomponent *c); - -/** For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the start and end - times of an event in UTC */ -struct icaltime_span icalcomponent_get_span(icalcomponent* comp); - -/******************** Convienience routines **********************/ - -void icalcomponent_set_dtstart(icalcomponent* comp, struct icaltimetype v); -struct icaltimetype icalcomponent_get_dtstart(icalcomponent* comp); - -/* For the icalcomponent routines only, dtend and duration are tied - together. If you call the set routine for one and the other exists, - the routine will calculate the change to the other. That is, if - there is a DTEND and you call set_duration, the routine will modify - DTEND to be the sum of DTSTART and the duration. If you call a get - routine for one and the other exists, the routine will calculate - the return value. If you call a set routine and neither exists, the - routine will create the apcompriate comperty */ - - -struct icaltimetype icalcomponent_get_dtend(icalcomponent* comp); -void icalcomponent_set_dtend(icalcomponent* comp, struct icaltimetype v); - -struct icaltimetype icalcomponent_get_due(icalcomponent* comp); -void icalcomponent_set_due(icalcomponent* comp, struct icaltimetype v); - -void icalcomponent_set_duration(icalcomponent* comp, - struct icaldurationtype v); -struct icaldurationtype icalcomponent_get_duration(icalcomponent* comp); - -void icalcomponent_set_method(icalcomponent* comp, icalproperty_method method); -icalproperty_method icalcomponent_get_method(icalcomponent* comp); - -struct icaltimetype icalcomponent_get_dtstamp(icalcomponent* comp); -void icalcomponent_set_dtstamp(icalcomponent* comp, struct icaltimetype v); - -void icalcomponent_set_summary(icalcomponent* comp, const char* v); -const char* icalcomponent_get_summary(icalcomponent* comp); - -void icalcomponent_set_comment(icalcomponent* comp, const char* v); -const char* icalcomponent_get_comment(icalcomponent* comp); - -void icalcomponent_set_uid(icalcomponent* comp, const char* v); -const char* icalcomponent_get_uid(icalcomponent* comp); - -void icalcomponent_set_relcalid(icalcomponent* comp, const char* v); -const char* icalcomponent_get_relcalid(icalcomponent* comp); - -void icalcomponent_set_recurrenceid(icalcomponent* comp, - struct icaltimetype v); -struct icaltimetype icalcomponent_get_recurrenceid(icalcomponent* comp); - -void icalcomponent_set_description(icalcomponent* comp, const char* v); -const char* icalcomponent_get_description(icalcomponent* comp); - -void icalcomponent_set_location(icalcomponent* comp, const char* v); -const char* icalcomponent_get_location(icalcomponent* comp); - -void icalcomponent_set_sequence(icalcomponent* comp, int v); -int icalcomponent_get_sequence(icalcomponent* comp); - -void icalcomponent_set_status(icalcomponent* comp, enum icalproperty_status v); -enum icalproperty_status icalcomponent_get_status(icalcomponent* comp); - - -/** Calls the given function for each TZID parameter found in the - component, and any subcomponents. */ -void icalcomponent_foreach_tzid(icalcomponent* comp, - void (*callback)(icalparameter *param, void *data), - void *callback_data); - -/** Returns the icaltimezone in the component corresponding to the - TZID, or NULL if it can't be found. */ -icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, - const char *tzid); - -int icalproperty_recurrence_is_excluded(icalcomponent *comp, - struct icaltimetype *dtstart, - struct icaltimetype *recurtime); - -void icalcomponent_foreach_recurrence(icalcomponent* comp, - struct icaltimetype start, - struct icaltimetype end, - void (*callback)(icalcomponent *comp, - struct icaltime_span *span, - void *data), - void *callback_data); - - -/*************** Type Specific routines ***************/ - -icalcomponent* icalcomponent_new_vcalendar(void); -icalcomponent* icalcomponent_new_vevent(void); -icalcomponent* icalcomponent_new_vtodo(void); -icalcomponent* icalcomponent_new_vjournal(void); -icalcomponent* icalcomponent_new_valarm(void); -icalcomponent* icalcomponent_new_vfreebusy(void); -icalcomponent* icalcomponent_new_vtimezone(void); -icalcomponent* icalcomponent_new_xstandard(void); -icalcomponent* icalcomponent_new_xdaylight(void); -icalcomponent* icalcomponent_new_vagenda(void); -icalcomponent* icalcomponent_new_vquery(void); - -#endif /* !ICALCOMPONENT_H */ diff --git a/calendar/libical/src/libical/icalderivedparameter.c.in b/calendar/libical/src/libical/icalderivedparameter.c.in deleted file mode 100644 index 8242a25356..0000000000 --- a/calendar/libical/src/libical/icalderivedparameter.c.in +++ /dev/null @@ -1,216 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalderivedparameters.{c,h} - CREATOR: eric 09 May 1999 - - $Id: icalderivedparameter.c.in,v 1.9 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalderivedparameters.{c,h} - - Contributions from: - Graham Davison (g.m.davison@computer.org) - - ======================================================================*/ -/*#line 29 "icalparameter.c.in"*/ -#ifdef HAVE_CONFIG_H -#include -#endif - - -#include "icalparameter.h" -#include "icalparameterimpl.h" - -#include "icalproperty.h" -#include "icalerror.h" -#include "icalmemory.h" -#include "icaltypes.h" - -#include /* for malloc() */ -#include -#include /* for memset() */ - -#ifdef WIN32 -#define strcasecmp stricmp -#endif - -icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value); - -struct icalparameter_impl* icalparameter_new_impl(icalparameter_kind kind); - -/* This map associates each of the parameters with the string - representation of the parameter's name */ -struct icalparameter_kind_map { - icalparameter_kind kind; - const char *name; - -}; - -/* This map associates the enumerations for the VALUE parameter with - the kinds of VALUEs. */ - -struct icalparameter_value_kind_map { - icalparameter_value value; - icalvalue_kind kind; -}; - -/* This map associates the parameter enumerations with a specific parameter and the string representation of the enumeration */ - -struct icalparameter_map { - icalparameter_kind kind; - int enumeration; - const char* str; -}; - - - - - -const char* icalparameter_kind_to_string(icalparameter_kind kind) -{ - int i; - - for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) { - if (parameter_map[i].kind == kind) { - return parameter_map[i].name; - } - } - - return 0; - -} - -icalparameter_kind icalparameter_string_to_kind(const char* string) -{ - int i; - - if (string ==0 ) { - return ICAL_NO_PARAMETER; - } - - for (i=0; parameter_map[i].kind != ICAL_NO_PARAMETER; i++) { - - if (strcasecmp(parameter_map[i].name, string) == 0) { - return parameter_map[i].kind; - } - } - - if(strncmp(string,"X-",2)==0){ - return ICAL_X_PARAMETER; - } - - if (ical_get_unknown_token_handling_setting() == ICAL_TREAT_AS_ERROR) { - return ICAL_NO_PARAMETER; - } else { - return ICAL_IANA_PARAMETER; - } -} - - -icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value) -{ - int i; - - for (i=0; value_kind_map[i].kind != ICAL_NO_VALUE; i++) { - - if (value_kind_map[i].value == value) { - return value_kind_map[i].kind; - } - } - - return ICAL_NO_VALUE; -} - - -const char* icalparameter_enum_to_string(int e) -{ - int i; - - icalerror_check_arg_rz(e >= ICALPARAMETER_FIRST_ENUM,"e"); - icalerror_check_arg_rz(e <= ICALPARAMETER_LAST_ENUM,"e"); - - for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){ - if(e == icalparameter_map[i].enumeration){ - return icalparameter_map[i].str; - } - } - - return 0; -} - -int icalparameter_string_to_enum(const char* str) -{ - int i; - - icalerror_check_arg_rz(str != 0,"str"); - - for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){ - if(strcasecmp(str,icalparameter_map[i].str) == 0) { - return icalparameter_map[i].enumeration; - } - } - - return 0; -} - -icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const char* val) -{ - - struct icalparameter_impl* param=0; - int found_kind = 0; - int i; - - icalerror_check_arg_rz((val!=0),"val"); - - /* Search through the parameter map to find a matching kind */ - - param = icalparameter_new_impl(kind); - if (!param) - return 0; - - for (i=0; icalparameter_map[i].kind != ICAL_NO_PARAMETER; i++){ - if(kind == icalparameter_map[i].kind) { - found_kind = 1; - if(strcasecmp(val,icalparameter_map[i].str) == 0) { - - param->data = (int)icalparameter_map[i].enumeration; - return param; - } - } - } - - if(found_kind == 1){ - /* The kind was in the parameter map, but the string did not - match, so assume that it is an alternate value, like an - X-value.*/ - - icalparameter_set_xvalue(param, val); - - } else { - - /* If the kind was not found, then it must be a string type */ - - ((struct icalparameter_impl*)param)->string = icalmemory_strdup(val); - - } - - return param; -} - - - - diff --git a/calendar/libical/src/libical/icalderivedparameter.h.in b/calendar/libical/src/libical/icalderivedparameter.h.in deleted file mode 100644 index a4f9efb9f6..0000000000 --- a/calendar/libical/src/libical/icalderivedparameter.h.in +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalparam.h - CREATOR: eric 20 March 1999 - - - $Id: icalderivedparameter.h.in,v 1.4 2007-04-30 13:57:48 artcancro Exp $ - $Locker: $ - - - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalparam.h - - ======================================================================*/ - -#ifndef ICALDERIVEDPARAMETER_H -#define ICALDERIVEDPARAMETER_H - - -typedef struct icalparameter_impl icalparameter; - -const char* icalparameter_enum_to_string(int e); -int icalparameter_string_to_enum(const char* str); - - diff --git a/calendar/libical/src/libical/icalderivedproperty.c.in b/calendar/libical/src/libical/icalderivedproperty.c.in deleted file mode 100644 index 8382d2437e..0000000000 --- a/calendar/libical/src/libical/icalderivedproperty.c.in +++ /dev/null @@ -1,298 +0,0 @@ -/* -*- Mode: C -*- */ - -/*====================================================================== - FILE: icalderivedproperty.c - CREATOR: eric 15 Feb 2001 - - $Id: icalderivedproperty.c.in,v 1.15 2008-01-28 22:34:37 artcancro Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalproperty.c - -======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "icalproperty.h" -#include "icalcomponent.h" -#include "pvl.h" -#include "icalenums.h" -#include "icalerror.h" -#include "icalmemory.h" -#include "icalparser.h" -#include "icaltimezone.h" - -#include /* For icalmemory_strdup, rindex */ -#include -#include -#include -#include /* for printf */ -#include /* for va_list, va_start, etc. */ - -#ifdef WIN32 -#define strcasecmp stricmp -#endif - -struct icalproperty_impl* -icalproperty_new_impl (icalproperty_kind kind); -void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args); - -/* This map associates the property kinds with the string - representation of the property name and the kind of VALUE that the - property uses as a default */ - -struct icalproperty_map { - icalproperty_kind kind; - const char *name; - icalvalue_kind value; - -}; - -/* This map associates the property enumerations with the king of - property that they are used in and the string representation of the - enumeration */ - -struct icalproperty_enum_map { - icalproperty_kind prop; - int prop_enum; - const char* str; -}; - - - - -int icalproperty_kind_is_valid(const icalproperty_kind kind) -{ - int i = 0; - do { - if (property_map[i].kind == kind) - return 1; - } while (property_map[i++].kind != ICAL_NO_PROPERTY); - - return 0; -} - -const char* icalproperty_kind_to_string(icalproperty_kind kind) -{ - int i; - - for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) { - if (property_map[i].kind == kind) { - return property_map[i].name; - } - } - - return 0; - -} - - -icalproperty_kind icalproperty_string_to_kind(const char* string) -{ - int i; - - if (string ==0 ) { - return ICAL_NO_PROPERTY; - } - - - for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) { - if (strcasecmp(property_map[i].name, string) == 0) { - return property_map[i].kind; - } - } - - if(strncmp(string,"X-",2)==0){ - return ICAL_X_PROPERTY; - } - - - return ICAL_NO_PROPERTY; -} - - -icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind) -{ - int i; - - for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) { - if ( property_map[i].value == kind ) { - return property_map[i].kind; - } - } - - return ICAL_NO_PROPERTY; -} - - - -icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind) -{ - int i; - - for (i=0; property_map[i].kind != ICAL_NO_PROPERTY; i++) { - if ( property_map[i].kind == kind ) { - return property_map[i].value; - } - } - - return ICAL_NO_VALUE; -} - - -const char* icalproperty_enum_to_string(int e) -{ - icalerror_check_arg_rz(e >= ICALPROPERTY_FIRST_ENUM,"e"); - icalerror_check_arg_rz(e <= ICALPROPERTY_LAST_ENUM,"e"); - - return enum_map[e-ICALPROPERTY_FIRST_ENUM].str; -} - - -char *icalproperty_enum_to_string_r(int e) -{ - return icalmemory_strdup(icalproperty_enum_to_string(e)); -} - - -int icalproperty_kind_and_string_to_enum(const int kind, const char* str) -{ - icalproperty_kind pkind; - int i; - - icalerror_check_arg_rz(str!=0,"str") - - if ((pkind = icalproperty_value_kind_to_kind(kind)) == ICAL_NO_PROPERTY) - return 0; - - while(*str == ' '){ - str++; - } - - for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) { - if (enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == pkind) - break; - } - if (i == ICALPROPERTY_LAST_ENUM) - return 0; - - for (; i != ICALPROPERTY_LAST_ENUM; i++) { - if(enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == pkind && - strcasecmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) { - return enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum; - } - } - - return 0; -} - -/** @deprecated please use icalproperty_kind_and_string_to_enum instead */ -int icalproperty_string_to_enum(const char* str) -{ - int i; - - icalerror_check_arg_rz(str!=0,"str") - - while(*str == ' '){ - str++; - } - - for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) { - if ( strcasecmp(enum_map[i-ICALPROPERTY_FIRST_ENUM].str, str) == 0) { - return enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum; - } - } - - return 0; -} - -int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e) -{ - int i; - - - for (i=ICALPROPERTY_FIRST_ENUM; i != ICALPROPERTY_LAST_ENUM; i++) { - if(enum_map[i-ICALPROPERTY_FIRST_ENUM].prop_enum == e && - enum_map[i-ICALPROPERTY_FIRST_ENUM].prop == kind ){ - return 1; - } - } - - return 0; -} - - -const char* icalproperty_method_to_string(icalproperty_method method) -{ - icalerror_check_arg_rz(method >= ICAL_METHOD_X,"method"); - icalerror_check_arg_rz(method <= ICAL_METHOD_NONE,"method"); - - return enum_map[method-ICALPROPERTY_FIRST_ENUM].str; -} - -icalproperty_method icalproperty_string_to_method(const char* str) -{ - int i; - - icalerror_check_arg_rx(str!=0,"str",ICAL_METHOD_NONE) - - while(*str == ' '){ - str++; - } - - for (i=ICAL_METHOD_X-ICALPROPERTY_FIRST_ENUM; - i != ICAL_METHOD_NONE-ICALPROPERTY_FIRST_ENUM; - i++) { - if ( strcasecmp(enum_map[i].str, str) == 0) { - return (icalproperty_method)enum_map[i].prop_enum; - } - } - - return ICAL_METHOD_NONE; -} - - -const char* icalenum_status_to_string(icalproperty_status status) -{ - icalerror_check_arg_rz(status >= ICAL_STATUS_X,"status"); - icalerror_check_arg_rz(status <= ICAL_STATUS_NONE,"status"); - - return enum_map[status-ICALPROPERTY_FIRST_ENUM].str; -} - -icalproperty_status icalenum_string_to_status(const char* str) -{ - int i; - - icalerror_check_arg_rx(str!=0,"str",ICAL_STATUS_NONE) - - while(*str == ' '){ - str++; - } - - for (i=ICAL_STATUS_X-ICALPROPERTY_FIRST_ENUM; - i != ICAL_STATUS_NONE-ICALPROPERTY_FIRST_ENUM; - i++) { - if ( strcasecmp(enum_map[i].str, str) == 0) { - return (icalproperty_status)enum_map[i].prop_enum; - } - } - - return ICAL_STATUS_NONE; - -} diff --git a/calendar/libical/src/libical/icalderivedproperty.h.in b/calendar/libical/src/libical/icalderivedproperty.h.in deleted file mode 100644 index 44f6f3110d..0000000000 --- a/calendar/libical/src/libical/icalderivedproperty.h.in +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalderivedproperties.{c,h} - CREATOR: eric 09 May 1999 - - $Id: icalderivedproperty.h.in,v 1.7 2007-04-30 13:57:48 artcancro Exp $ - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - ======================================================================*/ - - -#ifndef ICALDERIVEDPROPERTY_H -#define ICALDERIVEDPROPERTY_H - -#include -#include "icalparameter.h" -#include "icalderivedvalue.h" -#include "icalrecur.h" - -typedef struct icalproperty_impl icalproperty; - - diff --git a/calendar/libical/src/libical/icalderivedvalue.c.in b/calendar/libical/src/libical/icalderivedvalue.c.in deleted file mode 100644 index 025890d0a8..0000000000 --- a/calendar/libical/src/libical/icalderivedvalue.c.in +++ /dev/null @@ -1,460 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalvalue.c - CREATOR: eric 02 May 1999 - - $Id: icalderivedvalue.c.in,v 1.15 2007-04-30 13:57:48 artcancro Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalvalue.c - - Contributions from: - Graham Davison (g.m.davison@computer.org) - - -======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "icalerror.h" -#include "icalmemory.h" -#include "icalparser.h" -#include "icalenums.h" - -#include "icalvalueimpl.h" - -#include /* for malloc */ -#include /* for snprintf */ -#include /* For memset, others */ -#include /* For offsetof() macro */ -#include -#include /* for mktime */ -#include /* for atoi and atof */ -#include /* for SHRT_MAX */ - -#ifdef WIN32 -#define strcasecmp stricmp -#endif - -struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind); - -/* This map associates each of the value types with its string - representation */ -struct icalvalue_kind_map { - icalvalue_kind kind; - char name[20]; -}; - - - - -int icalvalue_kind_is_valid(const icalvalue_kind kind) -{ - int i = 0; - do { - if (value_map[i].kind == kind) - return 1; - } while (value_map[i++].kind != ICAL_NO_VALUE); - - return 0; -} - -const char* icalvalue_kind_to_string(const icalvalue_kind kind) -{ - int i; - - for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) { - if (value_map[i].kind == kind) { - return value_map[i].name; - } - } - - return 0; -} - -icalvalue_kind icalvalue_string_to_kind(const char* str) -{ - int i; - - for (i=0; value_map[i].kind != ICAL_NO_VALUE; i++) { - if (strcasecmp(value_map[i].name,str) == 0) { - return value_map[i].kind; - } - } - - return value_map[i].kind; - -} - -icalvalue* icalvalue_new_x (const char* v){ - struct icalvalue_impl* impl; - icalerror_check_arg_rz( (v!=0),"v"); - - impl = icalvalue_new_impl(ICAL_X_VALUE); - - icalvalue_set_x((icalvalue*)impl,v); - return (icalvalue*)impl; -} -void icalvalue_set_x(icalvalue* impl, const char* v) { - icalerror_check_arg_rv( (impl!=0),"value"); - icalerror_check_arg_rv( (v!=0),"v"); - - if(impl->x_value!=0) {free((void*)impl->x_value);} - - impl->x_value = icalmemory_strdup(v); - - if (impl->x_value == 0){ - errno = ENOMEM; - } - - } -const char* icalvalue_get_x(const icalvalue* value) { - - icalerror_check_arg_rz( (value!=0),"value"); - icalerror_check_value_type(value, ICAL_X_VALUE); - return value->x_value; -} - -/* Recur is a special case, so it is not auto generated. */ -icalvalue* -icalvalue_new_recur (struct icalrecurrencetype v) -{ - struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_RECUR_VALUE); - - icalvalue_set_recur((icalvalue*)impl,v); - - return (icalvalue*)impl; -} - -void -icalvalue_set_recur(icalvalue* impl, struct icalrecurrencetype v) -{ - icalerror_check_arg_rv( (impl!=0),"value"); - icalerror_check_value_type(value, ICAL_RECUR_VALUE); - - if (impl->data.v_recur != 0){ - free(impl->data.v_recur); - impl->data.v_recur = 0; - } - - impl->data.v_recur = malloc(sizeof(struct icalrecurrencetype)); - - if (impl->data.v_recur == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } else { - memcpy(impl->data.v_recur, &v, sizeof(struct icalrecurrencetype)); - } - -} - -struct icalrecurrencetype -icalvalue_get_recur(const icalvalue* value) -{ - struct icalrecurrencetype rt; - icalrecurrencetype_clear(&rt); - - icalerror_check_arg_rx( (value!=0),"value", rt); - icalerror_check_arg_rx((value->data.v_recur != 0), "value", rt); - icalerror_check_value_type(value, ICAL_RECUR_VALUE); - - return *(value->data.v_recur); -} - - - - -icalvalue* -icalvalue_new_trigger (struct icaltriggertype v) -{ - struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_TRIGGER_VALUE); - - icalvalue_set_trigger((icalvalue*)impl,v); - - return (icalvalue*)impl; -} - -void -icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v) -{ - icalerror_check_arg_rv( (value!=0),"value"); - - if(!icaltime_is_null_time(v.time)){ - icalvalue_set_datetime(value,v.time); - value->kind = ICAL_DATETIME_VALUE; - } else { - icalvalue_set_duration(value,v.duration); - value->kind = ICAL_DURATION_VALUE; - } -} - -struct icaltriggertype -icalvalue_get_trigger(const icalvalue* impl) -{ - struct icaltriggertype tr; - - tr.duration = icaldurationtype_from_int(0); - tr.time = icaltime_null_time(); - - icalerror_check_arg_rx( (impl!=0),"value", tr); - - if(impl) { - if(impl->kind == ICAL_DATETIME_VALUE){ - tr.duration = icaldurationtype_from_int(0); - tr.time = impl->data.v_time; - } else if(impl->kind == ICAL_DURATION_VALUE){ - tr.time = icaltime_null_time(); - tr.duration = impl->data.v_duration; - } else { - tr.duration = icaldurationtype_from_int(0); - tr.time = icaltime_null_time(); - icalerror_set_errno(ICAL_BADARG_ERROR); - } - } else { - tr.duration = icaldurationtype_from_int(0); - tr.time = icaltime_null_time(); - icalerror_set_errno(ICAL_BADARG_ERROR); - } - - return tr; -} - -icalvalue* -icalvalue_new_datetime (struct icaltimetype v){ - - struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIME_VALUE); - icalvalue_set_datetime((icalvalue*)impl,v); - return (icalvalue*)impl; -} - -void -icalvalue_set_datetime(icalvalue* value, struct icaltimetype v) { - struct icalvalue_impl* impl; - icalerror_check_arg_rv( (value!=0),"value"); - - icalerror_check_value_type(value, ICAL_DATETIME_VALUE); - impl = (struct icalvalue_impl*)value; - - - impl->data.v_time = v; - - icalvalue_reset_kind(impl); -} - -struct icaltimetype -icalvalue_get_datetime (const icalvalue* value) { - struct icaltimetype dt; - dt = icaltime_null_time(); - - icalerror_check_arg_rx((value!=0),"value", dt); - icalerror_check_value_type (value, ICAL_DATETIME_VALUE); - return ((struct icalvalue_impl*)value)->data.v_time; -} - -/* DATE-TIME-PERIOD is a special case, and is not auto generated */ - -icalvalue* -icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v) -{ - struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_DATETIMEPERIOD_VALUE); - - icalvalue_set_datetimeperiod(impl,v); - - return (icalvalue*)impl; -} - -void -icalvalue_set_datetimeperiod(icalvalue* impl, struct icaldatetimeperiodtype v) -{ - icalerror_check_arg_rv( (impl!=0),"value"); - - icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE); - - if(!icaltime_is_null_time(v.time)){ - if(!icaltime_is_valid_time(v.time)){ - icalerror_set_errno(ICAL_BADARG_ERROR); - return; - } - impl->kind = ICAL_DATETIME_VALUE; - icalvalue_set_datetime(impl,v.time); - } else if (!icalperiodtype_is_null_period(v.period)) { - if(!icalperiodtype_is_valid_period(v.period)){ - icalerror_set_errno(ICAL_BADARG_ERROR); - return; - } - impl->kind = ICAL_PERIOD_VALUE; - icalvalue_set_period(impl,v.period); - } else { - icalerror_set_errno(ICAL_BADARG_ERROR); - } -} - -struct icaldatetimeperiodtype -icalvalue_get_datetimeperiod(const icalvalue* impl) -{ - struct icaldatetimeperiodtype dtp; - - dtp.period = icalperiodtype_null_period(); - dtp.time = icaltime_null_time(); - - icalerror_check_arg_rx( (impl!=0),"value", dtp); - icalerror_check_value_type(value, ICAL_DATETIMEPERIOD_VALUE); - - if(impl) { - if( impl->kind == ICAL_DATETIME_VALUE || impl->kind == ICAL_DATE_VALUE ){ - dtp.period = icalperiodtype_null_period(); - dtp.time = impl->data.v_time; - } else if(impl->kind == ICAL_PERIOD_VALUE) { - dtp.period = impl->data.v_period; - dtp.time = icaltime_null_time(); - } else { - dtp.period = icalperiodtype_null_period(); - dtp.time = icaltime_null_time(); - icalerror_set_errno(ICAL_BADARG_ERROR); - } - } else { - dtp.period = icalperiodtype_null_period(); - dtp.time = icaltime_null_time(); - icalerror_set_errno(ICAL_BADARG_ERROR); - } - - return dtp; -} - -icalvalue* -icalvalue_new_class (enum icalproperty_class v){ - - struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_CLASS_VALUE); - icalvalue_set_class((icalvalue*)impl,v); - return (icalvalue*)impl; -} - -void -icalvalue_set_class(icalvalue* value, enum icalproperty_class v) { - struct icalvalue_impl* impl; - icalerror_check_arg_rv( (value!=0),"value"); - - icalerror_check_value_type(value, ICAL_CLASS_VALUE); - impl = (struct icalvalue_impl*)value; - - impl->data.v_enum = v; - - icalvalue_reset_kind(impl); -} - -enum icalproperty_class -icalvalue_get_class (const icalvalue* value) { - - icalproperty_class pr; - pr = ICAL_CLASS_NONE; - - icalerror_check_arg_rx ((value!=NULL),"value", pr); - icalerror_check_arg ((value!=0),"value"); - icalerror_check_value_type (value, ICAL_CLASS_VALUE); - return ((struct icalvalue_impl*)value)->data.v_enum; -} - -icalvalue* -icalvalue_new_geo (struct icalgeotype v){ - - struct icalvalue_impl* impl = icalvalue_new_impl(ICAL_GEO_VALUE); - icalvalue_set_geo((icalvalue*)impl,v); - return (icalvalue*)impl; -} - -void -icalvalue_set_geo(icalvalue* value, struct icalgeotype v) { - struct icalvalue_impl* impl; - icalerror_check_arg_rv( (value!=0),"value"); - - icalerror_check_value_type(value, ICAL_GEO_VALUE); - impl = (struct icalvalue_impl*)value; - - impl->data.v_geo = v; - - icalvalue_reset_kind(impl); -} - -struct icalgeotype -icalvalue_get_geo (const icalvalue* value) { - struct icalgeotype gt; - gt.lat = 255.0; - gt.lon = 255.0; - - icalerror_check_arg_rx((value!=0),"value", gt); - icalerror_check_value_type (value, ICAL_GEO_VALUE); - return ((struct icalvalue_impl*)value)->data.v_geo; -} - - -icalvalue * -icalvalue_new_attach (icalattach *attach) -{ - struct icalvalue_impl *impl; - - icalerror_check_arg_rz ((attach != NULL), "attach"); - - impl = icalvalue_new_impl (ICAL_ATTACH_VALUE); - if (!impl) { - errno = ENOMEM; - return NULL; - } - - icalvalue_set_attach ((icalvalue *) impl, attach); - return (icalvalue *) impl; -} - -void -icalvalue_set_attach (icalvalue *value, icalattach *attach) -{ - struct icalvalue_impl *impl; - - icalerror_check_arg_rv ((value != NULL), "value"); - icalerror_check_value_type (value, ICAL_ATTACH_VALUE); - icalerror_check_arg_rv ((attach != NULL), "attach"); - - impl = (struct icalvalue_impl *) value; - - icalattach_ref (attach); - - if (impl->data.v_attach) - icalattach_unref (impl->data.v_attach); - - impl->data.v_attach = attach; -} - -icalattach * -icalvalue_get_attach (const icalvalue *value) -{ - icalerror_check_arg_rz ((value != NULL), "value"); - icalerror_check_value_type (value, ICAL_ATTACH_VALUE); - - return value->data.v_attach; -} - - - - - - - -/* The remaining interfaces are 'new', 'set' and 'get' for each of the value - types */ - - -/* Everything below this line is machine generated. Do not edit. */ diff --git a/calendar/libical/src/libical/icalderivedvalue.h.in b/calendar/libical/src/libical/icalderivedvalue.h.in deleted file mode 100644 index 5c6e2b5d1f..0000000000 --- a/calendar/libical/src/libical/icalderivedvalue.h.in +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalvalue.h - CREATOR: eric 20 March 1999 - - - $Id: icalderivedvalue.h.in,v 1.10 2007-04-30 13:57:48 artcancro Exp $ - $Locker: $ - - - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalvalue.h - - ======================================================================*/ - -#ifndef ICALDERIVEDVALUE_H -#define ICALDERIVEDVALUE_H - -#include "icaltypes.h" -#include "icalrecur.h" -#include "icaltime.h" -#include "icalduration.h" -#include "icalperiod.h" -#include "icalattach.h" - -typedef struct icalvalue_impl icalvalue; - -void icalvalue_set_x(icalvalue* value, const char* v); -icalvalue* icalvalue_new_x(const char* v); -const char* icalvalue_get_x(const icalvalue* value); - -icalvalue* icalvalue_new_recur (struct icalrecurrencetype v); -void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v); -struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value); - -icalvalue* icalvalue_new_trigger (struct icaltriggertype v); -void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v); -struct icaltriggertype icalvalue_get_trigger(const icalvalue* value); - -icalvalue* icalvalue_new_datetime(struct icaltimetype v); -struct icaltimetype icalvalue_get_datetime(const icalvalue* value); -void icalvalue_set_datetime(icalvalue* value, struct icaltimetype v); - -icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v); -void icalvalue_set_datetimeperiod(icalvalue* value, struct icaldatetimeperiodtype v); -struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value); - -/* GEO */ -icalvalue* icalvalue_new_geo(struct icalgeotype v); -struct icalgeotype icalvalue_get_geo(const icalvalue* value); -void icalvalue_set_geo(icalvalue* value, struct icalgeotype v); - -icalvalue *icalvalue_new_attach (icalattach *attach); -void icalvalue_set_attach (icalvalue *value, icalattach *attach); -icalattach *icalvalue_get_attach (const icalvalue *value); - -void icalvalue_reset_kind(icalvalue* value); - - - - -icalvalue* icalvalue_new_class(enum icalproperty_class v); -enum icalproperty_class icalvalue_get_class(const icalvalue* value); -void icalvalue_set_class(icalvalue* value, enum icalproperty_class v); diff --git a/calendar/libical/src/libical/icalduration.c b/calendar/libical/src/libical/icalduration.c deleted file mode 100644 index 6d73e73003..0000000000 --- a/calendar/libical/src/libical/icalduration.c +++ /dev/null @@ -1,352 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icaltime.c - CREATOR: eric 02 June 2000 - - $Id: icalduration.c,v 1.21 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "icalduration.h" - -#include -#include -#include -#include - -#include "icalerror.h" -#include "icalmemory.h" -#include "icalvalue.h" - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#endif - - - -/* From Seth Alves, */ -struct icaldurationtype icaldurationtype_from_int(int t) -{ - struct icaldurationtype dur; - int used = 0; - - dur = icaldurationtype_null_duration(); - - if(t < 0){ - dur.is_neg = 1; - t = -t; - } - - if (t % (60 * 60 * 24 * 7) == 0) { - dur.weeks = t / (60 * 60 * 24 * 7); - } else { - used += dur.weeks * (60 * 60 * 24 * 7); - dur.days = (t - used) / (60 * 60 * 24); - used += dur.days * (60 * 60 * 24); - dur.hours = (t - used) / (60 * 60); - used += dur.hours * (60 * 60); - dur.minutes = (t - used) / (60); - used += dur.minutes * (60); - dur.seconds = (t - used); - } - - return dur; -} - -struct icaldurationtype icaldurationtype_from_string(const char* str) -{ - - int i; - int begin_flag = 0; - int time_flag = 0; - int date_flag = 0; - int week_flag = 0; - int digits=-1; - int scan_size = -1; - int size = strlen(str); - char p; - struct icaldurationtype d; - - memset(&d, 0, sizeof(struct icaldurationtype)); - - for(i=0;i != size;i++){ - p = str[i]; - - switch(p) - { - case '-': { - if(i != 0 || begin_flag == 1) goto error; - - d.is_neg = 1; - break; - } - - case 'P': { - if (i != 0 && i !=1 ) goto error; - begin_flag = 1; - break; - } - - case 'T': { - time_flag = 1; - break; - } - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - { - - /* HACK. Skip any more digits if the l;ast one - read has not been assigned */ - if(digits != -1){ - break; - } - - if (begin_flag == 0) goto error; - /* Get all of the digits, not one at a time */ - scan_size = sscanf(&str[i],"%d",&digits); - if(scan_size == 0) goto error; - break; - } - - case 'H': { - if (time_flag == 0||week_flag == 1||d.hours !=0||digits ==-1) - goto error; - d.hours = digits; digits = -1; - break; - } - case 'M': { - if (time_flag == 0||week_flag==1||d.minutes != 0||digits ==-1) - goto error; - d.minutes = digits; digits = -1; - break; - } - case 'S': { - if (time_flag == 0||week_flag==1||d.seconds!=0||digits ==-1) - goto error; - d.seconds = digits; digits = -1; - break; - } - case 'W': { - if (time_flag==1||date_flag==1||d.weeks!=0||digits ==-1) - goto error; - week_flag = 1; - d.weeks = digits; digits = -1; - break; - } - case 'D': { - if (time_flag==1||week_flag==1||d.days!=0||digits ==-1) - goto error; - date_flag = 1; - d.days = digits; digits = -1; - break; - } - default: { - goto error; - } - - } - } - - return d; - - - error: - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return icaldurationtype_bad_duration(); -} - -#define TMP_BUF_SIZE 1024 -static -void append_duration_segment(char** buf, char** buf_ptr, size_t* buf_size, - const char* sep, unsigned int value) { - - char temp[TMP_BUF_SIZE]; - - snprintf(temp,sizeof(temp),"%d",value); - - icalmemory_append_string(buf, buf_ptr, buf_size, temp); - icalmemory_append_string(buf, buf_ptr, buf_size, sep); - -} - -char* icaldurationtype_as_ical_string(struct icaldurationtype d) -{ - char *buf; - buf = icaldurationtype_as_ical_string_r(d); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* icaldurationtype_as_ical_string_r(struct icaldurationtype d) -{ - - char *buf; - size_t buf_size = 256; - char* buf_ptr = 0; - int seconds; - - buf = (char*)icalmemory_new_buffer(buf_size); - buf_ptr = buf; - - - seconds = icaldurationtype_as_int(d); - - if(seconds !=0){ - - if(d.is_neg == 1){ - icalmemory_append_char(&buf, &buf_ptr, &buf_size, '-'); - } - - icalmemory_append_char(&buf, &buf_ptr, &buf_size, 'P'); - - if (d.weeks != 0 ) { - append_duration_segment(&buf, &buf_ptr, &buf_size, "W", d.weeks); - } - - if (d.days != 0 ) { - append_duration_segment(&buf, &buf_ptr, &buf_size, "D", d.days); - } - - if (d.hours != 0 || d.minutes != 0 || d.seconds != 0) { - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "T"); - - if (d.hours != 0 ) { - append_duration_segment(&buf, &buf_ptr, &buf_size, "H", d.hours); - } - if (d.minutes != 0 ) { - append_duration_segment(&buf, &buf_ptr, &buf_size, "M", - d.minutes); - } - if (d.seconds != 0 ) { - append_duration_segment(&buf, &buf_ptr, &buf_size, "S", - d.seconds); - } - - } - } else { - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "PT0S"); - } - - return buf; -} - - -/* From Russel Steinthal */ -int icaldurationtype_as_int(struct icaldurationtype dur) -{ - return (int)( (dur.seconds + - (60 * dur.minutes) + - (60 * 60 * dur.hours) + - (60 * 60 * 24 * dur.days) + - (60 * 60 * 24 * 7 * dur.weeks)) - * (dur.is_neg==1? -1 : 1) ) ; -} - -struct icaldurationtype icaldurationtype_null_duration(void) -{ - struct icaldurationtype d; - - memset(&d,0,sizeof(struct icaldurationtype)); - - return d; -} - -int icaldurationtype_is_null_duration(struct icaldurationtype d) -{ - if(icaldurationtype_as_int(d) == 0){ - return 1; - } else { - return 0; - } -} - -/* in icalvalue_new_from_string_with_error, we should not call - icaldurationtype_is_null_duration() to see if there is an error - condition. Null duration is perfectly valid for an alarm. - We cannot depend on the caller to check icalerrno either, - following the philosophy of unix errno. we set the is_neg - to -1 to indicate that this is a bad duration. -*/ -struct icaldurationtype icaldurationtype_bad_duration() -{ - struct icaldurationtype d; - memset(&d,0,sizeof(struct icaldurationtype)); - d.is_neg = -1; - return d; -} - -int icaldurationtype_is_bad_duration(struct icaldurationtype d) -{ - return (d.is_neg == -1); -} - - -struct icaltimetype icaltime_add(struct icaltimetype t, - struct icaldurationtype d) -{ - if (!d.is_neg) { - t.second += d.seconds; - t.minute += d.minutes; - t.hour += d.hours; - t.day += d.days; - t.day += d.weeks * 7; - } else { - t.second -= d.seconds; - t.minute -= d.minutes; - t.hour -= d.hours; - t.day -= d.days; - t.day -= d.weeks * 7; - } - - t = icaltime_normalize(t); - - return t; -} - -struct icaldurationtype icaltime_subtract(struct icaltimetype t1, - struct icaltimetype t2) -{ - - time_t t1t = icaltime_as_timet(t1); - time_t t2t = icaltime_as_timet(t2); - - return icaldurationtype_from_int((int)(t1t-t2t)); - - -} - diff --git a/calendar/libical/src/libical/icalduration.h b/calendar/libical/src/libical/icalduration.h deleted file mode 100644 index dd92f060ff..0000000000 --- a/calendar/libical/src/libical/icalduration.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalduration.h - CREATOR: eric 26 Jan 2001 - - - $Id: icalduration.h,v 1.5 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#ifndef ICALDURATION_H -#define ICALDURATION_H - -#include "icaltime.h" - -struct icaldurationtype -{ - int is_neg; - unsigned int days; - unsigned int weeks; - unsigned int hours; - unsigned int minutes; - unsigned int seconds; -}; - -struct icaldurationtype icaldurationtype_from_int(int t); -struct icaldurationtype icaldurationtype_from_string(const char*); -int icaldurationtype_as_int(struct icaldurationtype duration); -char* icaldurationtype_as_ical_string(struct icaldurationtype d); -char* icaldurationtype_as_ical_string_r(struct icaldurationtype d); -struct icaldurationtype icaldurationtype_null_duration(void); -struct icaldurationtype icaldurationtype_bad_duration(void); -int icaldurationtype_is_null_duration(struct icaldurationtype d); -int icaldurationtype_is_bad_duration(struct icaldurationtype d); - -struct icaltimetype icaltime_add(struct icaltimetype t, - struct icaldurationtype d); - -struct icaldurationtype icaltime_subtract(struct icaltimetype t1, - struct icaltimetype t2); - -#endif /* !ICALDURATION_H */ - - - diff --git a/calendar/libical/src/libical/icalenums.c b/calendar/libical/src/libical/icalenums.c deleted file mode 100644 index bb94017bc4..0000000000 --- a/calendar/libical/src/libical/icalenums.c +++ /dev/null @@ -1,183 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalenum.c - CREATOR: eric 29 April 1999 - - $Id: icalenums.c,v 1.16 2008-01-15 23:17:40 dothebart Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalenum.c - - ======================================================================*/ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icalenums.h" - -#include /* For fprintf */ -#include /* For stderr */ -#include /* For strncmp */ -#include -#include "icalmemory.h" - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#endif - - -/*** @brief Allowed request status values - */ -static const struct { - enum icalrequeststatus kind; - int major; - int minor; - const char* str; -} request_status_map[] = { - {ICAL_2_0_SUCCESS_STATUS, 2,0,"Success."}, - {ICAL_2_1_FALLBACK_STATUS, 2,1,"Success but fallback taken on one or more property values."}, - {ICAL_2_2_IGPROP_STATUS, 2,2,"Success, invalid property ignored."}, - {ICAL_2_3_IGPARAM_STATUS, 2,3,"Success, invalid property parameter ignored."}, - {ICAL_2_4_IGXPROP_STATUS, 2,4,"Success, unknown non-standard property ignored."}, - {ICAL_2_5_IGXPARAM_STATUS, 2,5,"Success, unknown non standard property value ignored."}, - {ICAL_2_6_IGCOMP_STATUS, 2,6,"Success, invalid calendar component ignored."}, - {ICAL_2_7_FORWARD_STATUS, 2,7,"Success, request forwarded to Calendar User."}, - {ICAL_2_8_ONEEVENT_STATUS, 2,8,"Success, repeating event ignored. Scheduled as a single component."}, - {ICAL_2_9_TRUNC_STATUS, 2,9,"Success, truncated end date time to date boundary."}, - {ICAL_2_10_ONETODO_STATUS, 2,10,"Success, repeating VTODO ignored. Scheduled as a single VTODO."}, - {ICAL_2_11_TRUNCRRULE_STATUS, 2,11,"Success, unbounded RRULE clipped at some finite number of instances "}, - {ICAL_3_0_INVPROPNAME_STATUS, 3,0,"Invalid property name."}, - {ICAL_3_1_INVPROPVAL_STATUS, 3,1,"Invalid property value."}, - {ICAL_3_2_INVPARAM_STATUS, 3,2,"Invalid property parameter."}, - {ICAL_3_3_INVPARAMVAL_STATUS, 3,3,"Invalid property parameter value."}, - {ICAL_3_4_INVCOMP_STATUS, 3,4,"Invalid calendar component."}, - {ICAL_3_5_INVTIME_STATUS, 3,5,"Invalid date or time."}, - {ICAL_3_6_INVRULE_STATUS, 3,6,"Invalid rule."}, - {ICAL_3_7_INVCU_STATUS, 3,7,"Invalid Calendar User."}, - {ICAL_3_8_NOAUTH_STATUS, 3,8,"No authority."}, - {ICAL_3_9_BADVERSION_STATUS, 3,9,"Unsupported version."}, - {ICAL_3_10_TOOBIG_STATUS, 3,10,"Request entity too large."}, - {ICAL_3_11_MISSREQCOMP_STATUS, 3,11,"Required component or property missing."}, - {ICAL_3_12_UNKCOMP_STATUS, 3,12,"Unknown component or property found."}, - {ICAL_3_13_BADCOMP_STATUS, 3,13,"Unsupported component or property found"}, - {ICAL_3_14_NOCAP_STATUS, 3,14,"Unsupported capability."}, - {ICAL_3_15_INVCOMMAND, 3,15,"Invalid command."}, - {ICAL_4_0_BUSY_STATUS, 4,0,"Event conflict. Date/time is busy."}, - {ICAL_4_1_STORE_ACCESS_DENIED, 4,1,"Store Access Denied."}, - {ICAL_4_2_STORE_FAILED, 4,2,"Store Failed."}, - {ICAL_4_3_STORE_NOT_FOUND, 4,3,"Store not found."}, - {ICAL_5_0_MAYBE_STATUS, 5,0,"Request MAY supported."}, - {ICAL_5_1_UNAVAIL_STATUS, 5,1,"Service unavailable."}, - {ICAL_5_2_NOSERVICE_STATUS, 5,2,"Invalid calendar service."}, - {ICAL_5_3_NOSCHED_STATUS, 5,3,"No scheduling support for user."}, - {ICAL_6_1_CONTAINER_NOT_FOUND, 6,1,"Container not found."}, - {ICAL_9_0_UNRECOGNIZED_COMMAND, 9,0,"An unrecognized command was received."}, - {ICAL_UNKNOWN_STATUS, 0,0,"Error: Unknown request status"} -}; - - -/*** @brief Return the descriptive text for a request status - */ -const char* icalenum_reqstat_desc(icalrequeststatus stat) -{ - int i; - - for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { - if ( request_status_map[i].kind == stat) { - return request_status_map[i].str; - } - } - - return 0; -} - -char* icalenum_reqstat_code(icalrequeststatus stat) -{ - char *buf; - buf = icalenum_reqstat_code_r(stat); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -/*** @brief Return the code for a request status - */ -char* icalenum_reqstat_code_r(icalrequeststatus stat) -{ - int i, major, minor; - char tmpbuf[36]; - - for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { - if ( request_status_map[i].kind == stat) { - major = request_status_map[i].major; - minor = request_status_map[i].minor; - snprintf(tmpbuf, sizeof(tmpbuf), "%i.%i", major, minor); - return icalmemory_strdup(tmpbuf); - } - } - return NULL; -} - -/*** @brief Return the major number for a request status - */ -short icalenum_reqstat_major(icalrequeststatus stat) -{ - int i; - - for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { - if ( request_status_map[i].kind == stat) { - return request_status_map[i].major; - } - } - return -1; -} - -/*** @brief Return the minor number for a request status - */ -short icalenum_reqstat_minor(icalrequeststatus stat) -{ - int i; - - for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { - if ( request_status_map[i].kind == stat) { - return request_status_map[i].minor; - } - } - return -1; -} - - -/*** @brief Return a request status for major/minor status numbers - */ -icalrequeststatus icalenum_num_to_reqstat(short major, short minor) -{ - int i; - - for (i=0; request_status_map[i].kind != ICAL_UNKNOWN_STATUS; i++) { - if ( request_status_map[i].major == major && request_status_map[i].minor == minor) { - return request_status_map[i].kind; - } - } - return 0; -} - - - diff --git a/calendar/libical/src/libical/icalenums.h b/calendar/libical/src/libical/icalenums.h deleted file mode 100644 index dada91ce3c..0000000000 --- a/calendar/libical/src/libical/icalenums.h +++ /dev/null @@ -1,168 +0,0 @@ - -/* -*- Mode: C -*-*/ -/*====================================================================== - FILE: icalenums.h - - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalenums.h - - Contributions from: - Graham Davison - -======================================================================*/ - -#ifndef ICALENUMS_H -#define ICALENUMS_H - - - -/*********************************************************************** - * Component enumerations -**********************************************************************/ - -typedef enum icalcomponent_kind { - ICAL_NO_COMPONENT, - ICAL_ANY_COMPONENT, /* Used to select all components*/ - ICAL_XROOT_COMPONENT, - ICAL_XATTACH_COMPONENT, /* MIME attached data, returned by parser. */ - ICAL_VEVENT_COMPONENT, - ICAL_VTODO_COMPONENT, - ICAL_VJOURNAL_COMPONENT, - ICAL_VCALENDAR_COMPONENT, - ICAL_VAGENDA_COMPONENT, - ICAL_VFREEBUSY_COMPONENT, - ICAL_VALARM_COMPONENT, - ICAL_XAUDIOALARM_COMPONENT, - ICAL_XDISPLAYALARM_COMPONENT, - ICAL_XEMAILALARM_COMPONENT, - ICAL_XPROCEDUREALARM_COMPONENT, - ICAL_VTIMEZONE_COMPONENT, - ICAL_XSTANDARD_COMPONENT, - ICAL_XDAYLIGHT_COMPONENT, - ICAL_X_COMPONENT, - ICAL_VSCHEDULE_COMPONENT, - ICAL_VQUERY_COMPONENT, - ICAL_VREPLY_COMPONENT, - ICAL_VCAR_COMPONENT, - ICAL_VCOMMAND_COMPONENT, - ICAL_XLICINVALID_COMPONENT, - ICAL_XLICMIMEPART_COMPONENT /* a non-stardard component that mirrors - structure of MIME data */ - -} icalcomponent_kind; - - - -/*********************************************************************** - * Request Status codes - **********************************************************************/ - -typedef enum icalrequeststatus { - ICAL_UNKNOWN_STATUS, - ICAL_2_0_SUCCESS_STATUS, - ICAL_2_1_FALLBACK_STATUS, - ICAL_2_2_IGPROP_STATUS, - ICAL_2_3_IGPARAM_STATUS, - ICAL_2_4_IGXPROP_STATUS, - ICAL_2_5_IGXPARAM_STATUS, - ICAL_2_6_IGCOMP_STATUS, - ICAL_2_7_FORWARD_STATUS, - ICAL_2_8_ONEEVENT_STATUS, - ICAL_2_9_TRUNC_STATUS, - ICAL_2_10_ONETODO_STATUS, - ICAL_2_11_TRUNCRRULE_STATUS, - ICAL_3_0_INVPROPNAME_STATUS, - ICAL_3_1_INVPROPVAL_STATUS, - ICAL_3_2_INVPARAM_STATUS, - ICAL_3_3_INVPARAMVAL_STATUS, - ICAL_3_4_INVCOMP_STATUS, - ICAL_3_5_INVTIME_STATUS, - ICAL_3_6_INVRULE_STATUS, - ICAL_3_7_INVCU_STATUS, - ICAL_3_8_NOAUTH_STATUS, - ICAL_3_9_BADVERSION_STATUS, - ICAL_3_10_TOOBIG_STATUS, - ICAL_3_11_MISSREQCOMP_STATUS, - ICAL_3_12_UNKCOMP_STATUS, - ICAL_3_13_BADCOMP_STATUS, - ICAL_3_14_NOCAP_STATUS, - ICAL_3_15_INVCOMMAND, - ICAL_4_0_BUSY_STATUS, - ICAL_4_1_STORE_ACCESS_DENIED, - ICAL_4_2_STORE_FAILED, - ICAL_4_3_STORE_NOT_FOUND, - ICAL_5_0_MAYBE_STATUS, - ICAL_5_1_UNAVAIL_STATUS, - ICAL_5_2_NOSERVICE_STATUS, - ICAL_5_3_NOSCHED_STATUS, - ICAL_6_1_CONTAINER_NOT_FOUND, - ICAL_9_0_UNRECOGNIZED_COMMAND -} icalrequeststatus; - - -const char* icalenum_reqstat_desc(icalrequeststatus stat); -short icalenum_reqstat_major(icalrequeststatus stat); -short icalenum_reqstat_minor(icalrequeststatus stat); -icalrequeststatus icalenum_num_to_reqstat(short major, short minor); -char* icalenum_reqstat_code(icalrequeststatus stat); -char* icalenum_reqstat_code_r(icalrequeststatus stat); - -/*********************************************************************** - * Conversion functions -**********************************************************************/ - - -/* Thse routines used to be in icalenums.c, but were moved into the - icalproperty, icalparameter, icalvalue, or icalcomponent modules. */ - -/* const char* icalproperty_kind_to_string(icalproperty_kind kind);*/ -#define icalenum_property_kind_to_string(x) icalproperty_kind_to_string(x) - -/*icalproperty_kind icalproperty_string_to_kind(const char* string)*/ -#define icalenum_string_to_property_kind(x) icalproperty_string_to_kind(x) - -/*icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind);*/ -#define icalenum_property_kind_to_value_kind(x) icalproperty_kind_to_value_kind(x) - -/*const char* icalenum_method_to_string(icalproperty_method);*/ -#define icalenum_method_to_string(x) icalproperty_method_to_string(x) - -/*icalproperty_method icalenum_string_to_method(const char* string);*/ -#define icalenum_string_to_method(x) icalproperty_string_to_method(x) - -/*const char* icalenum_status_to_string(icalproperty_status);*/ -#define icalenum_status_to_string(x) icalproperty_status_to_string(x) - -/*icalproperty_status icalenum_string_to_status(const char* string);*/ -#define icalenum_string_to_status(x) icalproperty_string_to_status(x) - -/*icalvalue_kind icalenum_string_to_value_kind(const char* str);*/ -#define icalenum_string_to_value_kind(x) icalvalue_string_to_kind(x) - -/*const char* icalenum_value_kind_to_string(icalvalue_kind kind);*/ -#define icalenum_value_kind_to_string(x) icalvalue_kind_to_string(x) - -/*const char* icalenum_component_kind_to_string(icalcomponent_kind kind);*/ -#define icalenum_component_kind_to_string(x) icalcomponent_kind_to_string(x) - -/*icalcomponent_kind icalenum_string_to_component_kind(const char* string);*/ -#define icalenum_string_to_component_kind(x) icalcomponent_string_to_kind(x) - - -#endif /* !ICALENUMS_H */ - diff --git a/calendar/libical/src/libical/icalerror.c b/calendar/libical/src/libical/icalerror.c deleted file mode 100644 index f2697188bf..0000000000 --- a/calendar/libical/src/libical/icalerror.c +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalerror.c - CREATOR: eric 16 May 1999 - - $Id: icalerror.c,v 1.22 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalerror.c - - ======================================================================*/ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef HAVE_BACKTRACE -#include -#endif - -#include /* for malloc() */ -#include /* for strcmp */ -#include "icalerror.h" - -#ifdef HAVE_PTHREAD -#include - -static pthread_key_t icalerrno_key; -static pthread_once_t icalerrno_key_once = PTHREAD_ONCE_INIT; - -static void icalerrno_destroy(void* buf) { - free(buf); - pthread_setspecific(icalerrno_key, NULL); -} - -static void icalerrno_key_alloc(void) { - pthread_key_create(&icalerrno_key, icalerrno_destroy); -} - -icalerrorenum *icalerrno_return(void) { - icalerrorenum *_errno; - - pthread_once(&icalerrno_key_once, icalerrno_key_alloc); - - _errno = (icalerrorenum*) pthread_getspecific(icalerrno_key); - - if (!_errno) { - _errno = malloc(sizeof(icalerrorenum)); - *_errno = ICAL_NO_ERROR; - pthread_setspecific(icalerrno_key, _errno); - } - return _errno; -} - -#else - -static icalerrorenum icalerrno_storage = ICAL_NO_ERROR; - -icalerrorenum *icalerrno_return(void) { - return &icalerrno_storage; -} - -#endif - - -static int foo; - -void icalerror_stop_here(void) -{ - foo++; /* Keep optimizers from removing routine */ -} - -void icalerror_crash_here(void) -{ - int *p=0; - *p = 1; - - assert( *p); -} - -#ifdef ICAL_SETERROR_ISFUNC -void icalerror_set_errno(icalerrorenum x) -{ - icalerrno = x; - if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || - (icalerror_get_error_state(x)==ICAL_ERROR_DEFAULT && - icalerror_errors_are_fatal == 1 )){ - icalerror_warn(icalerror_strerror(x)); - ical_bt(); - assert(0); - } - -} -#endif - -void icalerror_clear_errno() { - - icalerrno = ICAL_NO_ERROR; -} - -#if ICAL_ERRORS_ARE_FATAL == 1 -int icalerror_errors_are_fatal = 1; -#else -int icalerror_errors_are_fatal = 0; -#endif - -struct icalerror_state { - icalerrorenum error; - icalerrorstate state; -}; - -static struct icalerror_state error_state_map[] = -{ - { ICAL_BADARG_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_NEWFAILED_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_ALLOCATION_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_PARSE_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_INTERNAL_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_FILE_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_USAGE_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_UNIMPLEMENTED_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_UNKNOWN_ERROR,ICAL_ERROR_DEFAULT}, - { ICAL_NO_ERROR,ICAL_ERROR_DEFAULT} - -}; - -struct icalerror_string_map { - const char* str; - icalerrorenum error; - char name[160]; -}; - -static const struct icalerror_string_map string_map[] = -{ - {"BADARG",ICAL_BADARG_ERROR,"BADARG: Bad argument to function"}, - { "NEWFAILED",ICAL_NEWFAILED_ERROR,"NEWFAILED: Failed to create a new object via a *_new() routine"}, - { "ALLOCATION",ICAL_ALLOCATION_ERROR,"ALLOCATION: Failed to allocate new memory"}, - {"MALFORMEDDATA",ICAL_MALFORMEDDATA_ERROR,"MALFORMEDDATA: An input string was not correctly formed or a component has missing or extra properties"}, - { "PARSE",ICAL_PARSE_ERROR,"PARSE: Failed to parse a part of an iCal component"}, - {"INTERNAL",ICAL_INTERNAL_ERROR,"INTERNAL: Random internal error. This indicates an error in the library code, not an error in use"}, - { "FILE",ICAL_FILE_ERROR,"FILE: An operation on a file failed. Check errno for more detail."}, - { "USAGE",ICAL_USAGE_ERROR,"USAGE: Failed to propertyl sequence calls to a set of interfaces"}, - { "UNIMPLEMENTED",ICAL_UNIMPLEMENTED_ERROR,"UNIMPLEMENTED: This feature has not been implemented"}, - { "NO",ICAL_NO_ERROR,"NO: No error"}, - {"UNKNOWN",ICAL_UNKNOWN_ERROR,"UNKNOWN: Unknown error type -- icalerror_strerror() was probably given bad input"} -}; - - -icalerrorenum icalerror_error_from_string(const char* str){ - int i; - - for( i = 0; string_map[i].error != ICAL_UNKNOWN_ERROR; i++) - if (strcmp(string_map[i].str,str) == 0) - break; - - return string_map[i].error; -} - -icalerrorstate icalerror_supress(const char* error){ - - icalerrorenum e = icalerror_error_from_string(error); - icalerrorstate es; - - if (e == ICAL_NO_ERROR){ - return ICAL_ERROR_UNKNOWN; - } - - - es = icalerror_get_error_state(e); - icalerror_set_error_state(e,ICAL_ERROR_NONFATAL); - - return es; -} - -const char* icalerror_perror(void) -{ - return icalerror_strerror(icalerrno); -} - -void icalerror_restore(const char* error, icalerrorstate es){ - - - icalerrorenum e = icalerror_error_from_string(error); - - if (e != ICAL_NO_ERROR){ - icalerror_set_error_state(e,es); - } - -} - - - -void icalerror_set_error_state( icalerrorenum error, - icalerrorstate state) -{ - int i; - - for(i = 0; error_state_map[i].error!= ICAL_NO_ERROR;i++){ - if(error_state_map[i].error == error){ - error_state_map[i].state = state; - } - } -} - -icalerrorstate icalerror_get_error_state( icalerrorenum error) -{ - int i; - - for(i = 0; error_state_map[i].error!= ICAL_NO_ERROR;i++){ - if(error_state_map[i].error == error){ - return error_state_map[i].state; - } - } - - return ICAL_ERROR_UNKNOWN; -} - - - - -const char* icalerror_strerror(icalerrorenum e) { - - int i; - - for (i=0; string_map[i].error != ICAL_UNKNOWN_ERROR; i++) { - if (string_map[i].error == e) { - return string_map[i].name; - } - } - - return string_map[i].name; /* Return string for ICAL_UNKNOWN_ERROR*/ - -} - - -void ical_bt(void) -{ -#ifdef HAVE_BACKTRACE - void *stack_frames[50]; - size_t size, i; - char **strings; - - size = backtrace(stack_frames, sizeof(stack_frames) / sizeof(void*)); - strings = backtrace_symbols(stack_frames, size); - for (i = 0; i < size; i++) { - if (strings != NULL) - fprintf(stderr, "%s\n", strings[i]); - else - fprintf(stderr, "%p\n", stack_frames[i]); - } - free(strings); -#endif -} - diff --git a/calendar/libical/src/libical/icalerror.h b/calendar/libical/src/libical/icalerror.h deleted file mode 100644 index bb7cee000f..0000000000 --- a/calendar/libical/src/libical/icalerror.h +++ /dev/null @@ -1,173 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalerror.h - CREATOR: eric 09 May 1999 - - $Id: icalerror.h,v 1.17 2008-01-15 23:17:40 dothebart Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalerror.h - -======================================================================*/ - - -#ifndef ICALERROR_H -#define ICALERROR_H - -#include -#include /* For icalerror_warn() */ - - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define ICAL_SETERROR_ISFUNC - - -/** This routine is called before any error is triggered. It is called - by icalerror_set_errno, so it does not appear in all of the macros - below */ -void icalerror_stop_here(void); - -void icalerror_crash_here(void); - -typedef enum icalerrorenum { - ICAL_NO_ERROR, /* icalerrno may not be initialized - put it first so and pray that the compiler initialize things to zero */ - ICAL_BADARG_ERROR, - ICAL_NEWFAILED_ERROR, - ICAL_ALLOCATION_ERROR, - ICAL_MALFORMEDDATA_ERROR, - ICAL_PARSE_ERROR, - ICAL_INTERNAL_ERROR, /* Like assert --internal consist. prob */ - ICAL_FILE_ERROR, - ICAL_USAGE_ERROR, - ICAL_UNIMPLEMENTED_ERROR, - ICAL_UNKNOWN_ERROR /* Used for problems in input to icalerror_strerror()*/ - -} icalerrorenum; - -icalerrorenum * icalerrno_return(void); -#define icalerrno (*(icalerrno_return())) - -/** If true, libicl aborts after a call to icalerror_set_error - * - * @warning NOT THREAD SAFE -- recommended that you do not change - * this in a multithreaded program. - */ -#ifdef _MSC_VER - #ifdef BUILD_LIBICALDLL - #define LIBICAL_EXPORT __declspec(dllexport) - #else - #define LIBICAL_EXPORT __declspec(dllimport) - #endif -#else - #define LIBICAL_EXPORT extern -#endif - -LIBICAL_EXPORT int icalerror_errors_are_fatal; - -/* Warning messages */ - -#ifdef __GNUC__ca -#define icalerror_warn(message) {fprintf(stderr,"%s(), %s:%d: %s\n",__FUNCTION__,__FILE__,__LINE__,message);} -#else /* __GNU_C__ */ -#define icalerror_warn(message) {fprintf(stderr,"%s:%d: %s\n",__FILE__,__LINE__,message);} -#endif /* __GNU_C__ */ - - -void icalerror_clear_errno(void); -void _icalerror_set_errno(icalerrorenum); - -/* Make an individual error fatal or non-fatal. */ -typedef enum icalerrorstate { - ICAL_ERROR_FATAL, /* Not fata */ - ICAL_ERROR_NONFATAL, /* Fatal */ - ICAL_ERROR_DEFAULT, /* Use the value of icalerror_errors_are_fatal*/ - ICAL_ERROR_UNKNOWN /* Asked state for an unknown error type */ -} icalerrorstate ; - -const char* icalerror_strerror(icalerrorenum e); -const char* icalerror_perror(void); -void ical_bt(void); -void icalerror_set_error_state( icalerrorenum error, icalerrorstate); -icalerrorstate icalerror_get_error_state( icalerrorenum error); - -#ifndef ICAL_SETERROR_ISFUNC -#define icalerror_set_errno(x) \ -icalerrno = x; \ -if(icalerror_get_error_state(x)==ICAL_ERROR_FATAL || \ - (icalerror_get_error_state(x)==ICAL_ERROR_DEFAULT && \ - icalerror_errors_are_fatal == 1 )){ \ - icalerror_warn(icalerror_strerror(x)); \ - ical_bt(); \ - assert(0); \ -} } -#else -void icalerror_set_errno(icalerrorenum x); -#endif - -#ifdef ICAL_ERRORS_ARE_FATAL -#undef NDEBUG -#endif - -#define icalerror_check_value_type(value,type); -#define icalerror_check_property_type(value,type); -#define icalerror_check_parameter_type(value,type); -#define icalerror_check_component_type(value,type); - -/* Assert with a message */ -#ifdef ICAL_ERRORS_ARE_FATAL - -#ifdef __GNUC__ -#define icalerror_assert(test,message) if(!(test)){fprintf(stderr,"%s(), %s:%d: %s\n",__FUNCTION__,__FILE__,__LINE__,message);icalerror_stop_here(); abort();} -#else /*__GNUC__*/ -#define icalerror_assert(test,message) if(!(test)){fprintf(stderr,"%s:%d: %s\n",__FILE__,__LINE__,message);icalerror_stop_here(); abort();} -#endif /*__GNUC__*/ - -#else /* ICAL_ERRORS_ARE_FATAL */ -#define icalerror_assert(test,message) -#endif /* ICAL_ERRORS_ARE_FATAL */ - -/* Check & abort if check fails */ -#define icalerror_check_arg(test,arg) if(!(test)) { icalerror_set_errno(ICAL_BADARG_ERROR); } - -/* Check & return void if check fails*/ -#define icalerror_check_arg_rv(test,arg) if(!(test)) {icalerror_set_errno(ICAL_BADARG_ERROR); return; } - -/* Check & return 0 if check fails*/ -#define icalerror_check_arg_rz(test,arg) if(!(test)) { icalerror_set_errno(ICAL_BADARG_ERROR); return 0;} - -/* Check & return an error if check fails*/ -#define icalerror_check_arg_re(test,arg,error) if(!(test)) { icalerror_stop_here(); assert(0); return error;} - -/* Check & return something*/ -#define icalerror_check_arg_rx(test,arg,x) if(!(test)) { icalerror_set_errno(ICAL_BADARG_ERROR); return x;} - - - -/* String interfaces to set an error to NONFATAL and restore it to its - original value */ - -icalerrorstate icalerror_supress(const char* error); -void icalerror_restore(const char* error, icalerrorstate es); - - -#endif /* !ICALERROR_H */ - - - diff --git a/calendar/libical/src/libical/icallangbind.c b/calendar/libical/src/libical/icallangbind.c deleted file mode 100644 index b04274933a..0000000000 --- a/calendar/libical/src/libical/icallangbind.c +++ /dev/null @@ -1,337 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icallangbind.c - CREATOR: eric 15 dec 2000 - - DESCRIPTION: - - $Id: icallangbind.c,v 1.24 2008-01-02 20:07:31 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - This package is free software and is provided "as is" without - express or implied warranty. It may be used, redistributed and/or - modified under the same terms as perl itself. ( Either the Artistic - License or the GPL. ) - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icalcomponent.h" -#include "icalproperty.h" -#include "icalerror.h" -#include "icalmemory.h" -#include "icalvalue.h" -#include -#include - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -int* icallangbind_new_array(int size){ - int* p = (int*)malloc(size*sizeof(int)); - return p; /* Caller handles failures */ -} - -void icallangbind_free_array(int* array){ - free(array); -} - -int icallangbind_access_array(int* array, int index) { - return array[index]; -} - -/** Iterators to fetch parameters given property */ - -icalparameter* icallangbind_get_first_parameter(icalproperty *prop) - -{ - icalparameter_kind kind = ICAL_ANY_PARAMETER; - - return icalproperty_get_first_parameter(prop,kind); -} - -icalparameter* icallangbind_get_next_parameter(icalproperty *prop) -{ - icalparameter_kind kind = ICAL_ANY_PARAMETER; - - return icalproperty_get_next_parameter(prop,kind); -} - - -/** Like icalcomponent_get_first_component(), but takes a string for the - kind and can iterate over X properties as if each X name was a - seperate kind */ - -icalproperty* icallangbind_get_first_property(icalcomponent *c, - const char* prop) -{ - icalproperty_kind kind = icalproperty_string_to_kind(prop); - icalproperty *p; - - if (kind == ICAL_NO_PROPERTY){ - return 0; - } - - if(kind == ICAL_X_PROPERTY){ - for(p = icalcomponent_get_first_property(c,kind); - p !=0; - p = icalcomponent_get_next_property(c,kind)){ - - if(strcmp(icalproperty_get_x_name(p),prop) == 0){ - return p; - } - } - } else { - p=icalcomponent_get_first_property(c,kind); - - return p; - } - - return 0; - -} - -icalproperty* icallangbind_get_next_property(icalcomponent *c, - const char* prop) -{ - icalproperty_kind kind = icalenum_string_to_property_kind(prop); - icalproperty *p; - - if (kind == ICAL_NO_PROPERTY){ - return 0; - } - - if(kind == ICAL_X_PROPERTY){ - for(p = icalcomponent_get_next_property(c,kind); - p !=0; - p = icalcomponent_get_next_property(c,kind)){ - - if(strcmp(icalproperty_get_x_name(p),prop) == 0){ - return p; - } - } - } else { - p=icalcomponent_get_next_property(c,kind); - - return p; - } - - return 0; - -} - - -icalcomponent* icallangbind_get_first_component(icalcomponent *c, - const char* comp) -{ - icalcomponent_kind kind = icalenum_string_to_component_kind(comp); - - if (kind == ICAL_NO_COMPONENT){ - return 0; - } - return icalcomponent_get_first_component(c,kind); -} - -icalcomponent* icallangbind_get_next_component(icalcomponent *c, - const char* comp) -{ - icalcomponent_kind kind = icalenum_string_to_component_kind(comp); - - if (kind == ICAL_NO_COMPONENT){ - return 0; - } - return icalcomponent_get_next_component(c,kind); -} - - -#define APPENDS(x) icalmemory_append_string(&buf, &buf_ptr, &buf_size, x); - -#define APPENDC(x) icalmemory_append_char(&buf, &buf_ptr, &buf_size, x); - -char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep) -{ - char tmp[25]; - size_t buf_size = 1024; - char* buf; - char* buf_ptr; - icalparameter *param; - - icalvalue* value; - - if( prop == 0){ - return 0; - } - - buf = icalmemory_new_buffer(buf_size); - buf_ptr = buf; - - APPENDS("{ "); - - value = icalproperty_get_value(prop); - - APPENDS(" 'name' "); - APPENDS(sep); - APPENDC('\''); - APPENDS(icalproperty_kind_to_string(icalproperty_isa(prop))); - APPENDC('\''); - - if(value){ - APPENDS(", 'value_type' "); - APPENDS(sep); - APPENDC('\''); - APPENDS(icalvalue_kind_to_string(icalvalue_isa(value))); - APPENDC('\''); - } - - APPENDS(", 'pid' "); - APPENDS(sep); - APPENDC('\''); - snprintf(tmp,25,"%p",prop); - APPENDS(tmp); - APPENDC('\''); - - - if(value){ - switch (icalvalue_isa(value)){ - - case ICAL_ATTACH_VALUE: - case ICAL_BINARY_VALUE: - case ICAL_NO_VALUE: { - icalerror_set_errno(ICAL_INTERNAL_ERROR); - break; - } - - default: - { - char* str = icalvalue_as_ical_string_r(value); - char* copy = (char*) malloc(strlen(str)+1); - - const char *i; - char *j; - - if(copy ==0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - break; - } - /* Remove any newlines */ - - for(j=copy, i = str; *i != 0; j++,i++){ - if(*i=='\n'){ - i++; - } - *j = *i; - } - - *j = 0; - - APPENDS(", 'value'"); - APPENDS(sep); - APPENDC('\''); - APPENDS(copy); - APPENDC('\''); - - free(copy); - free(str); - break; - - } - } - } - - /* Add Parameters */ - - for(param = icalproperty_get_first_parameter(prop,ICAL_ANY_PARAMETER); - param != 0; - param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)){ - - char *copy = icalparameter_as_ical_string_r(param); - char *v; - - if(copy == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - continue; - } - - v = strchr(copy,'='); - - - if(v == 0){ - free(copy); - continue; - } - - *v = 0; - - v++; - - APPENDS(", "); - APPENDC('\''); - APPENDS(copy); - APPENDC('\''); - APPENDS(sep); - APPENDC('\''); - APPENDS(v); - APPENDC('\''); - free(copy); - } - - - APPENDC('}'); - - return buf; - -} - -const char* icallangbind_property_eval_string(icalproperty* prop, char* sep) -{ - char *buf; - buf = icallangbind_property_eval_string_r(prop, sep); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -#include "fcntl.h" -int icallangbind_string_to_open_flag(const char* str) -{ - if (strcmp(str,"r") == 0) {return O_RDONLY;} - else if (strcmp(str,"r+") == 0) {return O_RDWR;} - else if (strcmp(str,"w") == 0) {return O_WRONLY;} - else if (strcmp(str,"w+") == 0) {return O_RDWR|O_CREAT;} - else if (strcmp(str,"a") == 0) {return O_WRONLY|O_APPEND;} - else return -1; -} - - -char* icallangbind_quote_as_ical_r(const char* str) -{ - size_t buf_size = 2 * strlen(str); - - /* assume every char could be quoted */ - char* buf = icalmemory_new_buffer(buf_size); - int result; - - result = icalvalue_encode_ical_string(str, buf, buf_size); - - return buf; -} - - -const char* icallangbind_quote_as_ical(const char* str) -{ - char *buf; - buf = icallangbind_quote_as_ical_r(str); - icalmemory_add_tmp_buffer(buf); - return(buf); -} - diff --git a/calendar/libical/src/libical/icallangbind.h b/calendar/libical/src/libical/icallangbind.h deleted file mode 100644 index ff5129e13d..0000000000 --- a/calendar/libical/src/libical/icallangbind.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icallangbind.h - CREATOR: eric 25 jan 2001 - - DESCRIPTION: - - $Id: icallangbind.h,v 1.8 2008-01-02 20:07:31 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 1999 Eric Busboom - http://www.softwarestudio.org - - This package is free software and is provided "as is" without - express or implied warranty. It may be used, redistributed and/or - modified under the same terms as perl itself. ( Either the Artistic - License or the GPL. ) - - ======================================================================*/ - -#ifndef __ICALLANGBIND_H__ -#define __ICALLANGBIND_H__ - -int* icallangbind_new_array(int size); -void icallangbind_free_array(int* array); -int icallangbind_access_array(int* array, int index); -icalproperty* icallangbind_get_property(icalcomponent *c, int n, const char* prop); -const char* icallangbind_get_property_val(icalproperty* p); -const char* icallangbind_get_parameter(icalproperty *p, const char* parameter); -icalcomponent* icallangbind_get_component(icalcomponent *c, const char* comp); - -icalproperty* icallangbind_get_first_property(icalcomponent *c, - const char* prop); - -icalproperty* icallangbind_get_next_property(icalcomponent *c, - const char* prop); - -icalcomponent* icallangbind_get_first_component(icalcomponent *c, - const char* comp); - -icalcomponent* icallangbind_get_next_component(icalcomponent *c, - const char* comp); - -icalparameter* icallangbind_get_first_parameter(icalproperty *prop); - -icalparameter* icallangbind_get_next_parameter(icalproperty *prop); - -const char* icallangbind_property_eval_string(icalproperty* prop, char* sep); -char* icallangbind_property_eval_string_r(icalproperty* prop, char* sep); - - -int icallangbind_string_to_open_flag(const char* str); - -const char* icallangbind_quote_as_ical(const char* str); -char* icallangbind_quote_as_ical_r(const char* str); -#endif /*__ICALLANGBIND_H__*/ diff --git a/calendar/libical/src/libical/icalmemory.c b/calendar/libical/src/libical/icalmemory.c deleted file mode 100644 index c5234e9deb..0000000000 --- a/calendar/libical/src/libical/icalmemory.c +++ /dev/null @@ -1,375 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalmemory.c - CREATOR: eric 30 June 1999 - - $Id: icalmemory.c,v 1.12 2008-02-03 16:10:46 dothebart Exp $ - $Locker: $ - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is icalmemory.h - - ======================================================================*/ - -/** - * @file icalmemory.c - * @brief Common memory management routines. - * - * libical often passes strings back to the caller. To make these - * interfaces simple, I did not want the caller to have to pass in a - * memory buffer, but having libical pass out newly allocated memory - * makes it difficult to de-allocate the memory. - * - * The ring buffer in this scheme makes it possible for libical to pass - * out references to memory which the caller does not own, and be able - * to de-allocate the memory later. The ring allows libical to have - * several buffers active simultaneously, which is handy when creating - * string representations of components. - */ - -#define ICALMEMORY_C - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -#include "icalmemory.h" -#include "icalerror.h" - -#include /* for printf (debugging) */ -#include /* for malloc, realloc */ -#include /* for memset(), strdup */ - -#ifdef WIN32 -#include -#endif - -#define BUFFER_RING_SIZE 2500 -#define MIN_BUFFER_SIZE 200 - - -/* HACK. Not threadsafe */ - -typedef struct { - int pos; - void *ring[BUFFER_RING_SIZE]; -} buffer_ring; - -void icalmemory_free_tmp_buffer (void* buf); -void icalmemory_free_ring_byval(buffer_ring *br); - -#ifndef HAVE_PTHREAD -static buffer_ring* global_buffer_ring = 0; -#endif - -#ifdef HAVE_PTHREAD -#include - -static pthread_key_t ring_key; -static pthread_once_t ring_key_once = PTHREAD_ONCE_INIT; - -static void ring_destroy(void * buf) { - if (buf) icalmemory_free_ring_byval((buffer_ring *) buf); - pthread_setspecific(ring_key, NULL); -} - -static void ring_key_alloc(void) { - pthread_key_create(&ring_key, ring_destroy); -} -#endif - - -static buffer_ring * buffer_ring_new(void) { - buffer_ring *br; - int i; - - br = (buffer_ring *)malloc(sizeof(buffer_ring)); - - for(i=0; iring[i] = 0; - } - br->pos = 0; - return(br); -} - - -#ifdef HAVE_PTHREAD -static buffer_ring* get_buffer_ring_pthread(void) { - buffer_ring *br; - - pthread_once(&ring_key_once, ring_key_alloc); - - br = pthread_getspecific(ring_key); - - if (!br) { - br = buffer_ring_new(); - pthread_setspecific(ring_key, br); - } - return(br); -} -#else -/* get buffer ring via a single global for a non-threaded program */ -static buffer_ring* get_buffer_ring_global(void) { - if (global_buffer_ring == 0) { - global_buffer_ring = buffer_ring_new(); - } - return(global_buffer_ring); -} -#endif - -static buffer_ring *get_buffer_ring(void) { -#ifdef HAVE_PTHREAD - return(get_buffer_ring_pthread()); -#else - return get_buffer_ring_global(); -#endif -} - - -/** Add an existing buffer to the buffer ring */ -void icalmemory_add_tmp_buffer(void* buf) -{ - buffer_ring *br = get_buffer_ring(); - - - /* Wrap around the ring */ - if(++(br->pos) == BUFFER_RING_SIZE){ - br->pos = 0; - } - - /* Free buffers as their slots are overwritten */ - if ( br->ring[br->pos] != 0){ - free( br->ring[br->pos]); - } - - /* Assign the buffer to a slot */ - br->ring[br->pos] = buf; -} - - -/** - * Create a new temporary buffer on the ring. Libical owns these and - * will deallocate them. - */ - -void* -icalmemory_tmp_buffer (size_t size) -{ - char *buf; - - if (size < MIN_BUFFER_SIZE){ - size = MIN_BUFFER_SIZE; - } - - buf = (void*)malloc(size); - - if( buf == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - memset(buf,0,size); - - icalmemory_add_tmp_buffer(buf); - - return buf; -} - -/** get rid of this buffer ring */ -void icalmemory_free_ring_byval(buffer_ring *br) { - int i; - for(i=0; iring[i] != 0){ - free( br->ring[i]); - } - } - free(br); -} - -void icalmemory_free_ring() -{ - buffer_ring *br; - br = get_buffer_ring(); - - icalmemory_free_ring_byval(br); -#ifdef HAVE_PTHREAD - pthread_setspecific(ring_key, 0); -#else - global_buffer_ring = 0; -#endif - -} - - - -/** Like strdup, but the buffer is on the ring. */ -char* -icalmemory_tmp_copy(const char* str) -{ - char* b = icalmemory_tmp_buffer(strlen(str)+1); - - strcpy(b,str); - - return b; -} - - -char* icalmemory_strdup(const char *s) -{ - return strdup(s); -} - -void -icalmemory_free_tmp_buffer (void* buf) -{ - if(buf == 0) - { - return; - } - - free(buf); -} - - -/* - * These buffer routines create memory the old fashioned way -- so the - * caller will have to deallocate the new memory - */ - -void* icalmemory_new_buffer(size_t size) -{ - void *b = malloc(size); - - if( b == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - memset(b,0,size); - - return b; -} - -void* icalmemory_resize_buffer(void* buf, size_t size) -{ - void *b = realloc(buf, size); - - if( b == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - return b; -} - -void icalmemory_free_buffer(void* buf) -{ - free(buf); -} - -void -icalmemory_append_string(char** buf, char** pos, size_t* buf_size, - const char* string) -{ - char *new_buf; - char *new_pos; - - size_t data_length, final_length, string_length; - -#ifndef ICAL_NO_INTERNAL_DEBUG - icalerror_check_arg_rv( (buf!=0),"buf"); - icalerror_check_arg_rv( (*buf!=0),"*buf"); - icalerror_check_arg_rv( (pos!=0),"pos"); - icalerror_check_arg_rv( (*pos!=0),"*pos"); - icalerror_check_arg_rv( (buf_size!=0),"buf_size"); - icalerror_check_arg_rv( (*buf_size!=0),"*buf_size"); - icalerror_check_arg_rv( (string!=0),"string"); -#endif - - string_length = strlen(string); - data_length = (size_t)*pos - (size_t)*buf; - final_length = data_length + string_length; - - if ( final_length >= (size_t) *buf_size) { - - - *buf_size = (*buf_size) * 2 + final_length; - - new_buf = realloc(*buf,*buf_size); - - new_pos = (void*)((size_t)new_buf + data_length); - - *pos = new_pos; - *buf = new_buf; - } - - strcpy(*pos, string); - - *pos += string_length; -} - - -void -icalmemory_append_char(char** buf, char** pos, size_t* buf_size, - char ch) -{ - char *new_buf; - char *new_pos; - - size_t data_length, final_length; - -#ifndef ICAL_NO_INTERNAL_DEBUG - icalerror_check_arg_rv( (buf!=0),"buf"); - icalerror_check_arg_rv( (*buf!=0),"*buf"); - icalerror_check_arg_rv( (pos!=0),"pos"); - icalerror_check_arg_rv( (*pos!=0),"*pos"); - icalerror_check_arg_rv( (buf_size!=0),"buf_size"); - icalerror_check_arg_rv( (*buf_size!=0),"*buf_size"); -#endif - - data_length = (size_t)*pos - (size_t)*buf; - - final_length = data_length + 2; - - if ( final_length > (size_t) *buf_size ) { - - - *buf_size = (*buf_size) * 2 + final_length +1; - - new_buf = realloc(*buf,*buf_size); - - new_pos = (void*)((size_t)new_buf + data_length); - - *pos = new_pos; - *buf = new_buf; - } - - **pos = ch; - *pos += 1; - **pos = 0; -} diff --git a/calendar/libical/src/libical/icalmemory.h b/calendar/libical/src/libical/icalmemory.h deleted file mode 100644 index 4bd1d92e4b..0000000000 --- a/calendar/libical/src/libical/icalmemory.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalmemory.h - CREATOR: eric 30 June 1999 - - - $Id: icalmemory.h,v 1.6 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Initial Developer of the Original Code is Eric Busboom - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org -======================================================================*/ - -#ifndef ICALMEMORY_H -#define ICALMEMORY_H - -#ifndef WIN32 -#include /* for size_t */ -#else -#include -#endif - -/* Tmp buffers are managed by ical. References can be returned to the - caller, although the caller will not own the memory. */ - -void* icalmemory_tmp_buffer(size_t size); -char* icalmemory_tmp_copy(const char* str); - -/** Add an externally allocated buffer to the ring. */ -void icalmemory_add_tmp_buffer(void*); - - -/** Free all memory used in the ring */ -void icalmemory_free_ring(void); - -/* Non-tmp buffers must be freed. These are mostly wrappers around - * malloc, etc, but are used so the caller can change the memory - * allocators in a future version of the library */ - -void* icalmemory_new_buffer(size_t size); -void* icalmemory_resize_buffer(void* buf, size_t size); -void icalmemory_free_buffer(void* buf); - -/** - icalmemory_append_string will copy the string 'string' to the - buffer 'buf' starting at position 'pos', reallocing 'buf' if it is - too small. 'buf_size' is the size of 'buf' and will be changed if - 'buf' is reallocated. 'pos' will point to the last byte of the new - string in 'buf', usually a '\0' */ - -/* THESE ROUTINES CAN NOT BE USED ON TMP BUFFERS. Only use them on - normally allocated memory, or on buffers created from - icalmemory_new_buffer, never with buffers created by - icalmemory_tmp_buffer. If icalmemory_append_string has to resize a - buffer on the ring, the ring will loose track of it an you will - have memory problems. */ - -void icalmemory_append_string(char** buf, char** pos, size_t* buf_size, - const char* string); - -/** icalmemory_append_char is similar, but is appends a character instead of a string */ -void icalmemory_append_char(char** buf, char** pos, size_t* buf_size, - char ch); - -/** A wrapper around strdup. Partly to trap calls to strdup, partly - because in -ansi, gcc on Red Hat claims that strdup is undeclared */ -char* icalmemory_strdup(const char *s); - -#endif /* !ICALMEMORY_H */ - - - diff --git a/calendar/libical/src/libical/icalmime.c b/calendar/libical/src/libical/icalmime.c deleted file mode 100644 index 280b917346..0000000000 --- a/calendar/libical/src/libical/icalmime.c +++ /dev/null @@ -1,411 +0,0 @@ -/* -*- Mode: C -*-*/ -/*====================================================================== - FILE: icalmime.c - CREATOR: eric 26 July 2000 - - - $Id: icalmime.c,v 1.14 2008-01-29 22:25:05 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#include "icalmime.h" -#include "icalerror.h" -#include "icalmemory.h" -#include "sspm.h" -#include "stdlib.h" -#include /* For strdup */ -#include /* for snprintf*/ - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -/* These *_part routines are called by the MIME parser via the - local_action_map */ - -struct text_part -{ - char* buf; - char* buf_pos; - size_t buf_size; -}; - -void* icalmime_text_new_part(void) -{ - -#define BUF_SIZE 2048 - - struct text_part* impl; - - if ( ( impl = (struct text_part*) - malloc(sizeof(struct text_part))) == 0) { - return 0; - } - - impl->buf = icalmemory_new_buffer(BUF_SIZE); - impl->buf_pos = impl->buf; - impl->buf_size = BUF_SIZE; - - return impl; -} -void icalmime_text_add_line(void *part, - struct sspm_header *header, - const char* line, size_t size) -{ - struct text_part* impl = (struct text_part*) part; - (void)header; - (void)size; - - icalmemory_append_string(&(impl->buf),&(impl->buf_pos), - &(impl->buf_size),line); - -} - -void* icalmime_textcalendar_end_part(void* part) -{ - - struct text_part* impl = (struct text_part*) part; - icalcomponent *c = icalparser_parse_string(impl->buf); - - icalmemory_free_buffer(impl->buf); - free(impl); - - return c; - -} - -void* icalmime_text_end_part_r(void* part) -{ - char *buf; - struct text_part* impl = ( struct text_part*) part; - - buf = impl->buf; - free(impl); - - return buf; -} - -void* icalmime_text_end_part(void* part) -{ - void *buf; - buf = icalmime_text_end_part_r(part); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -void icalmime_text_free_part(void *part) -{ - part = part; -} - - -/* Ignore Attachments for now */ - -void* icalmime_attachment_new_part(void) -{ - return 0; -} -void icalmime_attachment_add_line(void *part, struct sspm_header *header, - const char* line, size_t size) -{ - (void)part; - (void)header; - (void)line; - (void)size; -} - -void* icalmime_attachment_end_part(void* part) -{ - (void)part; - return 0; -} - -void icalmime_attachment_free_part(void *part) -{ - (void)part; -} - - - - -static const struct sspm_action_map icalmime_local_action_map[] = -{ - {SSPM_TEXT_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_text_new_part,icalmime_text_add_line,icalmime_textcalendar_end_part,icalmime_text_free_part}, - {SSPM_TEXT_MAJOR_TYPE,SSPM_ANY_MINOR_TYPE,icalmime_text_new_part,icalmime_text_add_line,icalmime_text_end_part_r,icalmime_text_free_part}, - {SSPM_TEXT_MAJOR_TYPE,SSPM_PLAIN_MINOR_TYPE,icalmime_text_new_part,icalmime_text_add_line,icalmime_text_end_part_r,icalmime_text_free_part}, - {SSPM_APPLICATION_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_attachment_new_part,icalmime_attachment_add_line,icalmime_attachment_end_part,icalmime_attachment_free_part}, - {SSPM_IMAGE_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_attachment_new_part,icalmime_attachment_add_line,icalmime_attachment_end_part,icalmime_attachment_free_part}, - {SSPM_AUDIO_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_attachment_new_part,icalmime_attachment_add_line,icalmime_attachment_end_part,icalmime_attachment_free_part}, - {SSPM_IMAGE_MAJOR_TYPE,SSPM_CALENDAR_MINOR_TYPE,icalmime_attachment_new_part,icalmime_attachment_add_line,icalmime_attachment_end_part,icalmime_attachment_free_part}, - {SSPM_UNKNOWN_MAJOR_TYPE,SSPM_UNKNOWN_MINOR_TYPE,0,0,0,0} -}; - -#define NUM_PARTS 100 /* HACK. Hard Limit */ - - - -struct sspm_part* icalmime_make_part(icalcomponent* comp) -{ - comp = comp; - return 0; -} - -char* icalmime_as_mime_string(char* icalcomponent); - -icalcomponent* icalmime_parse(char* (*get_string)(char *s, size_t size, - void *d), - void *data) -{ - struct sspm_part *parts; - int i, last_level=0; - icalcomponent *root=0, *parent=0, *comp=0, *last = 0; - - if ( (parts = (struct sspm_part *) - malloc(NUM_PARTS*sizeof(struct sspm_part)))==0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - memset(parts,0,sizeof(NUM_PARTS*sizeof(struct sspm_part))); - - sspm_parse_mime(parts, - NUM_PARTS, /* Max parts */ - icalmime_local_action_map, /* Actions */ - get_string, - data, /* data for get_string*/ - 0 /* First header */); - - - - for(i = 0; i last_level){ - - parent = last; - icalcomponent_add_component(parent,comp); - - last_level = parts[i].level; - - } else if (parts[i].level < last_level){ - - if (parent) - parent = icalcomponent_get_parent(parent); - icalcomponent_add_component(parent,comp); - - last_level = parts[i].level; - } else { - assert(0); - } - - last = comp; - last_level = parts[i].level; - assert(parts[i].data == 0); - } - - sspm_free_parts(parts,NUM_PARTS); - free(parts); - - return root; -} - - - -int icalmime_test(char* (*get_string)(char *s, size_t size, void *d), - void *data) -{ - char *out; - struct sspm_part *parts; - int i; - - if ( (parts = (struct sspm_part *) - malloc(NUM_PARTS*sizeof(struct sspm_part)))==0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - memset(parts,0,sizeof(NUM_PARTS*sizeof(struct sspm_part))); - - sspm_parse_mime(parts, - NUM_PARTS, /* Max parts */ - icalmime_local_action_map, /* Actions */ - get_string, - data, /* data for get_string*/ - 0 /* First header */); - - for(i = 0; i - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - -======================================================================*/ - -#ifndef ICALMIME_H -#define ICALMIME_H - -#include "icalcomponent.h" -#include "icalparser.h" - -icalcomponent* icalmime_parse( char* (*line_gen_func)(char *s, size_t size, - void *d), - void *data); - -/* The inverse of icalmime_parse, not implemented yet. Use sspm.h directly. */ -char* icalmime_as_mime_string(char* component); - - - -#endif /* !ICALMIME_H */ - - - diff --git a/calendar/libical/src/libical/icalparameter.c b/calendar/libical/src/libical/icalparameter.c deleted file mode 100644 index 5f87893c2b..0000000000 --- a/calendar/libical/src/libical/icalparameter.c +++ /dev/null @@ -1,448 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalderivedparameters.{c,h} - CREATOR: eric 09 May 1999 - - $Id: icalparameter.c,v 1.15 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalderivedparameters.{c,h} - - Contributions from: - Graham Davison - - ======================================================================*/ -#ifdef HAVE_CONFIG_H -#include -#endif - - -#include "icalparameter.h" -#include "icalproperty.h" -#include "icalerror.h" -#include "icalmemory.h" -#include "icalparameterimpl.h" - -#include /* for malloc() */ -#include -#include /* for memset() */ - - -#ifdef WIN32 -#ifndef HAVE_SNPRINTF -#include "vsnprintf.h" -#endif -#define strcasecmp stricmp -#endif - -/* In icalderivedparameter */ -icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind,const char* val); - - -struct icalparameter_impl* icalparameter_new_impl(icalparameter_kind kind) -{ - struct icalparameter_impl* v; - - if ( ( v = (struct icalparameter_impl*) - malloc(sizeof(struct icalparameter_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - strcpy(v->id,"para"); - - v->kind = kind; - v->size = 0; - v->string = 0; - v->x_name = 0; - v->parent = 0; - v->data = 0; - - return v; -} - -icalparameter* -icalparameter_new (icalparameter_kind kind) -{ - struct icalparameter_impl* v = icalparameter_new_impl(kind); - - return (icalparameter*) v; - -} - -void -icalparameter_free (icalparameter* param) -{ - -/* HACK. This always triggers, even when parameter is non-zero - icalerror_check_arg_rv((parameter==0),"parameter");*/ - - -#ifdef ICAL_FREE_ON_LIST_IS_ERROR - icalerror_assert( (param->parent ==0),"Tried to free a parameter that is still attached to a component. "); - -#else - if(param->parent !=0){ - return; - } -#endif - - - if (param->string != 0){ - free ((void*)param->string); - } - - if (param->x_name != 0){ - free ((void*)param->x_name); - } - - memset(param,0,sizeof(icalparameter)); - - param->parent = 0; - param->id[0] = 'X'; - free(param); -} - - - -icalparameter* -icalparameter_new_clone(icalparameter* old) -{ - struct icalparameter_impl *new; - - new = icalparameter_new_impl(old->kind); - - icalerror_check_arg_rz((old!=0),"param"); - - if (new == 0){ - return 0; - } - - memcpy(new,old,sizeof(struct icalparameter_impl)); - - if (old->string != 0){ - new->string = icalmemory_strdup(old->string); - if (new->string == 0){ - icalparameter_free(new); - return 0; - } - } - - if (old->x_name != 0){ - new->x_name = icalmemory_strdup(old->x_name); - if (new->x_name == 0){ - icalparameter_free(new); - return 0; - } - } - - return new; -} - -icalparameter* icalparameter_new_from_string(const char *str) -{ - char* eq; - char* cpy; - icalparameter_kind kind; - icalparameter *param; - - icalerror_check_arg_rz(str != 0,"str"); - - cpy = icalmemory_strdup(str); - - if (cpy == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - eq = strchr(cpy,'='); - - if(eq == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(cpy); - return 0; - } - - *eq = '\0'; - - eq++; - - kind = icalparameter_string_to_kind(cpy); - - if(kind == ICAL_NO_PARAMETER){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(cpy); - return 0; - } - - param = icalparameter_new_from_value_string(kind,eq); - - if(kind == ICAL_X_PARAMETER){ - icalparameter_set_xname(param,cpy); - } else if(kind == ICAL_IANA_PARAMETER) { - icalparameter_set_iana_name(param, cpy); - } - - free(cpy); - - return param; - -} - -char* -icalparameter_as_ical_string(icalparameter* param) -{ - char *buf; - buf = icalparameter_as_ical_string_r(param); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -/** - * Return a string representation of the parameter according to RFC2445. - * - * param = param-name "=" param-value - * param-name = iana-token / x-token - * param-value = paramtext /quoted-string - * paramtext = *SAFE-SHARE - * quoted-string= DQUOTE *QSAFE-CHARE DQUOTE - * QSAFE-CHAR = any character except CTLs and DQUOTE - * SAFE-CHAR = any character except CTLs, DQUOTE. ";", ":", "," - */ -char* -icalparameter_as_ical_string_r(icalparameter* param) -{ - size_t buf_size = 1024; - char* buf; - char* buf_ptr; - const char *kind_string; - - icalerror_check_arg_rz( (param!=0), "parameter"); - - /* Create new buffer that we can append names, parameters and a - * value to, and reallocate as needed. - */ - - buf = icalmemory_new_buffer(buf_size); - buf_ptr = buf; - - if(param->kind == ICAL_X_PARAMETER) { - icalmemory_append_string(&buf, &buf_ptr, &buf_size, - icalparameter_get_xname(param)); - } else if (param->kind == ICAL_IANA_PARAMETER) { - icalmemory_append_string(&buf, &buf_ptr, &buf_size, - icalparameter_get_iana_name(param)); - } else { - - kind_string = icalparameter_kind_to_string(param->kind); - - if (param->kind == ICAL_NO_PARAMETER || - param->kind == ICAL_ANY_PARAMETER || - kind_string == 0) - { - icalerror_set_errno(ICAL_BADARG_ERROR); - free(buf); - return 0; - } - - - /* Put the parameter name into the string */ - icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); - - } - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "="); - - if(param->string !=0){ - int qm = 0; - - /* Encapsulate the property in quotes if necessary */ - if (strpbrk(param->string, ";:,") != 0) { - icalmemory_append_char (&buf, &buf_ptr, &buf_size, '"'); - qm = 1; - } - icalmemory_append_string(&buf, &buf_ptr, &buf_size, param->string); - if (qm == 1) { - icalmemory_append_char (&buf, &buf_ptr, &buf_size, '"'); - } - } else if (param->data != 0){ - const char* str = icalparameter_enum_to_string(param->data); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, str); - } else { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(buf); - return 0; - } - - return buf; -} - - -int -icalparameter_is_valid (icalparameter* parameter); - - -icalparameter_kind -icalparameter_isa (icalparameter* parameter) -{ - if(parameter == 0){ - return ICAL_NO_PARAMETER; - } - - return parameter->kind; -} - - -int -icalparameter_isa_parameter (void* parameter) -{ - struct icalparameter_impl *impl = (struct icalparameter_impl *)parameter; - - if (parameter == 0){ - return 0; - } - - if (strcmp(impl->id,"para") == 0) { - return 1; - } else { - return 0; - } -} - - -void -icalparameter_set_xname (icalparameter* param, const char* v) -{ - icalerror_check_arg_rv( (param!=0),"param"); - icalerror_check_arg_rv( (v!=0),"v"); - - if (param->x_name != 0){ - free((void*)param->x_name); - } - - param->x_name = icalmemory_strdup(v); - - if (param->x_name == 0){ - errno = ENOMEM; - } - -} - -const char* -icalparameter_get_xname (icalparameter* param) -{ - icalerror_check_arg_rz( (param!=0),"param"); - - return param->x_name; -} - -void -icalparameter_set_xvalue (icalparameter* param, const char* v) -{ - icalerror_check_arg_rv( (param!=0),"param"); - icalerror_check_arg_rv( (v!=0),"v"); - - if (param->string != 0){ - free((void*)param->string); - } - - param->string = icalmemory_strdup(v); - - if (param->string == 0){ - errno = ENOMEM; - } - -} - -const char* -icalparameter_get_xvalue (icalparameter* param) -{ - icalerror_check_arg_rz( (param!=0),"param"); - - return param->string; -} - -void icalparameter_set_iana_value (icalparameter* param, const char* v) -{ - icalparameter_set_xvalue(param, v); -} - -const char* icalparameter_get_iana_value(icalparameter* param) -{ - return icalparameter_get_xvalue(param); -} - -void icalparameter_set_iana_name (icalparameter* param, const char* v) -{ - icalparameter_set_xname(param, v); -} - -const char* icalparameter_get_iana_name (icalparameter* param) -{ - return icalparameter_get_xname(param); -} - -void icalparameter_set_parent(icalparameter* param, - icalproperty* property) -{ - icalerror_check_arg_rv( (param!=0),"param"); - - param->parent = property; -} - -icalproperty* icalparameter_get_parent(icalparameter* param) -{ - icalerror_check_arg_rz( (param!=0),"param"); - - return param->parent; -} - -/* returns 1 if parameters have same name in ICAL, otherwise 0 */ -int icalparameter_has_same_name(icalparameter* param1, icalparameter* param2) -{ - icalparameter_kind kind1; - icalparameter_kind kind2; - const char *name1; - const char *name2; - - icalerror_check_arg_rz( (param1!=0),"param1"); - icalerror_check_arg_rz( (param2!=0),"param2"); - - kind1 = icalparameter_isa(param1); - kind2 = icalparameter_isa(param2); - - if (kind1 != kind2) - return 0; - - if (kind1 == ICAL_X_PARAMETER) { - name1 = icalparameter_get_xname(param1); - name2 = icalparameter_get_xname(param2); - if (strcasecmp(name1, name2) != 0) - return 0; - } else if (kind1 == ICAL_IANA_PARAMETER) { - name1 = icalparameter_get_iana_name(param1); - name2 = icalparameter_get_iana_name(param2); - if (strcasecmp(name1, name2) != 0) - return 0; - } - return 1; -} - -/* Everything below this line is machine generated. Do not edit. */ -/* ALTREP */ diff --git a/calendar/libical/src/libical/icalparameter.h b/calendar/libical/src/libical/icalparameter.h deleted file mode 100644 index cc15953951..0000000000 --- a/calendar/libical/src/libical/icalparameter.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalparam.h - CREATOR: eric 20 March 1999 - - - $Id: icalparameter.h,v 1.5 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalparam.h - - ======================================================================*/ - -#ifndef ICALPARAM_H -#define ICALPARAM_H - -#include "icalderivedparameter.h" - -/* Declared in icalderivedparameter.h */ -/*typedef struct icalparameter_impl icalparameter;*/ - -icalparameter* icalparameter_new(icalparameter_kind kind); -icalparameter* icalparameter_new_clone(icalparameter* p); - -/* Create from string of form "PARAMNAME=VALUE" */ -icalparameter* icalparameter_new_from_string(const char* value); - -/* Create from just the value, the part after the "=" */ -icalparameter* icalparameter_new_from_value_string(icalparameter_kind kind, const char* value); - -void icalparameter_free(icalparameter* parameter); - -char* icalparameter_as_ical_string(icalparameter* parameter); -char* icalparameter_as_ical_string_r(icalparameter* parameter); - -int icalparameter_is_valid(icalparameter* parameter); - -icalparameter_kind icalparameter_isa(icalparameter* parameter); - -int icalparameter_isa_parameter(void* param); - -/* Access the name of an X parameter */ -void icalparameter_set_xname (icalparameter* param, const char* v); -const char* icalparameter_get_xname(icalparameter* param); -void icalparameter_set_xvalue (icalparameter* param, const char* v); -const char* icalparameter_get_xvalue(icalparameter* param); - -/* Access the name of an IANA parameter */ -void icalparameter_set_iana_name (icalparameter* param, const char* v); -const char* icalparameter_get_iana_name(icalparameter* param); -void icalparameter_set_iana_value (icalparameter* param, const char* v); -const char* icalparameter_get_iana_value(icalparameter* param); - -/* returns 1 if parameters have same name in ICAL, otherwise 0 */ -int icalparameter_has_same_name(icalparameter* param1, icalparameter* param2); - -/* Convert enumerations */ - -const char* icalparameter_kind_to_string(icalparameter_kind kind); -icalparameter_kind icalparameter_string_to_kind(const char* string); - - - -#endif diff --git a/calendar/libical/src/libical/icalparameterimpl.h b/calendar/libical/src/libical/icalparameterimpl.h deleted file mode 100644 index 3a5d1f570c..0000000000 --- a/calendar/libical/src/libical/icalparameterimpl.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalparameterimpl.h - CREATOR: eric 09 May 1999 - - $Id: icalparameterimpl.h,v 1.4 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalderivedparameters.{c,h} - - Contributions from: - Graham Davison (g.m.davison@computer.org) - - ======================================================================*/ -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifndef ICALPARAMETER_IMPL -#define ICALPARAMETER_IMPL - -#include "icalparameter.h" -#include "icalproperty.h" - -struct icalparameter_impl -{ - icalparameter_kind kind; - char id[5]; - int size; - const char* string; - const char* x_name; - icalproperty* parent; - - int data; -}; - - -#endif /*ICALPARAMETER_IMPL*/ diff --git a/calendar/libical/src/libical/icalparser.c b/calendar/libical/src/libical/icalparser.c deleted file mode 100644 index c0ad1d6f7b..0000000000 --- a/calendar/libical/src/libical/icalparser.c +++ /dev/null @@ -1,1291 +0,0 @@ -/* -*- Mode: C; tab-width: 4; c-basic-offset: 8; -*- - ====================================================================== - FILE: icalparser.c - CREATOR: eric 04 August 1999 - - $Id: icalparser.c,v 1.53 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Initial Developer of the Original Code is Eric Busboom - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - - -#include "pvl.h" -#include "icalerror.h" -#include "icalvalue.h" -#include "icalderivedparameter.h" -#include "icalparameter.h" -#include "icalproperty.h" -#include "icalcomponent.h" - -#include /* For strncpy & size_t */ -#include /* For FILE and fgets and snprintf */ -#include /* for free */ -#include - -#include "icalmemory.h" -#include "icalparser.h" - -#ifdef HAVE_WCTYPE_H -# include -/* Some systems have an imcomplete implementation on wctype (FreeBSD, - * Darwin). Cope with that. */ -# ifndef HAVE_ISWSPACE -# define iswspace isspace -# endif -#else -# if !defined HAVE_ISWSPACE && !defined WIN32 -# define iswspace isspace -# endif -#endif - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -static char* parser_get_next_char(char c, char *str, int qm); -static char* parser_get_next_parameter(char* line,char** end); -static char* parser_get_next_value(char* line, char **end, icalvalue_kind kind); -static char* parser_get_prop_name(char* line, char** end); -static char* parser_get_param_name(char* line, char **end, char **buf_value); - -#define TMP_BUF_SIZE 80 - -struct icalparser_impl -{ - int buffer_full; /* flag indicates that temp is smaller that - data being read into it*/ - int continuation_line; /* last line read was a continuation line */ - size_t tmp_buf_size; - char temp[TMP_BUF_SIZE]; - icalcomponent *root_component; - int version; - int level; - int lineno; - icalparser_state state; - pvl_list components; - - void *line_gen_data; - -}; - - -/* - * New version of strstrip() that does not move the pointer. - */ -void strstriplt(char *buf) -{ - size_t len; - int a; - - if (buf==NULL) { - return; - } - if (buf[0] == 0) { - return; - } - len = strlen(buf); - while ((buf[0] != 0) && (isspace(buf[len - 1]))) { - buf[--len] = 0; - } - if (buf[0] == 0) { - return; - } - a = 0; - while ((buf[0]!=0) && (isspace(buf[a]))) { - a++; - } - if (a > 0) { - memmove(buf, &buf[a], len - a + 1); - } -} - - - -icalparser* icalparser_new(void) -{ - struct icalparser_impl* impl = 0; - if ( ( impl = (struct icalparser_impl*) - malloc(sizeof(struct icalparser_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - impl->root_component = 0; - impl->components = pvl_newlist(); - impl->level = 0; - impl->state = ICALPARSER_SUCCESS; - impl->tmp_buf_size = TMP_BUF_SIZE; - impl->buffer_full = 0; - impl->continuation_line = 0; - impl->lineno = 0; - impl->continuation_line = 0; - memset(impl->temp,0, TMP_BUF_SIZE); - - return (icalparser*)impl; -} - - -void icalparser_free(icalparser* parser) -{ - icalcomponent *c; - - if (parser->root_component != 0){ - icalcomponent_free(parser->root_component); - } - - while( (c=pvl_pop(parser->components)) != 0){ - icalcomponent_free(c); - } - - pvl_free(parser->components); - - free(parser); -} - -void icalparser_set_gen_data(icalparser* parser, void* data) -{ - parser->line_gen_data = data; -} - - -icalvalue* icalvalue_new_From_string_with_error(icalvalue_kind kind, - char* str, - icalproperty **error); - - -static -char* parser_get_next_char(char c, char *str, int qm) -{ - int quote_mode = 0; - char *p = str; - char next_char = *p; - char prev_char = 0; - - while (next_char != '\0') { - if (prev_char != '\\') { - if (qm == 1 && next_char == '"') { - /* Encountered a quote, toggle quote mode */ - quote_mode = !quote_mode; - } else if (quote_mode == 0 && next_char == c) { - /* Found a matching character out of quote mode, return it */ - return p; - } - } - - /* Save the previous character so we can check if it's a backslash in the next iteration */ - prev_char = next_char; - next_char = *(++p); - } - - return 0; -} - - -/** make a new tmp buffer out of a substring */ -static char* make_segment(char* start, char* end) -{ - char *buf, *tmp; - size_t size = (size_t)end - (size_t)start; - - buf = icalmemory_new_buffer(size+1); - strncpy(buf,start,size); - *(buf+size) = 0; - - tmp = (buf+size); - while ((tmp >= buf) && - ((*tmp == '\0') || iswspace(*tmp))) - { - *tmp = 0; - tmp--; - } - - return buf; -} - -static -char* parser_get_prop_name(char* line, char** end) -{ - char* p; - char* v; - char *str; - - p = parser_get_next_char(';',line,1); - v = parser_get_next_char(':',line,1); - if (p== 0 && v == 0) { - return 0; - } - - /* There is no ';' or, it is after the ';' that marks the beginning of - the value */ - if (v!=0 && ( p == 0 || p > v)){ - str = make_segment(line,v); - *end = v+1; - } else { - str = make_segment(line,p); - *end = p+1; - } - - return str; -} - -static -char* parser_get_param_name(char* line, char **end, char **buf) -{ - char* next; - char *str; - - next = parser_get_next_char('=',line,1); - - *buf = 0; - if (next == 0) { - return 0; - } - - str = make_segment(line,next); - *end = next+1; - if (**end == '"') { - *end = *end+1; - next = parser_get_next_char('"',*end,0); - if (next == 0) { - free(str); - return 0; - } - - *buf = *end = make_segment(*end,next); - } - - return str; -} - -#if 0 -static -char* parser_get_next_paramvalue(char* line, char **end) -{ - char* next; - char *str; - - next = parser_get_next_char(',',line,1); - - if (next == 0){ - next = (char*)(size_t)line+(size_t)strlen(line);\ - } - - if (next == line){ - return 0; - } else { - str = make_segment(line,next); - *end = next+1; - return str; - } -} -#endif - -char* icalparser_get_value(char* line, char **end, icalvalue_kind kind) -{ - char *str; - size_t length = strlen(line); - - if (length == 0){ - return 0; - } - - *end = line+length; - str = make_segment(line, *end); - - return str; -} - -/** - A property may have multiple values, if the values are seperated by - commas in the content line. This routine will look for the next - comma after line and will set the next place to start searching in - end. */ - -static -char* parser_get_next_value(char* line, char **end, icalvalue_kind kind) -{ - - char* next; - char *p; - char *str; - size_t length = strlen(line); - - p = line; - while(1){ - - next = parser_get_next_char(',',p,1); - - /* Unforunately, RFC2445 says that for the RECUR value, COMMA - can both separate digits in a list, and it can separate - multiple recurrence specifications. This is not a friendly - part of the spec. This weirdness tries to - distinguish the two uses. it is probably a HACK*/ - - if( kind == ICAL_RECUR_VALUE ) { - if ( next != 0 && - (*end+length) > next+5 && - strncmp(next,"FREQ",4) == 0 - ) { - /* The COMMA was followed by 'FREQ', is it a real separator*/ - /* Fall through */ - } else if (next != 0){ - /* Not real, get the next COMMA */ - p = next+1; - next = 0; - continue; - } - } - /* ignore all , for query value. select dtstart, dtend etc ... */ - else if( kind == ICAL_QUERY_VALUE) { - if ( next != 0) { - p = next+1; - continue; - } - else - break; - } - - /* If the comma is preceded by a '\', then it is a literal and - not a value separator*/ - - if ((next!=0 && *(next-1) == '\\') || - (next!=0 && (next-3) >= line && *(next-3) == '\\' && *(next-2) == '\r' && *(next-1) == '\n')) - /* second clause for '\' is on prev line */ - { - p = next+1; - } else { - break; - } - - } - - if (next == 0){ - next = (char*)(size_t)line+length; - *end = next; - } else { - *end = next+1; - } - - if (next == line){ - return 0; - } - - - str = make_segment(line,next); - return str; - -} - -static -char* parser_get_next_parameter(char* line,char** end) -{ - char *next; - char *v; - char *str; - - v = parser_get_next_char(':',line,1); - next = parser_get_next_char(';', line,1); - - /* There is no ';' or, it is after the ':' that marks the beginning of - the value */ - - if (next == 0 || next > v) { - next = parser_get_next_char(':', line,1); - } - - if (next != 0) { - str = make_segment(line,next); - *end = next+1; - return str; - } else { - *end = line; - return 0; - } -} - - -/** - * Get a single property line, from the property name through the - * final new line, and include any continuation lines - */ -char* icalparser_get_line(icalparser *parser, - char* (*line_gen_func)(char *s, size_t size, void *d)) -{ - char *line; - char *line_p; - size_t buf_size = parser->tmp_buf_size; - - line_p = line = icalmemory_new_buffer(buf_size); - line[0] = '\0'; - - /* Read lines by calling line_gen_func and putting the data into - parser->temp. If the line is a continuation line ( begins with a - space after a newline ) then append the data onto line and read - again. Otherwise, exit the loop. */ - - while(1) { - - /* The first part of the loop deals with the temp buffer, - which was read on he last pass through the loop. The - routine is split like this because it has to read lone line - ahead to determine if a line is a continuation line. */ - - - /* The tmp buffer is not clear, so transfer the data in it to the - output. This may be left over from a previous call */ - if (parser->temp[0] != '\0' ) { - - /* If the last position in the temp buffer is occupied, - mark the buffer as full. The means we will do another - read later, because the line is not finished */ - if (parser->temp[parser->tmp_buf_size-1] == 0 && - parser->temp[parser->tmp_buf_size-2] != '\n'&& - parser->temp[parser->tmp_buf_size-2] != 0 ){ - parser->buffer_full = 1; - } else { - parser->buffer_full = 0; - } - - /* Copy the temp to the output and clear the temp buffer. */ - if(parser->continuation_line==1){ - /* back up the pointer to erase the continuation characters */ - parser->continuation_line = 0; - line_p--; - - if ( *(line_p-1) == '\r'){ - line_p--; - } - - /* copy one space up to eliminate the leading space*/ - icalmemory_append_string(&line,&line_p,&buf_size, - parser->temp+1); - - } else { - icalmemory_append_string(&line,&line_p,&buf_size,parser->temp); - } - - parser->temp[0] = '\0' ; - } - - parser->temp[parser->tmp_buf_size-1] = 1; /* Mark end of buffer */ - - /****** Here is where the routine gets string data ******************/ - if ((*line_gen_func)(parser->temp,parser->tmp_buf_size,parser->line_gen_data) - ==0){/* Get more data */ - - /* If the first position is clear, it means we didn't get - any more data from the last call to line_ge_func*/ - if (parser->temp[0] == '\0'){ - - if(line[0] != '\0'){ - /* There is data in the output, so fall trhough and process it*/ - break; - } else { - /* No data in output; return and signal that there - is no more input*/ - free(line); - return 0; - } - } - } - - - /* If the output line ends in a '\n' and the temp buffer - begins with a ' ' or tab, then the buffer holds a continuation - line, so keep reading. RFC 2445, section 4.1 */ - - if ( line_p > line+1 && *(line_p-1) == '\n' - && (parser->temp[0] == ' ' || parser->temp[0] == '\t') ) { - - parser->continuation_line = 1; - - } else if ( parser->buffer_full == 1 ) { - - /* The buffer was filled on the last read, so read again */ - - } else { - - /* Looks like the end of this content line, so break */ - break; - } - - - } - - /* Erase the final newline and/or carriage return*/ - if ( line_p > line+1 && *(line_p-1) == '\n') { - *(line_p-1) = '\0'; - if ( *(line_p-2) == '\r'){ - *(line_p-2) = '\0'; - } - - } else { - *(line_p) = '\0'; - } - - while ( (*line_p == '\0' || iswspace(*line_p)) && line_p > line ) - { - *line_p = '\0'; - line_p--; - } - - return line; - -} - -static void insert_error(icalcomponent* comp, const char* text, - const char* message, icalparameter_xlicerrortype type) -{ - char temp[1024]; - - if (text == 0){ - snprintf(temp,1024,"%s:",message); - } else { - snprintf(temp,1024,"%s: %s",message,text); - } - - icalcomponent_add_property - (comp, - icalproperty_vanew_xlicerror( - temp, - icalparameter_new_xlicerrortype(type), - 0)); -} - - -static int line_is_blank(char* line){ - int i=0; - - for(i=0; *(line+i)!=0; i++){ - char c = *(line+i); - - if(c != ' ' && c != '\n' && c != '\t'){ - return 0; - } - } - - return 1; -} - -icalcomponent* icalparser_parse(icalparser *parser, - char* (*line_gen_func)(char *s, size_t size, - void* d)) -{ - - char* line; - icalcomponent *c=0; - icalcomponent *root=0; - icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); - int cont; - - icalerror_check_arg_rz((parser !=0),"parser"); - - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL); - - do{ - line = icalparser_get_line(parser, line_gen_func); - - if ((c = icalparser_add_line(parser,line)) != 0){ - - if(icalcomponent_get_parent(c) !=0){ - /* This is bad news... assert? */ - } - - assert(parser->root_component == 0); - assert(pvl_count(parser->components) ==0); - - if (root == 0){ - /* Just one component */ - root = c; - } else if(icalcomponent_isa(root) != ICAL_XROOT_COMPONENT) { - /*Got a second component, so move the two components under - an XROOT container */ - icalcomponent *tempc = icalcomponent_new(ICAL_XROOT_COMPONENT); - icalcomponent_add_component(tempc, root); - icalcomponent_add_component(tempc, c); - root = tempc; - } else if(icalcomponent_isa(root) == ICAL_XROOT_COMPONENT) { - /* Already have an XROOT container, so add the component - to it*/ - icalcomponent_add_component(root, c); - - } else { - /* Badness */ - assert(0); - } - - c = 0; - - } - cont = 0; - if(line != 0){ - icalmemory_free_buffer(line); - cont = 1; - } - } while ( cont ); - - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); - - return root; - -} - - -icalcomponent* icalparser_add_line(icalparser* parser, - char* line) -{ - char *str; - char *end; - int vcount = 0; - icalproperty *prop; - icalproperty_kind prop_kind; - icalvalue *value; - icalvalue_kind value_kind = ICAL_NO_VALUE; - - - icalerror_check_arg_rz((parser != 0),"parser"); - - - if (line == 0) - { - parser->state = ICALPARSER_ERROR; - return 0; - } - - if(line_is_blank(line) == 1){ - return 0; - } - - /* Begin by getting the property name at the start of the line. The - property name may end up being "BEGIN" or "END" in which case it - is not really a property, but the marker for the start or end of - a component */ - - end = 0; - str = parser_get_prop_name(line, &end); - - if (str == 0 || *str == '\0' ){ - /* Could not get a property name */ - icalcomponent *tail = pvl_data(pvl_tail(parser->components)); - - if (tail){ - insert_error(tail,line, - "Got a data line, but could not find a property name or component begin tag", - ICAL_XLICERRORTYPE_COMPONENTPARSEERROR); - } - tail = 0; - parser->state = ICALPARSER_ERROR; - icalmemory_free_buffer(str); - str = NULL; - return 0; - } - - /********************************************************************** - * Handle begin and end of components - **********************************************************************/ - /* If the property name is BEGIN or END, we are actually - starting or ending a new component */ - - - if(strcasecmp(str,"BEGIN") == 0){ - icalcomponent *c; - icalcomponent_kind comp_kind; - - icalmemory_free_buffer(str); - str = NULL; - - parser->level++; - str = parser_get_next_value(end,&end, value_kind); - - comp_kind = icalenum_string_to_component_kind(str); - - c = icalcomponent_new(comp_kind); - - if (c == 0){ - c = icalcomponent_new(ICAL_XLICINVALID_COMPONENT); - insert_error(c,str,"Parse error in component name", - ICAL_XLICERRORTYPE_COMPONENTPARSEERROR); - } - - pvl_push(parser->components,c); - - parser->state = ICALPARSER_BEGIN_COMP; - - icalmemory_free_buffer(str); - str = NULL; - return 0; - - } else if (strcasecmp(str,"END") == 0 ) { - icalcomponent* tail; - - icalmemory_free_buffer(str); - str = NULL; - parser->level--; - - str = parser_get_next_value(end,&end, value_kind); - - /* Pop last component off of list and add it to the second-to-last*/ - parser->root_component = pvl_pop(parser->components); - - tail = pvl_data(pvl_tail(parser->components)); - - if(tail != 0){ - icalcomponent_add_component(tail,parser->root_component); - } - - tail = 0; - icalmemory_free_buffer(str); - str = NULL; - - /* Return the component if we are back to the 0th level */ - if (parser->level == 0){ - icalcomponent *rtrn; - - if(pvl_count(parser->components) != 0){ - /* There are still components on the stack -- this means - that one of them did not have a proper "END" */ - pvl_push(parser->components,parser->root_component); - icalparser_clean(parser); /* may reset parser->root_component*/ - } - - assert(pvl_count(parser->components) == 0); - - parser->state = ICALPARSER_SUCCESS; - rtrn = parser->root_component; - parser->root_component = 0; - return rtrn; - - } else { - parser->state = ICALPARSER_END_COMP; - return 0; - } - } - - - /* There is no point in continuing if we have not seen a - component yet */ - - if(pvl_data(pvl_tail(parser->components)) == 0){ - parser->state = ICALPARSER_ERROR; - icalmemory_free_buffer(str); - str = NULL; - return 0; - } - - - /********************************************************************** - * Handle property names - **********************************************************************/ - - /* At this point, the property name really is a property name, - (Not a component name) so make a new property and add it to - the component */ - - - prop_kind = icalproperty_string_to_kind(str); - - prop = icalproperty_new(prop_kind); - - if (prop != 0){ - icalcomponent *tail = pvl_data(pvl_tail(parser->components)); - - if(prop_kind==ICAL_X_PROPERTY){ - icalproperty_set_x_name(prop,str); - } - - icalcomponent_add_property(tail, prop); - - /* Set the value kind for the default for this type of - property. This may be re-set by a VALUE parameter */ - value_kind = icalproperty_kind_to_value_kind(icalproperty_isa(prop)); - - } else { - icalcomponent* tail = pvl_data(pvl_tail(parser->components)); - - insert_error(tail,str,"Parse error in property name", - ICAL_XLICERRORTYPE_PROPERTYPARSEERROR); - - tail = 0; - parser->state = ICALPARSER_ERROR; - icalmemory_free_buffer(str); - str = NULL; - return 0; - } - - icalmemory_free_buffer(str); - str = NULL; - - /********************************************************************** - * Handle parameter values - **********************************************************************/ - - /* Now, add any parameters to the last property */ - - while(1) { - - if (*(end-1) == ':'){ - /* if the last separator was a ":" and the value is a - URL, icalparser_get_next_parameter will find the - ':' in the URL, so better break now. */ - break; - } - - str = parser_get_next_parameter(end,&end); - strstriplt(str); - if (str != 0){ - char* name = 0; - char* pvalue = 0; - char *buf_value = NULL; - - icalparameter *param = 0; - icalparameter_kind kind; - icalcomponent *tail = pvl_data(pvl_tail(parser->components)); - - name = parser_get_param_name(str,&pvalue,&buf_value); - - if (name == 0){ - /* 'tail' defined above */ - insert_error(tail, str, "Cant parse parameter name", - ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR); - tail = 0; - break; - } - - kind = icalparameter_string_to_kind(name); - - if(kind == ICAL_X_PARAMETER){ - param = icalparameter_new(ICAL_X_PARAMETER); - if(param != 0){ - icalparameter_set_xname(param,name); - icalparameter_set_xvalue(param,pvalue); - } - icalmemory_free_buffer(buf_value); - buf_value = NULL; - } else if (kind == ICAL_IANA_PARAMETER){ - ical_unknown_token_handling tokHandlingSetting = - ical_get_unknown_token_handling_setting(); - if (tokHandlingSetting == ICAL_DISCARD_TOKEN) - continue; - param = icalparameter_new(ICAL_IANA_PARAMETER); - - if(param != 0){ - icalparameter_set_xname(param,name); - icalparameter_set_xvalue(param,pvalue); - } - icalmemory_free_buffer(buf_value); - buf_value = NULL; - - } else if (kind != ICAL_NO_PARAMETER){ - param = icalparameter_new_from_value_string(kind,pvalue); - - icalmemory_free_buffer(buf_value); - buf_value = NULL; - - } else { - /* Error. Failed to parse the parameter*/ - /* 'tail' defined above */ - - /* Change for mozilla */ - /* have the option of being flexible towards unsupported parameters */ - #ifndef ICAL_ERRORS_ARE_FATAL - continue; - #endif - - insert_error(tail, str, "Cant parse parameter name", - ICAL_XLICERRORTYPE_PARAMETERNAMEPARSEERROR); - tail = 0; - parser->state = ICALPARSER_ERROR; - /* if (pvalue) { - free(pvalue); - pvalue = 0; - } */ - if (name) { - free(name); - name = 0; - } - return 0; - } - - /* if (pvalue) { - free(pvalue); - pvalue = 0; - } */ - if (name) { - free(name); - name = 0; - } - - if (param == 0){ - /* 'tail' defined above */ - insert_error(tail,str,"Cant parse parameter value", - ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR); - - tail = 0; - parser->state = ICALPARSER_ERROR; - - icalmemory_free_buffer(buf_value); - buf_value = NULL; - icalmemory_free_buffer(name); - name = NULL; - icalmemory_free_buffer(str); - str = NULL; - - continue; - } - - /* If it is a VALUE parameter, set the kind of value*/ - if (icalparameter_isa(param)==ICAL_VALUE_PARAMETER){ - const char unknown_type[] = - "Got a VALUE parameter with an unknown type"; - const char illegal_type[] = - "Got a VALUE parameter with an illegal type for property"; - const char *value_err = NULL; - - - value_kind = (icalvalue_kind) - icalparameter_value_to_value_kind( - icalparameter_get_value(param) - ); - - if (value_kind == ICAL_NO_VALUE){ - - /* Ooops, could not parse the value of the - parameter ( it was not one of the defined - values ), so reset the value_kind */ - - value_err = unknown_type; - } - else if (value_kind != - icalproperty_kind_to_value_kind(icalproperty_isa(prop))) { - /* VALUE parameter type does not match default type - for this property (check for allowed alternate types) */ - - switch (prop_kind) { - case ICAL_ATTACH_PROPERTY: - // case ICAL_IMAGE_PROPERTY: - /* Accept BINARY */ - if (value_kind != ICAL_BINARY_VALUE) - value_err = illegal_type; - break; - - case ICAL_DTEND_PROPERTY: - case ICAL_DUE_PROPERTY: - case ICAL_DTSTART_PROPERTY: - case ICAL_EXDATE_PROPERTY: - case ICAL_RECURRENCEID_PROPERTY: - /* Accept DATE */ - if (value_kind != ICAL_DATE_VALUE) - value_err = illegal_type; - break; - - case ICAL_GEO_PROPERTY: - /* Accept FLOAT (but change to GEO) */ - if (value_kind != ICAL_FLOAT_VALUE) - value_err = illegal_type; - else value_kind = ICAL_GEO_VALUE; - break; - - case ICAL_RDATE_PROPERTY: - /* Accept DATE-TIME, DATE or PERIOD */ - if (value_kind != ICAL_DATETIME_VALUE && - value_kind != ICAL_DATE_VALUE && - value_kind != ICAL_PERIOD_VALUE) - value_err = illegal_type; - break; - - case ICAL_TRIGGER_PROPERTY: - /* Accept DATE-TIME */ - if (value_kind != ICAL_DATETIME_VALUE && - value_kind != ICAL_DURATION_VALUE) - value_err = illegal_type; - break; - - case ICAL_X_PROPERTY: - /* Accept ANY value type */ - break; - - default: - /* ONLY default type is allowed */ - value_err = illegal_type; - break; - } - } - - if (value_err != NULL) { - /* Ooops, unknown/illegal VALUE parameter, - so reset the value_kind */ - - insert_error(tail, str, value_err, - ICAL_XLICERRORTYPE_PARAMETERVALUEPARSEERROR); - - value_kind = - icalproperty_kind_to_value_kind( - icalproperty_isa(prop)); - - icalparameter_free(param); - tail = 0; - parser->state = ICALPARSER_ERROR; - - icalmemory_free_buffer(name); - name = NULL; - icalmemory_free_buffer(str); - str = NULL; - continue; - } - } - icalmemory_free_buffer(name); - name = NULL; - - /* Everything is OK, so add the parameter */ - icalproperty_add_parameter(prop,param); - tail = 0; - icalmemory_free_buffer(str); - str = NULL; - - } else { /* if ( str != 0) */ - /* If we did not get a param string, go on to looking for a value */ - if (str != NULL) { - icalmemory_free_buffer(str); - str = NULL; - } - break; - } /* if ( str != 0) */ - - } /* while(1) */ - - /********************************************************************** - * Handle values - **********************************************************************/ - - /* Look for values. If there are ',' characters in the values, - then there are multiple values, so clone the current - parameter and add one part of the value to each clone */ - - vcount=0; - while(1) { - /* Only some properies can have multiple values. This list was taken - from rfc2445. Also added the x-properties, because the spec actually - says that commas should be escaped. For x-properties, other apps may - depend on that behaviour - */ - switch (prop_kind) { - case ICAL_X_PROPERTY: - case ICAL_CATEGORIES_PROPERTY: - case ICAL_RESOURCES_PROPERTY: - /* Referring to RFC 2445, section 4.8.5.3 and section 4.8.5.1: - RDATE and EXDATE can specify a list of dates/date-times/periods. - */ - case ICAL_RDATE_PROPERTY: - case ICAL_EXDATE_PROPERTY: - /* Referring to RFC 2445, section 4.8.2.6 Free/Busy Time: - The "FREEBUSY" property can specify more than one value, separated by - the COMMA character (US-ASCII decimal 44). - */ - case ICAL_FREEBUSY_PROPERTY: - str = parser_get_next_value(end,&end, value_kind); - strstriplt (str); - break; - default: - str = icalparser_get_value(end, &end, value_kind); - strstriplt (str); - break; - } - - if (str != 0){ - - if (vcount > 0){ - /* Actually, only clone after the second value */ - icalproperty* clone = icalproperty_new_clone(prop); - icalcomponent* tail = pvl_data(pvl_tail(parser->components)); - - icalcomponent_add_property(tail, clone); - prop = clone; - tail = 0; - } - - value = icalvalue_new_from_string(value_kind, str); - - /* Don't add properties without value */ - if (value == 0){ - icalcomponent* tail = pvl_data(pvl_tail(parser->components)); - - /* Remove the empty property */ - icalcomponent_remove_property(tail,prop); - icalproperty_free(prop); - prop = NULL; - } else { - vcount++; - icalproperty_set_value(prop, value); - } - icalmemory_free_buffer(str); - str = NULL; - - } else { - /* Don't replace empty properties with an error. - Set an empty length string (not null) as the value instead */ - if (vcount == 0) { - icalproperty_set_value(prop, icalvalue_new(ICAL_NO_VALUE)); - } - - break; - } - } - - /**************************************************************** - * End of component parsing. - *****************************************************************/ - - if (pvl_data(pvl_tail(parser->components)) == 0 && - parser->level == 0){ - /* HACK. Does this clause ever get executed? */ - parser->state = ICALPARSER_SUCCESS; - assert(0); - return parser->root_component; - } else { - parser->state = ICALPARSER_IN_PROGRESS; - return 0; - } - -} - -icalparser_state icalparser_get_state(icalparser* parser) -{ - return parser->state; - -} - -icalcomponent* icalparser_clean(icalparser* parser) -{ - icalcomponent *tail; - - icalerror_check_arg_rz((parser != 0 ),"parser"); - - /* We won't get a clean exit if some components did not have an - "END" tag. Clear off any component that may be left in the list */ - - while((tail=pvl_data(pvl_tail(parser->components))) != 0){ - - insert_error(tail," ", - "Missing END tag for this component. Closing component at end of input.", - ICAL_XLICERRORTYPE_COMPONENTPARSEERROR); - - - parser->root_component = pvl_pop(parser->components); - tail=pvl_data(pvl_tail(parser->components)); - - if(tail != 0 && parser->root_component != NULL){ - if(icalcomponent_get_parent(parser->root_component)!=0){ - icalerror_warn("icalparser_clean is trying to attach a component for the second time"); - } else { - icalcomponent_add_component(tail,parser->root_component); - } - } - - } - - return parser->root_component; - -} - -struct slg_data { - const char* pos; - const char* str; -}; - - -char* icalparser_string_line_generator(char *out, size_t buf_size, void *d) -{ - char *n; - size_t size; - struct slg_data* data = (struct slg_data*)d; - - if(data->pos==0){ - data->pos=data->str; - } - - /* If the pointer is at the end of the string, we are done */ - if (*(data->pos)==0){ - return 0; - } - - n = strchr(data->pos,'\n'); - - if (n == 0){ - size = strlen(data->pos); - } else { - n++; /* include newline in output */ - size = (n-data->pos); - } - - if (size > buf_size-1){ - size = buf_size-1; - } - - - strncpy(out,data->pos,size); - - *(out+size) = '\0'; - - data->pos += size; - - return out; -} - -icalcomponent* icalparser_parse_string(const char* str) -{ - icalcomponent *c; - struct slg_data d; - icalparser *p; - - icalerrorstate es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); - - d.pos = 0; - d.str = str; - - p = icalparser_new(); - icalparser_set_gen_data(p,&d); - - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL); - - c = icalparser_parse(p,icalparser_string_line_generator); - - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); - - icalparser_free(p); - - return c; - -} diff --git a/calendar/libical/src/libical/icalparser.h b/calendar/libical/src/libical/icalparser.h deleted file mode 100644 index e1a024059c..0000000000 --- a/calendar/libical/src/libical/icalparser.h +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalparser.h - CREATOR: eric 20 April 1999 - - $Id: icalparser.h,v 1.9 2008-01-15 23:17:41 dothebart Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalparser.h - -======================================================================*/ - - -#ifndef ICALPARSER_H -#define ICALPARSER_H - -#include "icalenums.h" -#include "icaltypes.h" -#include"icalcomponent.h" - -#include /* For FILE* */ - -typedef struct icalparser_impl icalparser; - - -/** - * @file icalparser.h - * @brief Line-oriented parsing. - * - * Create a new parser via icalparse_new_parser, then add lines one at - * a time with icalparse_add_line(). icalparser_add_line() will return - * non-zero when it has finished with a component. - */ - -typedef enum icalparser_state { - ICALPARSER_ERROR, - ICALPARSER_SUCCESS, - ICALPARSER_BEGIN_COMP, - ICALPARSER_END_COMP, - ICALPARSER_IN_PROGRESS -} icalparser_state; - -icalparser* icalparser_new(void); -icalcomponent* icalparser_add_line(icalparser* parser, char* str ); -icalcomponent* icalparser_clean(icalparser* parser); -icalparser_state icalparser_get_state(icalparser* parser); -void icalparser_free(icalparser* parser); - - -/** - * Message oriented parsing. icalparser_parse takes a string that - * holds the text ( in RFC 2445 format ) and returns a pointer to an - * icalcomponent. The caller owns the memory. line_gen_func is a - * pointer to a function that returns one content line per invocation - */ - -icalcomponent* icalparser_parse(icalparser *parser, - char* (*line_gen_func)(char *s, size_t size, void *d)); - -/** - Set the data that icalparser_parse will give to the line_gen_func - as the parameter 'd' - */ -void icalparser_set_gen_data(icalparser* parser, void* data); - - -icalcomponent* icalparser_parse_string(const char* str); - - -/*********************************************************************** - * Parser support functions - ***********************************************************************/ - -/** Use the flex/bison parser to turn a string into a value type */ -icalvalue* icalparser_parse_value(icalvalue_kind kind, - const char* str, icalcomponent** errors); - -/** Given a line generator function, return a single iCal content line.*/ -char* icalparser_get_line(icalparser* parser, char* (*line_gen_func)(char *s, size_t size, void *d)); - -char* icalparser_string_line_generator(char *out, size_t buf_size, void *d); - -#endif /* !ICALPARSE_H */ diff --git a/calendar/libical/src/libical/icalperiod.c b/calendar/libical/src/libical/icalperiod.c deleted file mode 100644 index 15610165be..0000000000 --- a/calendar/libical/src/libical/icalperiod.c +++ /dev/null @@ -1,179 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalperiod.c - CREATOR: eric 02 June 2000 - - $Id: icalperiod.c,v 1.13 2008-01-15 23:17:41 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icalperiod.h" - -#include -#include -#include -#include - -#include "icalerror.h" -#include "icalmemory.h" - - - - -struct icalperiodtype icalperiodtype_from_string (const char* str) -{ - - struct icalperiodtype p, null_p; - char *s = icalmemory_strdup(str); - char *start, *end = s; - icalerrorstate es; - - /* Errors are normally generated in the following code, so save - the error state for resoration later */ - - icalerrorenum e = icalerrno; - - p.start = p.end = icaltime_null_time(); - p.duration = icaldurationtype_from_int(0); - - null_p = p; - - if(s == 0) goto error; - - start = s; - end = strchr(s, '/'); - - if(end == 0) goto error; - - *end = 0; - end++; - - p.start = icaltime_from_string(start); - - if (icaltime_is_null_time(p.start)) goto error; - - es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL); - - p.end = icaltime_from_string(end); - - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); - - - if (icaltime_is_null_time(p.end)){ - - p.duration = icaldurationtype_from_string(end); - - if(icaldurationtype_as_int(p.duration) == 0) goto error; - } - - icalerrno = e; - - icalmemory_free_buffer(s); - - return p; - - error: - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - - if (s) - icalmemory_free_buffer (s); - return null_p; -} - - -const char* icalperiodtype_as_ical_string(struct icalperiodtype p) -{ - char *buf; - buf = icalperiodtype_as_ical_string_r(p); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* icalperiodtype_as_ical_string_r(struct icalperiodtype p) -{ - - char* start; - char* end; - - char *buf; - size_t buf_size = 40; - char* buf_ptr = 0; - - buf = (char*)icalmemory_new_buffer(buf_size); - buf_ptr = buf; - - - start = icaltime_as_ical_string_r(p.start); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, start); - icalmemory_free_buffer(start); - - if(!icaltime_is_null_time(p.end)){ - end = icaltime_as_ical_string_r(p.end); - } else { - end = icaldurationtype_as_ical_string_r(p.duration); - } - - icalmemory_append_char(&buf, &buf_ptr, &buf_size, '/'); - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, end); - icalmemory_free_buffer(end); - - return buf; -} - - - -struct icalperiodtype icalperiodtype_null_period(void) { - struct icalperiodtype p; - p.start = icaltime_null_time(); - p.end = icaltime_null_time(); - p.duration = icaldurationtype_null_duration(); - - return p; -} -int icalperiodtype_is_null_period(struct icalperiodtype p){ - - if(icaltime_is_null_time(p.start) && - icaltime_is_null_time(p.end) && - icaldurationtype_is_null_duration(p.duration)){ - return 1; - } else { - return 0; - } -} - -int icalperiodtype_is_valid_period(struct icalperiodtype p){ - if(icaltime_is_valid_time(p.start) && - (icaltime_is_valid_time(p.end) || icaltime_is_null_time(p.end)) ) - { - return 1; - } - - return 0; -} - diff --git a/calendar/libical/src/libical/icalperiod.h b/calendar/libical/src/libical/icalperiod.h deleted file mode 100644 index 3a541f595d..0000000000 --- a/calendar/libical/src/libical/icalperiod.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalperiod.h - CREATOR: eric 26 Jan 2001 - - - $Id: icalperiod.h,v 1.6 2008-01-15 23:17:41 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -#ifndef ICALPERIOD_H -#define ICALPERIOD_H - -#include "icaltime.h" -#include "icalduration.h" - -struct icalperiodtype -{ - struct icaltimetype start; - struct icaltimetype end; - struct icaldurationtype duration; -}; - -struct icalperiodtype icalperiodtype_from_string (const char* str); - -const char* icalperiodtype_as_ical_string(struct icalperiodtype p); -char* icalperiodtype_as_ical_string_r(struct icalperiodtype p); - -struct icalperiodtype icalperiodtype_null_period(void); - -int icalperiodtype_is_null_period(struct icalperiodtype p); - -int icalperiodtype_is_valid_period(struct icalperiodtype p); - -#endif /* !ICALTIME_H */ - - - diff --git a/calendar/libical/src/libical/icalproperty.c b/calendar/libical/src/libical/icalproperty.c deleted file mode 100644 index 1e1dfb27e5..0000000000 --- a/calendar/libical/src/libical/icalproperty.c +++ /dev/null @@ -1,1054 +0,0 @@ -/* -*- Mode: C -*- */ - -/*====================================================================== - FILE: icalproperty.c - CREATOR: eric 28 April 1999 - - $Id: icalproperty.c,v 1.44 2008-01-30 20:28:42 dothebart Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalproperty.c - -======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icalproperty.h" -#include "icalparameter.h" -#include "icalcomponent.h" -#include "pvl.h" -#include "icalenums.h" -#include "icalerror.h" -#include "icalmemory.h" -#include "icalparser.h" - -#include /* For icalmemory_strdup, rindex */ -#include -#include -#include -#include /* for printf */ -#include /* for va_list, va_start, etc. */ - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -/* Private routines for icalproperty */ -void icalvalue_set_parent(icalvalue* value, - icalproperty* property); -icalproperty* icalvalue_get_parent(icalvalue* value); - -void icalparameter_set_parent(icalparameter* param, - icalproperty* property); -icalproperty* icalparameter_get_parent(icalparameter* value); - - -void icalproperty_set_x_name(icalproperty* prop, const char* name); - -struct icalproperty_impl -{ - char id[5]; - icalproperty_kind kind; - char* x_name; - pvl_list parameters; - pvl_elem parameter_iterator; - icalvalue* value; - icalcomponent *parent; -}; - -void icalproperty_add_parameters(icalproperty* prop, va_list args) -{ - void* vp; - - while((vp = va_arg(args, void*)) != 0) { - - if (icalvalue_isa_value(vp) != 0 ){ - } else if (icalparameter_isa_parameter(vp) != 0 ){ - - icalproperty_add_parameter((icalproperty*)prop, - (icalparameter*)vp); - } else { - icalerror_set_errno(ICAL_BADARG_ERROR); - } - - } -} - - -icalproperty* -icalproperty_new_impl(icalproperty_kind kind) -{ - icalproperty* prop; - - if (!icalproperty_kind_is_valid(kind)) - return NULL; - - if ( ( prop = (icalproperty*) malloc(sizeof(icalproperty))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - strcpy(prop->id,"prop"); - - prop->kind = kind; - prop->parameters = pvl_newlist(); - prop->parameter_iterator = 0; - prop->value = 0; - prop->x_name = 0; - prop->parent = 0; - - return prop; -} - - -icalproperty* -icalproperty_new (icalproperty_kind kind) -{ - if (kind == ICAL_NO_PROPERTY){ - return 0; - } - - return (icalproperty*)icalproperty_new_impl(kind); -} - - -icalproperty* -icalproperty_new_clone(icalproperty* old) -{ - icalproperty *new; - pvl_elem p; - - icalerror_check_arg_rz((old!=0),"old"); - - new = icalproperty_new_impl(old->kind); - icalerror_check_arg_rz((new!=0),"new"); - - if (old->value !=0) { - new->value = icalvalue_new_clone(old->value); - } - - if (old->x_name != 0) { - - new->x_name = icalmemory_strdup(old->x_name); - - if (new->x_name == 0) { - icalproperty_free(new); - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - } - - for(p=pvl_head(old->parameters);p != 0; p = pvl_next(p)){ - icalparameter *param = icalparameter_new_clone(pvl_data(p)); - - if (param == 0){ - icalproperty_free(new); - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - pvl_push(new->parameters,param); - - } - - return new; - -} - -icalproperty* icalproperty_new_from_string(const char* str) -{ - - size_t buf_size = 1024; - char* buf; - char* buf_ptr; - icalproperty *prop; - icalcomponent *comp; - int errors = 0; - - icalerror_check_arg_rz( (str!=0),"str"); - - buf = icalmemory_new_buffer(buf_size); - buf_ptr = buf; - - /* Is this a HACK or a crafty reuse of code? */ - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "BEGIN:VCALENDAR\r\n"); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, str); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "\r\n"); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, "END:VCALENDAR\r\n"); - - comp = icalparser_parse_string(buf); - - if(comp == 0){ - icalerror_set_errno(ICAL_PARSE_ERROR); - free(buf); - return 0; - } - - errors = icalcomponent_count_errors(comp); - - prop = icalcomponent_get_first_property(comp,ICAL_ANY_PROPERTY); - - icalcomponent_remove_property(comp,prop); - - icalcomponent_free(comp); - free(buf); - - if(errors > 0){ - icalproperty_free(prop); - return 0; - } else { - return prop; - } - -} - -void -icalproperty_free (icalproperty* p) -{ - icalparameter* param; - - icalerror_check_arg_rv((p!=0),"prop"); - -#ifdef ICAL_FREE_ON_LIST_IS_ERROR - icalerror_assert( (p->parent ==0),"Tried to free a property that is still attached to a component. "); - -#else - if(p->parent !=0){ - return; - } -#endif - - if (p->value != 0){ - icalvalue_set_parent(p->value,0); - icalvalue_free(p->value); - } - - while( (param = pvl_pop(p->parameters)) != 0){ - icalparameter_free(param); - } - - pvl_free(p->parameters); - - if (p->x_name != 0) { - free(p->x_name); - } - - p->kind = ICAL_NO_PROPERTY; - p->parameters = 0; - p->parameter_iterator = 0; - p->value = 0; - p->x_name = 0; - p->id[0] = 'X'; - - free(p); - -} - - -/* This returns where the start of the next line should be. chars_left does - not include the trailing '\0'. */ -#define MAX_LINE_LEN 75 -/*#define MAX_LINE_LEN 120*/ - -static char* -get_next_line_start (char *line_start, int chars_left) -{ - char *pos; - - /* If we have 74 chars or less left, we can output all of them. - we return a pointer to the '\0' at the end of the string. */ - if (chars_left < MAX_LINE_LEN) { - return line_start + chars_left; - } - - /* Now try to split on a UTF-8 boundary defined as a 7-bit - value or as a byte with the two high-most bits set: - 11xxxxxx. See http://czyborra.com/utf/ */ - - pos = line_start + MAX_LINE_LEN - 1; - while (pos > line_start) { - /* plain ascii */ - if ((*pos & 128) == 0) - return pos; - - /* utf8 escape byte */ - if ((*pos & 192) == 192) - return pos; - - pos--; - } - - /* Give up, just break at 74 chars (the 75th char is the space at - the start of the line). */ - - return line_start + MAX_LINE_LEN - 1; -} - - -/** This splits the property into lines less than 75 octects long (as - * specified in RFC2445). It tries to split after a ';' if it can. - * It returns a tmp buffer. NOTE: I'm not sure if it matters if we - * split a line in the middle of a UTF-8 character. It probably won't - * look nice in a text editor. - */ -static char* -fold_property_line (char *text) -{ - size_t buf_size; - char *buf, *buf_ptr, *line_start, *next_line_start; - int len, chars_left, first_line; - char ch; - - /* Start with a buffer twice the size of our property line, so we almost - certainly won't overflow it. */ - len = strlen (text); - buf_size = len * 2; - buf = icalmemory_new_buffer (buf_size); - buf_ptr = buf; - - /* Step through the text, finding each line to add to the output. */ - line_start = text; - chars_left = len; - first_line = 1; - for (;;) { - if (chars_left <= 0) - break; - - /* This returns the first character for the next line. */ - next_line_start = get_next_line_start (line_start, chars_left); - - /* If this isn't the first line, we need to output a newline and space - first. */ - if (!first_line) { - icalmemory_append_string (&buf, &buf_ptr, &buf_size, "\r\n "); - } - first_line = 0; - - /* This adds the line to our tmp buffer. We temporarily place a '\0' - in text, so we can copy the line in one go. */ - ch = *next_line_start; - *next_line_start = '\0'; - icalmemory_append_string (&buf, &buf_ptr, &buf_size, line_start); - *next_line_start = ch; - - /* Now we move on to the next line. */ - chars_left -= (next_line_start - line_start); - line_start = next_line_start; - } - - return buf; -} - - -/* Determine what VALUE parameter to include. The VALUE parameters - are ignored in the normal parameter printing ( the block after - this one, so we need to do it here */ -static const char * -icalproperty_get_value_kind(icalproperty *prop) -{ - const char* kind_string = 0; - - icalparameter *orig_val_param - = icalproperty_get_first_parameter(prop,ICAL_VALUE_PARAMETER); - - icalvalue *value = icalproperty_get_value(prop); - - icalvalue_kind orig_kind = ICAL_NO_VALUE; - - icalvalue_kind this_kind = ICAL_NO_VALUE; - - icalvalue_kind default_kind - = icalproperty_kind_to_value_kind(prop->kind); - - if(orig_val_param){ - orig_kind = icalparameter_value_to_value_kind( icalparameter_get_value(orig_val_param) ); - } - - if(value != 0){ - this_kind = icalvalue_isa(value); - } - - if ( orig_kind != ICAL_NO_VALUE ) { - kind_string = icalvalue_kind_to_string( orig_kind ); - } else if(this_kind == default_kind && - orig_kind != ICAL_NO_VALUE){ - /* The kind is the default, so it does not need to be - included, but do it anyway, since it was explicit in - the property. But, use the default, not the one - specified in the property */ - - kind_string = icalvalue_kind_to_string(default_kind); - - } else if (this_kind != default_kind && this_kind != ICAL_NO_VALUE){ - /* Not the default, so it must be specified */ - kind_string = icalvalue_kind_to_string(this_kind); - } else { - /* Don'tinclude the VALUE parameter at all */ - } - - return kind_string; -} - -const char* -icalproperty_as_ical_string (icalproperty* prop) -{ - char *buf; - buf = icalproperty_as_ical_string_r(prop); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* -icalproperty_as_ical_string_r(icalproperty* prop) -{ - icalparameter *param; - - /* Create new buffer that we can append names, parameters and a - * value to, and reallocate as needed. - */ - - const char* property_name = 0; - size_t buf_size = 1024; - char* buf; - char* buf_ptr; - icalvalue* value; - char *out_buf; - const char* kind_string = 0; - const char newline[] = "\r\n"; - - - icalerror_check_arg_rz( (prop!=0),"prop"); - - buf = icalmemory_new_buffer(buf_size); - buf_ptr = buf; - - /* Append property name */ - - if (prop->kind == ICAL_X_PROPERTY && prop->x_name != 0){ - property_name = prop->x_name; - } else { - property_name = icalproperty_kind_to_string(prop->kind); - } - - if (property_name == 0 ) { - icalerror_warn("Got a property of an unknown kind."); - icalmemory_free_buffer(buf); - return 0; - - } - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name); - - kind_string = icalproperty_get_value_kind(prop); - if(kind_string!=0){ - icalmemory_append_string(&buf, &buf_ptr, &buf_size, ";VALUE="); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); - } - - /* Append parameters */ - for(param = icalproperty_get_first_parameter(prop,ICAL_ANY_PARAMETER); - param != 0; - param = icalproperty_get_next_parameter(prop,ICAL_ANY_PARAMETER)) { - - icalparameter_kind kind = icalparameter_isa(param); - kind_string = icalparameter_as_ical_string_r(param); - - if (kind_string == 0 ) { - icalerror_warn("Got a parameter of unknown kind for the following property"); - - icalerror_warn((property_name) ? property_name : "(NULL)"); - continue; - } - - if (kind==ICAL_VALUE_PARAMETER) { - free ((char *) kind_string); - continue; - } - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, ";"); - icalmemory_append_string(&buf, &buf_ptr, &buf_size, kind_string); - free((char *)kind_string); - } - - /* Append value */ - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, ":"); - - value = icalproperty_get_value(prop); - - if (value != 0){ - char *str = icalvalue_as_ical_string_r(value); - if (str != 0) - icalmemory_append_string(&buf, &buf_ptr, &buf_size, str); - else - icalmemory_append_string(&buf, &buf_ptr, &buf_size,"ERROR: No Value"); - free(str); - } else { - icalmemory_append_string(&buf, &buf_ptr, &buf_size,"ERROR: No Value"); - - } - - icalmemory_append_string(&buf, &buf_ptr, &buf_size, newline); - - /* We now use a function to fold the line properly every 75 characters. - That function also adds the newline for us. */ - out_buf = fold_property_line (buf); - - icalmemory_free_buffer(buf); - - return out_buf; -} - - - -icalproperty_kind -icalproperty_isa (icalproperty* p) -{ - if(p != 0){ - return p->kind; - } - - return ICAL_NO_PROPERTY; -} - -int -icalproperty_isa_property (void* property) -{ - icalproperty *impl = (icalproperty *) property; - - icalerror_check_arg_rz( (property!=0), "property"); - if (strcmp(impl->id,"prop") == 0) { - return 1; - } else { - return 0; - } -} - - -void -icalproperty_add_parameter (icalproperty* p,icalparameter* parameter) -{ - icalerror_check_arg_rv( (p!=0),"prop"); - icalerror_check_arg_rv( (parameter!=0),"parameter"); - - pvl_push(p->parameters, parameter); - -} - -void -icalproperty_set_parameter (icalproperty* prop,icalparameter* parameter) -{ - icalparameter_kind kind; - - icalerror_check_arg_rv( (prop!=0),"prop"); - icalerror_check_arg_rv( (parameter!=0),"parameter"); - - kind = icalparameter_isa(parameter); - if (kind == ICAL_X_PARAMETER) { - icalproperty_remove_parameter_by_name(prop, - icalparameter_get_xname(parameter)); - } else if (kind == ICAL_IANA_PARAMETER) { - icalproperty_remove_parameter_by_name(prop, - icalparameter_get_iana_name(parameter)); - } - else - icalproperty_remove_parameter_by_kind(prop,kind); - - icalproperty_add_parameter(prop,parameter); -} - -void icalproperty_set_parameter_from_string(icalproperty* prop, - const char* name, const char* value) -{ - - icalparameter_kind kind; - icalparameter *param; - - icalerror_check_arg_rv( (prop!=0),"prop"); - icalerror_check_arg_rv( (name!=0),"name"); - icalerror_check_arg_rv( (value!=0),"value"); - - kind = icalparameter_string_to_kind(name); - - if(kind == ICAL_NO_PARAMETER){ - icalerror_set_errno(ICAL_BADARG_ERROR); - return; - } - - param = icalparameter_new_from_value_string(kind,value); - - if (param == 0){ - icalerror_set_errno(ICAL_BADARG_ERROR); - return; - } - - if (kind == ICAL_X_PARAMETER) { - icalparameter_set_xname(param, name); - } else if (kind == ICAL_IANA_PARAMETER) { - icalparameter_set_iana_name(param, name); - } - - icalproperty_set_parameter(prop,param); - -} - -const char* icalproperty_get_parameter_as_string(icalproperty* prop, - const char* name) -{ - char *buf; - buf = icalproperty_get_parameter_as_string_r(prop, name); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* icalproperty_get_parameter_as_string_r(icalproperty* prop, - const char* name) -{ - icalparameter_kind kind; - icalparameter *param; - char* str; - char *pv, *t; - char* pvql; - char* pvqr; - - icalerror_check_arg_rz( (prop!=0),"prop"); - icalerror_check_arg_rz( (name!=0),"name"); - - kind = icalparameter_string_to_kind(name); - - if(kind == ICAL_NO_PARAMETER){ - /* icalenum_string_to_parameter_kind will set icalerrno */ - return 0; - } - - for(param = icalproperty_get_first_parameter(prop,kind); - param != 0; - param = icalproperty_get_next_parameter(prop,kind)) { - - if (kind == ICAL_X_PARAMETER) { - if (strcmp(icalparameter_get_xname(param),name)==0) { - break; - } - } else if (kind == ICAL_IANA_PARAMETER) { - if (strcmp(icalparameter_get_iana_name(param),name)==0) { - break; - } - } else { - break; - } - - } - - if (param == 0){ - return 0; - } - - - str = icalparameter_as_ical_string_r(param); - - t = strchr(str,'='); - - if (t == 0) { - icalerror_set_errno(ICAL_INTERNAL_ERROR); - free(str); - return 0; - } - - /* Strip the property name and the equal sign */ - pv = icalmemory_strdup(t+1); - free(str); - - /* Is the string quoted? */ - pvql = strchr(pv, '"'); - if (pvql == 0) { - return(pv); /* No quotes? Return it immediately. */ - } - - /* Strip everything up to the first quote */ - str = icalmemory_strdup(pvql+1); - free(pv); - - /* Search for the end quote */ - pvqr = strrchr(str, '"'); - if (pvqr == 0) { - icalerror_set_errno(ICAL_INTERNAL_ERROR); - free(str); - return 0; - } - - *pvqr = '\0'; - return str; -} - -/** @see icalproperty_remove_parameter_by_kind() - * - * @deprecated Please use icalproperty_remove_parameter_by_kind() - * instead. - */ - -void -icalproperty_remove_parameter(icalproperty* prop, icalparameter_kind kind) -{ - icalproperty_remove_parameter_by_kind(prop, kind); -} - - -/** @brief Remove all parameters with the specified kind. - * - * @param prop A valid icalproperty. - * @param kind The kind to remove (ex. ICAL_TZID_PARAMETER) - * - * See icalproperty_remove_parameter_by_name() and - * icalproperty_remove_parameter_by_ref() for alternate ways of - * removing parameters - */ - -void -icalproperty_remove_parameter_by_kind(icalproperty* prop, icalparameter_kind kind) -{ - pvl_elem p; - - icalerror_check_arg_rv((prop!=0),"prop"); - - for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){ - icalparameter* param = (icalparameter *)pvl_data (p); - if (icalparameter_isa(param) == kind) { - pvl_remove (prop->parameters, p); - icalparameter_free(param); - break; - } - } -} - - -/** @brief Remove all parameters with the specified name. - * - * @param prop A valid icalproperty. - * @param name The name of the parameter to remove - * - * This function removes parameters with the given name. The name - * corresponds to either a built-in name (TZID, etc.) or the name of - * an extended parameter (X-FOO) - * - * See icalproperty_remove_parameter_by_kind() and - * icalproperty_remove_parameter_by_ref() for alternate ways of removing - * parameters - */ - - -void -icalproperty_remove_parameter_by_name(icalproperty* prop, const char *name) -{ - pvl_elem p; - - icalerror_check_arg_rv((prop!=0),"prop"); - - for(p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)){ - icalparameter* param = (icalparameter *)pvl_data (p); - const char * kind_string; - - if (icalparameter_isa(param) == ICAL_X_PARAMETER) - kind_string = icalparameter_get_xname(param); - else if (icalparameter_isa(param) == ICAL_IANA_PARAMETER) - kind_string = icalparameter_get_iana_name(param); - else - kind_string = icalparameter_kind_to_string(icalparameter_isa(param)); - - if (!kind_string) - continue; - - if (0 == strcmp(kind_string, name)) { - pvl_remove (prop->parameters, p); - icalparameter_free(param); - break; - } - } -} - - -/** @brief Remove the specified parameter reference from the property. - * - * @param prop A valid icalproperty. - * @param parameter A reference to a specific icalparameter. - * - * This function removes the specified parameter reference from the - * property. - */ - -void -icalproperty_remove_parameter_by_ref(icalproperty* prop, icalparameter* parameter) -{ - pvl_elem p; - - icalerror_check_arg_rv((prop!=0),"prop"); - icalerror_check_arg_rv((parameter!=0),"parameter"); - - for (p=pvl_head(prop->parameters);p != 0; p = pvl_next(p)) { - icalparameter* p_param = (icalparameter *)pvl_data (p); - - if (icalparameter_has_same_name(parameter, p_param)) { - pvl_remove (prop->parameters, p); - icalparameter_free(p_param); - break; - } - } -} - - -int -icalproperty_count_parameters (const icalproperty* prop) -{ - if(prop != 0){ - return pvl_count(prop->parameters); - } - - icalerror_set_errno(ICAL_USAGE_ERROR); - return -1; -} - - -icalparameter* -icalproperty_get_first_parameter(icalproperty* p, icalparameter_kind kind) -{ - icalerror_check_arg_rz( (p!=0),"prop"); - - p->parameter_iterator = pvl_head(p->parameters); - - if (p->parameter_iterator == 0) { - return 0; - } - - for( p->parameter_iterator = pvl_head(p->parameters); - p->parameter_iterator !=0; - p->parameter_iterator = pvl_next(p->parameter_iterator)){ - - icalparameter *param = (icalparameter*)pvl_data(p->parameter_iterator); - - if(icalparameter_isa(param) == kind || kind == ICAL_ANY_PARAMETER){ - return param; - } - } - - return 0; -} - - -icalparameter* -icalproperty_get_next_parameter (icalproperty* p, icalparameter_kind kind) -{ - icalerror_check_arg_rz( (p!=0),"prop"); - - if (p->parameter_iterator == 0) { - return 0; - } - - for( p->parameter_iterator = pvl_next(p->parameter_iterator); - p->parameter_iterator !=0; - p->parameter_iterator = pvl_next(p->parameter_iterator)){ - - icalparameter *param = (icalparameter*)pvl_data(p->parameter_iterator); - - if(icalparameter_isa(param) == kind || kind == ICAL_ANY_PARAMETER){ - return param; - } - } - - return 0; - -} - -void -icalproperty_set_value (icalproperty* p, icalvalue* value) -{ - icalerror_check_arg_rv((p !=0),"prop"); - icalerror_check_arg_rv((value !=0),"value"); - - if (p->value != 0){ - icalvalue_set_parent(p->value,0); - icalvalue_free(p->value); - p->value = 0; - } - - p->value = value; - - icalvalue_set_parent(value,p); -} - - -void icalproperty_set_value_from_string(icalproperty* prop,const char* str, - const char* type) -{ - icalvalue *oval,*nval; - icalvalue_kind kind = ICAL_NO_VALUE; - - icalerror_check_arg_rv( (prop!=0),"prop"); - icalerror_check_arg_rv( (str!=0),"str"); - icalerror_check_arg_rv( (type!=0),"type"); - - if(strcmp(type,"NO")==0){ - /* Get the type from the value the property already has, if it exists */ - oval = icalproperty_get_value(prop); - if(oval != 0){ - /* Use the existing value kind */ - kind = icalvalue_isa(oval); - } else { - /* Use the default kind for the property */ - kind = icalproperty_kind_to_value_kind(icalproperty_isa(prop)); - } - } else { - /* Use the given kind string */ - kind = icalvalue_string_to_kind(type); - } - - if(kind == ICAL_NO_VALUE){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return; - } - - icalerror_clear_errno(); - nval = icalvalue_new_from_string(kind, str); - - if(nval == 0){ - /* icalvalue_new_from_string sets errno */ - assert(icalerrno != ICAL_NO_ERROR); - return; - } - - icalproperty_set_value(prop,nval); - - -} - -icalvalue* -icalproperty_get_value(const icalproperty* prop) -{ - icalerror_check_arg_rz( (prop!=0),"prop"); - - return prop->value; -} - -const char* icalproperty_get_value_as_string(const icalproperty* prop) -{ - char *buf; - buf = icalproperty_get_value_as_string_r(prop); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* icalproperty_get_value_as_string_r(const icalproperty* prop) -{ - icalvalue *value; - - icalerror_check_arg_rz( (prop!=0),"prop"); - - value = prop->value; - - return icalvalue_as_ical_string_r(value); -} - - -void icalproperty_set_x_name(icalproperty* prop, const char* name) -{ - icalerror_check_arg_rv( (name!=0),"name"); - icalerror_check_arg_rv( (prop!=0),"prop"); - - if (prop->x_name != 0) { - free(prop->x_name); - } - - prop->x_name = icalmemory_strdup(name); - - if(prop->x_name == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - } - -} - -const char* icalproperty_get_x_name(icalproperty* prop){ - icalerror_check_arg_rz( (prop!=0),"prop"); - - return prop->x_name; -} - -const char* icalproperty_get_property_name(const icalproperty* prop) -{ - char *buf; - buf = icalproperty_get_property_name_r(prop); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* icalproperty_get_property_name_r(const icalproperty* prop) -{ - - const char* property_name = 0; - size_t buf_size = 256; - char* buf; - char* buf_ptr; - - icalerror_check_arg_rz( (prop!=0),"prop"); - - buf = icalmemory_new_buffer(buf_size); - buf_ptr = buf; - - if (prop->kind == ICAL_X_PROPERTY && prop->x_name != 0){ - property_name = prop->x_name; - } else { - property_name = icalproperty_kind_to_string(prop->kind); - } - - if (property_name == 0 ) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - icalmemory_free_buffer(buf); - return 0; - - } else { - /* _append_string will automatically grow the buffer if - property_name is longer than the initial buffer size */ - icalmemory_append_string(&buf, &buf_ptr, &buf_size, property_name); - } - - return buf; -} - - - - -void icalproperty_set_parent(icalproperty* property, - icalcomponent* component) -{ - icalerror_check_arg_rv( (property!=0),"property"); - - property->parent = component; -} - -icalcomponent* icalproperty_get_parent(const icalproperty* property) -{ - icalerror_check_arg_rz( (property!=0),"property"); - - return property->parent; -} diff --git a/calendar/libical/src/libical/icalproperty.h b/calendar/libical/src/libical/icalproperty.h deleted file mode 100644 index d47835a0f6..0000000000 --- a/calendar/libical/src/libical/icalproperty.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalproperty.h - CREATOR: eric 20 March 1999 - - - $Id: icalproperty.h,v 1.20 2008-01-15 23:17:41 dothebart Exp $ - $Locker: $ - - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalparam.h - - ======================================================================*/ - - -#ifndef ICALPROPERTY_H -#define ICALPROPERTY_H - -#include -#include /* for va_... */ - -#include "icalderivedparameter.h" - -#include "icalvalue.h" -#include "icalrecur.h" - -/* Actually in icalderivedproperty.h: - typedef struct icalproperty_impl icalproperty; */ - -#include "icalderivedproperty.h" /* To get icalproperty_kind enumerations */ - -icalproperty* icalproperty_new(icalproperty_kind kind); - -icalproperty* icalproperty_new_clone(icalproperty * prop); - -icalproperty* icalproperty_new_from_string(const char* str); - -const char* icalproperty_as_ical_string(icalproperty* prop); -char* icalproperty_as_ical_string_r(icalproperty* prop); - -void icalproperty_free(icalproperty* prop); - -icalproperty_kind icalproperty_isa(icalproperty* property); -int icalproperty_isa_property(void* property); - -void icalproperty_add_parameters(struct icalproperty_impl *prop,va_list args); -void icalproperty_add_parameter(icalproperty* prop,icalparameter* parameter); -void icalproperty_set_parameter(icalproperty* prop,icalparameter* parameter); -void icalproperty_set_parameter_from_string(icalproperty* prop, - const char* name, const char* value); -const char* icalproperty_get_parameter_as_string(icalproperty* prop, - const char* name); -char* icalproperty_get_parameter_as_string_r(icalproperty* prop, - const char* name); - -void icalproperty_remove_parameter(icalproperty* prop, - icalparameter_kind kind); - -void icalproperty_remove_parameter_by_kind(icalproperty* prop, - icalparameter_kind kind); - -void icalproperty_remove_parameter_by_name(icalproperty* prop, - const char *name); - -void icalproperty_remove_parameter_by_ref(icalproperty* prop, - icalparameter *param); - - - -int icalproperty_count_parameters(const icalproperty* prop); - -/* Iterate through the parameters */ -icalparameter* icalproperty_get_first_parameter(icalproperty* prop, - icalparameter_kind kind); -icalparameter* icalproperty_get_next_parameter(icalproperty* prop, - icalparameter_kind kind); -/* Access the value of the property */ -void icalproperty_set_value(icalproperty* prop, icalvalue* value); -void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char* kind); - -icalvalue* icalproperty_get_value(const icalproperty* prop); -const char* icalproperty_get_value_as_string(const icalproperty* prop); -char* icalproperty_get_value_as_string_r(const icalproperty* prop); - -/* Deal with X properties */ - -void icalproperty_set_x_name(icalproperty* prop, const char* name); -const char* icalproperty_get_x_name(icalproperty* prop); - -/** Return the name of the property -- the type name converted to a - * string, or the value of _get_x_name if the type is and X - * property - */ -const char* icalproperty_get_property_name (const icalproperty* prop); -char* icalproperty_get_property_name_r(const icalproperty* prop); - -icalvalue_kind icalparameter_value_to_value_kind(icalparameter_value value); - -/* Convert kinds to string and get default value type */ - -icalvalue_kind icalproperty_kind_to_value_kind(icalproperty_kind kind); -icalproperty_kind icalproperty_value_kind_to_kind(icalvalue_kind kind); -const char* icalproperty_kind_to_string(icalproperty_kind kind); -icalproperty_kind icalproperty_string_to_kind(const char* string); - -/** Check validity of a specific icalproperty_kind **/ -int icalproperty_kind_is_valid(const icalproperty_kind kind); - -icalproperty_method icalproperty_string_to_method(const char* str); -const char* icalproperty_method_to_string(icalproperty_method method); - - -const char* icalproperty_enum_to_string(int e); -char* icalproperty_enum_to_string_r(int e); -int icalproperty_string_to_enum(const char* str); -int icalproperty_kind_and_string_to_enum(const int kind, const char* str); - -const char* icalproperty_status_to_string(icalproperty_status); -icalproperty_status icalproperty_string_to_status(const char* string); - -int icalproperty_enum_belongs_to_property(icalproperty_kind kind, int e); - - - - -#endif /*ICALPROPERTY_H*/ diff --git a/calendar/libical/src/libical/icalrecur.c b/calendar/libical/src/libical/icalrecur.c deleted file mode 100644 index 7faf2346ed..0000000000 --- a/calendar/libical/src/libical/icalrecur.c +++ /dev/null @@ -1,2670 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icalrecur.c - CREATOR: eric 16 May 2000 - - $Id: icalrecur.c,v 1.71 2008-02-03 16:10:46 dothebart Exp $ - $Locker: $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ -*/ - -/** - @file icalrecur.c - @brief Implementation of routines for dealing with recurring time - - How this code works: - - Processing starts when the caller generates a new recurrence - iterator via icalrecur_iterator_new(). This routine copies the - recurrence rule into the iterator and extracts things like start and - end dates. Then, it checks if the rule is legal, using some logic - from RFC2445 and some logic that probably should be in RFC2445. - - Then, icalrecur_iterator_new() re-writes some of the BY* - arrays. This involves ( via a call to setup_defaults() ) : - - 1) For BY rule parts with no data ( ie BYSECOND was not specified ) - copy the corresponding time part from DTSTART into the BY array. ( - So impl->by_ptrs[BY_SECOND] will then have one element if is - originally had none ) This only happens if the BY* rule part data - would expand the number of occurrences in the occurrence set. This - lets the code ignore DTSTART later on and still use it to get the - time parts that were not specified in any other way. - - 2) For the by rule part that are not the same interval as the - frequency -- for HOURLY anything but BYHOUR, for instance -- copy the - first data element from the rule part into the first occurrence. For - example, for "INTERVAL=MONTHLY and BYHOUR=10,30", initialize the - first time to be returned to have an hour of 10. - - Finally, for INTERVAL=YEARLY, the routine expands the rule to get - all of the days specified in the rule. The code will do this for - each new year, and this is the first expansion. This is a special - case for the yearly interval; no other frequency gets expanded this - way. The yearly interval is the most complex, so some special - processing is required. - - After creating a new iterator, the caller will make successive calls - to icalrecur_iterator_next() to get the next time specified by the - rule. The main part of this routine is a switch on the frequency of - the rule. Each different frequency is handled by a different - routine. - - For example, next_hour handles the case of INTERVAL=HOURLY, and it - is called by other routines to get the next hour. First, the routine - tries to get the next minute part of a time with a call to - next_minute(). If next_minute() returns 1, it has reached the end of - its data, usually the last element of the BYMINUTE array. Then, if - there is data in the BYHOUR array, the routine changes the hour to - the next one in the array. If INTERVAL=HOURLY, the routine advances - the hour by the interval. - - If the routine used the last hour in the BYHOUR array, and the - INTERVAL=HOURLY, then the routine calls increment_monthday() to set - the next month day. The increment_* routines may call higher routine - to increment the month or year also. - - The code for INTERVAL=DAILY is handled by next_day(). First, the - routine tries to get the next hour part of a time with a call to - next_hour. If next_hour() returns 1, it has reached the end of its - data, usually the last element of the BYHOUR array. This means that - next_day() should increment the time to the next day. If FREQUENCY==DAILY, - the routine increments the day by the interval; otherwise, it - increments the day by 1. - - Next_day() differs from next_hour because it does not use the BYDAY - array to select an appropriate day. Instead, it returns every day ( - incrementing by 1 if the frequency is not DAILY with INTERVAL!=1) - Any days that are not specified in an non-empty BYDAY array are - filtered out later. - - Generally, the flow of these routine is for a next_* call a next_* - routine of a lower interval ( next_day calls next_hour) and then to - possibly call an increment_* routine of an equal or higher - interval. ( next_day calls increment_monthday() ) - - When the call to the original next_* routine returns, - icalrecur_iterator_next() will check the returned data against other - BYrule parts to determine if is should be excluded by calling - check_contracting_rules. Generally, a contracting rule is any with a - larger time span than the interval. For instance, if - INTERVAL=DAILY, BYMONTH is a contracting rule part. - - Check_contracting_rules() uses icalrecur_check_rulepart() to do its - work. icalrecur_check_rulepart() uses expand_map[] to determine if a rule - is contracting, and if it is, and if the BY rule part has some data, - then the routine checks if the value of a component of the time is - part of the byrule part. For instance, for "INTERVAL=DAILY; - BYMONTH=6,10", icalrecur_check_rulepart() would check that the time value - given to it has a month of either 6 or 10. - - Finally, icalrecur_iterator_next() does a few other checks on the - time value, and if it passes, it returns the time. - - A note about the end_of_data flag. The flag indicates that the - routine is at the end of its data -- the last BY rule if the routine - is using by rules, or the last day of the week/month/year/etc if - not. - - This flag is usually set early in a next_* routine and returned in - the end. The way it is used allows the next_* routine to set the - last time back to the first element in a BYxx rule, and then signal - to the higer level routine to increment the next higher level. For - instance. WITH FREQ=MONTHLY;BYDAY=TU,FR, After next_weekday_by_month - runs though both TU and FR, it sets the week day back to TU and sets - end_of_data to 1x. This signals next_month to increment the month. - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef HAVE_STDINT_H -#include -#endif - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#endif - - -#include - -#ifndef HAVE_INTPTR_T -#if (defined (_MSC_VER) && _MSC_VER < 1400) || defined (XP_BEOS) -typedef long intptr_t; -#endif -#endif - -#ifdef WIN32 -#define strcasecmp stricmp -#endif - -#include "icalrecur.h" - -#include "icalerror.h" -#include "icalmemory.h" - -#include /* for malloc */ -#include /* for errno */ -#include /* for strdup and strchr*/ -#include -#include /* For offsetof() macro */ -#ifdef HAVE_INTTYPES_H -#include -#endif - -#include "pvl.h" - -/** This is the last year we will go up to, since 32-bit time_t values - only go up to the start of 2038. */ -#define MAX_TIME_T_YEAR 2037 - -#define TEMP_MAX 1024 - - -#define BYDAYIDX impl->by_indices[BY_DAY] -#define BYDAYPTR impl->by_ptrs[BY_DAY] - -#define BYMONIDX impl->by_indices[BY_MONTH] -#define BYMONPTR impl->by_ptrs[BY_MONTH] - -#define BYMDIDX impl->by_indices[BY_MONTH_DAY] -#define BYMDPTR impl->by_ptrs[BY_MONTH_DAY] - -#define BYWEEKIDX impl->by_indices[BY_WEEK_NO] -#define BYWEEKPTR impl->by_ptrs[BY_WEEK_NO] - -const char* icalrecur_freq_to_string(icalrecurrencetype_frequency kind); -icalrecurrencetype_frequency icalrecur_string_to_freq(const char* str); - -const char* icalrecur_weekday_to_string(icalrecurrencetype_weekday kind); -icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str); - - -/*********************** Rule parsing routines ************************/ - -struct icalrecur_parser { - const char* rule; - char* copy; - char* this_clause; - char* next_clause; - - struct icalrecurrencetype rt; -}; - -const char* icalrecur_first_clause(struct icalrecur_parser *parser) -{ - char *idx; - parser->this_clause = parser->copy; - - idx = strchr(parser->this_clause,';'); - - if (idx == 0){ - parser->next_clause = 0; - return 0; - } - - *idx = 0; - idx++; - parser->next_clause = idx; - - return parser->this_clause; - -} - -const char* icalrecur_next_clause(struct icalrecur_parser *parser) -{ - char* idx; - - parser->this_clause = parser->next_clause; - - if(parser->this_clause == 0){ - return 0; - } - - idx = strchr(parser->this_clause,';'); - - if (idx == 0){ - parser->next_clause = 0; - } else { - - *idx = 0; - idx++; - parser->next_clause = idx; - } - - return parser->this_clause; - -} - -void icalrecur_clause_name_and_value(struct icalrecur_parser *parser, - char** name, char** value) -{ - char *idx; - - *name = parser->this_clause; - - idx = strchr(parser->this_clause,'='); - - if (idx == 0){ - *name = 0; - *value = 0; - return; - } - - *idx = 0; - idx++; - *value = idx; -} - -void icalrecur_add_byrules(struct icalrecur_parser *parser, short *array, - int size, char* vals) -{ - char *t, *n; - int i=0; - int sign = 1; - int v; - - n = vals; - - while(n != 0){ - - if(i == size){ - return; - } - - t = n; - - n = strchr(t,','); - - if(n != 0){ - *n = 0; - n++; - } - - /* Get optional sign. HACK. sign is not allowed for all BYxxx - rule parts */ - if( *t == '-'){ - sign = -1; - t++; - } else if (*t == '+'){ - sign = 1; - t++; - } else { - sign = 1; - } - - v = atoi(t) * sign ; - - - array[i++] = (short)v; - array[i] = ICAL_RECURRENCE_ARRAY_MAX; - - } - -} - -/* - * Days in the BYDAY rule are expected by the code to be sorted, and while - * this may be the common case, the RFC doesn't actually mandate it. This - * function sorts the days taking into account the first day of week. - */ -static void -sort_bydayrules(short *array, int week_start) -{ - int one, two, i, j; - - for (i=0; - i two) { - short tmp = array[j]; - array[j] = array[i]; - array[i] = tmp; - } - } - } -} - -void icalrecur_add_bydayrules(struct icalrecur_parser *parser, const char* vals) -{ - - char *t, *n; - int i=0; - int sign = 1; - int weekno = 0; - icalrecurrencetype_weekday wd; - short *array = parser->rt.by_day; - char* end; - char* vals_copy; - - vals_copy = icalmemory_strdup(vals); - - end = (char*)vals_copy+strlen(vals_copy); - n = vals_copy; - - array[0] = ICAL_RECURRENCE_ARRAY_MAX; - - while(n != 0){ - - - t = n; - - n = strchr(t,','); - - if(n != 0){ - *n = 0; - n++; - } - - /* Get optional sign. */ - if( *t == '-'){ - sign = -1; - t++; - } else if (*t == '+'){ - sign = 1; - t++; - } else { - sign = 1; - } - - /* Get Optional weekno */ - weekno = strtol(t,&t,10); - - /* Outlook/Exchange generate "BYDAY=MO, FR" and "BYDAY=2 TH". - * Cope with that. - */ - if (*t == ' ') - t++; - - wd = icalrecur_string_to_weekday(t); - - /* Sanity check value */ - if (wd == ICAL_NO_WEEKDAY || weekno >= ICAL_BY_WEEKNO_SIZE) { - free(vals_copy); - return; - } - - int position = sign * weekno; - array[i++] = (wd + (8 * abs(position))) * ((position < 0) ? -1 : 1); - array[i] = ICAL_RECURRENCE_ARRAY_MAX; - } - - free(vals_copy); - - sort_bydayrules(parser->rt.by_day, parser->rt.week_start); -} - - -struct icalrecurrencetype icalrecurrencetype_from_string(const char* str) -{ - struct icalrecur_parser parser; - - memset(&parser,0,sizeof(parser)); - icalrecurrencetype_clear(&parser.rt); - - icalerror_check_arg_re(str!=0,"str",parser.rt); - - - /* Set up the parser struct */ - parser.rule = str; - parser.copy = icalmemory_strdup(parser.rule); - parser.this_clause = parser.copy; - - if(parser.copy == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return parser.rt; - } - - /* Loop through all of the clauses */ - for(icalrecur_first_clause(&parser); - parser.this_clause != 0; - icalrecur_next_clause(&parser)) - { - char *name, *value; - icalrecur_clause_name_and_value(&parser,&name,&value); - - if(name == 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - icalrecurrencetype_clear(&parser.rt); - free(parser.copy); - return parser.rt; - } - - if (strcasecmp(name,"FREQ") == 0){ - parser.rt.freq = icalrecur_string_to_freq(value); - } else if (strcasecmp(name,"COUNT") == 0){ - int v = atoi(value); - if (v >= 0) { - parser.rt.count = v; - } - } else if (strcasecmp(name,"UNTIL") == 0){ - parser.rt.until = icaltime_from_string(value); - } else if (strcasecmp(name,"INTERVAL") == 0){ - int v = atoi(value); - if (v > 0 && v <= SHRT_MAX) { - parser.rt.interval = (short) v; - } - } else if (strcasecmp(name,"WKST") == 0){ - parser.rt.week_start = icalrecur_string_to_weekday(value); - sort_bydayrules(parser.rt.by_day, parser.rt.week_start); - } else if (strcasecmp(name,"BYSECOND") == 0){ - icalrecur_add_byrules(&parser,parser.rt.by_second, - ICAL_BY_SECOND_SIZE,value); - } else if (strcasecmp(name,"BYMINUTE") == 0){ - icalrecur_add_byrules(&parser,parser.rt.by_minute, - ICAL_BY_MINUTE_SIZE,value); - } else if (strcasecmp(name,"BYHOUR") == 0){ - icalrecur_add_byrules(&parser,parser.rt.by_hour, - ICAL_BY_HOUR_SIZE,value); - } else if (strcasecmp(name,"BYDAY") == 0){ - icalrecur_add_bydayrules(&parser,value); - } else if (strcasecmp(name,"BYMONTHDAY") == 0){ - icalrecur_add_byrules(&parser,parser.rt.by_month_day, - ICAL_BY_MONTHDAY_SIZE,value); - } else if (strcasecmp(name,"BYYEARDAY") == 0){ - icalrecur_add_byrules(&parser,parser.rt.by_year_day, - ICAL_BY_YEARDAY_SIZE,value); - } else if (strcasecmp(name,"BYWEEKNO") == 0){ - icalrecur_add_byrules(&parser,parser.rt.by_week_no, - ICAL_BY_WEEKNO_SIZE,value); - } else if (strcasecmp(name,"BYMONTH") == 0){ - icalrecur_add_byrules(&parser,parser.rt.by_month, - ICAL_BY_MONTH_SIZE,value); - } else if (strcasecmp(name,"BYSETPOS") == 0){ - icalrecur_add_byrules(&parser,parser.rt.by_set_pos, - ICAL_BY_SETPOS_SIZE,value); - } else { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - icalrecurrencetype_clear(&parser.rt); - free(parser.copy); - return parser.rt; - } - - } - - free(parser.copy); - - return parser.rt; - -} - -static struct {const char* str;size_t offset; int limit; } recurmap[] = -{ - {";BYSECOND=",offsetof(struct icalrecurrencetype,by_second),ICAL_BY_SECOND_SIZE - 1}, - {";BYMINUTE=",offsetof(struct icalrecurrencetype,by_minute),ICAL_BY_MINUTE_SIZE - 1}, - {";BYHOUR=",offsetof(struct icalrecurrencetype,by_hour),ICAL_BY_HOUR_SIZE - 1}, - {";BYDAY=",offsetof(struct icalrecurrencetype,by_day),ICAL_BY_DAY_SIZE - 1}, - {";BYMONTHDAY=",offsetof(struct icalrecurrencetype,by_month_day),ICAL_BY_MONTHDAY_SIZE - 1}, - {";BYYEARDAY=",offsetof(struct icalrecurrencetype,by_year_day),ICAL_BY_YEARDAY_SIZE - 1}, - {";BYWEEKNO=",offsetof(struct icalrecurrencetype,by_week_no),ICAL_BY_WEEKNO_SIZE - 1}, - {";BYMONTH=",offsetof(struct icalrecurrencetype,by_month),ICAL_BY_MONTH_SIZE - 1}, - {";BYSETPOS=",offsetof(struct icalrecurrencetype,by_set_pos),ICAL_BY_SETPOS_SIZE - 1}, - {0,0,0}, -}; - -/* A private routine in icalvalue.c */ -void print_date_to_string(char* str, struct icaltimetype *data); -void print_datetime_to_string(char* str, struct icaltimetype *data); - -char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur) -{ - char *buf; - buf = icalrecurrencetype_as_string_r(recur); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* icalrecurrencetype_as_string_r(struct icalrecurrencetype *recur) -{ - char* str; - char *str_p; - size_t buf_sz = 200; - char temp[20]; - int i,j; - - if(recur->freq == ICAL_NO_RECURRENCE){ - return 0; - } - - str = (char*)icalmemory_new_buffer(buf_sz); - str_p = str; - - icalmemory_append_string(&str,&str_p,&buf_sz,"FREQ="); - icalmemory_append_string(&str,&str_p,&buf_sz, - icalrecur_freq_to_string(recur->freq)); - - if(recur->until.year != 0){ - - temp[0] = 0; - if (recur->until.is_date) - print_date_to_string(temp,&(recur->until)); - else - print_datetime_to_string(temp,&(recur->until)); - - icalmemory_append_string(&str,&str_p,&buf_sz,";UNTIL="); - icalmemory_append_string(&str,&str_p,&buf_sz, temp); - } - - if(recur->count != 0){ - snprintf(temp,sizeof(temp),"%d",recur->count); - icalmemory_append_string(&str,&str_p,&buf_sz,";COUNT="); - icalmemory_append_string(&str,&str_p,&buf_sz, temp); - } - - if(recur->interval != 1){ - snprintf(temp,sizeof(temp),"%d",recur->interval); - icalmemory_append_string(&str,&str_p,&buf_sz,";INTERVAL="); - icalmemory_append_string(&str,&str_p,&buf_sz, temp); - } - - for(j =0; recurmap[j].str != 0; j++){ - short* array = (short*)(recurmap[j].offset+ (size_t)recur); - int limit = recurmap[j].limit; - - /* Skip unused arrays */ - if( array[0] != ICAL_RECURRENCE_ARRAY_MAX ) { - - icalmemory_append_string(&str,&str_p,&buf_sz,recurmap[j].str); - - for(i=0; - i< limit && array[i] != ICAL_RECURRENCE_ARRAY_MAX; - i++){ - if (j == 3) { /* BYDAY */ - const char *daystr = icalrecur_weekday_to_string( - icalrecurrencetype_day_day_of_week(array[i])); - int pos; - - pos = icalrecurrencetype_day_position(array[i]); - - if (pos == 0) - icalmemory_append_string(&str,&str_p,&buf_sz,daystr); - else { - snprintf(temp,sizeof(temp),"%d%s",pos,daystr); - icalmemory_append_string(&str,&str_p,&buf_sz,temp); - } - - } else { - snprintf(temp,sizeof(temp),"%d",array[i]); - icalmemory_append_string(&str,&str_p,&buf_sz, temp); - } - - if( (i+1)week_start != ICAL_MONDAY_WEEKDAY && recur->week_start != ICAL_NO_WEEKDAY ) { - const char *daystr = icalrecur_weekday_to_string( - icalrecurrencetype_day_day_of_week( recur->week_start )); - icalmemory_append_string(&str,&str_p,&buf_sz,";WKST="); - icalmemory_append_string(&str,&str_p,&buf_sz,daystr); - } - - return str; -} - - -/************************* occurrence iteration routiens ******************/ - -enum byrule { - NO_CONTRACTION = -1, - BY_SECOND = 0, - BY_MINUTE = 1, - BY_HOUR = 2, - BY_DAY = 3, - BY_MONTH_DAY = 4, - BY_YEAR_DAY = 5, - BY_WEEK_NO = 6, - BY_MONTH = 7, - BY_SET_POS -}; - - - -struct icalrecur_iterator_impl { - - struct icaltimetype dtstart; /* Hack. Make into time_t */ - struct icaltimetype last; /* last time return from _iterator_next*/ - int occurrence_no; /* number of step made on t iterator */ - struct icalrecurrencetype rule; - - short days[366]; - short days_index; - - enum byrule byrule; - short by_indices[9]; - short orig_data[9]; /**< 1 if there was data in the byrule */ - - - short *by_ptrs[9]; /**< Pointers into the by_* array elements of the rule */ - -}; - -static void increment_year(icalrecur_iterator* impl, int inc); - -int icalrecur_iterator_sizeof_byarray(short* byarray) -{ - int array_itr; - - for(array_itr = 0; - byarray[array_itr] != ICAL_RECURRENCE_ARRAY_MAX; - array_itr++){ - } - - return array_itr; -} - -enum expand_table { - UNKNOWN = 0, - CONTRACT = 1, - EXPAND =2, - ILLEGAL=3 -}; - -/** - * The split map indicates, for a particular interval, wether a BY_* - * rule part expands the number of instances in the occcurrence set or - * contracts it. 1=> contract, 2=>expand, and 3 means the pairing is - * not allowed. - */ - -struct expand_split_map_struct -{ - icalrecurrencetype_frequency frequency; - - /* Elements of the 'map' array correspond to the BYxxx rules: - Second,Minute,Hour,Day,Month Day,Year Day,Week No,Month*/ - - short map[8]; -}; - -static const struct expand_split_map_struct expand_map[] = -{ - {ICAL_SECONDLY_RECURRENCE,{1,1,1,1,1,1,1,1}}, - {ICAL_MINUTELY_RECURRENCE,{2,1,1,1,1,1,1,1}}, - {ICAL_HOURLY_RECURRENCE, {2,2,1,1,1,1,1,1}}, - {ICAL_DAILY_RECURRENCE, {2,2,2,1,1,1,1,1}}, - {ICAL_WEEKLY_RECURRENCE, {2,2,2,2,3,3,1,1}}, - {ICAL_MONTHLY_RECURRENCE, {2,2,2,2,2,3,3,1}}, - {ICAL_YEARLY_RECURRENCE, {2,2,2,2,2,2,2,2}}, - {ICAL_NO_RECURRENCE, {0,0,0,0,0,0,0,0}} - -}; - - - -/** Check that the rule has only the two given interday byrule parts. */ -static -int icalrecur_two_byrule(icalrecur_iterator* impl, - enum byrule one,enum byrule two) -{ - short test_array[9]; - enum byrule itr; - int passes = 0; - - memset(test_array,0,sizeof(test_array)); - - test_array[one] = 1; - test_array[two] = 1; - - for(itr = BY_DAY; itr != BY_SET_POS; itr++){ - - if( (test_array[itr] == 0 && - impl->by_ptrs[itr][0] != ICAL_RECURRENCE_ARRAY_MAX - ) || - (test_array[itr] == 1 && - impl->by_ptrs[itr][0] == ICAL_RECURRENCE_ARRAY_MAX - ) - ) { - /* test failed */ - passes = 0; - } - } - - return passes; - -} - -/** Check that the rule has only the one given interdat byrule parts. */ -static int icalrecur_one_byrule(icalrecur_iterator* impl,enum byrule one) -{ - int passes = 1; - enum byrule itr; - - for(itr = BY_DAY; itr != BY_SET_POS; itr++){ - - if ((itr==one && impl->by_ptrs[itr][0] == ICAL_RECURRENCE_ARRAY_MAX) || - (itr!=one && impl->by_ptrs[itr][0] != ICAL_RECURRENCE_ARRAY_MAX)) { - passes = 0; - } - } - - return passes; -} -/* -static int count_byrules(icalrecur_iterator* impl) -{ - int count = 0; - enum byrule itr; - - for(itr = BY_DAY; itr <= BY_SET_POS; itr++){ - if(impl->by_ptrs[itr][0] != ICAL_RECURRENCE_ARRAY_MAX){ - count++; - } - } - - return count; -} -*/ - -static void setup_defaults(icalrecur_iterator* impl, - enum byrule byrule, icalrecurrencetype_frequency req, - int deftime, int *timepart) -{ - - icalrecurrencetype_frequency freq; - freq = impl->rule.freq; - - /* Re-write the BY rule arrays with data from the DTSTART time so - we don't have to explicitly deal with DTSTART */ - - if(impl->by_ptrs[byrule][0] == ICAL_RECURRENCE_ARRAY_MAX && - expand_map[freq].map[byrule] != CONTRACT){ - impl->by_ptrs[byrule][0] = (short)deftime; - } - - /* Initialize the first occurrence */ - if( freq != req && expand_map[freq].map[byrule] != CONTRACT){ - *timepart = impl->by_ptrs[byrule][0]; - } - - -} - -static int has_by_data(icalrecur_iterator* impl, enum byrule byrule){ - - return (impl->orig_data[byrule] == 1); -} - - -static int expand_year_days(icalrecur_iterator* impl, int year); -static int nth_weekday(int dow, int pos, struct icaltimetype t); -static void increment_month(icalrecur_iterator* impl); -static int next_month(icalrecur_iterator* impl); - - -icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, - struct icaltimetype dtstart) -{ - icalrecur_iterator* impl; - icalrecurrencetype_frequency freq; - - icalerror_clear_errno(); - - if ( ( impl = (icalrecur_iterator*) - malloc(sizeof(icalrecur_iterator))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - memset(impl,0,sizeof(icalrecur_iterator)); - - impl->rule = rule; - impl->last = dtstart; - impl->dtstart = dtstart; - impl->days_index =0; - impl->occurrence_no = 0; - freq = impl->rule.freq; - - /* Set up convienience pointers to make the code simpler. Allows - us to iterate through all of the BY* arrays in the rule. */ - - impl->by_ptrs[BY_MONTH]=impl->rule.by_month; - impl->by_ptrs[BY_WEEK_NO]=impl->rule.by_week_no; - impl->by_ptrs[BY_YEAR_DAY]=impl->rule.by_year_day; - impl->by_ptrs[BY_MONTH_DAY]=impl->rule.by_month_day; - impl->by_ptrs[BY_DAY]=impl->rule.by_day; - impl->by_ptrs[BY_HOUR]=impl->rule.by_hour; - impl->by_ptrs[BY_MINUTE]=impl->rule.by_minute; - impl->by_ptrs[BY_SECOND]=impl->rule.by_second; - impl->by_ptrs[BY_SET_POS]=impl->rule.by_set_pos; - - memset(impl->orig_data,0,9*sizeof(short)); - - /* Note which by rules had data in them when the iterator was - created. We can't use the actuall by_x arrays, because the - empty ones will be given default values later in this - routine. The orig_data array will be used later in has_by_data */ - - impl->orig_data[BY_MONTH] - = (short)(impl->rule.by_month[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->orig_data[BY_WEEK_NO] - =(short)(impl->rule.by_week_no[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->orig_data[BY_YEAR_DAY] - =(short)(impl->rule.by_year_day[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->orig_data[BY_MONTH_DAY] - =(short)(impl->rule.by_month_day[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->orig_data[BY_DAY] - = (short)(impl->rule.by_day[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->orig_data[BY_HOUR] - = (short)(impl->rule.by_hour[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->orig_data[BY_MINUTE] - = (short)(impl->rule.by_minute[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->orig_data[BY_SECOND] - = (short)(impl->rule.by_second[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->orig_data[BY_SET_POS] - = (short)(impl->rule.by_set_pos[0]!=ICAL_RECURRENCE_ARRAY_MAX); - - - /* Check if the recurrence rule is legal */ - - /* If the BYYEARDAY appears, no other date rule part may appear. */ - - if(icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_MONTH) || - icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_WEEK_NO) || - icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_MONTH_DAY) || - icalrecur_two_byrule(impl,BY_YEAR_DAY,BY_DAY) ){ - - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - - - - /* BYWEEKNO and BYMONTHDAY rule parts may not both appear.*/ - - if(icalrecur_two_byrule(impl,BY_WEEK_NO,BY_MONTH_DAY)){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - - - /*For MONTHLY recurrences (FREQ=MONTHLY) neither BYYEARDAY nor - BYWEEKNO may appear. */ - - if(freq == ICAL_MONTHLY_RECURRENCE && - icalrecur_one_byrule(impl,BY_WEEK_NO)){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - - - /*For WEEKLY recurrences (FREQ=WEEKLY) neither BYMONTHDAY nor - BYYEARDAY may appear. */ - - if(freq == ICAL_WEEKLY_RECURRENCE && - icalrecur_one_byrule(impl,BY_MONTH_DAY )) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - - /* BYYEARDAY may only appear in YEARLY rules */ - if(freq != ICAL_YEARLY_RECURRENCE && - icalrecur_one_byrule(impl,BY_YEAR_DAY )) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - - /* Rewrite some of the rules and set up defaults to make later - processing easier. Primarily, t involves copying an element - from the start time into the corresponding BY_* array when the - BY_* array is empty */ - - - setup_defaults(impl,BY_SECOND,ICAL_SECONDLY_RECURRENCE, - impl->dtstart.second, - &(impl->last.second)); - - setup_defaults(impl,BY_MINUTE,ICAL_MINUTELY_RECURRENCE, - impl->dtstart.minute, - &(impl->last.minute)); - - setup_defaults(impl,BY_HOUR,ICAL_HOURLY_RECURRENCE, - impl->dtstart.hour, - &(impl->last.hour)); - - setup_defaults(impl,BY_MONTH_DAY,ICAL_DAILY_RECURRENCE, - impl->dtstart.day, - &(impl->last.day)); - - setup_defaults(impl,BY_MONTH,ICAL_MONTHLY_RECURRENCE, - impl->dtstart.month, - &(impl->last.month)); - - - if(impl->rule.freq == ICAL_WEEKLY_RECURRENCE ){ - - if(impl->by_ptrs[BY_DAY][0] == ICAL_RECURRENCE_ARRAY_MAX){ - - /* Weekly recurrences with no BY_DAY data should occur on the - same day of the week as the start time . */ - impl->by_ptrs[BY_DAY][0] = (short)icaltime_day_of_week(impl->dtstart); - - } else { - /* If there is BY_DAY data, then we need to move the initial - time to the start of the BY_DAY data. That is if the - start time is on a Wednesday, and the rule has - BYDAY=MO,WE,FR, move the initial time back to - monday. Otherwise, jumping to the next week ( jumping 7 - days ahead ) will skip over some occurrences in the - second week. */ - - /* This depends on impl->by_ptrs[BY_DAY] being correctly sorted by - * day. This should probably be abstracted to make such assumption - * more explicit. */ - short dow = (short)(impl->by_ptrs[BY_DAY][0]-icaltime_day_of_week(impl->last)); - - if((icaltime_day_of_week(impl->last) < impl->by_ptrs[BY_DAY][0] && dow >= 0) || dow < 0) - { - /* initial time is after first day of BY_DAY data */ - impl->last.day += dow; - impl->last = icaltime_normalize(impl->last); - } - - } - - - } - - /* For YEARLY rule, begin by setting up the year days array . The - YEARLY rules work by expanding one year at a time. */ - - if(impl->rule.freq == ICAL_YEARLY_RECURRENCE){ - struct icaltimetype next; - icalerror_clear_errno(); - - for (;;) { - expand_year_days(impl, impl->last.year); - if( icalerrno != ICAL_NO_ERROR) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - if (impl->days[0] != ICAL_RECURRENCE_ARRAY_MAX) - break; /* break when no days are expanded */ - increment_year(impl,impl->rule.interval); - } - - /* Copy the first day into last. */ - next = icaltime_from_day_of_year(impl->days[0], impl->last.year); - - impl->last.day = next.day; - impl->last.month = next.month; - } - - - /* If this is a monthly interval with by day data, then we need to - set the last value to the appropriate day of the month */ - - if(impl->rule.freq == ICAL_MONTHLY_RECURRENCE && - has_by_data(impl,BY_DAY)) { - - struct icaltimetype tmp_last = icaltime_null_time(); - struct icaltimetype init_last = impl->last; - int days_in_month = - icaltime_days_in_month(impl->last.month, impl->last.year); - int i, dow, pos, day_of_month; - - /* Check every weekday in BYDAY with relative dow and pos. */ - for (i = 0; impl->by_ptrs[BY_DAY][i] != ICAL_RECURRENCE_ARRAY_MAX; i++) { - impl->last = init_last; - dow = icalrecurrencetype_day_day_of_week(impl->by_ptrs[BY_DAY][i]); - pos = icalrecurrencetype_day_position(impl->by_ptrs[BY_DAY][i]); - day_of_month = nth_weekday(dow, pos, impl->last); - - /* If |pos| >= 6, the byday is invalid for a monthly rule */ - if (pos >= 6 || pos <= -6) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - - /* If a Byday with pos=+/-5 is not in the current month it - must be searched in the next months. */ - if (day_of_month > days_in_month || day_of_month <= 0) { - /* Skip if we have already found a "last" in this month. */ - if (!icaltime_is_null_time(tmp_last) && tmp_last.month == init_last.month) { - continue; - } - while (day_of_month > days_in_month || day_of_month <= 0) { - impl->last.day = 1; - increment_month(impl); - days_in_month = - icaltime_days_in_month(impl->last.month, impl->last.year); - day_of_month = nth_weekday(dow, pos, impl->last); - } - } - - impl->last.day = day_of_month; - if (icaltime_is_null_time(tmp_last) || - icaltime_compare(impl->last, tmp_last) < 0) { - tmp_last = impl->last; - } - } - - impl->last = tmp_last; - - - if (impl->last.day > days_in_month || impl->last.day == 0) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - - if (has_by_data(impl, BY_MONTH_DAY)) { - /* If there is also a BYMONTHDAY rule, the "last" found must - match one of the bymonthdays too. - The funtion next_month() allows to find it. */ - - int months_counter = 48; /* Maximum number of months to check for - (keeping in count a possible leap year).*/ - impl->last.day--; - while (!next_month(impl) && months_counter) { - /* If next_month() hasn't found a valid day, continue to loop - in the next month. - Malformed rules such as BYDAY=4MO;BYMONTHDAY=1,2,3 can - cause an infinite loop, months_counter allows to get out. */ - months_counter--; - } - if (months_counter <= 0) { - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - free(impl); - return 0; - } - } - - } else if (has_by_data(impl,BY_MONTH_DAY)) { - // setup_defaults sets the day to -1 for negative BYMONTHDAY values, - // so make sure to re-calculate with days_in_month - if (impl->last.day < 0) { - int days_in_month = - icaltime_days_in_month(impl->last.month, impl->last.year); - impl->last.day = days_in_month + impl->last.day + 1; - } - impl->last = icaltime_normalize(impl->last); - } - - - - return impl; -} - - -void icalrecur_iterator_free(icalrecur_iterator* i) -{ - icalerror_check_arg_rv((i!=0),"impl"); - - free(i); - -} - -static void increment_year(icalrecur_iterator* impl, int inc) -{ - impl->last.year+=inc; -} - -/** Increment month is different that the other incement_* routines -- - it figures out the interval for itself, and uses BYMONTH data if - available. */ -static void increment_month(icalrecur_iterator* impl) -{ - int years; - - if(has_by_data(impl,BY_MONTH) ){ - /* Ignore the frequency and use the byrule data */ - - impl->by_indices[BY_MONTH]++; - - if (impl->by_ptrs[BY_MONTH][impl->by_indices[BY_MONTH]] - ==ICAL_RECURRENCE_ARRAY_MAX){ - impl->by_indices[BY_MONTH] = 0; - - increment_year(impl,1); - - } - - impl->last.month = - impl->by_ptrs[BY_MONTH][impl->by_indices[BY_MONTH]]; - - } else { - - int inc; - - if(impl->rule.freq == ICAL_MONTHLY_RECURRENCE){ - inc = impl->rule.interval; - } else { - inc = 1; - } - - impl->last.month+=inc; - - /* Months are offset by one */ - impl->last.month--; - - years = impl->last.month / 12; - - impl->last.month = impl->last.month % 12; - - impl->last.month++; - - if (years != 0){ - increment_year(impl,years); - } - } -} - -static void increment_monthday(icalrecur_iterator* impl, int inc) -{ - int i; - - for(i=0; ilast.month, impl->last.year); - - impl->last.day++; - - if (impl->last.day > days_in_month){ - impl->last.day = impl->last.day-days_in_month; - increment_month(impl); - } - } -} - - -static void increment_hour(icalrecur_iterator* impl, int inc) -{ - int days; - - impl->last.hour+=inc; - - days = impl->last.hour / 24; - impl->last.hour = impl->last.hour % 24; - - if (days != 0){ - increment_monthday(impl,days); - } -} - -static void increment_minute(icalrecur_iterator* impl, int inc) -{ - int hours; - - impl->last.minute+=inc; - - hours = impl->last.minute / 60; - impl->last.minute = impl->last.minute % 60; - - if (hours != 0){ - increment_hour(impl,hours); - } - -} - -static void increment_second(icalrecur_iterator* impl, int inc) -{ - int minutes; - - impl->last.second+=inc; - - minutes = impl->last.second / 60; - impl->last.second = impl->last.second % 60; - - if (minutes != 0) - { - increment_minute(impl, minutes); - } -} - -#if 0 -#include "ical.h" -void test_increment() -{ - icalrecur_iterator impl; - - impl.last = icaltime_from_string("20000101T000000Z"); - - printf("Orig: %s\n",icaltime_as_ctime(impl.last)); - - increment_second(&impl,5); - printf("+ 5 sec : %s\n",icaltime_as_ctime(impl.last)); - - increment_second(&impl,355); - printf("+ 355 sec : %s\n",icaltime_as_ctime(impl.last)); - - increment_minute(&impl,5); - printf("+ 5 min : %s\n",icaltime_as_ctime(impl.last)); - - increment_minute(&impl,360); - printf("+ 360 min : %s\n",icaltime_as_ctime(impl.last)); - increment_hour(&impl,5); - printf("+ 5 hours : %s\n",icaltime_as_ctime(impl.last)); - increment_hour(&impl,43); - printf("+ 43 hours : %s\n",icaltime_as_ctime(impl.last)); - increment_monthday(&impl,3); - printf("+ 3 days : %s\n",icaltime_as_ctime(impl.last)); - increment_monthday(&impl,600); - printf("+ 600 days : %s\n",icaltime_as_ctime(impl.last)); - -} - -#endif - -static int next_second(icalrecur_iterator* impl) -{ - - int has_by_second = (impl->by_ptrs[BY_SECOND][0]!=ICAL_RECURRENCE_ARRAY_MAX); - int this_frequency = (impl->rule.freq == ICAL_SECONDLY_RECURRENCE); - - int end_of_data = 0; - - assert(has_by_second || this_frequency); - - if( has_by_second ){ - /* Ignore the frequency and use the byrule data */ - - impl->by_indices[BY_SECOND]++; - - if (impl->by_ptrs[BY_SECOND][impl->by_indices[BY_SECOND]] - ==ICAL_RECURRENCE_ARRAY_MAX){ - impl->by_indices[BY_SECOND] = 0; - - end_of_data = 1; - } - - - impl->last.second = - impl->by_ptrs[BY_SECOND][impl->by_indices[BY_SECOND]]; - - - } else if( !has_by_second && this_frequency ){ - /* Compute the next value from the last time and the frequency interval*/ - increment_second(impl, impl->rule.interval); - - } - - /* If we have gone through all of the seconds on the BY list, then we - need to move to the next minute */ - - if(has_by_second && end_of_data && this_frequency ){ - increment_minute(impl,1); - } - - return end_of_data; - -} - -static int next_minute(icalrecur_iterator* impl) -{ - - int has_by_minute = (impl->by_ptrs[BY_MINUTE][0]!=ICAL_RECURRENCE_ARRAY_MAX); - int this_frequency = (impl->rule.freq == ICAL_MINUTELY_RECURRENCE); - - int end_of_data = 0; - - assert(has_by_minute || this_frequency); - - - if (next_second(impl) == 0){ - return 0; - } - - if( has_by_minute ){ - /* Ignore the frequency and use the byrule data */ - - impl->by_indices[BY_MINUTE]++; - - if (impl->by_ptrs[BY_MINUTE][impl->by_indices[BY_MINUTE]] - ==ICAL_RECURRENCE_ARRAY_MAX){ - - impl->by_indices[BY_MINUTE] = 0; - - end_of_data = 1; - } - - impl->last.minute = - impl->by_ptrs[BY_MINUTE][impl->by_indices[BY_MINUTE]]; - - } else if( !has_by_minute && this_frequency ){ - /* Compute the next value from the last time and the frequency interval*/ - increment_minute(impl,impl->rule.interval); - } - -/* If we have gone through all of the minutes on the BY list, then we - need to move to the next hour */ - - if(has_by_minute && end_of_data && this_frequency ){ - increment_hour(impl,1); - } - - return end_of_data; -} - -static int next_hour(icalrecur_iterator* impl) -{ - - int has_by_hour = (impl->by_ptrs[BY_HOUR][0]!=ICAL_RECURRENCE_ARRAY_MAX); - int this_frequency = (impl->rule.freq == ICAL_HOURLY_RECURRENCE); - - int end_of_data = 0; - - assert(has_by_hour || this_frequency); - - if (next_minute(impl) == 0){ - return 0; - } - - if( has_by_hour ){ - /* Ignore the frequency and use the byrule data */ - - impl->by_indices[BY_HOUR]++; - - if (impl->by_ptrs[BY_HOUR][impl->by_indices[BY_HOUR]] - ==ICAL_RECURRENCE_ARRAY_MAX){ - impl->by_indices[BY_HOUR] = 0; - - end_of_data = 1; - } - - impl->last.hour = - impl->by_ptrs[BY_HOUR][impl->by_indices[BY_HOUR]]; - - } else if( !has_by_hour && this_frequency ){ - /* Compute the next value from the last time and the frequency interval*/ - increment_hour(impl,impl->rule.interval); - - } - - /* If we have gone through all of the hours on the BY list, then we - need to move to the next day */ - - if(has_by_hour && end_of_data && this_frequency ){ - increment_monthday(impl,1); - } - - return end_of_data; - -} - -static int next_day(icalrecur_iterator* impl) -{ - - int has_by_day = (impl->by_ptrs[BY_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX); - int this_frequency = (impl->rule.freq == ICAL_DAILY_RECURRENCE); - - assert(has_by_day || this_frequency); - - if (next_hour(impl) == 0){ - return 0; - } - - /* Always increment through the interval, since this routine is not - called by any other next_* routine, and the days that are - excluded will be taken care of by restriction filtering */ - - if(this_frequency){ - increment_monthday(impl,impl->rule.interval); - } else { - increment_monthday(impl,1); - } - - - return 0; - -} - -/* -static int next_yearday(icalrecur_iterator* impl) -{ - - int has_by_yearday = (impl->by_ptrs[BY_YEAR_DAY][0]!=ICAL_RECURRENCE_ARRAY_MAX); - - int end_of_data = 0; - - assert(has_by_yearday ); - - if (next_hour(impl) == 0){ - return 0; - } - - impl->by_indices[BY_YEAR_DAY]++; - - if (impl->by_ptrs[BY_YEAR_DAY][impl->by_indices[BY_YEAR_DAY]] - ==ICAL_RECURRENCE_ARRAY_MAX){ - impl->by_indices[BY_YEAR_DAY] = 0; - - end_of_data = 1; - } - - impl->last.day = - impl->by_ptrs[BY_YEAR_DAY][impl->by_indices[BY_YEAR_DAY]]; - - if(has_by_yearday && end_of_data){ - increment_year(impl,1); - } - - return end_of_data; - -} -*/ - -/* Returns the day of the month for the current month of t that is the - pos'th instance of the day-of-week dow */ - -static int nth_weekday(int dow, int pos, struct icaltimetype t){ - - int days_in_month = icaltime_days_in_month(t.month, t.year); - int end_dow, start_dow; - int wd; - - if(pos >= 0){ - t.day = 1; - start_dow = icaltime_day_of_week(t); - - if (pos != 0) { - pos--; - } - - /* find month day of first occurrence of dow -- such as the - month day of the first monday */ - - wd = dow-start_dow+1; - - if (wd <= 0){ - wd = wd + 7; - } - - wd = wd + pos * 7; - - } else { - t.day = days_in_month; - end_dow = icaltime_day_of_week(t); - - pos++; - - /* find month day of last occurrence of dow -- such as the - month day of the last monday */ - - wd = (end_dow - dow); - - if (wd < 0){ - wd = wd+ 7; - } - - wd = days_in_month - wd; - - wd = wd + pos * 7; - } - - return wd; -} - -static int is_day_in_byday(icalrecur_iterator* impl,struct icaltimetype tt){ - - int idx; - - for(idx = 0; BYDAYPTR[idx] != ICAL_RECURRENCE_ARRAY_MAX; idx++){ - int dow = icalrecurrencetype_day_day_of_week(BYDAYPTR[idx]); - int pos = icalrecurrencetype_day_position(BYDAYPTR[idx]); - int this_dow = icaltime_day_of_week(tt); - - if( (pos == 0 && dow == this_dow ) || /* Just a dow, like "TU" or "FR" */ - (nth_weekday(dow,pos,tt) == tt.day)){ /*pos+wod: "3FR" or -1TU" */ - return 1; - } - } - - return 0; -} - -int check_set_position(icalrecur_iterator* impl, int set_pos) -{ - int i; - int found = 0; - for (i = 0; impl->rule.by_set_pos[i] != ICAL_RECURRENCE_ARRAY_MAX && - i != ICAL_BY_SETPOS_SIZE; i++){ - if (impl->rule.by_set_pos[i] == set_pos) { - found = 1; - break; - } - } - return found; -} - -static int next_month(icalrecur_iterator* impl) -{ - int data_valid = 1; - - int this_frequency = (impl->rule.freq == ICAL_MONTHLY_RECURRENCE); - - assert( has_by_data(impl,BY_MONTH) || this_frequency); - - /* Iterate through the occurrences within a day. If we don't get to - the end of the intra-day data, don't bother going to the next - month */ - - if (next_hour(impl) == 0){ - return data_valid; /* Signal that the data is valid */ - } - - /* Now iterate through the occurrences within a month -- by days, - weeks or weekdays. */ - - /* - * Case 1: - * Rules Like: FREQ=MONTHLY;INTERVAL=1;BYDAY=FR;BYMONTHDAY=13 - */ - - if(has_by_data(impl,BY_DAY) && has_by_data(impl,BY_MONTH_DAY)){ - int day, idx,j; - int days_in_month = icaltime_days_in_month(impl->last.month, - impl->last.year); - /* Iterate through the remaining days in the month and check if - each day is listed in the BY_DAY array and in the BY_MONTHDAY - array. This seems very inneficient, but I think it is the - simplest way to account for both BYDAY=1FR (First friday in - month) and BYDAY=FR ( every friday in month ) */ - - for(day = impl->last.day+1; day <= days_in_month; day++){ - for(idx = 0; BYDAYPTR[idx] != ICAL_RECURRENCE_ARRAY_MAX; idx++){ - for(j = 0; BYMDPTR[j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){ - int dow = - icalrecurrencetype_day_day_of_week(BYDAYPTR[idx]); - int pos = icalrecurrencetype_day_position(BYDAYPTR[idx]); - int mday = BYMDPTR[j]; - int this_dow; - - impl->last.day = day; - this_dow = icaltime_day_of_week(impl->last); - - if( (pos == 0 && dow == this_dow && mday == day) || - (nth_weekday(dow,pos,impl->last) == day && mday==day)){ - goto MDEND; - } - } - } - } - - MDEND: - - if ( day > days_in_month){ - impl->last.day = 1; - increment_month(impl); - impl->last.day--; /* Go back one day, so searches next month start at day 1 */ - data_valid = 0; /* signal that impl->last is invalid */ - } - - - /* - * Case 2: - * Rules Like: FREQ=MONTHLY;INTERVAL=1;BYDAY=FR - */ - - } else if(has_by_data(impl,BY_DAY)){ - /* For this case, the weekdays are relative to the - month. BYDAY=FR -> First Friday in month, etc. */ - - /* This code iterates through the remaining days in the month - and checks if each day is listed in the BY_DAY array. This - seems very inneficient, but I think it is the simplest way to - account for both BYDAY=1FR (First friday in month) and - BYDAY=FR ( every friday in month ) */ - - int day; - int days_in_month = icaltime_days_in_month(impl->last.month, - impl->last.year); - int set_pos_counter = 0; - int set_pos_total = 0; - int found = 0; - - assert( BYDAYPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX); - - /* Count the past positions for the BYSETPOS calculation */ - if(has_by_data(impl,BY_SET_POS)){ - int last_day = impl->last.day; - for(day = 1; day <= days_in_month; day++){ - impl->last.day = day; - - if(is_day_in_byday(impl,impl->last)){ - set_pos_total++; - if(day <= last_day) - set_pos_counter++; - } - } - impl->last.day = last_day; - } - - for(day = impl->last.day+1; day <= days_in_month; day++){ - impl->last.day = day; - - if(is_day_in_byday(impl,impl->last)){ - /* If there is no BYSETPOS rule, calculate only by BYDAY - If there is BYSETPOS rule, take into account the occurence - matches with BYDAY */ - if(!has_by_data(impl,BY_SET_POS) || check_set_position(impl, ++set_pos_counter) - || check_set_position(impl, set_pos_counter-set_pos_total-1)) { - found = 1; - break; - } - } - } - - data_valid = found; - - if ( day > days_in_month){ - impl->last.day = 1; - increment_month(impl); - - /* Did moving to the next month put us on a valid date? if - so, note that the new data is valid, if, not, mark it - invalid */ - - if(is_day_in_byday(impl,impl->last)){ - /* If there is no BYSETPOS rule or BYSETPOS=1, new data is valid */ - if(!has_by_data(impl,BY_SET_POS) || check_set_position(impl,1)) - data_valid = 1; - } else { - data_valid = 0; /* signal that impl->last is invalid */ - } - } - - /* - * Case 3 - * Rules Like: FREQ=MONTHLY;COUNT=10;BYMONTHDAY=-3 - */ - - } else if (has_by_data(impl,BY_MONTH_DAY)) { - int day, days_in_month; - - assert( BYMDPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX); - - BYMDIDX++; - - /* Are we at the end of the BYDAY array? */ - if (BYMDPTR[BYMDIDX] ==ICAL_RECURRENCE_ARRAY_MAX){ - - BYMDIDX = 0; /* Reset to 0 */ - increment_month(impl); - } - - days_in_month = icaltime_days_in_month(impl->last.month, - impl->last.year); - - day = BYMDPTR[BYMDIDX]; - - if (day < 0) { - day = icaltime_days_in_month(impl->last.month, impl->last.year) + day + 1; - } - - if ( day > days_in_month){ - impl->last.day = 1; - - /* Did moving to the next month put us on a valid date? if - so, note that the new data is valid, if, not, mark it - invalid */ - - if(is_day_in_byday(impl,impl->last)){ - data_valid = 1; - } else { - data_valid = 0; /* signal that impl->last is invalid */ - } - } - - impl->last.day = day; - - } else { - int days_in_month; - - assert( BYMDPTR[0]!=ICAL_RECURRENCE_ARRAY_MAX); - impl->last.day = BYMDPTR[0]; - - increment_month(impl); - - days_in_month = icaltime_days_in_month(impl->last.month, - impl->last.year); - if (impl->last.day > days_in_month) { - data_valid = 0; /* signal that impl->last is invalid */ - } - } - - return data_valid; - -} - -static int next_weekday_by_week(icalrecur_iterator* impl) -{ - - int end_of_data = 0; - int start_of_week, dow; - struct icaltimetype next; - - if (next_hour(impl) == 0){ - return 0; - } - - if(!has_by_data(impl,BY_DAY)){ - return 1; - } - - /* this call to 'sort_bydayrules' assures that the occurrences for - weekly recurrences will be generated in a strict linear order. */ - sort_bydayrules(BYDAYPTR, impl->rule.week_start); - - /* If we get here, we need to step to tne next day */ - - for (;;) { - struct icaltimetype tt = icaltime_null_time(); - BYDAYIDX++; /* Look at next elem in BYDAY array */ - - /* Are we at the end of the BYDAY array? */ - if (BYDAYPTR[BYDAYIDX]==ICAL_RECURRENCE_ARRAY_MAX){ - BYDAYIDX = 0; /* Reset to 0 */ - end_of_data = 1; /* Signal that we're at the end */ - } - - /* Add the day of week offset to to the start of this week, and use - that to get the next day */ - /* ignore position of dow ("4FR"), only use dow ("FR")*/ - dow = icalrecurrencetype_day_day_of_week(BYDAYPTR[BYDAYIDX]); - dow -= impl->rule.week_start; /* Set Sunday to be 0 */ - if (dow < 0) { - dow += 7; - } - - tt.year = impl->last.year; - tt.day = impl->last.day; - tt.month = impl->last.month; - - start_of_week = icaltime_start_doy_week(tt, impl->rule.week_start); - - if(dow+start_of_week <1){ - /* The selected date is in the previous year. */ - if(!end_of_data){ - continue; - } - } - - next = icaltime_from_day_of_year(start_of_week + dow,impl->last.year); - - impl->last.day = next.day; - impl->last.month = next.month; - impl->last.year = next.year; - - return end_of_data; - } - -} - -static int next_week(icalrecur_iterator* impl) -{ - int end_of_data = 0; - - /* Increment to the next week day, if there is data at a level less than a week */ - if (next_weekday_by_week(impl) == 0){ - return 0; /* Have not reached end of week yet */ - } - - /* If we get here, we have incremented through the entire week, and - can increment to the next week */ - - if( has_by_data(impl,BY_WEEK_NO)){ - /*FREQ=WEEKLY;BYWEEK=20*/ - /* Use the Week Number byrule data */ - int week_no; - struct icaltimetype t; - - impl->by_indices[BY_WEEK_NO]++; - - if (impl->by_ptrs[BY_WEEK_NO][impl->by_indices[BY_WEEK_NO]] - ==ICAL_RECURRENCE_ARRAY_MAX){ - impl->by_indices[BY_WEEK_NO] = 0; - - end_of_data = 1; - } - - t = impl->last; - t.month=1; /* HACK, should be setting to the date of the first week of year*/ - t.day=1; - - week_no = impl->by_ptrs[BY_WEEK_NO][impl->by_indices[BY_WEEK_NO]]; - - impl->last.day += week_no*7; - - impl->last = icaltime_normalize(impl->last); - - } else { - /* Jump to the next week */ - increment_monthday(impl,7*impl->rule.interval); - } - - if( has_by_data(impl,BY_WEEK_NO) && end_of_data){ - increment_year(impl,1); - } - - return end_of_data; - -} - -/** Expand the BYDAY rule part and return a pointer to a newly allocated list of days. */ -static pvl_list expand_by_day(icalrecur_iterator* impl, int year) -{ - /* Try to calculate each of the occurrences. */ - int i; - pvl_list days_list = pvl_newlist(); - - int start_dow, end_dow, end_year_day; - struct icaltimetype tmp = impl->last; - - tmp.year= year; - tmp.month = 1; - tmp.day = 1; - tmp.is_date = 1; - - /* Find the day that 1st Jan falls on, 1 (Sun) to 7 (Sat). */ - start_dow = icaltime_day_of_week(tmp); - - /* Get the last day of the year*/ - tmp.year= year; - tmp.month = 12; - tmp.day = 31; - tmp.is_date = 1; - - end_dow = icaltime_day_of_week(tmp); - end_year_day = icaltime_day_of_year(tmp); - - for(i = 0; BYDAYPTR[i] != ICAL_RECURRENCE_ARRAY_MAX; i++){ - /* This is 1 (Sun) to 7 (Sat). */ - int dow = - icalrecurrencetype_day_day_of_week(BYDAYPTR[i]); - int pos = icalrecurrencetype_day_position(BYDAYPTR[i]); - - if(pos == 0){ - /* The day was specified without a position -- it is just - a bare day of the week ( BYDAY=SU) so add all of the - days of the year with this day-of-week*/ - int doy, tmp_start_doy; - - tmp_start_doy = ((dow + 7 - start_dow) % 7) + 1; - - for (doy = tmp_start_doy; doy <= end_year_day; doy += 7) - pvl_push(days_list,(void*)(ptrdiff_t)doy); - - } else if ( pos > 0) { - int first; - /* First occurrence of dow in year */ - if( dow >= start_dow) { - first = dow - start_dow + 1; - } else { - first = dow - start_dow + 8; - } - - /* Then just multiple the position times 7 to get the pos'th day in the year */ - pvl_push(days_list,(void*)(ptrdiff_t)(first + (pos-1) * 7)); - - } else { /* pos < 0 */ - int last; - pos = -pos; - - /* last occurrence of dow in year */ - if( dow <= end_dow) { - last = end_year_day - end_dow + dow; - } else { - last = end_year_day - end_dow + dow - 7; - } - - pvl_push(days_list,(void*)(ptrdiff_t)(last - (pos-1) * 7)); - } - } - return days_list; -} - -/* A compare function to be used with qsort() in order to get - a sorted array of days of the year */ -int daysOfYear_compare(const void * a, const void * b) -{ - return ( *(short*)a - *(short*)b ); -} - -/* For INTERVAL=YEARLY, set up the days[] array in the iterator to - list all of the days of the current year that are specified in this - rule. */ - -static int expand_year_days(icalrecur_iterator* impl, int year) -{ - int i,j,k; - int days_index=0; - struct icaltimetype t; - int flags; - - t = icaltime_null_date(); - -#define HBD(x) has_by_data(impl,x) - - memset(impl->days,ICAL_RECURRENCE_ARRAY_MAX_BYTE,sizeof(impl->days)); - - /* The flags and the following switch statement select which code - to use to expand the yers days, based on which BY-rules are - present. */ - - flags = (HBD(BY_DAY) ? 1<by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX; j++){ - int month = impl->by_ptrs[BY_MONTH][j]; - int first_week, last_week; - t.month = month; - t.day = 1; - first_week = icaltime_week_number(t); - t.day = icaltime_days_in_month(month,year); - last_week = icaltime_week_number(t); - for(j=first_week; jdtstart; - t.year = impl->last.year; - - impl->days[days_index++] = (short)icaltime_day_of_year(t); - - break; - } - case 1<by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){ - int month = impl->by_ptrs[BY_MONTH][j]; - int doy; - - t = impl->dtstart; - t.year = year; - t.month = month; - t.is_date = 1; - - doy = icaltime_day_of_year(t); - - impl->days[days_index++] = (short)doy; - - } - break; - } - - case 1<by_ptrs[BY_MONTH_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++) - { - int month_day = impl->by_ptrs[BY_MONTH_DAY][k]; - int doy; - - t = impl->dtstart; - if (month_day < 0) { - int days_in_month = icaltime_days_in_month(t.month, year); - month_day = days_in_month + month_day + 1; - } - t.day = month_day; - t.year = year; - t.is_date = 1; - - doy = icaltime_day_of_year(t); - - impl->days[days_index++] = (short)doy; - - } - break; - } - - case (1<by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){ - int month = impl->by_ptrs[BY_MONTH][j]; - int days_in_month = icaltime_days_in_month(month, year); - for(k=0;impl->by_ptrs[BY_MONTH_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++) - { - int month_day = impl->by_ptrs[BY_MONTH_DAY][k]; - int doy; - - if (month_day < 0) { - month_day = days_in_month + month_day + 1; - } - - t.day = month_day; - t.month = month; - t.year = year; - t.is_date = 1; - - doy = icaltime_day_of_year(t); - - impl->days[days_index++] = (short)doy; - - } - } - - break; - } - - case 1<dtstart.day; - t.month = impl->dtstart.month; - t.year = year; - t.is_date = 1; - - dow = icaltime_day_of_week(t); - /* HACK Not finished */ - - icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR); - - break; - } - - case (1<days[days_index++] = day; - } - - pvl_free(days); - - break; - } - - case (1<by_ptrs[BY_MONTH][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){ - int month = impl->by_ptrs[BY_MONTH][j]; - int days_in_month = icaltime_days_in_month(month,year); - int first_dow, last_dow, doy_offset; - - t.year = year; - t.month = month; - t.day = 1; - t.is_date = 1; - - first_dow = icaltime_day_of_week(t); - - /* This holds the day offset used to calculate the day of the year - from the month day. Just add the month day to this. */ - doy_offset = icaltime_day_of_year(t) - 1; - - t.day = days_in_month; - last_dow = icaltime_day_of_week(t); - - if(has_by_data(impl,BY_SET_POS)) { - /*FREQ=YEARLY; BYDAY=TH,20MO,-10FR; BYMONTH = 12; BYSETPOS=1*/ - int day; - int set_pos_counter = 0; - int set_pos_total = 0; - int by_month_day[ICAL_BY_MONTHDAY_SIZE]; - for(day = 1; day <= days_in_month; day++){ - t.day = day; - if(is_day_in_byday(impl,t)) - by_month_day[set_pos_total++] = day; - } - for(set_pos_counter = 0; set_pos_counter < set_pos_total; set_pos_counter++){ - if(check_set_position(impl, set_pos_counter+1) || - check_set_position(impl, set_pos_counter-set_pos_total)) - impl->days[days_index++] = doy_offset + by_month_day[set_pos_counter]; - } - } - else for(k=0;impl->by_ptrs[BY_DAY][k]!=ICAL_RECURRENCE_ARRAY_MAX;k++){ - short day_coded = impl->by_ptrs[BY_DAY][k]; - enum icalrecurrencetype_weekday dow = - icalrecurrencetype_day_day_of_week(day_coded); - int pos = icalrecurrencetype_day_position(day_coded); - int first_matching_day, last_matching_day, day, month_day; - - /* Calculate the first day in the month with the given weekday, - and the last day. */ - first_matching_day = ((dow + 7 - first_dow) % 7) + 1; - last_matching_day = days_in_month - ((last_dow + 7 - dow) % 7); - - if (pos == 0) { - /* Add all of instances of the weekday within the month. */ - for (day = first_matching_day; day <= days_in_month; day += 7) - impl->days[days_index++] = (short)(doy_offset + day); - - } else if (pos > 0) { - /* Add the nth instance of the weekday within the month. */ - month_day = first_matching_day + (pos - 1) * 7; - - if (month_day <= days_in_month) - impl->days[days_index++] = (short)(doy_offset + month_day); - - } else { - /* Add the -nth instance of the weekday within the month.*/ - month_day = last_matching_day + (pos + 1) * 7; - - if (month_day > 0) - impl->days[days_index++] = (short)(doy_offset + month_day); - } - } - } - /* Sort the days according to the Bymonthday order (1,2,3,...). */ - qsort(impl->days, days_index, sizeof(short), daysOfYear_compare); - break; - } - - case (1<days[days_index++] = day; - } - } - - } - - pvl_free(days); - - break; - } - - case (1<days[days_index++] = day; - } - } - } - - } - - pvl_free(days); - - break; - - } - - case (1<days[days_index++] = day; - } - } - - } - - pvl_free(days); - break; - } - - case (1<by_ptrs[BY_YEAR_DAY][j]!=ICAL_RECURRENCE_ARRAY_MAX;j++){ - impl->days[days_index++] = impl->by_ptrs[BY_YEAR_DAY][j]; - } - break; - } - - default: { - icalerror_set_errno(ICAL_UNIMPLEMENTED_ERROR); - break; - } - - } - - return 0; -} - - -static int next_year(icalrecur_iterator* impl) -{ - struct icaltimetype next; - - if (next_hour(impl) == 0){ - return 0; - } - - if (impl->days[++impl->days_index] == ICAL_RECURRENCE_ARRAY_MAX){ - impl->days_index = 0; - - for (;;) { - increment_year(impl,impl->rule.interval); - expand_year_days(impl,impl->last.year); - if (impl->days[0] != ICAL_RECURRENCE_ARRAY_MAX) - break; - } - } - - next = icaltime_from_day_of_year(impl->days[impl->days_index], impl->last.year); - - impl->last.day = next.day; - impl->last.month = next.month; - - return 1; -} - -int icalrecur_check_rulepart(icalrecur_iterator* impl, - int v, enum byrule byrule) -{ - int itr; - - if(impl->by_ptrs[byrule][0]!=ICAL_RECURRENCE_ARRAY_MAX){ - for(itr=0; impl->by_ptrs[byrule][itr]!=ICAL_RECURRENCE_ARRAY_MAX;itr++){ - if(impl->by_ptrs[byrule][itr] == v){ - return 1; - } - } - } - - return 0; -} - -static int check_contract_restriction(icalrecur_iterator* impl, - enum byrule byrule, int v) -{ - int pass = 0; - int itr; - icalrecurrencetype_frequency freq = impl->rule.freq; - - if(impl->by_ptrs[byrule][0]!=ICAL_RECURRENCE_ARRAY_MAX && - expand_map[freq].map[byrule] == CONTRACT){ - for(itr=0; impl->by_ptrs[byrule][itr]!=ICAL_RECURRENCE_ARRAY_MAX;itr++){ - if(impl->by_ptrs[byrule][itr] == v){ - pass=1; - break; - } - } - - return pass; - } else { - /* This is not a contracting byrule, or it has no data, so the - test passes*/ - return 1; - } -} - - -static int check_contracting_rules(icalrecur_iterator* impl) -{ - - int day_of_week = icaltime_day_of_week(impl->last); - int week_no = icaltime_week_number(impl->last); - int year_day = icaltime_day_of_year(impl->last); - - if ( - check_contract_restriction(impl,BY_SECOND, impl->last.second) && - check_contract_restriction(impl,BY_MINUTE, impl->last.minute) && - check_contract_restriction(impl,BY_HOUR, impl->last.hour) && - check_contract_restriction(impl,BY_DAY, day_of_week) && - check_contract_restriction(impl,BY_WEEK_NO, week_no) && - check_contract_restriction(impl,BY_MONTH_DAY, impl->last.day) && - check_contract_restriction(impl,BY_MONTH, impl->last.month) && - check_contract_restriction(impl,BY_YEAR_DAY, year_day) ) - { - - return 1; - } else { - return 0; - } -} - -struct icaltimetype icalrecur_iterator_next(icalrecur_iterator *impl) -{ - int valid = 1; - - if( !impl || (impl->rule.count!=0 &&impl->occurrence_no >= impl->rule.count) || - (!icaltime_is_null_time(impl->rule.until) && - icaltime_compare(impl->last,impl->rule.until) > 0)) { - return icaltime_null_time(); - } - - if(impl->occurrence_no == 0 - && icaltime_compare(impl->last,impl->dtstart) >= 0){ - - impl->occurrence_no++; - return impl->last; - } - - do { - valid = 1; - switch(impl->rule.freq){ - - case ICAL_SECONDLY_RECURRENCE: { - next_second(impl); - break; - } - case ICAL_MINUTELY_RECURRENCE: { - next_minute(impl); - break; - } - case ICAL_HOURLY_RECURRENCE: { - next_hour(impl); - break; - } - case ICAL_DAILY_RECURRENCE: { - next_day(impl); - break; - } - case ICAL_WEEKLY_RECURRENCE: { - next_week(impl); - break; - } - case ICAL_MONTHLY_RECURRENCE: { - valid = next_month(impl); - break; - } - case ICAL_YEARLY_RECURRENCE:{ - next_year(impl); - break; - } - default:{ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return icaltime_null_time(); - } - } - - } while(!check_contracting_rules(impl) - || icaltime_compare(impl->last,impl->dtstart) < 0 - || valid == 0); - - -/* Ignore null times and times that are after the until time */ - if( !icaltime_is_null_time(impl->rule.until) && - icaltime_compare(impl->last,impl->rule.until) > 0 ) { - return icaltime_null_time(); - } - - impl->occurrence_no++; - - return impl->last; -} - - -/************************** Type Routines **********************/ - - -void icalrecurrencetype_clear(struct icalrecurrencetype *recur) -{ - memset(recur,ICAL_RECURRENCE_ARRAY_MAX_BYTE, - sizeof(struct icalrecurrencetype)); - - recur->week_start = ICAL_MONDAY_WEEKDAY; - recur->freq = ICAL_NO_RECURRENCE; - recur->interval = 1; - memset(&(recur->until),0,sizeof(struct icaltimetype)); - recur->count = 0; -} - -/** The 'day' element of icalrecurrencetype_weekday is encoded to - * allow representation of both the day of the week ( Monday, Tueday), - * but also the Nth day of the week ( First tuesday of the month, last - * thursday of the year) These routines decode the day values. - * - * The day's position in the period ( Nth-ness) and the numerical - * value of the day are encoded together as: pos*7 + dow - * - * A position of 0 means 'any' or 'every' - */ - -enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day) -{ - return abs(day)%8; -} - -int icalrecurrencetype_day_position(short day) -{ - int wd, pos; - - wd = icalrecurrencetype_day_day_of_week(day); - - pos = (abs(day)-wd)/8 * ((day<0)?-1:1); - - - return pos; -} - - -/****************** Enumeration Routines ******************/ - -static struct {icalrecurrencetype_weekday wd; const char * str; } -wd_map[] = { - {ICAL_SUNDAY_WEEKDAY,"SU"}, - {ICAL_MONDAY_WEEKDAY,"MO"}, - {ICAL_TUESDAY_WEEKDAY,"TU"}, - {ICAL_WEDNESDAY_WEEKDAY,"WE"}, - {ICAL_THURSDAY_WEEKDAY,"TH"}, - {ICAL_FRIDAY_WEEKDAY,"FR"}, - {ICAL_SATURDAY_WEEKDAY,"SA"}, - {ICAL_NO_WEEKDAY,0} -}; - -const char* icalrecur_weekday_to_string(icalrecurrencetype_weekday kind) -{ - int i; - - for (i=0; wd_map[i].wd != ICAL_NO_WEEKDAY; i++) { - if ( wd_map[i].wd == kind) { - return wd_map[i].str; - } - } - - return 0; -} - -icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str) -{ - int i; - - for (i=0; wd_map[i].wd != ICAL_NO_WEEKDAY; i++) { - if ( strcasecmp(str,wd_map[i].str) == 0){ - return wd_map[i].wd; - } - } - - return ICAL_NO_WEEKDAY; -} - - - -static struct { - icalrecurrencetype_frequency kind; - const char* str; -} freq_map[] = { - {ICAL_SECONDLY_RECURRENCE,"SECONDLY"}, - {ICAL_MINUTELY_RECURRENCE,"MINUTELY"}, - {ICAL_HOURLY_RECURRENCE,"HOURLY"}, - {ICAL_DAILY_RECURRENCE,"DAILY"}, - {ICAL_WEEKLY_RECURRENCE,"WEEKLY"}, - {ICAL_MONTHLY_RECURRENCE,"MONTHLY"}, - {ICAL_YEARLY_RECURRENCE,"YEARLY"}, - {ICAL_NO_RECURRENCE,0} -}; - -const char* icalrecur_freq_to_string(icalrecurrencetype_frequency kind) -{ - int i; - - for (i=0; freq_map[i].kind != ICAL_NO_RECURRENCE ; i++) { - if ( freq_map[i].kind == kind ) { - return freq_map[i].str; - } - } - return 0; -} - -icalrecurrencetype_frequency icalrecur_string_to_freq(const char* str) -{ - int i; - - for (i=0; freq_map[i].kind != ICAL_NO_RECURRENCE ; i++) { - if ( strcasecmp(str,freq_map[i].str) == 0){ - return freq_map[i].kind; - } - } - return ICAL_NO_RECURRENCE; -} - -/** Fill an array with the 'count' number of occurrences generated by - * the rrule. Note that the times are returned in UTC, but the times - * are calculated in local time. YOu will have to convert the results - * back into local time before using them. - */ - -int icalrecur_expand_recurrence(char* rule, time_t start, - int count, time_t* array) -{ - struct icalrecurrencetype recur; - icalrecur_iterator* ritr; - time_t tt; - struct icaltimetype icstart, next; - int i = 0; - - memset(array, 0, count*sizeof(time_t)); - - icstart = icaltime_from_timet_with_zone(start,0,0); - - recur = icalrecurrencetype_from_string(rule); - ritr = icalrecur_iterator_new(recur,icstart); - if(ritr) { - for(next = icalrecur_iterator_next(ritr); - !icaltime_is_null_time(next) && i < count; - next = icalrecur_iterator_next(ritr)){ - - tt = icaltime_as_timet(next); - - if (tt >= start ){ - array[i++] = tt; - } - } - icalrecur_iterator_free(ritr); - } - - - return 1; -} diff --git a/calendar/libical/src/libical/icalrecur.h b/calendar/libical/src/libical/icalrecur.h deleted file mode 100644 index 884bf049cf..0000000000 --- a/calendar/libical/src/libical/icalrecur.h +++ /dev/null @@ -1,217 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalrecur.h - CREATOR: eric 20 March 2000 - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ -*/ - -/** -@file icalrecur.h -@brief Routines for dealing with recurring time - -How to use: - -1) Get a rule and a start time from a component - -@code - icalproperty rrule; - struct icalrecurrencetype recur; - struct icaltimetype dtstart; - - rrule = icalcomponent_get_first_property(comp,ICAL_RRULE_PROPERTY); - recur = icalproperty_get_rrule(rrule); - start = icalproperty_get_dtstart(dtstart); -@endcode - -Or, just make them up: - -@code - recur = icalrecurrencetype_from_string("FREQ=YEARLY;BYDAY=SU,WE"); - dtstart = icaltime_from_string("19970101T123000") -@endcode - -2) Create an iterator - -@code - icalrecur_iterator* ritr; - ritr = icalrecur_iterator_new(recur,start); -@endcode - -3) Iterator over the occurrences - -@code - struct icaltimetype next; - while (next = icalrecur_iterator_next(ritr) - && !icaltime_is_null_time(next){ - Do something with next - } -@endcode - -Note that that the time returned by icalrecur_iterator_next is in -whatever timezone that dtstart is in. - -*/ - -#ifndef ICALRECUR_H -#define ICALRECUR_H - -#include -#include "icaltime.h" - -/* - * Recurrance enumerations - */ - -typedef enum icalrecurrencetype_frequency -{ - /* These enums are used to index an array, so don't change the - order or the integers */ - - ICAL_SECONDLY_RECURRENCE=0, - ICAL_MINUTELY_RECURRENCE=1, - ICAL_HOURLY_RECURRENCE=2, - ICAL_DAILY_RECURRENCE=3, - ICAL_WEEKLY_RECURRENCE=4, - ICAL_MONTHLY_RECURRENCE=5, - ICAL_YEARLY_RECURRENCE=6, - ICAL_NO_RECURRENCE=7 - -} icalrecurrencetype_frequency; - -typedef enum icalrecurrencetype_weekday -{ - ICAL_NO_WEEKDAY, - ICAL_SUNDAY_WEEKDAY, - ICAL_MONDAY_WEEKDAY, - ICAL_TUESDAY_WEEKDAY, - ICAL_WEDNESDAY_WEEKDAY, - ICAL_THURSDAY_WEEKDAY, - ICAL_FRIDAY_WEEKDAY, - ICAL_SATURDAY_WEEKDAY -} icalrecurrencetype_weekday; - -enum { - ICAL_RECURRENCE_ARRAY_MAX = 0x7f7f, - ICAL_RECURRENCE_ARRAY_MAX_BYTE = 0x7f -}; - - - -/** - * Recurrence type routines - */ - -/* See RFC 2445 Section 4.3.10, RECUR Value, for an explaination of - the values and fields in struct icalrecurrencetype */ - -#define ICAL_BY_SECOND_SIZE 61 -#define ICAL_BY_MINUTE_SIZE 61 -#define ICAL_BY_HOUR_SIZE 25 -#define ICAL_BY_DAY_SIZE 364 /* 7 days * 52 weeks */ -#define ICAL_BY_MONTHDAY_SIZE 32 -#define ICAL_BY_YEARDAY_SIZE 367 -#define ICAL_BY_WEEKNO_SIZE 54 -#define ICAL_BY_MONTH_SIZE 13 -#define ICAL_BY_SETPOS_SIZE 367 - -/** Main struct for holding digested recurrence rules */ -struct icalrecurrencetype -{ - icalrecurrencetype_frequency freq; - - - /* until and count are mutually exclusive. */ - struct icaltimetype until; - int count; - - short interval; - - icalrecurrencetype_weekday week_start; - - /* The BY* parameters can each take a list of values. Here I - * assume that the list of values will not be larger than the - * range of the value -- that is, the client will not name a - * value more than once. - - * Each of the lists is terminated with the value - * ICAL_RECURRENCE_ARRAY_MAX unless the the list is full. - */ - - short by_second[ICAL_BY_SECOND_SIZE]; - short by_minute[ICAL_BY_MINUTE_SIZE]; - short by_hour[ICAL_BY_HOUR_SIZE]; - short by_day[ICAL_BY_DAY_SIZE]; /* Encoded value, see below */ - short by_month_day[ICAL_BY_MONTHDAY_SIZE]; - short by_year_day[ ICAL_BY_YEARDAY_SIZE]; - short by_week_no[ICAL_BY_WEEKNO_SIZE]; - short by_month[ICAL_BY_MONTH_SIZE]; - short by_set_pos[ICAL_BY_SETPOS_SIZE]; -}; - - -void icalrecurrencetype_clear(struct icalrecurrencetype *r); - -/** - * Array Encoding - * - * The 'day' element of the by_day array is encoded to allow - * representation of both the day of the week ( Monday, Tueday), but also - * the Nth day of the week ( First tuesday of the month, last thursday of - * the year) These routines decode the day values - */ - -/** 1 == Monday, etc. */ -enum icalrecurrencetype_weekday icalrecurrencetype_day_day_of_week(short day); - -/** 0 == any of day of week. 1 == first, 2 = second, -2 == second to last, etc */ -int icalrecurrencetype_day_position(short day); - -icalrecurrencetype_weekday icalrecur_string_to_weekday(const char* str); - -/** Recurrance rule parser */ - -/** Convert between strings and recurrencetype structures. */ -struct icalrecurrencetype icalrecurrencetype_from_string(const char* str); -char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur); -char* icalrecurrencetype_as_string_r(struct icalrecurrencetype *recur); - - -/** Recurrence iteration routines */ - -typedef struct icalrecur_iterator_impl icalrecur_iterator; - -/** Create a new recurrence rule iterator */ -icalrecur_iterator* icalrecur_iterator_new(struct icalrecurrencetype rule, - struct icaltimetype dtstart); - -/** Get the next occurrence from an iterator */ -struct icaltimetype icalrecur_iterator_next(icalrecur_iterator*); - -void icalrecur_iterator_decrement_count(icalrecur_iterator*); - -/** Free the iterator */ -void icalrecur_iterator_free(icalrecur_iterator*); - -/** - * Fills array up with at most 'count' time_t values, each - * representing an occurrence time in seconds past the POSIX epoch - */ -int icalrecur_expand_recurrence(char* rule, time_t start, - int count, time_t* array); - - -#endif diff --git a/calendar/libical/src/libical/icalrestriction.c.in b/calendar/libical/src/libical/icalrestriction.c.in deleted file mode 100644 index 2a5983aabf..0000000000 --- a/calendar/libical/src/libical/icalrestriction.c.in +++ /dev/null @@ -1,523 +0,0 @@ -/* -*- Mode: C -*- */ -/* ====================================================================== - File: icalrestriction.c - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - ======================================================================*/ -/*#line 7 "icalrestriction.c.in"*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "icalrestriction.h" -#include "icalenums.h" -#include "icalerror.h" - -#include -#include /* For snprintf */ - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#endif - - -#define TMP_BUF_SIZE 1024 - -/* Define the structs for the restrictions. these data are filled out -in machine generated code below */ - -struct icalrestriction_property_record; - -typedef const char* (*restriction_func)(const struct icalrestriction_property_record* rec,icalcomponent* comp,icalproperty* prop); - - -typedef struct icalrestriction_property_record { - icalproperty_method method; - icalcomponent_kind component; - icalproperty_kind property; - icalrestriction_kind restriction; - restriction_func function; -} icalrestriction_property_record; - - -typedef struct icalrestriction_component_record { - icalproperty_method method; - icalcomponent_kind component; - icalcomponent_kind subcomponent; - icalrestriction_kind restriction; - restriction_func function; -} icalrestriction_component_record; - -static const icalrestriction_property_record* -icalrestriction_get_property_restriction(icalproperty_method method, - icalcomponent_kind component, - icalproperty_kind property); -static const icalrestriction_component_record* -icalrestriction_get_component_restriction(icalproperty_method method, - icalcomponent_kind component, - icalcomponent_kind subcomponent); - -icalrestriction_property_record null_prop_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_RESTRICTION_UNKNOWN,0}; -icalrestriction_component_record null_comp_record = {ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_COMPONENT,ICAL_RESTRICTION_UNKNOWN,0}; - - -/** Each row gives the result of comparing a restriction against a count. - The columns in each row represent 0,1,2+. '-1' indicates - 'invalid, 'don't care' or 'needs more analysis' So, for - ICAL_RESTRICTION_ONE, if there is 1 of a property with that - restriction, it passes, but if there are 0 or 2+, it fails. */ - -char compare_map[ICAL_RESTRICTION_UNKNOWN+1][3] = { - { 1, 1, 1},/*ICAL_RESTRICTION_NONE*/ - { 1, 0, 0},/*ICAL_RESTRICTION_ZERO*/ - { 0, 1, 0},/*ICAL_RESTRICTION_ONE*/ - { 1, 1, 1},/*ICAL_RESTRICTION_ZEROPLUS*/ - { 0, 1, 1},/*ICAL_RESTRICTION_ONEPLUS*/ - { 1, 1, 0},/*ICAL_RESTRICTION_ZEROORONE*/ - { 1, 1, 0},/*ICAL_RESTRICTION_ONEEXCLUSIVE*/ - { 1, 1, 0},/*ICAL_RESTRICTION_ONEMUTUAL*/ - { 1, 1, 1} /*ICAL_RESTRICTION_UNKNOWN*/ -}; - -const char restr_string_map[ICAL_RESTRICTION_UNKNOWN+1][60] = { - "unknown number",/*ICAL_RESTRICTION_NONE*/ - "0",/*ICAL_RESTRICTION_ZERO*/ - "1",/*ICAL_RESTRICTION_ONE*/ - "zero or more",/*ICAL_RESTRICTION_ZEROPLUS*/ - "one or more" ,/*ICAL_RESTRICTION_ONEPLUS*/ - "zero or one",/*ICAL_RESTRICTION_ZEROORONE*/ - "zero or one, exclusive with another property",/*ICAL_RESTRICTION_ONEEXCLUSIVE*/ - "zero or one, mutual with another property",/*ICAL_RESTRICTION_ONEMUTUAL*/ - "unknown number" /*ICAL_RESTRICTION_UNKNOWN*/ -}; - - -int -icalrestriction_compare(icalrestriction_kind restr, int count){ - - /* restr is an unsigned int, ICAL_RESTRICTION_NONE == 0, so the check will always return false */ - if ( /*restr < ICAL_RESTRICTION_NONE ||*/ restr > ICAL_RESTRICTION_UNKNOWN - || count < 0){ - return -1; - } - - if (count > 2) { - count = 2; - } - - return compare_map[restr][count]; - -} - -/* Special case routines */ - -const char* icalrestriction_may_be_draft_final_canceled( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - icalproperty_status stat = icalproperty_get_status(prop); - (void)rec; - (void)comp; - - if( !( stat == ICAL_STATUS_DRAFT || - stat == ICAL_STATUS_FINAL || - stat == ICAL_STATUS_CANCELLED )){ - - return "Failed iTIP restrictions for STATUS property. Value must be one of DRAFT, FINAL, or CANCELED"; - - } - - return 0; -} - -const char* icalrestriction_may_be_comp_need_process( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - icalproperty_status stat = icalproperty_get_status(prop); - (void)rec; - (void)comp; - - if( !( stat == ICAL_STATUS_COMPLETED || - stat == ICAL_STATUS_NEEDSACTION || - stat == ICAL_STATUS_INPROCESS )){ - - return "Failed iTIP restrictions for STATUS property. Value must be one of COMPLETED, NEEDS-ACTION or IN-PROCESS"; - - } - - return 0; -} -const char* icalrestriction_may_be_tent_conf(const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - icalproperty_status stat = icalproperty_get_status(prop); - - (void)rec; - (void)comp; - - if( !( stat == ICAL_STATUS_TENTATIVE || - stat == ICAL_STATUS_CONFIRMED )){ - - return "Failed iTIP restrictions for STATUS property. Value must be one of TENTATIVE or CONFIRMED"; - - } - - return 0; -} -const char* icalrestriction_may_be_tent_conf_cancel( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - icalproperty_status stat = icalproperty_get_status(prop); - - (void)rec; - (void)comp; - - if( !( stat == ICAL_STATUS_TENTATIVE || - stat == ICAL_STATUS_CONFIRMED || - stat == ICAL_STATUS_CANCELLED )){ - - return "Failed iTIP restrictions for STATUS property. Value must be one of TENTATIVE, CONFIRMED or CANCELED"; - - } - - return 0; -} - -const char* icalrestriction_must_be_cancel_if_present( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - /* This routine will not be called if prop == 0 */ - icalproperty_status stat = icalproperty_get_status(prop); - (void)rec; - (void)comp; - - if( stat != ICAL_STATUS_CANCELLED) - { - return "Failed iTIP restrictions for STATUS property. Value must be CANCELLED"; - - } - - - return 0; -} - -const char* icalrestriction_must_be_canceled_no_attendee( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - (void)rec; - (void)comp; - (void)prop; - - /* Hack. see rfc2446, 3.2.5 CANCEL for porperty STATUS. I don't - understand the note */ - - return 0; -} - -const char* icalrestriction_must_be_recurring( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop){ - /* Hack */ - (void)rec; - (void)comp; - (void)prop; - return 0; -} - -const char* icalrestriction_must_have_duration( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - if( !icalcomponent_get_first_property(comp,ICAL_DURATION_PROPERTY)){ - - return "Failed iTIP restrictions for DURATION property. This component must have a DURATION property"; - - } - - return 0; -} - -const char* icalrestriction_must_have_repeat( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - (void)rec; - (void)prop; - if( !icalcomponent_get_first_property(comp,ICAL_REPEAT_PROPERTY)){ - - return "Failed iTIP restrictions for REPEAT property. This component must have a REPEAT property"; - - } - - return 0; -} - -const char* icalrestriction_must_if_tz_ref( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop){ - - /* Hack */ - (void)rec; - (void)comp; - (void)prop; - return 0; -} - -const char* icalrestriction_no_dtend( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - - (void)rec; - (void)prop; - if(icalcomponent_get_first_property(comp,ICAL_DTEND_PROPERTY)){ - - return "Failed iTIP restrictions for DTEND property. The component must not have both DURATION and DTEND"; - - } - - return 0; -} - -const char* icalrestriction_no_duration( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - (void)rec; - (void)comp; - (void)prop; - - /* _no_dtend takes care of this one */ - return 0; -} - -const char* icalrestriction_must_be_email( - const icalrestriction_property_record *rec, - icalcomponent* comp, - icalproperty* prop) -{ - icalproperty_action stat = icalproperty_get_action(prop); - - (void)rec; - (void)comp; - - if( !( stat == ICAL_ACTION_EMAIL)){ - - return "Failed iTIP restrictions for ACTION property. Value must be EMAIL."; - - } - - return 0; -} - -int icalrestriction_check_component(icalproperty_method method, - icalcomponent* comp) -{ - icalproperty_kind kind; - icalcomponent_kind comp_kind; - icalrestriction_kind restr; - const icalrestriction_property_record *prop_record; - const char* funcr = 0; - icalproperty *prop; - - int count; - int compare; - int valid = 1; - - comp_kind = icalcomponent_isa(comp); - - /* Check all of the properties in this component */ - - for(kind = ICAL_ANY_PROPERTY+1; kind != ICAL_NO_PROPERTY; kind++){ - count = icalcomponent_count_properties(comp, kind); - - prop_record = icalrestriction_get_property_restriction(method, - comp_kind, - kind); - - restr = prop_record->restriction; - - if(restr == ICAL_RESTRICTION_ONEEXCLUSIVE || - restr == ICAL_RESTRICTION_ONEMUTUAL) { - - /* First treat is as a 0/1 restriction */ - restr = ICAL_RESTRICTION_ZEROORONE; - compare = icalrestriction_compare(restr,count); - - } else { - - compare = icalrestriction_compare(restr,count); - } - - assert(compare != -1); - - if (compare == 0){ - char temp[TMP_BUF_SIZE]; - - snprintf(temp, TMP_BUF_SIZE,"Failed iTIP restrictions for %s property. Expected %s instances of the property and got %d", - icalenum_property_kind_to_string(kind), - restr_string_map[restr], count); - - icalcomponent_add_property - (comp, - icalproperty_vanew_xlicerror( - temp, - icalparameter_new_xlicerrortype(ICAL_XLICERRORTYPE_INVALIDITIP), - 0)); - } - - - prop = icalcomponent_get_first_property(comp, kind); - - if (prop != 0 && prop_record->function !=0 ){ - funcr = prop_record->function(prop_record,comp,prop); - } - - if(funcr !=0){ - icalcomponent_add_property - (comp, - icalproperty_vanew_xlicerror( - funcr, - icalparameter_new_xlicerrortype( - ICAL_XLICERRORTYPE_INVALIDITIP), - 0)); - - compare = 0; - } - - valid = valid && compare; - } - - - - return valid; - - -} - -int icalrestriction_check(icalcomponent* outer_comp) -{ - icalcomponent_kind comp_kind; - icalproperty_method method; - icalcomponent* inner_comp; - icalproperty *method_prop; - int valid; - - icalerror_check_arg_rz( (outer_comp!=0), "outer comp"); - - - /* Get the Method value from the outer component */ - - comp_kind = icalcomponent_isa(outer_comp); - - if (comp_kind != ICAL_VCALENDAR_COMPONENT){ - icalerror_set_errno(ICAL_BADARG_ERROR); - return 0; - } - - method_prop = icalcomponent_get_first_property(outer_comp, - ICAL_METHOD_PROPERTY); - - if (method_prop == 0){ - method = ICAL_METHOD_NONE; - } else { - method = icalproperty_get_method(method_prop); - } - - - /* Check the VCALENDAR wrapper */ - valid = icalrestriction_check_component(ICAL_METHOD_NONE,outer_comp); - - - /* Now check the inner components */ - - for(inner_comp= icalcomponent_get_first_component(outer_comp, - ICAL_ANY_COMPONENT); - inner_comp != 0; - inner_comp= icalcomponent_get_next_component(outer_comp, - ICAL_ANY_COMPONENT)){ - - valid = valid && icalrestriction_check_component(method,inner_comp); - - } - - - return valid; - -} - - - -static const icalrestriction_property_record* -icalrestriction_get_property_restriction(icalproperty_method method, - icalcomponent_kind component, - icalproperty_kind property) -{ - int i; - - for(i = 0; - icalrestriction_property_records[i].restriction != ICAL_RESTRICTION_NONE; - i++){ - - if (method == icalrestriction_property_records[i].method && - component == icalrestriction_property_records[i].component && - property == icalrestriction_property_records[i].property ){ - return &icalrestriction_property_records[i]; - } - } - - return &null_prop_record; -} - - -static const icalrestriction_component_record* -icalrestriction_get_component_restriction(icalproperty_method method, - icalcomponent_kind component, - icalcomponent_kind subcomponent) -{ - - int i; - - for(i = 0; - icalrestriction_component_records[i].restriction != ICAL_RESTRICTION_NONE; - i++){ - - if (method == icalrestriction_component_records[i].method && - component == icalrestriction_component_records[i].component && - subcomponent == icalrestriction_component_records[i].subcomponent ){ - return &icalrestriction_component_records[i]; - } - } - - return &null_comp_record; -} diff --git a/calendar/libical/src/libical/icalrestriction.h b/calendar/libical/src/libical/icalrestriction.h deleted file mode 100644 index a4914247a1..0000000000 --- a/calendar/libical/src/libical/icalrestriction.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalrestriction.h - CREATOR: eric 24 April 1999 - - $Id: icalrestriction.h,v 1.3 2008-01-15 23:17:42 dothebart Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalrestriction.h - - Contributions from: - Graham Davison (g.m.davison@computer.org) - - -======================================================================*/ - -#include "icalproperty.h" -#include "icalcomponent.h" - -#ifndef ICALRESTRICTION_H -#define ICALRESTRICTION_H - -/* These must stay in this order for icalrestriction_compare to work */ -typedef enum icalrestriction_kind { - ICAL_RESTRICTION_NONE=0, /* 0 */ - ICAL_RESTRICTION_ZERO, /* 1 */ - ICAL_RESTRICTION_ONE, /* 2 */ - ICAL_RESTRICTION_ZEROPLUS, /* 3 */ - ICAL_RESTRICTION_ONEPLUS, /* 4 */ - ICAL_RESTRICTION_ZEROORONE, /* 5 */ - ICAL_RESTRICTION_ONEEXCLUSIVE, /* 6 */ - ICAL_RESTRICTION_ONEMUTUAL, /* 7 */ - ICAL_RESTRICTION_UNKNOWN /* 8 */ -} icalrestriction_kind; - -int -icalrestriction_compare(icalrestriction_kind restr, int count); - - -int -icalrestriction_is_parameter_allowed(icalproperty_kind property, - icalparameter_kind parameter); - -int icalrestriction_check(icalcomponent* comp); - - -#endif /* !ICALRESTRICTION_H */ - - - diff --git a/calendar/libical/src/libical/icaltime.c b/calendar/libical/src/libical/icaltime.c deleted file mode 100644 index a3f10c5ee8..0000000000 --- a/calendar/libical/src/libical/icaltime.c +++ /dev/null @@ -1,1241 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icaltime.c - CREATOR: eric 02 June 2000 - - $Id: icaltime.c,v 1.71 2008-01-29 18:31:48 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - - ======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icaltime.h" -#include -#include -#include -#include -#include - -#include "astime.h" /* Julian data handling routines */ - -#include "icalerror.h" -#include "icalmemory.h" - -#include "icaltimezone.h" -#include "icalvalue.h" - -#ifdef WIN32 -#include - -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -#ifdef WIN32 -/* Undef the similar macro from pthread.h, it doesn't check if - * gmtime() returns NULL. - */ -#undef gmtime_r - -/* The gmtime() in Microsoft's C library is MT-safe */ -#define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0) -#endif - -#ifdef HAVE_PTHREAD - #include - static pthread_mutex_t tzid_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif - -/* - * Function to convert a struct tm time specification - * to an ANSI time_t using the specified time zone. - * This is different from the standard mktime() function - * in that we don't want the automatic adjustments for - * local daylight savings time applied to the result. - * This function expects well-formed input. - */ -static time_t make_time(struct tm *tm, int tzm) -{ - time_t tim; - - static int days[] = { -1, 30, 58, 89, 119, 150, 180, 211, 242, 272, 303, 333, 364 }; - - /* check that year specification within range */ - - if (tm->tm_year < 70 || tm->tm_year > 138) - return((time_t) -1); - - /* check that month specification within range */ - - if (tm->tm_mon < 0 || tm->tm_mon > 11) - return((time_t) -1); - - /* check for upper bound of Jan 17, 2038 (to avoid possibility of - 32-bit arithmetic overflow) */ - - if (tm->tm_year == 138) { - if (tm->tm_mon > 0) - return((time_t) -1); - else if (tm->tm_mday > 17) - return((time_t) -1); - } - - /* - * calculate elapsed days since start of the epoch (midnight Jan - * 1st, 1970 UTC) 17 = number of leap years between 1900 and 1970 - * (number of leap days to subtract) - */ - - tim = (tm->tm_year - 70) * 365 + ((tm->tm_year - 1) / 4) - 17; - - /* add number of days elapsed in the current year */ - - tim += days[tm->tm_mon]; - - /* check and adjust for leap years (the leap year check only valid - during the 32-bit era */ - - if ((tm->tm_year & 3) == 0 && tm->tm_mon > 1) - tim += 1; - - /* elapsed days to current date */ - - tim += tm->tm_mday; - - - /* calculate elapsed hours since start of the epoch */ - - tim = tim * 24 + tm->tm_hour; - - /* calculate elapsed minutes since start of the epoch */ - - tim = tim * 60 + tm->tm_min; - - /* adjust per time zone specification */ - - tim -= tzm; - - /* calculate elapsed seconds since start of the epoch */ - - tim = tim * 60 + tm->tm_sec; - - /* return number of seconds since start of the epoch */ - - return(tim); -} - -/** @brief Constructor (deprecated). - * - * Convert seconds past UNIX epoch to a timetype. - * - * @deprecated This constructor is deprecated and shouldn't be used in - * new software. Use icaltime_from_timet_with_zone(time_t, int, - * icaltimezone *) instead. In the meantime, calls to this method - * return a floating time, which can always be converted to a local - * time with an appropriate call to icaltime_convert_to_zone(). - */ - -struct icaltimetype -icaltime_from_timet(const time_t tm, const int is_date) -{ -#ifndef NO_WARN_DEPRECATED - icalerror_warn("icaltime_from_timet() is DEPRECATED, use icaltime_from_timet_with_zone() instead"); -#endif - - return icaltime_from_timet_with_zone(tm, is_date, 0); -} - - -/** @brief Constructor. - * - * @param tm The time - * @param is_date Boolean: 1 means we should treat tm as a DATE - * @param zone The timezone tm is in, NULL means to treat tm as a - * floating time - * - * Return a new icaltime instance, initialized to the given time - * expressed as seconds past UNIX epoch, optionally using the given - * timezone. - * - * If the caller specifies the is_date param as TRUE, the returned - * object is of DATE type, otherwise the input is meant to be of - * DATE-TIME type. - * If the zone is not specified (NULL zone param) the time is taken - * to be floating, that is, valid in any timezone. Note that, in - * addition to the uses specified in [RFC2445], this can be used - * when doing simple math on couples of times. - * If the zone is specified (UTC or otherwise), it's stored in the - * object and it's used as the native timezone for this object. - * This means that the caller can convert this time to a different - * target timezone with no need to store the source timezone. - * - */ -struct icaltimetype -icaltime_from_timet_with_zone(const time_t tm, const int is_date, - const icaltimezone *zone) -{ - struct icaltimetype tt; - struct tm t; - icaltimezone *utc_zone; - - utc_zone = icaltimezone_get_utc_timezone (); - - /* Convert the time_t to a struct tm in UTC time. We can trust gmtime - for this. */ -#ifdef HAVE_PTHREAD - gmtime_r (&tm, &t); -#else - t = *(gmtime (&tm)); -#endif - - tt.year = t.tm_year + 1900; - tt.month = t.tm_mon + 1; - tt.day = t.tm_mday; - tt.hour = t.tm_hour; - tt.minute = t.tm_min; - tt.second = t.tm_sec; - tt.is_date = 0; - tt.is_utc = (zone == utc_zone) ? 1 : 0; - tt.is_daylight = 0; - tt.zone = NULL; - - /* Use our timezone functions to convert to the required timezone. */ - icaltimezone_convert_time (&tt, utc_zone, (icaltimezone *)zone); - - tt.is_date = is_date; - - /* If it is a DATE value, make sure hour, minute & second are 0. */ - if (is_date) { - tt.hour = 0; - tt.minute = 0; - tt.second = 0; - } - - return tt; -} - -/** @brief Convenience constructor. - * - * Returns the current time in the given timezone, as an icaltimetype. - */ -struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone) -{ - return icaltime_from_timet_with_zone (time (NULL), 0, zone); -} - -/** @brief Convenience constructor. - * - * Returns the current day as an icaltimetype, with is_date set. - */ -struct icaltimetype icaltime_today(void) -{ - return icaltime_from_timet_with_zone (time (NULL), 1, NULL); -} - -/** @brief Return the time as seconds past the UNIX epoch - * - * While this function is not currently deprecated, it probably won't do - * what you expect, unless you know what you're doing. In particular, you - * should only pass an icaltime in UTC, since no conversion is done. Even - * in that case, it's probably better to just use - * icaltime_as_timet_with_zone(). - */ -time_t icaltime_as_timet(const struct icaltimetype tt) -{ - struct tm stm; - time_t t; - - /* If the time is the special null time, return 0. */ - if (icaltime_is_null_time(tt)) { - return 0; - } - - /* Copy the icaltimetype to a struct tm. */ - memset (&stm, 0, sizeof (struct tm)); - - if (icaltime_is_date(tt)) { - stm.tm_sec = stm.tm_min = stm.tm_hour = 0; - } else { - stm.tm_sec = tt.second; - stm.tm_min = tt.minute; - stm.tm_hour = tt.hour; - } - - stm.tm_mday = tt.day; - stm.tm_mon = tt.month-1; - stm.tm_year = tt.year-1900; - stm.tm_isdst = -1; - - t = make_time(&stm, 0); - - return t; - -} - - -/* Structure used by set_tz to hold an old value of TZ, and the new - value, which is in memory we will have to free in unset_tz */ -/* This will hold the last "TZ=XXX" string we used with putenv(). After we - call putenv() again to set a new TZ string, we can free the previous one. - As far as I know, no libc implementations actually free the memory used in - the environment variables (how could they know if it is a static string or - a malloc'ed string?), so we have to free it ourselves. */ -static char* saved_tz = NULL; - -/* If you use set_tz(), you must call unset_tz() some time later to restore the - original TZ. Pass unset_tz() the string that set_tz() returns. Call both the functions - locking the tzid mutex as in icaltime_as_timet_with_zone */ -char* set_tz(const char* tzid) -{ - char *old_tz, *old_tz_copy = NULL, *new_tz; - - /* Get the old TZ setting and save a copy of it to return. */ - old_tz = getenv("TZ"); - if(old_tz){ - old_tz_copy = (char*)malloc(strlen (old_tz) + 4); - - if(old_tz_copy == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - strcpy (old_tz_copy, "TZ="); - strcpy (old_tz_copy + 3, old_tz); - } - - /* Create the new TZ string. */ - new_tz = (char*)malloc(strlen (tzid) + 4); - - if(new_tz == 0){ - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - free(old_tz_copy); - return 0; - } - - strcpy (new_tz, "TZ="); - strcpy (new_tz + 3, tzid); - - /* Add the new TZ to the environment. */ - putenv(new_tz); - - /* Free any previous TZ environment string we have used in a synchronized manner. */ - - free (saved_tz); - - /* Save a pointer to the TZ string we just set, so we can free it later. */ - saved_tz = new_tz; - - return old_tz_copy; /* This will be zero if the TZ env var was not set */ -} - -void unset_tz(char *tzstr) -{ - /* restore the original environment */ - - if(tzstr!=0){ - putenv(tzstr); - } else { - /* Delete from environment. We prefer unsetenv(3) over putenv(3) - because the former is POSIX and behaves consistently. The later - does not unset the variable in some systems (like NetBSD), leaving - it with an empty value. This causes problems later because further - calls to time related functions in libc will treat times in UTC. */ -#ifdef HAVE_UNSETENV - unsetenv("TZ"); -#else - putenv("TZ"); -#endif - } - - /* Free any previous TZ environment string we have used in a synchronized manner */ - free (saved_tz); - - /* Save a pointer to the TZ string we just set, so we can free it later. - (This can possibly be NULL if there was no TZ to restore.) */ - saved_tz = tzstr; -} - -/** Return the time as seconds past the UNIX epoch, using the - * given timezone. - * - * This convenience method combines a call to icaltime_convert_to_zone() - * with a call to icaltime_as_timet(). - * If the input timezone is null, no conversion is done; that is, the - * time is simply returned as time_t in its native timezone. - */ -time_t icaltime_as_timet_with_zone(const struct icaltimetype tt, - const icaltimezone *zone) -{ - icaltimezone *utc_zone; - struct tm stm; - time_t t; - char *old_tz; - struct icaltimetype local_tt; - - utc_zone = icaltimezone_get_utc_timezone (); - - /* If the time is the special null time, return 0. */ - if (icaltime_is_null_time(tt)) { - return 0; - } - - local_tt = tt; - - /* Clear the is_date flag, so we can convert the time. */ - local_tt.is_date = 0; - - /* Use our timezone functions to convert to UTC. */ - icaltimezone_convert_time (&local_tt, (icaltimezone *)zone, utc_zone); - - /* Copy the icaltimetype to a struct tm. */ - memset (&stm, 0, sizeof (struct tm)); - - stm.tm_sec = local_tt.second; - stm.tm_min = local_tt.minute; - stm.tm_hour = local_tt.hour; - stm.tm_mday = local_tt.day; - stm.tm_mon = local_tt.month-1; - stm.tm_year = local_tt.year-1900; - stm.tm_isdst = -1; -/* The functions putenv and mktime are not thread safe, inserting a lock -to prevent any crashes */ - -#ifdef HAVE_PTHREAD - pthread_mutex_lock (&tzid_mutex); -#endif - - /* Set TZ to UTC and use mktime to convert to a time_t. */ - old_tz = set_tz ("UTC"); -#ifdef WIN32 - tzset (); -#endif - - t = mktime (&stm); - unset_tz (old_tz); -#ifdef WIN32 - tzset (); -#endif - -#ifdef HAVE_PTHREAD - pthread_mutex_unlock (&tzid_mutex); -#endif - return t; -} - -const char* icaltime_as_ical_string(const struct icaltimetype tt) -{ - char *buf; - buf = icaltime_as_ical_string_r(tt); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -/** - * Return a string represention of the time, in RFC2445 format. The - * string is owned by libical - */ -char* icaltime_as_ical_string_r(const struct icaltimetype tt) -{ - size_t size = 17; - char* buf = icalmemory_new_buffer(size); - - if(tt.is_date){ - snprintf(buf, size,"%04d%02d%02d",tt.year,tt.month,tt.day); - } else { - const char* fmt; - if(tt.is_utc){ - fmt = "%04d%02d%02dT%02d%02d%02dZ"; - } else { - fmt = "%04d%02d%02dT%02d%02d%02d"; - } - snprintf(buf, size,fmt,tt.year,tt.month,tt.day, - tt.hour,tt.minute,tt.second); - } - - return buf; -} - - -/** - * Reset all of the time components to be in their normal ranges. For - * instance, given a time with minutes=70, the minutes will be reduces - * to 10, and the hour incremented. This allows the caller to do - * arithmetic on times without worrying about overflow or - * underflow. - * - * Implementation note: we call icaltime_adjust() with no adjustment. - */ -struct icaltimetype icaltime_normalize(const struct icaltimetype tt) -{ - struct icaltimetype ret = tt; - icaltime_adjust(&ret, 0, 0, 0, 0); - return ret; -} - - - -/** @brief Contructor. - * - * Create a time from an ISO format string. - * - * @todo If the given string specifies a DATE-TIME not in UTC, there - * is no way to know if this is a floating time or really refers to a - * timezone. We should probably add a new constructor: - * icaltime_from_string_with_zone() - */ -struct icaltimetype icaltime_from_string(const char* str) -{ - struct icaltimetype tt = icaltime_null_time(); - int size; - - icalerror_check_arg_re(str!=0,"str",icaltime_null_time()); - - size = strlen(str); - - if ((size == 15) || (size == 19)) { /* floating time with/without separators*/ - tt.is_utc = 0; - tt.is_date = 0; - } else if ((size == 16) || (size == 20)) { /* UTC time, ends in 'Z'*/ - if ((str[size-1] != 'Z')) - goto FAIL; - - tt.is_utc = 1; - tt.zone = icaltimezone_get_utc_timezone(); - tt.is_date = 0; - } else if ((size == 8) || (size == 10)) { /* A DATE */ - tt.is_utc = 0; - tt.is_date = 1; - } else { /* error */ - goto FAIL; - } - - if (tt.is_date == 1){ - if (size == 10) { - char dsep1, dsep2; - if (sscanf(str,"%04d%c%02d%c%02d",&tt.year,&dsep1,&tt.month,&dsep2,&tt.day) < 5) - goto FAIL; - if ((dsep1 != '-') || (dsep2 != '-')) - goto FAIL; - } else if (sscanf(str,"%04d%02d%02d",&tt.year,&tt.month,&tt.day) < 3) { - goto FAIL; - } - } else { - if (size > 16 ) { - char dsep1, dsep2, tsep, tsep1, tsep2; - if (sscanf(str,"%04d%c%02d%c%02d%c%02d%c%02d%c%02d",&tt.year,&dsep1,&tt.month,&dsep2, - &tt.day,&tsep,&tt.hour,&tsep1,&tt.minute,&tsep2,&tt.second) < 11) - goto FAIL; - - if((tsep != 'T') || (dsep1 != '-') || (dsep2 != '-') || (tsep1 != ':') || (tsep2 != ':')) - goto FAIL; - - } else { - char tsep; - if (sscanf(str,"%04d%02d%02d%c%02d%02d%02d",&tt.year,&tt.month,&tt.day, - &tsep,&tt.hour,&tt.minute,&tt.second) < 7) - goto FAIL; - - if(tsep != 'T') - goto FAIL; - } - } - - return tt; - -FAIL: - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return icaltime_null_time(); -} - - -/* Returns whether the specified year is a leap year. Year is the normal year, - e.g. 2001. */ -int -icaltime_is_leap_year (const int year) -{ - - if (year <= 1752) - return (year % 4 == 0); - else - return ( (year % 4==0) && (year % 100 !=0 )) || (year % 400 == 0); -} - - -int -ycaltime_days_in_year (const int year) -{ - if (icaltime_is_leap_year (year)) - return 366; - else return 365; -} - -static int _days_in_month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; - -int icaltime_days_in_month(const int month, const int year) -{ - - int days = _days_in_month[month]; - -/* The old code aborting if it was passed a parameter like BYMONTH=0 - * Unfortunately it's not practical right now to pass an error all - * the way up the stack, so instead of aborting we're going to apply - * the GIGO principle and simply return '30 days' if we get an - * invalid month. Modern applications cannot tolerate crashing. - * assert(month > 0); - * assert(month <= 12); - */ - if ((month < 1) || (month > 12)) { - return 30; - } - - if( month == 2){ - days += icaltime_is_leap_year(year); - } - - return days; -} - -/* 1-> Sunday, 7->Saturday */ -int icaltime_day_of_week(const struct icaltimetype t){ - UTinstant jt; - - memset(&jt,0,sizeof(UTinstant)); - - jt.year = t.year; - jt.month = t.month; - jt.day = t.day; - jt.i_hour = 0; - jt.i_minute = 0; - jt.i_second = 0; - - juldat(&jt); - - return jt.weekday + 1; -} - -/** Day of the year that the first day of the week (Sunday) is on. - */ -int icaltime_start_doy_week(const struct icaltimetype t, int fdow){ - UTinstant jt; - int delta; - - memset(&jt,0,sizeof(UTinstant)); - - jt.year = t.year; - jt.month = t.month; - jt.day = t.day; - jt.i_hour = 0; - jt.i_minute = 0; - jt.i_second = 0; - - juldat(&jt); - caldat(&jt); - - delta = jt.weekday - (fdow - 1); - if (delta < 0) delta += 7; - return jt.day_of_year - delta; -} - -/** Day of the year that the first day of the week (Sunday) is on. - * - * @deprecated Doesn't take into account different week start days. - */ -int icaltime_start_doy_of_week(const struct icaltimetype t){ - -#ifndef NO_WARN_DEPRECATED - icalerror_warn("icaltime_start_doy_of_week() is DEPRECATED, use\ - icaltime_start_doy_week() instead"); -#endif - - return icaltime_start_doy_week(t, 1); -} - -/** - * @todo Doesn't take into account the start day of the - * week. strftime assumes that weeks start on Monday. - */ -int icaltime_week_number(const struct icaltimetype ictt) -{ - UTinstant jt; - - memset(&jt,0,sizeof(UTinstant)); - - jt.year = ictt.year; - jt.month = ictt.month; - jt.day = ictt.day; - jt.i_hour = 0; - jt.i_minute = 0; - jt.i_second = 0; - - juldat(&jt); - caldat(&jt); - - return (jt.day_of_year - jt.weekday) / 7; -} - -/* The first array is for non-leap years, the second for leap years*/ -static const int days_in_year_passed_month[2][13] = -{ /* jan feb mar apr may jun jul aug sep oct nov dec */ - { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 }, - { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } -}; - -/** - * Returns the day of the year, counting from 1 (Jan 1st). - */ -int icaltime_day_of_year(const struct icaltimetype t){ - int is_leap = icaltime_is_leap_year (t.year); - - return days_in_year_passed_month[is_leap][t.month - 1] + t.day; -} - -/** @brief Contructor. - * - * Create a new time, given a day of year and a year. - */ -/* Jan 1 is day #1, not 0 */ -struct icaltimetype icaltime_from_day_of_year(const int _doy, const int _year) -{ - struct icaltimetype tt = icaltime_null_date(); - int is_leap; - int month; - int doy = _doy; - int year = _year; - - is_leap = icaltime_is_leap_year(year); - - /* Zero and neg numbers represent days of the previous year */ - if(doy <1){ - year--; - is_leap = icaltime_is_leap_year(year); - doy += days_in_year_passed_month[is_leap][12]; - } else if(doy > days_in_year_passed_month[is_leap][12]){ - /* Move on to the next year*/ - is_leap = icaltime_is_leap_year(year); - doy -= days_in_year_passed_month[is_leap][12]; - year++; - } - - tt.year = year; - - for (month = 11; month >= 0; month--) { - if (doy > days_in_year_passed_month[is_leap][month]) { - tt.month = month + 1; - tt.day = doy - days_in_year_passed_month[is_leap][month]; - break; - } - } - - return tt; -} - -/** @brief Constructor. - * - * Return a null time, which indicates no time has been set. - * This time represents the beginning of the epoch. - */ -struct icaltimetype icaltime_null_time(void) -{ - struct icaltimetype t; - memset(&t,0,sizeof(struct icaltimetype)); - - return t; -} - -/** @brief Constructor. - * - * Return a null date, which indicates no time has been set. - */ -struct icaltimetype icaltime_null_date(void) -{ - struct icaltimetype t; - memset(&t,0,sizeof(struct icaltimetype)); - - t.is_date = 1; - - /* - * Init to -1 to match what icalyacc.y used to do. - * Does anything depend on this? - */ - t.hour = -1; - t.minute = -1; - t.second = -1; - - return t; -} - - -/** - * Returns false if the time is clearly invalid, but is not null. This - * is usually the result of creating a new time type buy not clearing - * it, or setting one of the flags to an illegal value. - */ -int icaltime_is_valid_time(const struct icaltimetype t){ - if(t.is_utc > 1 || t.is_utc < 0 || - t.year < 0 || t.year > 3000 || - t.is_date > 1 || t.is_date < 0){ - return 0; - } else { - return 1; - } - -} - -/** @brief Returns true if time is a DATE - */ -int icaltime_is_date(const struct icaltimetype t) { - - return t.is_date; -} - -/** @brief Returns true if time is relative to UTC zone - * - * @todo We should only check the zone - */ -int icaltime_is_utc(const struct icaltimetype t) { - - return t.is_utc; -} - -/** - * Return true if the time is null. - */ -int icaltime_is_null_time(const struct icaltimetype t) -{ - if (t.second +t.minute+t.hour+t.day+t.month+t.year == 0){ - return 1; - } - - return 0; - -} - -/** - * Return -1, 0, or 1 to indicate that ab. - * This calls icaltime_compare function after converting them to the utc - * timezone. - */ - -int icaltime_compare(const struct icaltimetype a_in, const struct icaltimetype b_in) -{ - struct icaltimetype a, b; - - a = icaltime_convert_to_zone(a_in, icaltimezone_get_utc_timezone()); - b = icaltime_convert_to_zone(b_in, icaltimezone_get_utc_timezone()); - - if (a.year > b.year) - return 1; - else if (a.year < b.year) - return -1; - - else if (a.month > b.month) - return 1; - else if (a.month < b.month) - return -1; - - else if (a.day > b.day) - return 1; - else if (a.day < b.day) - return -1; - - /* if both are dates, we are done */ - if (a.is_date && b.is_date) - return 0; - - /* else, if only one is a date (and we already know the date part is equal), - then the other is greater */ - else if (b.is_date) - return 1; - else if (a.is_date) - return -1; - - else if (a.hour > b.hour) - return 1; - else if (a.hour < b.hour) - return -1; - - else if (a.minute > b.minute) - return 1; - else if (a.minute < b.minute) - return -1; - - else if (a.second > b.second) - return 1; - else if (a.second < b.second) - return -1; - - return 0; -} - -/** - * like icaltime_compare, but only use the date parts. - */ - -int -icaltime_compare_date_only(const struct icaltimetype a_in, const struct icaltimetype b_in) -{ - struct icaltimetype a, b; - icaltimezone *tz = icaltimezone_get_utc_timezone(); - - a = icaltime_convert_to_zone(a_in, tz); - b = icaltime_convert_to_zone(b_in, tz); - - if (a.year > b.year) - return 1; - else if (a.year < b.year) - return -1; - - if (a.month > b.month) - return 1; - else if (a.month < b.month) - return -1; - - if (a.day > b.day) - return 1; - else if (a.day < b.day) - return -1; - - return 0; -} - -/** - * like icaltime_compare, but only use the date parts; accepts timezone. - */ - -int -icaltime_compare_date_only_tz(const struct icaltimetype a_in, const struct icaltimetype b_in, icaltimezone *tz) -{ - struct icaltimetype a, b; - - a = icaltime_convert_to_zone(a_in, tz); - b = icaltime_convert_to_zone(b_in, tz); - - if (a.year > b.year) - return 1; - else if (a.year < b.year) - return -1; - - if (a.month > b.month) - return 1; - else if (a.month < b.month) - return -1; - - if (a.day > b.day) - return 1; - else if (a.day < b.day) - return -1; - - return 0; -} - -/* These are defined in icalduration.c: -struct icaltimetype icaltime_add(struct icaltimetype t, - struct icaldurationtype d) -struct icaldurationtype icaltime_subtract(struct icaltimetype t1, - struct icaltimetype t2) -*/ - - - -/** @brief Internal, shouldn't be part of the public API - * - * Adds (or subtracts) a time from a icaltimetype. - * NOTE: This function is exactly the same as icaltimezone_adjust_change() - * except for the type of the first parameter. - */ -void -icaltime_adjust(struct icaltimetype *tt, const int days, const int hours, - const int minutes, const int seconds) { - - int second, minute, hour, day; - int minutes_overflow, hours_overflow, days_overflow = 0, years_overflow; - int days_in_month; - - /* If we are passed a date make sure to ignore hour minute and second */ - if (tt->is_date) - goto IS_DATE; - - /* Add on the seconds. */ - second = tt->second + seconds; - tt->second = second % 60; - minutes_overflow = second / 60; - if (tt->second < 0) { - tt->second += 60; - minutes_overflow--; - } - - /* Add on the minutes. */ - minute = tt->minute + minutes + minutes_overflow; - tt->minute = minute % 60; - hours_overflow = minute / 60; - if (tt->minute < 0) { - tt->minute += 60; - hours_overflow--; - } - - /* Add on the hours. */ - hour = tt->hour + hours + hours_overflow; - tt->hour = hour % 24; - days_overflow = hour / 24; - if (tt->hour < 0) { - tt->hour += 24; - days_overflow--; - } - -IS_DATE: - /* Normalize the month. We do this before handling the day since we may - need to know what month it is to get the number of days in it. - Note that months are 1 to 12, so we have to be a bit careful. */ - if (tt->month >= 13) { - years_overflow = (tt->month - 1) / 12; - tt->year += years_overflow; - tt->month -= years_overflow * 12; - } else if (tt->month <= 0) { - /* 0 to -11 is -1 year out, -12 to -23 is -2 years. */ - years_overflow = (tt->month / 12) - 1; - tt->year += years_overflow; - tt->month -= years_overflow * 12; - } - - /* Add on the days. */ - day = tt->day + days + days_overflow; - if (day > 0) { - for (;;) { - days_in_month = icaltime_days_in_month (tt->month, tt->year); - if (day <= days_in_month) - break; - - tt->month++; - if (tt->month >= 13) { - tt->year++; - tt->month = 1; - } - - day -= days_in_month; - } - } else { - while (day <= 0) { - if (tt->month == 1) { - tt->year--; - tt->month = 12; - } else { - tt->month--; - } - - day += icaltime_days_in_month (tt->month, tt->year); - } - } - tt->day = day; -} - -/** @brief Convert time to a given timezone - * - * Convert a time from its native timezone to a given timezone. - * - * If tt is a date, the returned time is an exact - * copy of the input. If it's a floating time, the returned object - * represents the same time translated to the given timezone. - * Otherwise the time will be converted to the new - * time zone, and its native timezone set to the right timezone. - */ -struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt, - icaltimezone *zone) { - - struct icaltimetype ret = tt; - - /* If it's a date do nothing */ - if (tt.is_date) { - return ret; - } - - if (tt.zone == zone) { - return ret; - } - - /* If it's a floating time we don't want to adjust the time */ - if (tt.zone != NULL) { - icaltimezone_convert_time(&ret, (icaltimezone *)tt.zone, zone); - } - - ret.zone = zone; - if (zone == icaltimezone_get_utc_timezone()) { - ret.is_utc = 1; - } else { - ret.is_utc = 0; - } - - return ret; -} - -const icaltimezone * -icaltime_get_timezone(const struct icaltimetype t) { - - return t.zone; -} - -const char * -icaltime_get_tzid(const struct icaltimetype t) { - - if (t.zone != NULL) { - return icaltimezone_get_tzid((icaltimezone *)t.zone); - } else { - return NULL; - } -} - -/** @brief Set the timezone - * - * Force the icaltime to be interpreted relative to another timezone. - * If you need to do timezone conversion, applying offset adjustments, - * then you should use icaltime_convert_to_timezone instead. - */ -struct icaltimetype -icaltime_set_timezone(struct icaltimetype *t, const icaltimezone *zone) { - - /* If it's a date do nothing */ - if (t->is_date) { - return *t; - } - - if (t->zone == zone) { - return *t; - } - - t->zone = zone; - if (zone == icaltimezone_get_utc_timezone()) { - t->is_utc = 1; - } else { - t->is_utc = 0; - } - - return *t; -} - - -/** - * @brief builds an icaltimespan given a start time, end time and busy value. - * - * @param dtstart The beginning time of the span, can be a date-time - * or just a date. - * @param dtend The end time of the span. - * @param is_busy A boolean value, 0/1. - * @return A span using the supplied values. - * - * returned span contains times specified in UTC. - */ - -icaltime_span icaltime_span_new(struct icaltimetype dtstart, - struct icaltimetype dtend, - int is_busy) -{ - icaltime_span span; - - span.is_busy = is_busy; - - span.start = icaltime_as_timet_with_zone(dtstart, - dtstart.zone ? dtstart.zone : icaltimezone_get_utc_timezone()); - - if (icaltime_is_null_time(dtend)) { - if (!icaltime_is_date(dtstart)) { - /* If dtstart is a DATE-TIME and there is no DTEND nor DURATION - it takes no time */ - span.end = span.start; - return span; - } else { - dtend = dtstart; - } - } - - span.end = icaltime_as_timet_with_zone(dtend, - dtend.zone ? dtend.zone : icaltimezone_get_utc_timezone()); - - if (icaltime_is_date(dtstart)) { - /* no time specified, go until the end of the day..*/ - span.end += 60*60*24 - 1; - } - return span; -} - - -/** @brief Returns true if the two spans overlap - * - * @param s1 1st span to test - * @param s2 2nd span to test - * @return boolean value - * - * The result is calculated by testing if the start time of s1 is contained - * by the s2 span, or if the end time of s1 is contained by the s2 span. - * - * Also returns true if the spans are equal. - * - * Note, this will return false if the spans are adjacent. - */ - -int icaltime_span_overlaps(icaltime_span *s1, - icaltime_span *s2) -{ - /* s1->start in s2 */ - if (s1->start > s2->start && s1->start < s2->end) - return 1; - - /* s1->end in s2 */ - if (s1->end > s2->start && s1->end < s2->end) - return 1; - - /* s2->start in s1 */ - if (s2->start > s1->start && s2->start < s1->end) - return 1; - - /* s2->end in s1 */ - if (s2->end > s1->start && s2->end < s1->end) - return 1; - - if (s1->start == s2->start && s1->end == s2->end) - return 1; - - return 0; -} - -/** @brief Returns true if the span is totally within the containing - * span - * - * @param s The span to test for. - * @param container The span to test against. - * @return boolean value. - * - */ - -int icaltime_span_contains(icaltime_span *s, - icaltime_span *container) -{ - - if ((s->start >= container->start && s->start < container->end) && - (s->end <= container->end && s->end > container->start)) - return 1; - - return 0; -} diff --git a/calendar/libical/src/libical/icaltime.h b/calendar/libical/src/libical/icaltime.h deleted file mode 100644 index 1919a2a5e4..0000000000 --- a/calendar/libical/src/libical/icaltime.h +++ /dev/null @@ -1,287 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icaltime.h - CREATOR: eric 02 June 2000 - - - $Id: icaltime.h,v 1.28 2008-01-15 23:17:42 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Original Code is eric. The Initial Developer of the Original - Code is Eric Busboom - - -======================================================================*/ - -/** @file icaltime.h - * @brief struct icaltimetype is a pseudo-object that abstracts time - * handling. - * - * It can represent either a DATE or a DATE-TIME (floating, UTC or in a - * given timezone), and it keeps track internally of its native timezone. - * - * The typical usage is to call the correct constructor specifying the - * desired timezone. If this is not known until a later time, the - * correct behavior is to specify a NULL timezone and call - * icaltime_convert_to_zone() at a later time. - * - * There are several ways to create a new icaltimetype: - * - * - icaltime_null_time() - * - icaltime_null_date() - * - icaltime_current_time_with_zone() - * - icaltime_today() - * - icaltime_from_timet_with_zone(time_t tm, int is_date, - * icaltimezone *zone) - * - icaltime_from_string_with_zone(const char* str, icaltimezone *zone) - * - icaltime_from_day_of_year(int doy, int year) - * - icaltime_from_week_number(int week_number, int year) - * - * italtimetype objects can be converted to different formats: - * - * - icaltime_as_timet(struct icaltimetype tt) - * - icaltime_as_timet_with_zone(struct icaltimetype tt, - * icaltimezone *zone) - * - icaltime_as_ical_string(struct icaltimetype tt) - * - * Accessor methods include: - * - * - icaltime_get_timezone(struct icaltimetype t) - * - icaltime_get_tzid(struct icaltimetype t) - * - icaltime_set_timezone(struct icaltimetype t, const icaltimezone *zone) - * - icaltime_day_of_year(struct icaltimetype t) - * - icaltime_day_of_week(struct icaltimetype t) - * - icaltime_start_doy_of_week(struct icaltimetype t, int fdow) - * - icaltime_week_number(struct icaltimetype t) - * - * Query methods include: - * - * - icaltime_is_null_time(struct icaltimetype t) - * - icaltime_is_valid_time(struct icaltimetype t) - * - icaltime_is_date(struct icaltimetype t) - * - icaltime_is_utc(struct icaltimetype t) - * - icaltime_is_floating(struct icaltimetype t) - * - * Modify, compare and utility methods include: - * - * - icaltime_add(struct icaltimetype t, struct icaldurationtype d) - * - icaltime_subtract(struct icaltimetype t1, struct icaltimetype t2) - * - icaltime_compare_with_zone(struct icaltimetype a,struct icaltimetype b) - * - icaltime_compare(struct icaltimetype a,struct icaltimetype b) - * - icaltime_compare_date_only(struct icaltimetype a, - * struct icaltimetype b) - * - icaltime_adjust(struct icaltimetype *tt, int days, int hours, - * int minutes, int seconds); - * - icaltime_normalize(struct icaltimetype t); - * - icaltime_convert_to_zone(const struct icaltimetype tt, - * icaltimezone *zone); - */ - -#ifndef ICALTIME_H -#define ICALTIME_H - -#include - -/* An opaque struct representing a timezone. We declare this here to avoid - a circular dependancy. */ -#ifndef ICALTIMEZONE_DEFINED -#define ICALTIMEZONE_DEFINED -typedef struct _icaltimezone icaltimezone; -#endif - -/** icaltime_span is returned by icalcomponent_get_span() */ -struct icaltime_span { - time_t start; /**< in UTC */ - time_t end; /**< in UTC */ - int is_busy; /**< 1->busy time, 0-> free time */ -}; - -typedef struct icaltime_span icaltime_span; - -/* - * FIXME - * - * is_utc is redundant, and might be considered a minor optimization. - * It might be deprecated, so you should use icaltime_is_utc() instead. - */ -struct icaltimetype -{ - int year; /**< Actual year, e.g. 2001. */ - int month; /**< 1 (Jan) to 12 (Dec). */ - int day; - int hour; - int minute; - int second; - - int is_utc; /**< 1-> time is in UTC timezone */ - - int is_date; /**< 1 -> interpret this as date. */ - - int is_daylight; /**< 1 -> time is in daylight savings time. */ - - const icaltimezone *zone; /**< timezone */ -}; - -typedef struct icaltimetype icaltimetype; - -/** Return a null time, which indicates no time has been set. - This time represent the beginning of the epoch */ -struct icaltimetype icaltime_null_time(void); - -/** Return a null date */ -struct icaltimetype icaltime_null_date(void); - -/** Returns the current time in the given timezone, as an icaltimetype. */ -struct icaltimetype icaltime_current_time_with_zone(const icaltimezone *zone); - -/** Returns the current day as an icaltimetype, with is_date set. */ -struct icaltimetype icaltime_today(void); - -/** Convert seconds past UNIX epoch to a timetype*/ -struct icaltimetype icaltime_from_timet(const time_t v, const int is_date); - -/** Convert seconds past UNIX epoch to a timetype, using timezones. */ -struct icaltimetype icaltime_from_timet_with_zone(const time_t tm, - const int is_date, const icaltimezone *zone); - -/** create a time from an ISO format string */ -struct icaltimetype icaltime_from_string(const char* str); - -/** create a time from an ISO format string */ -struct icaltimetype icaltime_from_string_with_zone(const char* str, - const icaltimezone *zone); - -/** Create a new time, given a day of year and a year. */ -struct icaltimetype icaltime_from_day_of_year(const int doy, - const int year); - -/** @brief Contructor (TODO). - * Create a new time from a weeknumber and a year. */ -struct icaltimetype icaltime_from_week_number(const int week_number, - const int year); - -/** Return the time as seconds past the UNIX epoch */ -time_t icaltime_as_timet(const struct icaltimetype); - -/** Return the time as seconds past the UNIX epoch, using timezones. */ -time_t icaltime_as_timet_with_zone(const struct icaltimetype tt, - const icaltimezone *zone); - -/** Return a string represention of the time, in RFC2445 format. */ -const char* icaltime_as_ical_string(const struct icaltimetype tt); -char* icaltime_as_ical_string_r(const struct icaltimetype tt); - -/** @brief Return the timezone */ -const icaltimezone *icaltime_get_timezone(const struct icaltimetype t); - -/** @brief Return the tzid, or NULL for a floating time */ -const char *icaltime_get_tzid(const struct icaltimetype t); - -/** @brief Set the timezone */ -struct icaltimetype icaltime_set_timezone(struct icaltimetype *t, - const icaltimezone *zone); - -/** Return the day of the year of the given time */ -int icaltime_day_of_year(const struct icaltimetype t); - -/** Return the day of the week of the given time. Sunday is 1 */ -int icaltime_day_of_week(const struct icaltimetype t); - -/** Return the day of the year for the Sunday of the week that the - given time is within. */ -int icaltime_start_doy_of_week(const struct icaltimetype t); - -/** Return the day of the year for the first day of the week that the - given time is within. */ -int icaltime_start_doy_week(const struct icaltimetype t, int fdow); - -/** Return the week number for the week the given time is within */ -int icaltime_week_number(const struct icaltimetype t); - -/** Return true of the time is null. */ -int icaltime_is_null_time(const struct icaltimetype t); - -/** Returns false if the time is clearly invalid, but is not null. This - is usually the result of creating a new time type buy not clearing - it, or setting one of the flags to an illegal value. */ -int icaltime_is_valid_time(const struct icaltimetype t); - -/** @brief Returns true if time is of DATE type, false if DATE-TIME */ -int icaltime_is_date(const struct icaltimetype t); - -/** @brief Returns true if time is relative to UTC zone */ -int icaltime_is_utc(const struct icaltimetype t); - -/** @brief Returns true if time is a floating time */ -int icaltime_is_floating(const struct icaltimetype t); - -/** Return -1, 0, or 1 to indicate that ab */ -int icaltime_compare_with_zone(const struct icaltimetype a, - const struct icaltimetype b); - -/** Return -1, 0, or 1 to indicate that ab */ -int icaltime_compare(const struct icaltimetype a, - const struct icaltimetype b); - -/** like icaltime_compare, but only use the date parts. */ -int icaltime_compare_date_only(const struct icaltimetype a, - const struct icaltimetype b); - -/** like icaltime_compare, but only use the date parts. */ -int icaltime_compare_date_only_tz(const struct icaltimetype a, - const struct icaltimetype b, icaltimezone *tz); - -/** Adds or subtracts a number of days, hours, minutes and seconds. */ -void icaltime_adjust(struct icaltimetype *tt, const int days, - const int hours, const int minutes, const int seconds); - -/** Normalize the icaltime, so that all fields are within the normal range. */ -struct icaltimetype icaltime_normalize(const struct icaltimetype t); - -/** convert tt, of timezone tzid, into a utc time. Does nothing if the - time is already UTC. */ -struct icaltimetype icaltime_convert_to_zone(const struct icaltimetype tt, - icaltimezone *zone); - -/** Return the number of days in the given month */ -int icaltime_days_in_month(const int month, const int year); - -/** Return whether you've specified a leapyear or not. */ -int icaltime_is_leap_year (const int year); - -/** Return the number of days in this year */ -int icaltime_days_in_year (const int year); - -/** @brief calculate an icaltimespan given a start and end time. */ -struct icaltime_span icaltime_span_new(struct icaltimetype dtstart, - struct icaltimetype dtend, - int is_busy); - -/** @brief Returns true if the two spans overlap **/ -int icaltime_span_overlaps(icaltime_span *s1, - icaltime_span *s2); - -/** @brief Returns true if the span is totally within the containing - * span - */ -int icaltime_span_contains(icaltime_span *s, - icaltime_span *container); - - -#endif /* !ICALTIME_H */ - - diff --git a/calendar/libical/src/libical/icaltimezone.c b/calendar/libical/src/libical/icaltimezone.c deleted file mode 100644 index 9a79971059..0000000000 --- a/calendar/libical/src/libical/icaltimezone.c +++ /dev/null @@ -1,2032 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/*====================================================================== - FILE: icaltimezone.c - CREATOR: Damon Chaplin 15 March 2001 - - $Id: icaltimezone.c,v 1.44 2008-02-03 16:10:46 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2001, Damon Chaplin - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - -======================================================================*/ - -/** @file icaltimezone.c - * @brief implementation of timezone handling routines - **/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include -#include -#include -#include - -#include "icalproperty.h" -#include "icalarray.h" -#include "icalerror.h" -#include "icalparser.h" -#include "icaltimezone.h" -#include "icaltimezoneimpl.h" -#ifndef NO_ZONES_TAB -#include "icaltz-util.h" -#endif - -#include - -#ifdef WIN32 -#include -#include -/* Undef the similar macro from pthread.h, it doesn't check if - * gmtime() returns NULL. - */ -#undef gmtime_r - -/* The gmtime() in Microsoft's C library is MT-safe */ -#define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0) - -// MSVC lacks the POSIX macro S_ISDIR, however it's a trivial one: -#ifndef S_ISDIR -#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) -#endif -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -/** This is the toplevel directory where the timezone data is installed in. */ -#define ZONEINFO_DIRECTORY PACKAGE_DATA_DIR "/zoneinfo" - -/** The prefix we use to uniquely identify TZIDs. - It must begin and end with forward slashes. - */ -const char *ical_tzid_prefix = "/freeassociation.sourceforge.net/"; - -/** This is the filename of the file containing the city names and - coordinates of all the builtin timezones. */ -#define ZONES_TAB_FILENAME "zones.tab" - -/** This is the number of years of extra coverage we do when expanding - the timezone changes. */ -#define ICALTIMEZONE_EXTRA_COVERAGE 5 - -/** This is the maximum year we will expand to. time_t values only go up to - somewhere around 2037. */ -#define ICALTIMEZONE_MAX_YEAR 2035 - -typedef struct _icaltimezonechange icaltimezonechange; - -struct _icaltimezonechange { - int utc_offset; - /**< The offset to add to UTC to get local time, in seconds. */ - - int prev_utc_offset; - /**< The offset to add to UTC, before this change, in seconds. */ - - int year; /**< Actual year, e.g. 2001. */ - int month; /**< 1 (Jan) to 12 (Dec). */ - int day; - int hour; - int minute; - int second; - /**< The time that the change came into effect, in UTC. - Note that the prev_utc_offset applies to this local time, - since we haven't changed to the new offset yet. */ - - int is_daylight; - /**< Whether this is STANDARD or DAYLIGHT time. */ -}; - - -/** An array of icaltimezones for the builtin timezones. */ -static icalarray *s_builtin_timezones = NULL; - -/** This is the special UTC timezone, which isn't in s_builtin_timezones. */ -static icaltimezone utc_timezone = { (char *) "UTC", NULL, NULL, 0.0, 0.0, NULL, NULL, 0, NULL }; - -static char* zone_files_directory = NULL; - -static void icaltimezone_reset (icaltimezone *zone); -static char* icaltimezone_get_location_from_vtimezone (icalcomponent *component); -static char* icaltimezone_get_tznames_from_vtimezone (icalcomponent *component); -static void icaltimezone_expand_changes (icaltimezone *zone, - int end_year); -static void icaltimezone_expand_vtimezone (icalcomponent *comp, - int end_year, - icalarray *changes); -static int icaltimezone_compare_change_fn (const void *elem1, - const void *elem2); - -static int icaltimezone_find_nearby_change (icaltimezone *zone, - icaltimezonechange *change); - -static void icaltimezone_adjust_change (icaltimezonechange *tt, - int days, - int hours, - int minutes, - int seconds); - -static void icaltimezone_init (icaltimezone *zone); - -/** Gets the TZID, LOCATION/X-LIC-LOCATION, and TZNAME properties from the - VTIMEZONE component and places them in the icaltimezone. It returns 1 on - success, or 0 if the TZID can't be found. */ -static int icaltimezone_get_vtimezone_properties (icaltimezone *zone, - icalcomponent *component); - - -static void icaltimezone_load_builtin_timezone (icaltimezone *zone); - -static void icaltimezone_ensure_coverage (icaltimezone *zone, - int end_year); - - -static void icaltimezone_parse_zone_tab (void); - -#ifdef USE_BUILTIN_TZDATA -static char* icaltimezone_load_get_line_fn (char *s, - size_t size, - void *data); -#endif - -static void format_utc_offset (int utc_offset, - char *buffer, size_t buffer_size); -static const char* get_zone_directory(void); - -/** Creates a new icaltimezone. */ -icaltimezone* -icaltimezone_new (void) -{ - icaltimezone *zone; - - zone = (icaltimezone*) malloc (sizeof (icaltimezone)); - if (!zone) { - icalerror_set_errno (ICAL_NEWFAILED_ERROR); - return NULL; - } - - icaltimezone_init (zone); - - return zone; -} - -icaltimezone * -icaltimezone_copy (icaltimezone *originalzone) -{ - icaltimezone *zone; - - zone = (icaltimezone*) malloc (sizeof (icaltimezone)); - if (!zone) { - icalerror_set_errno (ICAL_NEWFAILED_ERROR); - return NULL; - } - - memcpy (zone, originalzone, sizeof (icaltimezone)); - if (zone->tzid != NULL) - zone->tzid = strdup (zone->tzid); - if (zone->location != NULL) - zone->location = strdup (zone->location); - if (zone->tznames != NULL) - zone->tznames = strdup (zone->tznames); - if (zone->changes != NULL) - zone->changes = icalarray_copy(zone->changes); - - /* Let the caller set the component because then they will - know to be careful not to free this reference twice. */ - zone->component = NULL; - - return zone; -} - -/** Frees all memory used for the icaltimezone. */ -void -icaltimezone_free (icaltimezone *zone, - int free_struct) -{ - icaltimezone_reset (zone); - if (free_struct) - free (zone); -} - - -/** Resets the icaltimezone to the initial state, freeing most of the fields. */ -static void -icaltimezone_reset (icaltimezone *zone) -{ - if (zone->tzid) - free (zone->tzid); - if (zone->location) - free (zone->location); - if (zone->tznames) - free (zone->tznames); - if (zone->component) - icalcomponent_free (zone->component); - if (zone->changes) - icalarray_free (zone->changes); - - icaltimezone_init (zone); -} - - -/** Initializes an icaltimezone. */ -static void -icaltimezone_init (icaltimezone *zone) -{ - zone->tzid = NULL; - zone->location = NULL; - zone->tznames = NULL; - zone->latitude = 0.0; - zone->longitude = 0.0; - zone->component = NULL; - zone->builtin_timezone = NULL; - zone->end_year = 0; - zone->changes = NULL; -} - - -/** Gets the TZID, LOCATION/X-LIC-LOCATION and TZNAME properties of - the VTIMEZONE component and stores them in the icaltimezone. It - returns 1 on success, or 0 if the TZID can't be found. Note that - it expects the zone to be initialized or reset - it doesn't free - any old values. */ -static int -icaltimezone_get_vtimezone_properties (icaltimezone *zone, - icalcomponent *component) -{ - icalproperty *prop; - const char *tzid, *tzname; - - prop = icalcomponent_get_first_property (component, ICAL_TZID_PROPERTY); - if (!prop) - return 0; - - /* A VTIMEZONE MUST have a TZID, or a lot of our code won't work. */ - tzid = icalproperty_get_tzid (prop); - if (!tzid) - return 0; - - prop = icalcomponent_get_first_property (component, ICAL_TZNAME_PROPERTY); - if (prop) { - tzname = icalproperty_get_tzname (prop); - zone->tznames = strdup(tzname); - } else - zone->tznames = NULL; - - zone->tzid = strdup (tzid); - zone->component = component; - if ( zone->location != 0 ) free ( zone->location ); - zone->location = icaltimezone_get_location_from_vtimezone (component); - zone->tznames = icaltimezone_get_tznames_from_vtimezone (component); - - return 1; -} - -/** Gets the LOCATION or X-LIC-LOCATION property from a VTIMEZONE. */ -static char* -icaltimezone_get_location_from_vtimezone (icalcomponent *component) -{ - icalproperty *prop; - const char *location; - const char *name; - - prop = icalcomponent_get_first_property (component, - ICAL_LOCATION_PROPERTY); - if (prop) { - location = icalproperty_get_location (prop); - if (location) - return strdup (location); - } - - prop = icalcomponent_get_first_property (component, ICAL_X_PROPERTY); - while (prop) { - name = icalproperty_get_x_name (prop); - if (name && !strcasecmp (name, "X-LIC-LOCATION")) { - location = icalproperty_get_x (prop); - if (location) - return strdup (location); - } - prop = icalcomponent_get_next_property (component, - ICAL_X_PROPERTY); - } - - return NULL; -} - - -/** Gets the TZNAMEs used for the last STANDARD & DAYLIGHT components - in a VTIMEZONE. If both STANDARD and DAYLIGHT components use the - same TZNAME, it returns that. If they use different TZNAMEs, it - formats them like "EST/EDT". The returned string should be freed by - the caller. */ -static char* -icaltimezone_get_tznames_from_vtimezone (icalcomponent *component) -{ - icalcomponent *comp; - icalcomponent_kind type; - icalproperty *prop; - struct icaltimetype dtstart; - struct icaldatetimeperiodtype rdate; - const char *current_tzname; - const char *standard_tzname = NULL, *daylight_tzname = NULL; - struct icaltimetype standard_max_date, daylight_max_date; - struct icaltimetype current_max_date; - - standard_max_date = icaltime_null_time(); - daylight_max_date = icaltime_null_time(); - - /* Step through the STANDARD & DAYLIGHT subcomponents. */ - comp = icalcomponent_get_first_component (component, ICAL_ANY_COMPONENT); - while (comp) { - type = icalcomponent_isa (comp); - if (type == ICAL_XSTANDARD_COMPONENT - || type == ICAL_XDAYLIGHT_COMPONENT) { - current_max_date = icaltime_null_time (); - current_tzname = NULL; - - /* Step through the properties. We want to find the TZNAME, and - the largest DTSTART or RDATE. */ - prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY); - while (prop) { - switch (icalproperty_isa (prop)) { - case ICAL_TZNAME_PROPERTY: - current_tzname = icalproperty_get_tzname (prop); - break; - - case ICAL_DTSTART_PROPERTY: - dtstart = icalproperty_get_dtstart (prop); - if (icaltime_compare (dtstart, current_max_date) > 0) - current_max_date = dtstart; - - break; - - case ICAL_RDATE_PROPERTY: - rdate = icalproperty_get_rdate (prop); - if (icaltime_compare (rdate.time, current_max_date) > 0) - current_max_date = rdate.time; - - break; - - default: - break; - } - - prop = icalcomponent_get_next_property (comp, - ICAL_ANY_PROPERTY); - } - - if (current_tzname) { - if (type == ICAL_XSTANDARD_COMPONENT) { - if (!standard_tzname - || icaltime_compare (current_max_date, - standard_max_date) > 0) { - standard_max_date = current_max_date; - standard_tzname = current_tzname; - } - } else { - if (!daylight_tzname - || icaltime_compare (current_max_date, - daylight_max_date) > 0) { - daylight_max_date = current_max_date; - daylight_tzname = current_tzname; - } - } - } - } - - comp = icalcomponent_get_next_component (component, - ICAL_ANY_COMPONENT); - } - - /* Outlook (2000) places "Standard Time" and "Daylight Time" in the TZNAME - strings, which is totally useless. So we return NULL in that case. */ - if (standard_tzname && !strcmp (standard_tzname, "Standard Time")) - return NULL; - - /* If both standard and daylight TZNAMEs were found, if they are the same - we return just one, else we format them like "EST/EDT". */ - if (standard_tzname && daylight_tzname) { - unsigned int standard_len, daylight_len; - char *tznames; - - if (!strcmp (standard_tzname, daylight_tzname)) - return strdup (standard_tzname); - - standard_len = strlen (standard_tzname); - daylight_len = strlen (daylight_tzname); - tznames = malloc (standard_len + daylight_len + 2); - strcpy (tznames, standard_tzname); - tznames[standard_len] = '/'; - strcpy (tznames + standard_len + 1, daylight_tzname); - return tznames; - } else { - const char *tznames; - - /* If either of the TZNAMEs was found just return that, else NULL. */ - tznames = standard_tzname ? standard_tzname : daylight_tzname; - return tznames ? strdup (tznames) : NULL; - } -} - - -static void -icaltimezone_ensure_coverage (icaltimezone *zone, - int end_year) -{ - /* When we expand timezone changes we always expand at least up to this - year, plus ICALTIMEZONE_EXTRA_COVERAGE. */ - static int icaltimezone_minimum_expansion_year = -1; - - int changes_end_year; - - if (!zone->component) - icaltimezone_load_builtin_timezone (zone); - - if (icaltimezone_minimum_expansion_year == -1) { - struct icaltimetype today = icaltime_today(); - icaltimezone_minimum_expansion_year = today.year; - } - - changes_end_year = end_year; - if (changes_end_year < icaltimezone_minimum_expansion_year) - changes_end_year = icaltimezone_minimum_expansion_year; - - changes_end_year += ICALTIMEZONE_EXTRA_COVERAGE; - - if (changes_end_year > ICALTIMEZONE_MAX_YEAR) - changes_end_year = ICALTIMEZONE_MAX_YEAR; - - if (!zone->changes || zone->end_year < end_year) - icaltimezone_expand_changes (zone, changes_end_year); -} - - -static void -icaltimezone_expand_changes (icaltimezone *zone, - int end_year) -{ - icalarray *changes; - icalcomponent *comp; - -#if 0 - printf ("\nExpanding changes for: %s to year: %i\n", zone->tzid, end_year); -#endif - - changes = icalarray_new (sizeof (icaltimezonechange), 32); - if (!changes) - return; - - /* Scan the STANDARD and DAYLIGHT subcomponents. */ - comp = icalcomponent_get_first_component (zone->component, - ICAL_ANY_COMPONENT); - while (comp) { - icaltimezone_expand_vtimezone (comp, end_year, changes); - comp = icalcomponent_get_next_component (zone->component, - ICAL_ANY_COMPONENT); - } - - /* Sort the changes. We may have duplicates but I don't think it will - matter. */ - icalarray_sort (changes, icaltimezone_compare_change_fn); - - if (zone->changes) - icalarray_free (zone->changes); - - zone->changes = changes; - zone->end_year = end_year; -} - - -static void -icaltimezone_expand_vtimezone (icalcomponent *comp, - int end_year, - icalarray *changes) -{ - icaltimezonechange change; - icalproperty *prop; - struct icaltimetype dtstart, occ; - struct icalrecurrencetype rrule; - icalrecur_iterator* rrule_iterator; - struct icaldatetimeperiodtype rdate; - int found_dtstart = 0, found_tzoffsetto = 0, found_tzoffsetfrom = 0; - int has_recurrence = 0; - - /* First we check if it is a STANDARD or DAYLIGHT component, and - just return if it isn't. */ - if (icalcomponent_isa (comp) == ICAL_XSTANDARD_COMPONENT) - change.is_daylight = 0; - else if (icalcomponent_isa (comp) == ICAL_XDAYLIGHT_COMPONENT) - change.is_daylight = 1; - else - return; - - /* Step through each of the properties to find the DTSTART, - TZOFFSETFROM and TZOFFSETTO. We can't expand recurrences here - since we need these properties before we can do that. */ - prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY); - while (prop) { - switch (icalproperty_isa (prop)) { - case ICAL_DTSTART_PROPERTY: - dtstart = icalproperty_get_dtstart (prop); - found_dtstart = 1; - break; - case ICAL_TZOFFSETTO_PROPERTY: - change.utc_offset = icalproperty_get_tzoffsetto (prop); - /*printf ("Found TZOFFSETTO: %i\n", change.utc_offset);*/ - found_tzoffsetto = 1; - break; - case ICAL_TZOFFSETFROM_PROPERTY: - change.prev_utc_offset = icalproperty_get_tzoffsetfrom (prop); - /*printf ("Found TZOFFSETFROM: %i\n", change.prev_utc_offset);*/ - found_tzoffsetfrom = 1; - break; - case ICAL_RDATE_PROPERTY: - case ICAL_RRULE_PROPERTY: - has_recurrence = 1; - break; - default: - /* Just ignore any other properties. */ - break; - } - - prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY); - } - - /* If we didn't find a DTSTART, TZOFFSETTO and TZOFFSETFROM we have to - ignore the component. FIXME: Add an error property? */ - if (!found_dtstart || !found_tzoffsetto || !found_tzoffsetfrom) - return; - -#if 0 - printf ("\n Expanding component DTSTART (Y/M/D): %i/%i/%i %i:%02i:%02i\n", - dtstart.year, dtstart.month, dtstart.day, - dtstart.hour, dtstart.minute, dtstart.second); -#endif - - /* If the STANDARD/DAYLIGHT component has no recurrence data, we just add - a single change for the DTSTART. */ - if (!has_recurrence) { - change.year = dtstart.year; - change.month = dtstart.month; - change.day = dtstart.day; - change.hour = dtstart.hour; - change.minute = dtstart.minute; - change.second = dtstart.second; - - /* Convert to UTC. */ - icaltimezone_adjust_change (&change, 0, 0, 0, -change.prev_utc_offset); - -#if 0 - printf (" Appending single DTSTART (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n", - change.year, change.month, change.day, - change.hour, change.minute, change.second); -#endif - - /* Add the change to the array. */ - icalarray_append (changes, &change); - return; - } - - /* The component has recurrence data, so we expand that now. */ - prop = icalcomponent_get_first_property (comp, ICAL_ANY_PROPERTY); - while (prop) { -#if 0 - printf ("Expanding property...\n"); -#endif - switch (icalproperty_isa (prop)) { - case ICAL_RDATE_PROPERTY: - rdate = icalproperty_get_rdate (prop); - change.year = rdate.time.year; - change.month = rdate.time.month; - change.day = rdate.time.day; - /* RDATEs with a DATE value inherit the time from - the DTSTART. */ - if (icaltime_is_date(rdate.time)) { - change.hour = dtstart.hour; - change.minute = dtstart.minute; - change.second = dtstart.second; - } else { - change.hour = rdate.time.hour; - change.minute = rdate.time.minute; - change.second = rdate.time.second; - - /* The spec was a bit vague about whether RDATEs were in local - time or UTC so we support both to be safe. So if it is in - UTC we have to add the UTC offset to get a local time. */ - if (!icaltime_is_utc(rdate.time)) - icaltimezone_adjust_change (&change, 0, 0, 0, - -change.prev_utc_offset); - } - -#if 0 - printf (" Appending RDATE element (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n", - change.year, change.month, change.day, - change.hour, change.minute, change.second); -#endif - - icalarray_append (changes, &change); - break; - case ICAL_RRULE_PROPERTY: - rrule = icalproperty_get_rrule (prop); - - /* If the rrule UNTIL value is set and is in UTC, we convert it to - a local time, since the recurrence code has no way to convert - it itself. */ - if (!icaltime_is_null_time (rrule.until) && rrule.until.is_utc) { -#if 0 - printf (" Found RRULE UNTIL in UTC.\n"); -#endif - - /* To convert from UTC to a local time, we use the TZOFFSETFROM - since that is the offset from UTC that will be in effect - when each of the RRULE occurrences happens. */ - icaltime_adjust (&rrule.until, 0, 0, 0, - change.prev_utc_offset); - rrule.until.is_utc = 0; - } - - rrule_iterator = icalrecur_iterator_new (rrule, dtstart); - for (;rrule_iterator;) { - occ = icalrecur_iterator_next (rrule_iterator); - if (occ.year > end_year || icaltime_is_null_time (occ)) - break; - - change.year = occ.year; - change.month = occ.month; - change.day = occ.day; - change.hour = occ.hour; - change.minute = occ.minute; - change.second = occ.second; - -#if 0 - printf (" Appending RRULE element (Y/M/D): %i/%02i/%02i %i:%02i:%02i\n", - change.year, change.month, change.day, - change.hour, change.minute, change.second); -#endif - - icaltimezone_adjust_change (&change, 0, 0, 0, - -change.prev_utc_offset); - - icalarray_append (changes, &change); - } - - icalrecur_iterator_free (rrule_iterator); - break; - default: - break; - } - - prop = icalcomponent_get_next_property (comp, ICAL_ANY_PROPERTY); - } -} - - -/** A function to compare 2 icaltimezonechange elements, used for qsort(). */ -static int -icaltimezone_compare_change_fn (const void *elem1, - const void *elem2) -{ - const icaltimezonechange *change1, *change2; - int retval; - - change1 = (const icaltimezonechange *)elem1; - change2 = (const icaltimezonechange *)elem2; - - if (change1->year < change2->year) - retval = -1; - else if (change1->year > change2->year) - retval = 1; - - else if (change1->month < change2->month) - retval = -1; - else if (change1->month > change2->month) - retval = 1; - - else if (change1->day < change2->day) - retval = -1; - else if (change1->day > change2->day) - retval = 1; - - else if (change1->hour < change2->hour) - retval = -1; - else if (change1->hour > change2->hour) - retval = 1; - - else if (change1->minute < change2->minute) - retval = -1; - else if (change1->minute > change2->minute) - retval = 1; - - else if (change1->second < change2->second) - retval = -1; - else if (change1->second > change2->second) - retval = 1; - - else - retval = 0; - - return retval; -} - - - -void -icaltimezone_convert_time (struct icaltimetype *tt, - icaltimezone *from_zone, - icaltimezone *to_zone) -{ - int utc_offset, is_daylight; - - /* If the time is a DATE value or both timezones are the same, or we are - converting a floating time, we don't need to do anything. */ - if (icaltime_is_date(*tt) || from_zone == to_zone || from_zone == NULL) - return; - - /* Convert the time to UTC by getting the UTC offset and subtracting it. */ - utc_offset = icaltimezone_get_utc_offset (from_zone, tt, NULL); - icaltime_adjust (tt, 0, 0, 0, -utc_offset); - - /* Now we convert the time to the new timezone by getting the UTC offset - of our UTC time and adding it. */ - utc_offset = icaltimezone_get_utc_offset_of_utc_time (to_zone, tt, - &is_daylight); - tt->is_daylight = is_daylight; - icaltime_adjust (tt, 0, 0, 0, utc_offset); -} - - - - -/** @deprecated This API wasn't updated when we changed icaltimetype to contain its own - timezone. Also, this takes a pointer instead of the struct. */ -/* Calculates the UTC offset of a given local time in the given - timezone. It is the number of seconds to add to UTC to get local - time. The is_daylight flag is set to 1 if the time is in - daylight-savings time. */ -int -icaltimezone_get_utc_offset (icaltimezone *zone, - struct icaltimetype *tt, - int *is_daylight) -{ - icaltimezonechange *zone_change, *prev_zone_change, tt_change, tmp_change; - int change_num, step, utc_offset_change, cmp; - int change_num_to_use; - int want_daylight; - - if (tt == NULL) - return 0; - - if (is_daylight) - *is_daylight = 0; - - /* For local times and UTC return 0. */ - if (zone == NULL || zone == &utc_timezone) - return 0; - - /* Use the builtin icaltimezone if possible. */ - if (zone->builtin_timezone) - zone = zone->builtin_timezone; - - /* Make sure the changes array is expanded up to the given time. */ - icaltimezone_ensure_coverage (zone, tt->year); - - if (!zone->changes || zone->changes->num_elements == 0) - return 0; - - /* Copy the time parts of the icaltimetype to an icaltimezonechange so we - can use our comparison function on it. */ - tt_change.year = tt->year; - tt_change.month = tt->month; - tt_change.day = tt->day; - tt_change.hour = tt->hour; - tt_change.minute = tt->minute; - tt_change.second = tt->second; - - /* This should find a change close to the time, either the change before - it or the change after it. */ - change_num = icaltimezone_find_nearby_change (zone, &tt_change); - - /* Sanity check. */ - icalerror_assert (change_num >= 0, - "Negative timezone change index"); - icalerror_assert (change_num < zone->changes->num_elements, - "Timezone change index out of bounds"); - - /* Now move backwards or forwards to find the timezone change that applies - to tt. It should only have to do 1 or 2 steps. */ - zone_change = icalarray_element_at (zone->changes, change_num); - step = 1; - change_num_to_use = -1; - for (;;) { - /* Copy the change, so we can adjust it. */ - tmp_change = *zone_change; - - /* If the clock is going backward, check if it is in the region of time - that is used twice. If it is, use the change with the daylight - setting which matches tt, or use standard if we don't know. */ - if (tmp_change.utc_offset < tmp_change.prev_utc_offset) { - /* If the time change is at 2:00AM local time and the clock is - going back to 1:00AM we adjust the change to 1:00AM. We may - have the wrong change but we'll figure that out later. */ - icaltimezone_adjust_change (&tmp_change, 0, 0, 0, - tmp_change.utc_offset); - } else { - icaltimezone_adjust_change (&tmp_change, 0, 0, 0, - tmp_change.prev_utc_offset); - } - - cmp = icaltimezone_compare_change_fn (&tt_change, &tmp_change); - - /* If the given time is on or after this change, then this change may - apply, but we continue as a later change may be the right one. - If the given time is before this change, then if we have already - found a change which applies we can use that, else we need to step - backwards. */ - if (cmp >= 0) - change_num_to_use = change_num; - else - step = -1; - - /* If we are stepping backwards through the changes and we have found - a change that applies, then we know this is the change to use so - we exit the loop. */ - if (step == -1 && change_num_to_use != -1) - break; - - change_num += step; - - /* If we go past the start of the changes array, then we have no data - for this time so we return a UTC offset of 0. */ - if (change_num < 0) - return 0; - - if ((unsigned int)change_num >= zone->changes->num_elements) - break; - - zone_change = icalarray_element_at (zone->changes, change_num); - } - - /* If we didn't find a change to use, then we have a bug! */ - icalerror_assert (change_num_to_use != -1, - "No applicable timezone change found"); - - /* Now we just need to check if the time is in the overlapped region of - time when clocks go back. */ - zone_change = icalarray_element_at (zone->changes, change_num_to_use); - - utc_offset_change = zone_change->utc_offset - zone_change->prev_utc_offset; - if (utc_offset_change < 0 && change_num_to_use > 0) { - tmp_change = *zone_change; - icaltimezone_adjust_change (&tmp_change, 0, 0, 0, - tmp_change.prev_utc_offset); - - if (icaltimezone_compare_change_fn (&tt_change, &tmp_change) < 0) { - /* The time is in the overlapped region, so we may need to use - either the current zone_change or the previous one. If the - time has the is_daylight field set we use the matching change, - else we use the change with standard time. */ - prev_zone_change = icalarray_element_at (zone->changes, - change_num_to_use - 1); - - /* I was going to add an is_daylight flag to struct icaltimetype, - but iCalendar doesn't let us distinguish between standard and - daylight time anyway, so there's no point. So we just use the - standard time instead. */ - want_daylight = (tt->is_daylight == 1) ? 1 : 0; - -#if 0 - if (zone_change->is_daylight == prev_zone_change->is_daylight) - printf (" **** Same is_daylight setting\n"); -#endif - - if (zone_change->is_daylight != want_daylight - && prev_zone_change->is_daylight == want_daylight) - zone_change = prev_zone_change; - } - } - - /* Now we know exactly which timezone change applies to the time, so - we can return the UTC offset and whether it is a daylight time. */ - if (is_daylight) - *is_daylight = zone_change->is_daylight; - return zone_change->utc_offset; -} - - -/** @deprecated This API wasn't updated when we changed icaltimetype to contain its own - timezone. Also, this takes a pointer instead of the struct. */ -/** Calculates the UTC offset of a given UTC time in the given - timezone. It is the number of seconds to add to UTC to get local - time. The is_daylight flag is set to 1 if the time is in - daylight-savings time. */ -int -icaltimezone_get_utc_offset_of_utc_time (icaltimezone *zone, - struct icaltimetype *tt, - int *is_daylight) -{ - icaltimezonechange *zone_change, tt_change, tmp_change; - int change_num, step, change_num_to_use; - - if (is_daylight) - *is_daylight = 0; - - /* For local times and UTC return 0. */ - if (zone == NULL || zone == &utc_timezone) - return 0; - - /* Use the builtin icaltimezone if possible. */ - if (zone->builtin_timezone) - zone = zone->builtin_timezone; - - /* Make sure the changes array is expanded up to the given time. */ - icaltimezone_ensure_coverage (zone, tt->year); - - if (!zone->changes || zone->changes->num_elements == 0) - return 0; - - /* Copy the time parts of the icaltimetype to an icaltimezonechange so we - can use our comparison function on it. */ - tt_change.year = tt->year; - tt_change.month = tt->month; - tt_change.day = tt->day; - tt_change.hour = tt->hour; - tt_change.minute = tt->minute; - tt_change.second = tt->second; - - /* This should find a change close to the time, either the change before - it or the change after it. */ - change_num = icaltimezone_find_nearby_change (zone, &tt_change); - - /* Sanity check. */ - icalerror_assert (change_num >= 0, - "Negative timezone change index"); - icalerror_assert (change_num < zone->changes->num_elements, - "Timezone change index out of bounds"); - - /* Now move backwards or forwards to find the timezone change that applies - to tt. It should only have to do 1 or 2 steps. */ - zone_change = icalarray_element_at (zone->changes, change_num); - step = 1; - change_num_to_use = -1; - for (;;) { - /* Copy the change and adjust it to UTC. */ - tmp_change = *zone_change; - - /* If the given time is on or after this change, then this change may - apply, but we continue as a later change may be the right one. - If the given time is before this change, then if we have already - found a change which applies we can use that, else we need to step - backwards. */ - if (icaltimezone_compare_change_fn (&tt_change, &tmp_change) >= 0) - change_num_to_use = change_num; - else - step = -1; - - /* If we are stepping backwards through the changes and we have found - a change that applies, then we know this is the change to use so - we exit the loop. */ - if (step == -1 && change_num_to_use != -1) - break; - - change_num += step; - - /* If we go past the start of the changes array, then we have no data - for this time so we return a UTC offset of 0. */ - if (change_num < 0) - return 0; - - if ((unsigned int)change_num >= zone->changes->num_elements) - break; - - zone_change = icalarray_element_at (zone->changes, change_num); - } - - /* If we didn't find a change to use, then we have a bug! */ - icalerror_assert (change_num_to_use != -1, - "No applicable timezone change found"); - - /* Now we know exactly which timezone change applies to the time, so - we can return the UTC offset and whether it is a daylight time. */ - zone_change = icalarray_element_at (zone->changes, change_num_to_use); - if (is_daylight) - *is_daylight = zone_change->is_daylight; - - return zone_change->utc_offset; -} - - -/** Returns the index of a timezone change which is close to the time - given in change. */ -static int -icaltimezone_find_nearby_change (icaltimezone *zone, - icaltimezonechange *change) -{ - icaltimezonechange *zone_change; - int lower, upper, middle, cmp; - - /* Do a simple binary search. */ - lower = middle = 0; - upper = zone->changes->num_elements; - - while (lower < upper) { - middle = (lower + upper) / 2; - zone_change = icalarray_element_at (zone->changes, middle); - cmp = icaltimezone_compare_change_fn (change, zone_change); - if (cmp == 0) - break; - else if (cmp < 0) - upper = middle; - else - lower = middle + 1; - } - - return middle; -} - - - - -/** Adds (or subtracts) a time from a icaltimezonechange. NOTE: This - function is exactly the same as icaltime_adjust() except for the - type of the first parameter. */ -static void -icaltimezone_adjust_change (icaltimezonechange *tt, - int days, - int hours, - int minutes, - int seconds) -{ - int second, minute, hour, day; - int minutes_overflow, hours_overflow, days_overflow; - int days_in_month; - - /* Add on the seconds. */ - second = tt->second + seconds; - tt->second = second % 60; - minutes_overflow = second / 60; - if (tt->second < 0) { - tt->second += 60; - minutes_overflow--; - } - - /* Add on the minutes. */ - minute = tt->minute + minutes + minutes_overflow; - tt->minute = minute % 60; - hours_overflow = minute / 60; - if (tt->minute < 0) { - tt->minute += 60; - hours_overflow--; - } - - /* Add on the hours. */ - hour = tt->hour + hours + hours_overflow; - tt->hour = hour % 24; - days_overflow = hour / 24; - if (tt->hour < 0) { - tt->hour += 24; - days_overflow--; - } - - /* Add on the days. */ - day = tt->day + days + days_overflow; - if (day > 0) { - for (;;) { - days_in_month = icaltime_days_in_month (tt->month, tt->year); - if (day <= days_in_month) - break; - - tt->month++; - if (tt->month >= 13) { - tt->year++; - tt->month = 1; - } - - day -= days_in_month; - } - } else { - while (day <= 0) { - if (tt->month == 1) { - tt->year--; - tt->month = 12; - } else { - tt->month--; - } - - day += icaltime_days_in_month (tt->month, tt->year); - } - } - tt->day = day; -} - - -const char* -icaltimezone_get_tzid (icaltimezone *zone) -{ - /* If this is a floating time, without a timezone, return NULL. */ - if (!zone) - return NULL; - - if (!zone->tzid) - icaltimezone_load_builtin_timezone (zone); - - return zone->tzid; -} - - -const char* -icaltimezone_get_location (icaltimezone *zone) -{ - /* If this is a floating time, without a timezone, return NULL. */ - if (!zone) - return NULL; - - /* Note that for builtin timezones this comes from zones.tab so we don't - need to check the timezone is loaded here. */ - return zone->location; -} - - -const char* -icaltimezone_get_tznames (icaltimezone *zone) -{ - /* If this is a floating time, without a timezone, return NULL. */ - if (!zone) - return NULL; - - if (!zone->component) - icaltimezone_load_builtin_timezone (zone); - - return zone->tznames; -} - - -/** Returns the latitude of a builtin timezone. */ -double -icaltimezone_get_latitude (icaltimezone *zone) -{ - /* If this is a floating time, without a timezone, return 0. */ - if (!zone) - return 0.0; - - /* Note that for builtin timezones this comes from zones.tab so we don't - need to check the timezone is loaded here. */ - return zone->latitude; -} - - -/** Returns the longitude of a builtin timezone. */ -double -icaltimezone_get_longitude (icaltimezone *zone) -{ - /* If this is a floating time, without a timezone, return 0. */ - if (!zone) - return 0.0; - - /* Note that for builtin timezones this comes from zones.tab so we don't - need to check the timezone is loaded here. */ - return zone->longitude; -} - - -/** Returns the VTIMEZONE component of a timezone. */ -icalcomponent* -icaltimezone_get_component (icaltimezone *zone) -{ - /* If this is a floating time, without a timezone, return NULL. */ - if (!zone) - return NULL; - - if (!zone->component) - icaltimezone_load_builtin_timezone (zone); - - return zone->component; -} - - -/** Sets the VTIMEZONE component of an icaltimezone, initializing the - tzid, location & tzname fields. It returns 1 on success or 0 on - failure, i.e. no TZID was found. */ -int -icaltimezone_set_component (icaltimezone *zone, - icalcomponent *comp) -{ - icaltimezone_reset (zone); - return icaltimezone_get_vtimezone_properties (zone, comp); -} - - -/* Returns the timezone name to display to the user. We prefer to use the - Olson city name, but fall back on the TZNAME, or finally the TZID. We don't - want to use "" as it may be wrongly interpreted as a floating time. - Do not free the returned string. */ -const char* -icaltimezone_get_display_name (icaltimezone *zone) -{ - const char *display_name; - - display_name = icaltimezone_get_location (zone); - if (!display_name) - display_name = icaltimezone_get_tznames (zone); - if (!display_name) { - display_name = icaltimezone_get_tzid (zone); - /* Outlook will strip out X-LIC-LOCATION property and so all - we get back in the iTIP replies is the TZID. So we see if - this is one of our TZIDs and if so we jump to the city name - at the end of it. */ - if (display_name - && !strncmp (display_name, ical_tzid_prefix, strlen(ical_tzid_prefix))) { - /* Get the location, which is after the 3rd '/' char. */ - const char *p; - int num_slashes = 0; - for (p = display_name; *p; p++) { - if (*p == '/') { - num_slashes++; - if (num_slashes == 3) - return p + 1; - } - } - } - } - - return display_name; -} - -icalarray* -icaltimezone_array_new (void) -{ - return icalarray_new (sizeof (icaltimezone), 16); -} - - -void -icaltimezone_array_append_from_vtimezone (icalarray *timezones, - icalcomponent *child) -{ - icaltimezone zone; - - icaltimezone_init (&zone); - if (icaltimezone_get_vtimezone_properties (&zone, child)) - icalarray_append (timezones, &zone); -} - - -void -icaltimezone_array_free (icalarray *timezones) -{ - icaltimezone *zone; - int i; - - if ( timezones ) - { - for (i = 0; (unsigned int)i < timezones->num_elements; i++) { - zone = icalarray_element_at (timezones, i); - icaltimezone_free (zone, 0); - } - - icalarray_free (timezones); - } -} - - -/* - * BUILTIN TIMEZONE HANDLING - */ - - -/** Returns an icalarray of icaltimezone structs, one for each builtin - timezone. This will load and parse the zones.tab file to get the - timezone names and their coordinates. It will not load the - VTIMEZONE data for any timezones. */ -icalarray* -icaltimezone_get_builtin_timezones (void) -{ -#ifndef NO_ZONES_TAB - if (!s_builtin_timezones) { - icaltimezone_parse_zone_tab (); - } -#endif - return s_builtin_timezones; -} - -/** Release builtin timezone memory */ -void -icaltimezone_free_builtin_timezones(void) -{ - icaltimezone_array_free(s_builtin_timezones); - s_builtin_timezones = 0; -} - - -/** Returns a single builtin timezone, given its Olson city name. */ -icaltimezone* -icaltimezone_get_builtin_timezone (const char *location) -{ -#ifndef NO_ZONES_TAB - icalcomponent *comp; -#endif - icaltimezone *zone; - unsigned int lower; - const char *zone_location; - icalarray * builtin_timezones; - - if (!location || !location[0]) - return NULL; - - if (!strcmp (location, "UTC")) - return &utc_timezone; - - builtin_timezones = icaltimezone_get_builtin_timezones(); - if (!builtin_timezones) { - return NULL; - } - -#if 0 - /* Do a simple binary search. */ - lower = middle = 0; - upper = builtin_timezones->num_elements; - - while (lower < upper) { - middle = (lower + upper) / 2; - zone = icalarray_element_at (builtin_timezones, middle); - zone_location = icaltimezone_get_location (zone); - cmp = strcmp (location, zone_location); - if (cmp == 0) - return zone; - else if (cmp < 0) - upper = middle; - else - lower = middle + 1; - } -#endif - - /* The zones from the system are not stored in alphabetical order, - so we just do a sequential search */ - for (lower = 0; lower < builtin_timezones->num_elements; lower++) { - zone = icalarray_element_at (builtin_timezones, lower); - zone_location = icaltimezone_get_location (zone); - if (strcmp (location, zone_location) == 0) - return zone; - } -#ifndef NO_ZONES_TAB - /* Check whether file exists, but is not mentioned in zone.tab. - It means it's a deprecated timezone, but still available. */ - comp = icaltzutil_fetch_timezone (location); - if (comp) { - icaltimezone tz; - icaltimezone_init (&tz); - if (icaltimezone_set_component (&tz, comp)) { - icalarray_append (builtin_timezones, &tz); - return icalarray_element_at (builtin_timezones, builtin_timezones->num_elements - 1); - } else { - icalcomponent_free (comp); - } - } -#endif - - return NULL; -} - -static struct icaltimetype -tm_to_icaltimetype (struct tm *tm) -{ - struct icaltimetype itt; - - memset (&itt, 0, sizeof (struct icaltimetype)); - - itt.second = tm->tm_sec; - itt.minute = tm->tm_min; - itt.hour = tm->tm_hour; - - itt.day = tm->tm_mday; - itt.month = tm->tm_mon + 1; - itt.year = tm->tm_year+ 1900; - - itt.is_utc = 0; - itt.is_date = 0; - - return itt; -} - -static int -get_offset (icaltimezone *zone) -{ - struct tm local; - struct icaltimetype tt; - int offset; - time_t now = time(NULL); - - gmtime_r ((const time_t *) &now, &local); - tt = tm_to_icaltimetype (&local); - offset = icaltimezone_get_utc_offset(zone, &tt, NULL); - - return offset; -} - -/** Returns a single builtin timezone, given its offset from UTC */ -icaltimezone* -icaltimezone_get_builtin_timezone_from_offset (int offset, const char *tzname) -{ - icaltimezone *zone=NULL; - int count, i; - - icalarray * builtin_timezones; - - if (offset==0) - return &utc_timezone; - - if (!tzname) - return NULL; - - builtin_timezones = icaltimezone_get_builtin_timezones(); - if (!builtin_timezones) { - return NULL; - } - - count = builtin_timezones->num_elements; - - for (i=0; icomponent) - icaltimezone_load_builtin_timezone (zone); - - z_offset = get_offset(zone); - - if (z_offset == offset && zone->tznames && !strcmp(tzname, zone->tznames)) - return zone; - } - - return NULL; -} - -/** Returns a single builtin timezone, given its TZID. */ -icaltimezone* -icaltimezone_get_builtin_timezone_from_tzid (const char *tzid) -{ - int num_slashes = 0; - const char *p, *zone_tzid; - icaltimezone *zone; - - if (!tzid || !tzid[0]) - return NULL; - - /* Check that the TZID starts with our unique prefix. */ - if (strncmp (tzid, ical_tzid_prefix, strlen(ical_tzid_prefix))) - return NULL; - - /* Get the location, which is after the 3rd '/' character. */ - p = tzid; - for (p = tzid; *p; p++) { - if (*p == '/') { - num_slashes++; - if (num_slashes == 3) - break; - } - } - - if (num_slashes != 3) - return NULL; - - p++; - - /* Now we can use the function to get the builtin timezone from the - location string. */ - zone = icaltimezone_get_builtin_timezone (p); - if (!zone) - return NULL; - - /* Check that the builtin TZID matches exactly. We don't want to return - a different version of the VTIMEZONE. */ - zone_tzid = icaltimezone_get_tzid (zone); - if (!strcmp (zone_tzid, tzid)) - return zone; - else - return NULL; -} - - -/** Returns the special UTC timezone. */ -icaltimezone* -icaltimezone_get_utc_timezone (void) -{ - return &utc_timezone; -} - - - -static int -parse_coord (char *coord, - int len, - int *degrees, - int *minutes, - int *seconds) -{ - if (len == 5) - sscanf (coord + 1, "%2d%2d", degrees, minutes); - else if (len == 6) - sscanf (coord + 1, "%3d%2d", degrees, minutes); - else if (len == 7) - sscanf (coord + 1, "%2d%2d%2d", degrees, minutes, seconds); - else if (len == 8) - sscanf (coord + 1, "%3d%2d%2d", degrees, minutes, seconds); - else { - fprintf (stderr, "Invalid coordinate: %s\n", coord); - return 1; - } - - if (coord [0] == '-') - *degrees = -*degrees; - return 0; -} -static int -fetch_lat_long_from_string (const char *str, int *latitude_degrees, int *latitude_minutes, int *latitude_seconds, - int *longitude_degrees, int *longitude_minutes, int *longitude_seconds, char *location) -{ - size_t len; - char *sptr, *lat, *lon, *loc, *temp; - - /* We need to parse the latitude/longitude co-ordinates and location fields */ - sptr = (char *) str; - while (*sptr != '\t') - sptr++; - temp = ++sptr; - while (*sptr != '\t') - sptr++; - len = sptr-temp; - lat = (char *) malloc (len + 1); - lat = strncpy (lat, temp, len); - lat [len] = '\0'; - while (*sptr != '\t') - sptr++; - - loc = ++sptr; - while (!isspace (*sptr)) - sptr++; - len = sptr - loc; - location = strncpy (location, loc, len); - location [len] = '\0'; - -#if defined(sun) && defined(__SVR4) - /* Handle EET, MET and WET in zone_sun.tab. */ - if (!strcmp (location, "Europe/")) { - while (*sptr != '\t') - sptr++; - loc = ++sptr; - while (!isspace (*sptr)) - sptr++; - len = sptr - loc; - location = strncpy (location, loc, len); - location [len] = '\0'; - } -#endif - - lon = lat + 1; - while (*lon != '+' && *lon != '-') - lon++; - - if (parse_coord (lat, lon - lat, latitude_degrees, latitude_minutes, latitude_seconds) == 1 || - parse_coord (lon, strlen (lon), longitude_degrees, longitude_minutes, longitude_seconds) - == 1) { - free(lat); - return 1; - } - - free (lat); - - return 0; -} - -/** This parses the zones.tab file containing the names and locations - of the builtin timezones. It creates the builtin_timezones array - which is an icalarray of icaltimezone structs. It only fills in the - location, latitude and longtude fields; the rest are left - blank. The VTIMEZONE component is loaded later if it is needed. The - timezones in the zones.tab file are sorted by their name, which is - useful for binary searches. */ -static void -icaltimezone_parse_zone_tab (void) -{ -#ifndef NO_ZONES_TAB - char *filename; - FILE *fp; - char buf[1024]; /* Used to store each line of zones.tab as it is read. */ - char location[1024]; /* Stores the city name when parsing buf. */ - unsigned int filename_len; - int latitude_degrees = 0, latitude_minutes = 0, latitude_seconds = 0; - int longitude_degrees = 0, longitude_minutes = 0, longitude_seconds = 0; - icaltimezone zone; - - icalerror_assert (s_builtin_timezones == NULL, - "Parsing zones.tab file multiple times"); - - s_builtin_timezones = icalarray_new (sizeof (icaltimezone), 32); - -#ifndef USE_BUILTIN_TZDATA - filename_len = strlen ((char *) icaltzutil_get_zone_directory()) + strlen (ZONES_TAB_SYSTEM_FILENAME) - + 2; -#else - filename_len = strlen (get_zone_directory()) + strlen (ZONES_TAB_FILENAME) - + 2; -#endif - - filename = (char*) malloc (filename_len); - if (!filename) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } -#ifndef USE_BUILTIN_TZDATA - snprintf (filename, filename_len, "%s/%s", icaltzutil_get_zone_directory (), - ZONES_TAB_SYSTEM_FILENAME); -#else - snprintf (filename, filename_len, "%s/%s", get_zone_directory(), - ZONES_TAB_FILENAME); -#endif - - fp = fopen (filename, "r"); - free (filename); - if (!fp) { - icalerror_set_errno(ICAL_FILE_ERROR); - return; - } - - while (fgets (buf, sizeof(buf), fp)) { - if (*buf == '#') continue; - -#ifdef USE_BUILTIN_TZDATA - /* The format of each line is: "latitude longitude location". */ - if (sscanf (buf, "%4d%2d%2d %4d%2d%2d %s", - &latitude_degrees, &latitude_minutes, - &latitude_seconds, - &longitude_degrees, &longitude_minutes, - &longitude_seconds, - location) != 7) { - fprintf (stderr, "Invalid timezone description line: %s\n", buf); - continue; - } -#else - if (fetch_lat_long_from_string (buf, &latitude_degrees, &latitude_minutes, - &latitude_seconds, - &longitude_degrees, &longitude_minutes, &longitude_seconds, - location)) { - fprintf (stderr, "Invalid timezone description line: %s\n", buf); - continue; - } -#endif - - icaltimezone_init (&zone); - zone.location = strdup (location); - - if (latitude_degrees >= 0) - zone.latitude = (double) latitude_degrees - + (double) latitude_minutes / 60 - + (double) latitude_seconds / 3600; - else - zone.latitude = (double) latitude_degrees - - (double) latitude_minutes / 60 - - (double) latitude_seconds / 3600; - - if (longitude_degrees >= 0) - zone.longitude = (double) longitude_degrees - + (double) longitude_minutes / 60 - + (double) longitude_seconds / 3600; - else - zone.longitude = (double) longitude_degrees - - (double) longitude_minutes / 60 - - (double) longitude_seconds / 3600; - - icalarray_append (s_builtin_timezones, &zone); - -#if 0 - printf ("Found zone: %s %f %f\n", - location, zone.latitude, zone.longitude); -#endif - } - - fclose (fp); -#endif /* NO_ZONES_TAB */ -} - -void -icaltimezone_release_zone_tab (void) -{ - unsigned int i; - icalarray *mybuiltin_timezones = s_builtin_timezones; - if (s_builtin_timezones == NULL) - return; - s_builtin_timezones = NULL; - for (i = 0; i < mybuiltin_timezones->num_elements; i++) - free ( ((icaltimezone*)icalarray_element_at(mybuiltin_timezones, i))->location); - icalarray_free (mybuiltin_timezones); -} - -/** Loads the builtin VTIMEZONE data for the given timezone. */ -static void -icaltimezone_load_builtin_timezone (icaltimezone *zone) -{ -#ifndef NO_ZONES_TAB - icalcomponent *subcomp; - - /* If the location isn't set, it isn't a builtin timezone. */ - if (!zone->location || !zone->location[0]) - return; - -#ifdef USE_BUILTIN_TZDATA - { - char *filename; - icalcomponent *comp; - unsigned int filename_len; - FILE *fp; - icalparser *parser; - - filename_len = strlen (get_zone_directory()) + strlen (zone->location) + 6; - - filename = (char*) malloc (filename_len); - if (!filename) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return; - } - - snprintf (filename, filename_len, "%s/%s.ics", get_zone_directory(), - zone->location); - - fp = fopen (filename, "r"); - free (filename); - if (!fp) { - icalerror_set_errno(ICAL_FILE_ERROR); - return; - } - - - /* ##### B.# Sun, 11 Nov 2001 04:04:29 +1100 - this is where the MALFORMEDDATA error is being set, after the call to 'icalparser_parse' - fprintf(stderr, "** WARNING ** %s: %d %s\n", __FILE__, __LINE__, icalerror_strerror(icalerrno)); - */ - - parser = icalparser_new (); - icalparser_set_gen_data (parser, fp); - comp = icalparser_parse (parser, icaltimezone_load_get_line_fn); - icalparser_free (parser); - fclose (fp); - - /* Find the VTIMEZONE component inside the VCALENDAR. There should be 1. */ - subcomp = icalcomponent_get_first_component (comp, - ICAL_VTIMEZONE_COMPONENT); -#else - subcomp = icaltzutil_fetch_timezone (zone->location); -#endif - - if (!subcomp) { - icalerror_set_errno(ICAL_PARSE_ERROR); - return; - } - - icaltimezone_get_vtimezone_properties (zone, subcomp); - -#ifdef USE_BUILTIN_TZDATA - icalcomponent_remove_component(comp,subcomp); - icalcomponent_free(comp); - } -#endif -#endif /* NO_ZONES_TAB */ -} - - -#ifdef USE_BUILTIN_TZDATA -/** Callback used from icalparser_parse() */ -static char * -icaltimezone_load_get_line_fn (char *s, - size_t size, - void *data) -{ - return fgets (s, (int)size, (FILE*) data); -} -#endif - - - -/* - * DEBUGGING - */ - -/** - * This outputs a list of timezone changes for the given timezone to the - * given file, up to the maximum year given. We compare this output with the - * output from 'vzic --dump-changes' to make sure that we are consistent. - * (vzic is the Olson timezone database to VTIMEZONE converter.) - * - * The output format is: - * - * Zone-Name [tab] Date [tab] Time [tab] UTC-Offset - * - * The Date and Time fields specify the time change in UTC. - * - * The UTC Offset is for local (wall-clock) time. It is the amount of time - * to add to UTC to get local time. - */ -int -icaltimezone_dump_changes (icaltimezone *zone, - int max_year, - FILE *fp) -{ - static const char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - icaltimezonechange *zone_change; - int change_num; - char buffer[8]; - - /* Make sure the changes array is expanded up to the given time. */ - icaltimezone_ensure_coverage (zone, max_year); - -#if 0 - printf ("Num changes: %i\n", zone->changes->num_elements); -#endif - - change_num = 0; - for (change_num = 0; (unsigned int)change_num < zone->changes->num_elements; change_num++) { - zone_change = icalarray_element_at (zone->changes, change_num); - - if (zone_change->year > max_year) - break; - - fprintf (fp, "%s\t%2i %s %04i\t%2i:%02i:%02i", - zone->location, - zone_change->day, months[zone_change->month - 1], - zone_change->year, - zone_change->hour, zone_change->minute, zone_change->second); - - /* Wall Clock Time offset from UTC. */ - format_utc_offset (zone_change->utc_offset, buffer, sizeof(buffer)); - fprintf (fp, "\t%s", buffer); - - fprintf (fp, "\n"); - } - return 1; -} - - -/** This formats a UTC offset as "+HHMM" or "+HHMMSS". - buffer should have space for 8 characters. */ -static void -format_utc_offset (int utc_offset, - char *buffer, size_t buffer_size) -{ - const char *sign = "+"; - int hours, minutes, seconds; - - if (utc_offset < 0) { - utc_offset = -utc_offset; - sign = "-"; - } - - hours = utc_offset / 3600; - minutes = (utc_offset % 3600) / 60; - seconds = utc_offset % 60; - - /* Sanity check. Standard timezone offsets shouldn't be much more than 12 - hours, and daylight saving shouldn't change it by more than a few hours. - (The maximum offset is 15 hours 56 minutes at present.) */ - if (hours < 0 || hours >= 24 || minutes < 0 || minutes >= 60 - || seconds < 0 || seconds >= 60) { - fprintf (stderr, "Warning: Strange timezone offset: H:%i M:%i S:%i\n", - hours, minutes, seconds); - } - - if (seconds == 0) - snprintf (buffer, buffer_size, "%s%02i%02i", sign, hours, minutes); - else - snprintf (buffer, buffer_size, "%s%02i%02i%02i", sign, hours, minutes, seconds); -} - -static const char* get_zone_directory(void) -{ -#ifndef WIN32 - return zone_files_directory == NULL ? ZONEINFO_DIRECTORY : zone_files_directory; -#else - wchar_t wbuffer[1000]; - char buffer[1000], zoneinfodir[1000], dirname[1000]; - int used_default; - static char *cache = NULL; - char *dirslash, *zislash; - struct stat st; - - if (zone_files_directory) - return zone_files_directory; - - if (cache) - return cache; - - /* Get the filename of the application */ - if (!GetModuleFileNameW (NULL, wbuffer, sizeof (wbuffer) / sizeof (wbuffer[0]))) - return ZONEINFO_DIRECTORY; - - /* Convert to system codepage */ - if (!WideCharToMultiByte (CP_ACP, 0, wbuffer, -1, buffer, sizeof (buffer), - NULL, &used_default) || - used_default) { - /* Failed, try 8.3 format */ - if (!GetShortPathNameW (wbuffer, wbuffer, - sizeof (wbuffer) / sizeof (wbuffer[0])) || - !WideCharToMultiByte (CP_ACP, 0, wbuffer, -1, buffer, sizeof (buffer), - NULL, &used_default) || - used_default) - return ZONEINFO_DIRECTORY; - } - /* Look for the zoneinfo directory somewhere in the path where - * the app is installed. If the path to the app is - * - * C:\opt\evo-2.6\bin\evolution-2.6.exe - * - * and the compile-time ZONEINFO_DIRECTORY is - * - * C:/devel/target/evo/share/evolution-data-server-1.6/zoneinfo, - * - * we check the pathnames: - * - * C:\opt\evo-2.6/devel/target/evo/share/evolution-data-server-1.6/zoneinfo - * C:\opt\evo-2.6/target/evo/share/evolution-data-server-1.6/zoneinfo - * C:\opt\evo-2.6/evo/share/evolution-data-server-1.6/zoneinfo - * C:\opt\evo-2.6/share/evolution-data-server-1.6/zoneinfo <=== - * C:\opt\evo-2.6/evolution-data-server-1.6/zoneinfo - * C:\opt\evo-2.6/zoneinfo - * C:\opt/devel/target/evo/share/evolution-data-server-1.6/zoneinfo - * C:\opt/target/evo/share/evolution-data-server-1.6/zoneinfo - * C:\opt/evo/share/evolution-data-server-1.6/zoneinfo - * C:\opt/share/evolution-data-server-1.6/zoneinfo - * C:\opt/evolution-data-server-1.6/zoneinfo - * C:\opt/zoneinfo - * C:/devel/target/evo/share/evolution-data-server-1.6/zoneinfo - * C:/target/evo/share/evolution-data-server-1.6/zoneinfo - * C:/evo/share/evolution-data-server-1.6/zoneinfo - * C:/share/evolution-data-server-1.6/zoneinfo - * C:/evolution-data-server-1.6/zoneinfo - * C:/zoneinfo - * - * In Evolution's case, we would get a match already at the - * fourth pathname check. - */ - - /* Strip away basename of app .exe first */ - dirslash = _mbsrchr (buffer, '\\'); - if (dirslash) - *dirslash = '\0'; - - while ((dirslash = _mbsrchr (buffer, '\\'))) { - /* Strip one more directory from app .exe location */ - *dirslash = '\0'; - - strcpy (zoneinfodir, ZONEINFO_DIRECTORY); - while ((zislash = _mbschr (zoneinfodir, '/'))) { - *zislash = '.'; - strcpy (dirname, buffer); - strcat (dirname, "/"); - strcat (dirname, zislash + 1); - if (stat (dirname, &st) == 0 && - S_ISDIR (st.st_mode)) { - cache = strdup (dirname); - return cache; - } - } - } - return ZONEINFO_DIRECTORY; -#endif -} - -void set_zone_directory(char *path) -{ - if (zone_files_directory) - free_zone_directory(); - zone_files_directory = malloc(strlen(path)+1); - if ( zone_files_directory != NULL ) - { - strcpy(zone_files_directory,path); - } -} - -void free_zone_directory(void) -{ - if ( zone_files_directory != NULL ) - { - free(zone_files_directory); - zone_files_directory = NULL; - } -} - -void icaltimezone_set_tzid_prefix(const char *new_prefix) -{ - if (new_prefix) { - ical_tzid_prefix = new_prefix; - } -} diff --git a/calendar/libical/src/libical/icaltimezone.h b/calendar/libical/src/libical/icaltimezone.h deleted file mode 100644 index 0da233d661..0000000000 --- a/calendar/libical/src/libical/icaltimezone.h +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ -/*====================================================================== - FILE: icaltimezone.h - CREATOR: Damon Chaplin 15 March 2001 - - - $Id: icaltimezone.h,v 1.14 2008-01-15 23:17:42 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2001, Damon Chaplin - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - -======================================================================*/ -/** - * @file icaltimezone.h - * @brief timezone handling routines - */ - -#ifndef ICALTIMEZONE_H -#define ICALTIMEZONE_H - -#include /* For FILE* */ -#include "icaltime.h" -#include "icalarray.h" -#include "icalcomponent.h" - - -#ifndef ICALTIMEZONE_DEFINED -#define ICALTIMEZONE_DEFINED -/** @brief An opaque struct representing a timezone. - * We declare this here to avoid a circular dependancy. - */ -typedef struct _icaltimezone icaltimezone; -#endif - -/** - * @par Creating/Destroying individual icaltimezones. - */ - -/** Creates a new icaltimezone. */ -icaltimezone *icaltimezone_new (void); -icaltimezone *icaltimezone_copy (icaltimezone *originalzone); - -/** Frees all memory used for the icaltimezone. Set free_struct to free the - icaltimezone struct as well. */ -void icaltimezone_free (icaltimezone *zone, - int free_struct); - -/** Sets the prefix to be used for tzid's generated from system tzdata. - Must be globally unique (such as a domain name owned by the developer - of the calling application), and begin and end with forward slashes. - Do not change or de-allocate the string buffer after calling this. - */ -void icaltimezone_set_tzid_prefix(const char *new_prefix); - -/** - * @par Accessing timezones. - */ - -/** Free any builtin timezone information **/ -void icaltimezone_free_builtin_timezones(void); - -/** Returns the array of builtin icaltimezones. */ -icalarray* icaltimezone_get_builtin_timezones (void); - -/** Returns a single builtin timezone, given its Olson city name. */ -icaltimezone* icaltimezone_get_builtin_timezone (const char *location); - -/** Returns a single builtin timezone, given its offset. */ -icaltimezone* icaltimezone_get_builtin_timezone_from_offset (int offset, const char *tzname); - -/** Returns a single builtin timezone, given its TZID. */ -icaltimezone* icaltimezone_get_builtin_timezone_from_tzid (const char *tzid); - -/** Returns the UTC timezone. */ -icaltimezone* icaltimezone_get_utc_timezone (void); - -/** Returns the TZID of a timezone. */ -const char* icaltimezone_get_tzid (icaltimezone *zone); - -/** Returns the city name of a timezone. */ -const char* icaltimezone_get_location (icaltimezone *zone); - -/** Returns the TZNAME properties used in the latest STANDARD and DAYLIGHT - components. If they are the same it will return just one, e.g. "LMT". - If they are different it will format them like "EST/EDT". Note that this - may also return NULL. */ -const char* icaltimezone_get_tznames (icaltimezone *zone); - -/** Returns the latitude of a builtin timezone. */ -double icaltimezone_get_latitude (icaltimezone *zone); - -/** Returns the longitude of a builtin timezone. */ -double icaltimezone_get_longitude (icaltimezone *zone); - -/** Returns the VTIMEZONE component of a timezone. */ -icalcomponent* icaltimezone_get_component (icaltimezone *zone); - -/** Sets the VTIMEZONE component of an icaltimezone, initializing the tzid, - location & tzname fields. It returns 1 on success or 0 on failure, i.e. - no TZID was found. */ -int icaltimezone_set_component (icaltimezone *zone, - icalcomponent *comp); - -const char* icaltimezone_get_display_name (icaltimezone *zone); - -/** - * @par Converting times between timezones. - */ - -void icaltimezone_convert_time (struct icaltimetype *tt, - icaltimezone *from_zone, - icaltimezone *to_zone); - - -/** - * @par Getting offsets from UTC. - */ - -/** Calculates the UTC offset of a given local time in the given - timezone. It is the number of seconds to add to UTC to get local - time. The is_daylight flag is set to 1 if the time is in - daylight-savings time. */ -int icaltimezone_get_utc_offset (icaltimezone *zone, - struct icaltimetype *tt, - int *is_daylight); - -/** Calculates the UTC offset of a given UTC time in the given - timezone. It is the number of seconds to add to UTC to get local - time. The is_daylight flag is set to 1 if the time is in - daylight-savings time. */ -int icaltimezone_get_utc_offset_of_utc_time (icaltimezone *zone, - struct icaltimetype *tt, - int *is_daylight); - - - -/* - * Handling arrays of timezones. Mainly for internal use. - */ -icalarray* icaltimezone_array_new (void); - -void icaltimezone_array_append_from_vtimezone (icalarray *timezones, - icalcomponent *child); -void icaltimezone_array_free (icalarray *timezones); - - -/* - * @par Handling the default location the timezone files - */ - -/** Set the directory to look for the zonefiles */ -void set_zone_directory(char *path); - -/** Free memory dedicated to the zonefile directory */ -void free_zone_directory(void); -void icaltimezone_release_zone_tab(void); - -/* - * @par Debugging Output. - */ - -/** Dumps information about changes in the timezone up to and including - max_year. */ -int icaltimezone_dump_changes (icaltimezone *zone, - int max_year, - FILE *fp); - -#endif /* ICALTIMEZONE_H */ diff --git a/calendar/libical/src/libical/icaltimezoneimpl.h b/calendar/libical/src/libical/icaltimezoneimpl.h deleted file mode 100644 index 354d5bb2be..0000000000 --- a/calendar/libical/src/libical/icaltimezoneimpl.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icaltimezoneimpl.h - CREATOR: glenn 07 March 2010 - - $Id: icalparameterimpl.h,v 1.4 2008-01-15 23:17:40 dothebart Exp $ - $Locker: $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - Contributions from: - - ======================================================================*/ -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifndef ICALTIMEZONE_IMPL -#define ICALTIMEZONE_IMPL - -#include "icaltimezone.h" -#include "icalcomponent.h" -#include "icalarray.h" - -struct _icaltimezone { - char *tzid; - /**< The unique ID of this timezone, - e.g. "/citadel.org/Olson_20010601_1/Africa/Banjul". - This should only be used to identify a VTIMEZONE. It is not - meant to be displayed to the user in any form. */ - - char *location; - /**< The location for the timezone, e.g. "Africa/Accra" for the - Olson database. We look for this in the "LOCATION" or - "X-LIC-LOCATION" properties of the VTIMEZONE component. It - isn't a standard property yet. This will be NULL if no location - is found in the VTIMEZONE. */ - - char *tznames; - /**< This will be set to a combination of the TZNAME properties - from the last STANDARD and DAYLIGHT components in the - VTIMEZONE, e.g. "EST/EDT". If they both use the same TZNAME, - or only one type of component is found, then only one TZNAME - will appear, e.g. "AZOT". If no TZNAME is found this will be - NULL. */ - - double latitude; - double longitude; - /**< The coordinates of the city, in degrees. */ - - icalcomponent *component; - /**< The toplevel VTIMEZONE component loaded from the .ics file for this - timezone. If we need to regenerate the changes data we need this. */ - - icaltimezone *builtin_timezone; - /**< If this is not NULL it points to the builtin icaltimezone - that the above TZID refers to. This icaltimezone should be used - instead when accessing the timezone changes data, so that the - expanded timezone changes data is shared between calendar - components. */ - - int end_year; - /**< This is the last year for which we have expanded the data to. - If we need to calculate a date past this we need to expand the - timezone component data from scratch. */ - - icalarray *changes; - /**< A dynamically-allocated array of time zone changes, sorted by the - time of the change in local time. So we can do fast binary-searches - to convert from local time to UTC. */ -}; - - - -#endif /*ICALTIMEZONE_IMPL*/ diff --git a/calendar/libical/src/libical/icaltypes.c b/calendar/libical/src/libical/icaltypes.c deleted file mode 100644 index 689de0d507..0000000000 --- a/calendar/libical/src/libical/icaltypes.c +++ /dev/null @@ -1,241 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: icaltypes.c - CREATOR: eric 16 May 1999 - - $Id: icaltypes.c,v 1.18 2008-01-15 23:17:42 dothebart Exp $ - $Locker: $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icaltypes.c - - ======================================================================*/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "icaltypes.h" -#include "icalerror.h" -#include "icalmemory.h" -#include /* for malloc and abs() */ -#include /* for errno */ -#include /* for icalmemory_strdup */ -#include - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -#define TEMP_MAX 1024 - -#ifdef HAVE_PTHREAD - #include - static pthread_mutex_t unk_token_mutex = PTHREAD_MUTEX_INITIALIZER; -#endif - -static ical_unknown_token_handling unknownTokenHandling = ICAL_ASSUME_IANA_TOKEN; - -int icaltriggertype_is_null_trigger(struct icaltriggertype tr) -{ - if(icaltime_is_null_time(tr.time) && - icaldurationtype_is_null_duration(tr.duration)){ - return 1; - } - - return 0; -} - -int icaltriggertype_is_bad_trigger(struct icaltriggertype tr) -{ - if(icaldurationtype_is_bad_duration(tr.duration)){ - return 1; - } - - return 0; -} - -struct icaltriggertype icaltriggertype_from_int(const int reltime) -{ - struct icaltriggertype tr; - - tr.time = icaltime_null_time(); - tr.duration = icaldurationtype_from_int(reltime); - - return tr; -} - -struct icaltriggertype icaltriggertype_from_string(const char* str) -{ - - - struct icaltriggertype tr, null_tr; - icalerrorstate es = ICAL_ERROR_DEFAULT; - icalerrorenum e; - - tr.time= icaltime_null_time(); - tr.duration = icaldurationtype_from_int(0); - - null_tr = tr; - - - /* Suppress errors so a failure in icaltime_from_string() does not cause an abort */ - es = icalerror_get_error_state(ICAL_MALFORMEDDATA_ERROR); - if(str == 0) goto error; - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,ICAL_ERROR_NONFATAL); - e = icalerrno; - icalerror_set_errno(ICAL_NO_ERROR); - - tr.time = icaltime_from_string(str); - - if (icaltime_is_null_time(tr.time)){ - - tr.duration = icaldurationtype_from_string(str); - - if (icaldurationtype_is_bad_duration(tr.duration)) goto error; - } - - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); - icalerror_set_errno(e); - return tr; - - error: - icalerror_set_error_state(ICAL_MALFORMEDDATA_ERROR,es); - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return tr; - -} - - -struct icalreqstattype icalreqstattype_from_string(const char* str) -{ - const char *p1,*p2; - struct icalreqstattype stat; - short major=0, minor=0; - - icalerror_check_arg((str != 0),"str"); - - stat.code = ICAL_UNKNOWN_STATUS; - stat.debug = 0; - stat.desc = 0; - - /* Get the status numbers */ - - sscanf(str, "%hd.%hd",&major, &minor); - - if (major <= 0 || minor < 0){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return stat; - } - - stat.code = icalenum_num_to_reqstat(major, minor); - - if (stat.code == ICAL_UNKNOWN_STATUS){ - icalerror_set_errno(ICAL_MALFORMEDDATA_ERROR); - return stat; - } - - - p1 = strchr(str,';'); - - if (p1 == 0){ -/* icalerror_set_errno(ICAL_BADARG_ERROR);*/ - return stat; - } - - /* Just ignore the second clause; it will be taken from inside the library - */ - - - - p2 = strchr(p1+1,';'); - if (p2 != 0 && *p2 != 0){ - stat.debug = icalmemory_tmp_copy(p2 + 1); - } - - return stat; - -} - -const char* icalreqstattype_as_string(struct icalreqstattype stat) -{ - char *buf; - buf = icalreqstattype_as_string_r(stat); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* icalreqstattype_as_string_r(struct icalreqstattype stat) -{ - char *temp; - - icalerror_check_arg_rz((stat.code != ICAL_UNKNOWN_STATUS),"Status"); - - temp = (char*)icalmemory_new_buffer(TEMP_MAX); - - if (stat.desc == 0){ - stat.desc = icalenum_reqstat_desc(stat.code); - } - - if(stat.debug != 0){ - snprintf(temp,TEMP_MAX,"%d.%d;%s;%s", icalenum_reqstat_major(stat.code), - icalenum_reqstat_minor(stat.code), - stat.desc, stat.debug); - - } else { - snprintf(temp,TEMP_MAX,"%d.%d;%s", icalenum_reqstat_major(stat.code), - icalenum_reqstat_minor(stat.code), - stat.desc); - } - - return temp; -} - -ical_unknown_token_handling ical_get_unknown_token_handling_setting(void) -{ - ical_unknown_token_handling myHandling; - -#ifdef HAVE_PTHREAD - pthread_mutex_lock (&unk_token_mutex); -#endif - - myHandling = unknownTokenHandling; - -#ifdef HAVE_PTHREAD - pthread_mutex_unlock (&unk_token_mutex); -#endif - - return myHandling; -} - -void ical_set_unknown_token_handling_setting(ical_unknown_token_handling newSetting) -{ - -#ifdef HAVE_PTHREAD - pthread_mutex_lock (&unk_token_mutex); -#endif - - unknownTokenHandling = newSetting; - -#ifdef HAVE_PTHREAD - pthread_mutex_unlock (&unk_token_mutex); -#endif - -} diff --git a/calendar/libical/src/libical/icaltypes.h b/calendar/libical/src/libical/icaltypes.h deleted file mode 100644 index ed4097d029..0000000000 --- a/calendar/libical/src/libical/icaltypes.h +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icaltypes.h - CREATOR: eric 20 March 1999 - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icaltypes.h - -======================================================================*/ - -#ifndef ICALTYPES_H -#define ICALTYPES_H - -#include -#include "icalenums.h" -#include "icaltime.h" -#include "icalduration.h" -#include "icalperiod.h" - - -struct icalgeotype -{ - double lat; - double lon; -}; - - -struct icaldatetimeperiodtype -{ - struct icaltimetype time; - struct icalperiodtype period; -}; - - -struct icaltriggertype -{ - struct icaltimetype time; - struct icaldurationtype duration; -}; - -struct icaltriggertype icaltriggertype_from_int(const int reltime); -struct icaltriggertype icaltriggertype_from_string(const char* str); - -int icaltriggertype_is_null_trigger(struct icaltriggertype tr); -int icaltriggertype_is_bad_trigger(struct icaltriggertype tr); - -/* struct icalreqstattype. This struct contains two string pointers, -but don't try to free either of them. The "desc" string is a pointer -to a static table inside the library. Don't try to free it. The -"debug" string is a pointer into the string that the called passed -into to icalreqstattype_from_string. Don't try to free it either, and -don't use it after the original string has been freed. - -BTW, you would get that original string from -*icalproperty_get_requeststatus() or icalvalue_get_text(), when -operating on a the value of a request_status property. */ - -struct icalreqstattype { - - icalrequeststatus code; - const char* desc; - const char* debug; -}; - -struct icalreqstattype icalreqstattype_from_string(const char* str); -const char* icalreqstattype_as_string(struct icalreqstattype); -char* icalreqstattype_as_string_r(struct icalreqstattype); - - - -struct icaltimezonephase { - const char* tzname; - int is_stdandard; /* 1 = standard tme, 0 = daylight savings time */ - struct icaltimetype dtstart; - int offsetto; - int tzoffsetfrom; - const char* comment; - struct icaldatetimeperiodtype rdate; - const char* rrule; -}; - - -struct icaltimezonetype { - const char* tzid; - struct icaltimetype last_mod; - const char* tzurl; - - /* Array of phases. The end of the array is a phase with tzname == 0 */ - struct icaltimezonephase *phases; -}; - -void icaltimezonetype_free(struct icaltimezonetype tzt); - -/* ical_unknown_token_handling : - * How should the ICAL library handle components, properties and parameters with - * unknown names? - * FIXME: Currently only affects parameters. Extend to components and properties. - */ -typedef enum ical_unknown_token_handling { - ICAL_ASSUME_IANA_TOKEN = 1, - ICAL_DISCARD_TOKEN = 2, - ICAL_TREAT_AS_ERROR = 3 -} ical_unknown_token_handling; - -ical_unknown_token_handling ical_get_unknown_token_handling_setting(void); -void ical_set_unknown_token_handling_setting(ical_unknown_token_handling newSetting); - -#endif /* !ICALTYPES_H */ diff --git a/calendar/libical/src/libical/icalvalue.c b/calendar/libical/src/libical/icalvalue.c deleted file mode 100644 index 4ece8b795a..0000000000 --- a/calendar/libical/src/libical/icalvalue.c +++ /dev/null @@ -1,1547 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vi:set ts=4 sts=4 sw=4 expandtab : */ -/*====================================================================== - FILE: icalvalue.c - CREATOR: eric 02 May 1999 - - $Id: icalvalue.c,v 1.44 2008-01-15 23:17:43 dothebart Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalvalue.c - - Contributions from: - Graham Davison - - -======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include "icalerror.h" -#include "icalmemory.h" -#include "icalparser.h" -#include "icalenums.h" -#include "icalvalueimpl.h" - -#include /* for malloc */ -#include /* for snprintf */ -#include /* For memset, others */ -#include /* For offsetof() macro */ -#include -#include /* for mktime */ -#include /* for atoi and atof */ -#include /* for SHRT_MAX */ -#include -#include /* for isspace and isdigit */ - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -#if _MAC_OS_ -#include "icalmemory_strdup.h" -#endif - -#define TMP_BUF_SIZE 1024 - -void print_datetime_to_string(char* str, const struct icaltimetype *data); -void print_date_to_string(char* str, const struct icaltimetype *data); -void print_time_to_string(char* str, const struct icaltimetype *data); - - -struct icalvalue_impl* icalvalue_new_impl(icalvalue_kind kind){ - - struct icalvalue_impl* v; - - if (!icalvalue_kind_is_valid(kind)) - return NULL; - - if ( ( v = (struct icalvalue_impl*) - malloc(sizeof(struct icalvalue_impl))) == 0) { - icalerror_set_errno(ICAL_NEWFAILED_ERROR); - return 0; - } - - strcpy(v->id,"val"); - - v->kind = kind; - v->size = 0; - v->parent = 0; - v->x_value = 0; - memset(&(v->data),0,sizeof(v->data)); - - return v; - -} - - - -icalvalue* -icalvalue_new (icalvalue_kind kind) -{ - return (icalvalue*)icalvalue_new_impl(kind); -} - -icalvalue* icalvalue_new_clone(const icalvalue* old) { - struct icalvalue_impl* new; - - new = icalvalue_new_impl(old->kind); - - if (new == 0){ - return 0; - } - - strcpy(new->id, old->id); - new->kind = old->kind; - new->size = old->size; - - switch (new->kind){ - case ICAL_ATTACH_VALUE: - case ICAL_BINARY_VALUE: - { - /* Hmm. We just ref the attach value, which may not be the right - * thing to do. We cannot quite copy the data, anyways, since we - * don't know how long it is. - */ - new->data.v_attach = old->data.v_attach; - if (new->data.v_attach) - icalattach_ref (new->data.v_attach); - - break; - } - case ICAL_QUERY_VALUE: - case ICAL_STRING_VALUE: - case ICAL_TEXT_VALUE: - case ICAL_CALADDRESS_VALUE: - case ICAL_URI_VALUE: - { - if (old->data.v_string != 0) { - new->data.v_string=icalmemory_strdup(old->data.v_string); - - if ( new->data.v_string == 0 ) { - icalvalue_free(new); - return 0; - } - - } - break; - } - case ICAL_RECUR_VALUE: - { - if(old->data.v_recur != 0){ - new->data.v_recur = malloc(sizeof(struct icalrecurrencetype)); - - if(new->data.v_recur == 0){ - icalvalue_free(new); - return 0; - } - - memcpy( new->data.v_recur, old->data.v_recur, - sizeof(struct icalrecurrencetype)); - } - break; - } - - case ICAL_X_VALUE: - { - if (old->x_value != 0) { - new->x_value=icalmemory_strdup(old->x_value); - - if (new->x_value == 0) { - icalvalue_free(new); - return 0; - } - } - - break; - } - - default: - { - /* all of the other types are stored as values, not - pointers, so we can just copy the whole structure. */ - - new->data = old->data; - } - } - - return new; -} - -static char* icalmemory_strdup_and_dequote(const char* str) -{ - const char *p; - char *out = (char *)malloc(sizeof(char) * strlen(str) + 1); - char *pout; - int wroteNull = 0; - - if (out == 0) { - return 0; - } - - pout = out; - - /* Stop the loop when encountering a terminator in the source string - or if a null has been written to the destination. This prevents - reading past the end of the source string if the last character - is a backslash. */ - for (p = str; !wroteNull && *p != 0; p++) { - - if (*p == '\\') { - p++; - switch (*p) { - case 0: - { - wroteNull = 1; //stops iteration so p isn't incremented past the end of str - *pout = '\0'; - break; - } - case 'n': - case 'N': - { - *pout = '\n'; - break; - } - case 't': - case 'T': - { - *pout = '\t'; - break; - } - case 'r': - case 'R': - { - *pout = '\r'; - break; - } - case 'b': - case 'B': - { - *pout = '\b'; - break; - } - case 'f': - case 'F': - { - *pout = '\f'; - break; - } - case ';': - case ',': - case '"': - case '\\': - { - *pout = *p; - break; - } - default: - { - *pout = ' '; - } - } - } else { - *pout = *p; - } - - pout++; - } - - *pout = '\0'; - - return out; -} - - - - /* - * Returns a quoted copy of a string - */ - -static char* icalmemory_strdup_and_quote(const char* unquoted_str) -{ - char *str; - char *str_p; - const char *p; - size_t buf_sz; - - buf_sz = strlen(unquoted_str)+1; - - str_p = str = (char*)icalmemory_new_buffer(buf_sz); - - if (str_p == 0){ - return 0; - } - - for(p=unquoted_str; *p!=0; p++){ - - switch(*p){ - case '\n': { - icalmemory_append_string(&str,&str_p,&buf_sz,"\\n"); - break; - } - - case '\t': { - icalmemory_append_string(&str,&str_p,&buf_sz,"\\t"); - break; - } - case '\r': { - icalmemory_append_string(&str,&str_p,&buf_sz,"\\r"); - break; - } - case '\b': { - icalmemory_append_string(&str,&str_p,&buf_sz,"\\b"); - break; - } - case '\f': { - icalmemory_append_string(&str,&str_p,&buf_sz,"\\f"); - break; - } - - case ';': - case ',': - case '\\':{ - icalmemory_append_char(&str,&str_p,&buf_sz,'\\'); - icalmemory_append_char(&str,&str_p,&buf_sz,*p); - break; - } - - default: { - icalmemory_append_char(&str,&str_p,&buf_sz,*p); - } - } - } - /* Assume the last character is not a '\0' and add one. We could - check *str_p != 0, but that would be an uninitialized memory - read. */ - - - icalmemory_append_char(&str,&str_p,&buf_sz,'\0'); - return str; -} - -/* - * FIXME - * - * This is a bad API, as it forces callers to specify their own X type. - * This function should take care of this by itself. - */ -static -icalvalue* icalvalue_new_enum(icalvalue_kind kind, int x_type, const char* str) -{ - int e = icalproperty_kind_and_string_to_enum(kind, str); - struct icalvalue_impl *value; - - if(e != 0 && icalproperty_enum_belongs_to_property( - icalproperty_value_kind_to_kind(kind),e)) { - - value = icalvalue_new_impl(kind); - value->data.v_enum = e; - } else { - /* Make it an X value */ - value = icalvalue_new_impl(kind); - value->data.v_enum = x_type; - icalvalue_set_x(value,str); - } - - return value; -} - -/** - * Transforms a simple float number string into a double. - * The decimal separator (if any) of the double has to be '.' - * The code is locale *independant* and does *not* change the locale. - * It should be thread safe. - * If you want a code that that does the same job with a decimal separator - * dependant on the current locale, then use strtof() from libc. - */ -int simple_str_to_double(const char* from, - double *result, - char** to) -{ -#define TMP_NUM_SIZE 100 - char *start=NULL, *end=NULL, *cur=(char*)from ; - char tmp_buf[TMP_NUM_SIZE+1] ; /*hack*/ - struct lconv *loc_data = localeconv () ; - int i=0 ; - - /*sanity checks*/ - if (!from || !result) { - return 1 ; - } - - /*skip the white spaces at the beginning*/ - while (cur && isspace (*cur)) - cur++ ; - - start = cur ; - /* - * copy the part that looks like a double into tmp_buf - * so that we can call strtof() on it. - * during the copy, we give ourselves a chance to convert the '.' - * into the decimal separator of the current locale. - */ - while (cur && (isdigit (*cur) || - *cur == '.' || - *cur == '+' || - *cur == '-')){ - ++cur ; - } - end = cur ; - if (end - start + 1> 100) { - /*huh hoh, number is too big. getting out*/ - return 1 ; - } - memset(tmp_buf, 0, TMP_NUM_SIZE+1) ; - i=0 ; - /* - * copy the float number string into tmp_buf, and take - * care to have the (optional) decimal separator be the one - * of the current locale. - */ - for (i=0 ; i < end - from ;++i) { - if (start[i] == '.' - && loc_data - && loc_data->decimal_point - && loc_data->decimal_point[0] - && loc_data->decimal_point[0] != '.') { - /*replace '.' by the digit separator of the current locale*/ - tmp_buf[i] = loc_data->decimal_point[0] ; - } else { - tmp_buf[i] = start[i] ; - } - } - if (to) - *to = end ; - *result = atof(tmp_buf) ; - return 0 ; -} - -icalvalue* icalvalue_new_from_string_with_error(icalvalue_kind kind,const char* str,icalproperty** error) -{ - - struct icalvalue_impl *value = 0; - - icalerror_check_arg_rz(str!=0,"str"); - - if (error != 0){ - *error = 0; - } - - switch (kind){ - - case ICAL_ATTACH_VALUE: - { - icalattach *attach; - - attach = icalattach_new_from_url (str); - if (!attach) - break; - - value = icalvalue_new_attach (attach); - icalattach_unref (attach); - break; - } - - case ICAL_BINARY_VALUE: - { - icalattach *attach; - attach = icalattach_new_from_data (str, 0, 0); - if ( !attach ) - break; - value = icalvalue_new_attach (attach); - icalattach_unref (attach); - break; - } - case ICAL_BOOLEAN_VALUE: - { - /* HACK */ - value = 0; - - if (error != 0){ - char temp[TMP_BUF_SIZE]; - snprintf(temp,sizeof(temp),"%s Values are not implemented", - icalvalue_kind_to_string(kind)); - *error = icalproperty_vanew_xlicerror( - temp, - icalparameter_new_xlicerrortype( - ICAL_XLICERRORTYPE_VALUEPARSEERROR), - 0); - } - break; - } - - - case ICAL_TRANSP_VALUE: - value = icalvalue_new_enum(kind, (int)ICAL_TRANSP_X,str); - break; - case ICAL_METHOD_VALUE: - value = icalvalue_new_enum(kind, (int)ICAL_METHOD_X,str); - break; - case ICAL_STATUS_VALUE: - value = icalvalue_new_enum(kind, (int)ICAL_STATUS_X,str); - break; - case ICAL_ACTION_VALUE: - value = icalvalue_new_enum(kind, (int)ICAL_ACTION_X,str); - break; - - case ICAL_QUERY_VALUE: - value = icalvalue_new_query(str); - break; - - case ICAL_CLASS_VALUE: - value = icalvalue_new_enum(kind, (int)ICAL_CLASS_X,str); - break; - case ICAL_CMD_VALUE: - value = icalvalue_new_enum(kind, ICAL_CMD_X,str); - break; - case ICAL_QUERYLEVEL_VALUE: - value = icalvalue_new_enum(kind, ICAL_QUERYLEVEL_X,str); - break; - case ICAL_CARLEVEL_VALUE: - value = icalvalue_new_enum(kind, ICAL_CARLEVEL_X,str); - break; - - case ICAL_INTEGER_VALUE: - value = icalvalue_new_integer(atoi(str)); - break; - - case ICAL_FLOAT_VALUE: - value = icalvalue_new_float((float)atof(str)); - break; - - case ICAL_UTCOFFSET_VALUE: - { - int t,utcoffset, hours, minutes, seconds; - /* treat the UTCOFSET string a a decimal number, disassemble its digits - and reconstruct it as sections */ - t = strtol(str,0,10); - /* add phantom seconds field */ - if(abs(t)<9999){t *= 100; } - hours = (t/10000); - minutes = (t-hours*10000)/100; - seconds = (t-hours*10000-minutes*100); - utcoffset = hours*3600+minutes*60+seconds; - - value = icalvalue_new_utcoffset(utcoffset); - - break; - } - - case ICAL_TEXT_VALUE: - { - char* dequoted_str = icalmemory_strdup_and_dequote(str); - value = icalvalue_new_text(dequoted_str); - free(dequoted_str); - break; - } - - case ICAL_STRING_VALUE: - value = icalvalue_new_string(str); - break; - - case ICAL_CALADDRESS_VALUE: - value = icalvalue_new_caladdress(str); - break; - - case ICAL_URI_VALUE: - value = icalvalue_new_uri(str); - break; - - case ICAL_GEO_VALUE: - { - char *cur=NULL ; - struct icalgeotype geo = {0.0, 0.0}; - - if (simple_str_to_double (str, &geo.lat, &cur)) { - goto geo_parsing_error ; - } - - /*skip white spaces*/ - while (cur && isspace (*cur)) { - ++cur ; - } - - /*there is a ';' between the latitude and longitude parts*/ - if (!cur || *cur != ';') { - goto geo_parsing_error ; - } - - ++cur ; - if (!cur) - goto geo_parsing_error ; - - /*skip white spaces*/ - while (cur && isspace (*cur)) { - ++cur ; - } - - if (simple_str_to_double (cur, &geo.lon, &cur)) { - goto geo_parsing_error ; - } - value = icalvalue_new_geo (geo) ; - break ; - -geo_parsing_error: - if (error != 0){ - char temp[TMP_BUF_SIZE]; - sprintf(temp, "Could not parse %s as a %s property", - str, icalvalue_kind_to_string(kind)); - *error = icalproperty_vanew_xlicerror( - temp, - icalparameter_new_xlicerrortype( - ICAL_XLICERRORTYPE_VALUEPARSEERROR), - 0); - } - } - break; - - case ICAL_RECUR_VALUE: - { - struct icalrecurrencetype rt; - rt = icalrecurrencetype_from_string(str); - if(rt.freq != ICAL_NO_RECURRENCE){ - value = icalvalue_new_recur(rt); - } - break; - } - - case ICAL_DATE_VALUE: - case ICAL_DATETIME_VALUE: - { - struct icaltimetype tt; - - tt = icaltime_from_string(str); - if(!icaltime_is_null_time(tt)){ - value = icalvalue_new_impl(kind); - value->data.v_time = tt; - - icalvalue_reset_kind(value); - } - break; - } - - case ICAL_DATETIMEPERIOD_VALUE: - { - struct icaltimetype tt; - struct icalperiodtype p; - tt = icaltime_from_string(str); - - if(!icaltime_is_null_time(tt)){ - value = icalvalue_new_datetime(tt); - break; - } - - p = icalperiodtype_from_string(str); - if (!icalperiodtype_is_null_period(p)){ - value = icalvalue_new_period(p); - } - - break; - } - - case ICAL_DURATION_VALUE: - { - struct icaldurationtype dur = icaldurationtype_from_string(str); - - if (!icaldurationtype_is_bad_duration(dur)) { /* failed to parse */ - value = icalvalue_new_duration(dur); - } - - break; - } - - case ICAL_PERIOD_VALUE: - { - struct icalperiodtype p; - p = icalperiodtype_from_string(str); - - if(!icalperiodtype_is_null_period(p)){ - value = icalvalue_new_period(p); - } - break; - } - - case ICAL_TRIGGER_VALUE: - { - struct icaltriggertype tr = icaltriggertype_from_string(str); - if (!icaltriggertype_is_bad_trigger(tr)) { - value = icalvalue_new_trigger(tr); - } - break; - } - - case ICAL_REQUESTSTATUS_VALUE: - { - struct icalreqstattype rst = icalreqstattype_from_string(str); - if(rst.code != ICAL_UNKNOWN_STATUS){ - value = icalvalue_new_requeststatus(rst); - } - break; - - } - - case ICAL_X_VALUE: - { - char* dequoted_str = icalmemory_strdup_and_dequote(str); - value = icalvalue_new_x(dequoted_str); - free(dequoted_str); - } - break; - - default: - { - if (error != 0 ){ - char temp[TMP_BUF_SIZE]; - - snprintf(temp,TMP_BUF_SIZE,"Unknown type for \'%s\'",str); - - *error = icalproperty_vanew_xlicerror( - temp, - icalparameter_new_xlicerrortype( - ICAL_XLICERRORTYPE_VALUEPARSEERROR), - 0); - } - - icalerror_warn("icalvalue_new_from_string got an unknown value type"); - value=0; - } - } - - - if (error != 0 && *error == 0 && value == 0){ - char temp[TMP_BUF_SIZE]; - - snprintf(temp,TMP_BUF_SIZE,"Failed to parse value: \'%s\'",str); - - *error = icalproperty_vanew_xlicerror( - temp, - icalparameter_new_xlicerrortype( - ICAL_XLICERRORTYPE_VALUEPARSEERROR), - 0); - } - - - return value; - -} - -icalvalue* icalvalue_new_from_string(icalvalue_kind kind,const char* str) -{ - return icalvalue_new_from_string_with_error(kind,str,(icalproperty**)0); -} - - - -void -icalvalue_free (icalvalue* v) -{ - icalerror_check_arg_rv((v != 0),"value"); - -#ifdef ICAL_FREE_ON_LIST_IS_ERROR - icalerror_assert( (v->parent ==0),"This value is still attached to a property"); - -#else - if(v->parent !=0){ - return; - } -#endif - - if(v->x_value != 0){ - free(v->x_value); - } - - switch (v->kind){ - case ICAL_BINARY_VALUE: - case ICAL_ATTACH_VALUE: { - if (v->data.v_attach) { - icalattach_unref (v->data.v_attach); - v->data.v_attach = NULL; - } - - break; - } - case ICAL_TEXT_VALUE: - case ICAL_CALADDRESS_VALUE: - case ICAL_URI_VALUE: - case ICAL_STRING_VALUE: - case ICAL_QUERY_VALUE: - { - if (v->data.v_string != 0) { - free((void*)v->data.v_string); - v->data.v_string = 0; - } - break; - } - case ICAL_RECUR_VALUE: - { - if(v->data.v_recur != 0){ - free((void*)v->data.v_recur); - v->data.v_recur = 0; - } - break; - } - - default: - { - /* Nothing to do */ - } - } - - v->kind = ICAL_NO_VALUE; - v->size = 0; - v->parent = 0; - memset(&(v->data),0,sizeof(v->data)); - v->id[0] = 'X'; - free(v); -} - -int -icalvalue_is_valid (const icalvalue* value) -{ - if(value == 0){ - return 0; - } - - return 1; -} - -static char* icalvalue_binary_as_ical_string_r(const icalvalue* value) { - - const char* data; - char* str; - icalerror_check_arg_rz( (value!=0),"value"); - - data = icalvalue_get_binary(value); - - str = (char*)icalmemory_new_buffer(60); - snprintf(str, 60,"icalvalue_binary_as_ical_string is not implemented yet"); - - return str; -} - - -#define MAX_INT_DIGITS 12 /* Enough for 2^32 + sign*/ - -static char* icalvalue_int_as_ical_string_r(const icalvalue* value) { - int data; - char* str; - - icalerror_check_arg_rz( (value!=0),"value"); - str = (char*)icalmemory_new_buffer(MAX_INT_DIGITS); - - data = icalvalue_get_integer(value); - - snprintf(str,MAX_INT_DIGITS,"%d",data); - - return str; -} - - -static char* icalvalue_utcoffset_as_ical_string_r(const icalvalue* value) -{ - int data,h,m,s; - char sign; - char* str; - - icalerror_check_arg_rz( (value!=0),"value"); - - str = (char*)icalmemory_new_buffer(9); - data = icalvalue_get_utcoffset(value); - - if (abs(data) == data){ - sign = '+'; - } else { - sign = '-'; - } - - h = data/3600; - m = (data - (h*3600))/ 60; - s = (data - (h*3600) - (m*60)); - - if (s > 0) - snprintf(str,9,"%c%02d%02d%02d",sign,abs(h),abs(m),abs(s)); - else - snprintf(str,9,"%c%02d%02d",sign,abs(h),abs(m)); - - return str; -} - -static char* icalvalue_string_as_ical_string_r(const icalvalue* value) { - - const char* data; - char* str = 0; - icalerror_check_arg_rz( (value!=0),"value"); - data = value->data.v_string; - - str = (char*)icalmemory_new_buffer(strlen(data)+1); - - strcpy(str,data); - - return str; -} - - -static char* icalvalue_recur_as_ical_string_r(const icalvalue* value) -{ - struct icalrecurrencetype *recur = value->data.v_recur; - return icalrecurrencetype_as_string_r(recur); -} - - /* @todo This is not RFC2445 compliant. - * The RFC only allows: - * TSAFE-CHAR = %x20-21 / %x23-2B / %x2D-39 / %x3C-5B / %x5D-7E / NON-US-ASCII - * As such, \t\r\b\f are not allowed, not even escaped - */ - -static char* icalvalue_text_as_ical_string_r(const icalvalue* value) { - return icalmemory_strdup_and_quote(value->data.v_string); -} - - - -static char* -icalvalue_attach_as_ical_string_r(const icalvalue* value) -{ - icalattach *a; - char * str; - - icalerror_check_arg_rz( (value!=0),"value"); - - a = icalvalue_get_attach(value); - - if (icalattach_get_is_url (a)) { - const char *url; - - url = icalattach_get_url (a); - str = icalmemory_new_buffer (strlen (url) + 1); - strcpy (str, url); - return str; - } else { - const char *data = 0; - data = (const char*)icalattach_get_data(a); - str = icalmemory_new_buffer (strlen (data) + 1); - strcpy (str, data); - return str; -} -} - - -static char* icalvalue_duration_as_ical_string_r(const icalvalue* value) { - - struct icaldurationtype data; - - icalerror_check_arg_rz( (value!=0),"value"); - data = icalvalue_get_duration(value); - - return icaldurationtype_as_ical_string_r(data); -} - - - -void print_time_to_string(char* str, const struct icaltimetype *data) -{ - char temp[20]; - str[0] = '\0'; - - if (data != 0) { - if (icaltime_is_utc(*data)){ - snprintf(temp,sizeof(temp),"%02d%02d%02dZ",data->hour,data->minute,data->second); - strncat(str,temp,7); - } else { - snprintf(temp,sizeof(temp),"%02d%02d%02d",data->hour,data->minute,data->second); - strncat(str,temp,6); - } - } -} - - -void print_date_to_string(char* str, const struct icaltimetype *data) -{ - char temp[20]; - str[0] = '\0'; - - if (data != 0) { - snprintf(temp,sizeof(temp),"%04d%02d%02d",data->year,data->month,data->day); - strncat(str,temp,8); - } -} - -static char* icalvalue_date_as_ical_string_r(const icalvalue* value) { - - struct icaltimetype data; - char* str; - icalerror_check_arg_rz( (value!=0),"value"); - data = icalvalue_get_date(value); - - str = (char*)icalmemory_new_buffer(9); - - str[0] = '\0'; - print_date_to_string(str,&data); - - return str; -} - -void print_datetime_to_string(char* str, const struct icaltimetype *data) -{ - char temp[20]; - str[0] = '\0'; - - if (data != 0) { - print_date_to_string(str,data); - if ( !data->is_date ) { - strncat(str,"T",19); - temp[0] = '\0'; - print_time_to_string(temp,data); - strncat(str,temp,19); - } - } -} - - -static char* icalvalue_datetime_as_ical_string_r(const icalvalue* value) { - - struct icaltimetype data; - char* str; - icalvalue_kind kind = icalvalue_isa(value); - - icalerror_check_arg_rz( (value!=0),"value"); - - - if( !(kind == ICAL_DATE_VALUE || kind == ICAL_DATETIME_VALUE )) - { - icalerror_set_errno(ICAL_BADARG_ERROR); - return 0; - } - - data = icalvalue_get_datetime(value); - - str = (char*)icalmemory_new_buffer(20); - - str[0] = 0; - print_datetime_to_string(str,&data); - - return str; - -} - -static char* icalvalue_float_as_ical_string_r(const icalvalue* value) { - - float data; - char* str; - char* old_locale; - icalerror_check_arg_rz( (value!=0),"value"); - data = icalvalue_get_float(value); - - /* bypass current locale in order to make - sure snprintf uses a '.' as a separator - set locate to 'C' and keep old locale */ - old_locale = strdup (setlocale (LC_NUMERIC,NULL)); - setlocale (LC_NUMERIC,"C"); - - str = (char*)icalmemory_new_buffer(40); - - snprintf(str,40,"%f",data); - - /* restore saved locale */ - setlocale (LC_NUMERIC,old_locale); - free (old_locale); - - return str; -} - - -static char* icalvalue_geo_as_ical_string_r(const icalvalue* value) { - - struct icalgeotype data; - char* str; - char* old_locale; - icalerror_check_arg_rz( (value!=0),"value"); - - data = icalvalue_get_geo(value); - - /* bypass current locale in order to make - * sure snprintf uses a '.' as a separator - * set locate to 'C' and keep old locale */ - old_locale = strdup (setlocale (LC_NUMERIC,NULL)); - setlocale (LC_NUMERIC,"C"); - - str = (char*)icalmemory_new_buffer(80); - - snprintf(str,80,"%f;%f",data.lat,data.lon); - - /* restore saved locale */ - setlocale (LC_NUMERIC,old_locale); - free (old_locale); - - return str; -} - - -static char* icalvalue_datetimeperiod_as_ical_string_r(const icalvalue* value) { - struct icaldatetimeperiodtype dtp = icalvalue_get_datetimeperiod(value); - - icalerror_check_arg_rz( (value!=0),"value"); - - if(!icaltime_is_null_time(dtp.time)){ - return icaltime_as_ical_string_r(dtp.time); - } else { - return icalperiodtype_as_ical_string_r(dtp.period); - } -} - - -static char* icalvalue_period_as_ical_string_r(const icalvalue* value) { - struct icalperiodtype data; - icalerror_check_arg_rz( (value!=0),"value"); - data = icalvalue_get_period(value); - - return icalperiodtype_as_ical_string_r(data); - -} - - -static char* icalvalue_trigger_as_ical_string_r(const icalvalue* value) { - - struct icaltriggertype data; - - icalerror_check_arg_rz( (value!=0),"value"); - data = icalvalue_get_trigger(value); - - if(!icaltime_is_null_time(data.time)){ - return icaltime_as_ical_string_r(data.time); - } else { - return icaldurationtype_as_ical_string_r(data.duration); - } - -} - -const char* -icalvalue_as_ical_string(const icalvalue* value) -{ - char *buf; - buf = icalvalue_as_ical_string_r(value); - icalmemory_add_tmp_buffer(buf); - return buf; -} - - -char* -icalvalue_as_ical_string_r(const icalvalue* value) -{ - if(value == 0){ - return 0; - } - - switch (value->kind){ - - case ICAL_ATTACH_VALUE: - return icalvalue_attach_as_ical_string_r(value); - - case ICAL_BINARY_VALUE: - return icalvalue_binary_as_ical_string_r(value); - - case ICAL_BOOLEAN_VALUE: - case ICAL_INTEGER_VALUE: - return icalvalue_int_as_ical_string_r(value); - - case ICAL_UTCOFFSET_VALUE: - return icalvalue_utcoffset_as_ical_string_r(value); - - case ICAL_TEXT_VALUE: - return icalvalue_text_as_ical_string_r(value); - - case ICAL_QUERY_VALUE: - return icalvalue_string_as_ical_string_r(value); - - case ICAL_STRING_VALUE: - case ICAL_URI_VALUE: - case ICAL_CALADDRESS_VALUE: - return icalvalue_string_as_ical_string_r(value); - - case ICAL_DATE_VALUE: - return icalvalue_date_as_ical_string_r(value); - case ICAL_DATETIME_VALUE: - return icalvalue_datetime_as_ical_string_r(value); - case ICAL_DURATION_VALUE: - return icalvalue_duration_as_ical_string_r(value); - - case ICAL_PERIOD_VALUE: - return icalvalue_period_as_ical_string_r(value); - case ICAL_DATETIMEPERIOD_VALUE: - return icalvalue_datetimeperiod_as_ical_string_r(value); - - case ICAL_FLOAT_VALUE: - return icalvalue_float_as_ical_string_r(value); - - case ICAL_GEO_VALUE: - return icalvalue_geo_as_ical_string_r(value); - - case ICAL_RECUR_VALUE: - return icalvalue_recur_as_ical_string_r(value); - - case ICAL_TRIGGER_VALUE: - return icalvalue_trigger_as_ical_string_r(value); - - case ICAL_REQUESTSTATUS_VALUE: - return icalreqstattype_as_string_r(value->data.v_requeststatus); - - case ICAL_ACTION_VALUE: - case ICAL_CMD_VALUE: - case ICAL_QUERYLEVEL_VALUE: - case ICAL_CARLEVEL_VALUE: - case ICAL_METHOD_VALUE: - case ICAL_STATUS_VALUE: - case ICAL_TRANSP_VALUE: - case ICAL_CLASS_VALUE: - if(value->x_value !=0){ - return icalmemory_strdup(value->x_value); - } - - return icalproperty_enum_to_string_r(value->data.v_enum); - - case ICAL_X_VALUE: - if (value->x_value != 0) - return icalmemory_strdup_and_quote(value->x_value); - - /* FALLTHRU */ - - case ICAL_NO_VALUE: - default: - { - return 0; - } - } -} - - -icalvalue_kind -icalvalue_isa (const icalvalue* value) -{ - if(value == 0){ - return ICAL_NO_VALUE; - } - - return value->kind; -} - - -int -icalvalue_isa_value (void* value) -{ - struct icalvalue_impl *impl = (struct icalvalue_impl *)value; - - icalerror_check_arg_rz( (value!=0), "value"); - - if (strcmp(impl->id,"val") == 0) { - return 1; - } else { - return 0; - } -} - - -static int icalvalue_is_time(const icalvalue* a) { - icalvalue_kind kind = icalvalue_isa(a); - - if(kind == ICAL_DATETIME_VALUE || - kind == ICAL_DATE_VALUE ){ - return 1; - } - - return 0; - -} - -/* - * In case of error, this function returns 0. This is partly bogus, as 0 is - * not part of the returned enum. - * FIXME We should probably add an error value to the enum. - */ -icalparameter_xliccomparetype -icalvalue_compare(const icalvalue* a, const icalvalue *b) -{ - - icalerror_check_arg_rz( (a!=0), "a"); - icalerror_check_arg_rz( (b!=0), "b"); - - /* Not the same type; they can only be unequal */ - if( ! (icalvalue_is_time(a) && icalvalue_is_time(b)) && - icalvalue_isa(a) != icalvalue_isa(b)){ - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - - switch (icalvalue_isa(a)){ - - case ICAL_ATTACH_VALUE: - { - if (icalattach_get_is_url(a->data.v_attach) && - icalattach_get_is_url(b->data.v_attach)) { - if (strcasecmp(icalattach_get_url(a->data.v_attach), - icalattach_get_url(b->data.v_attach)) == 0) - return ICAL_XLICCOMPARETYPE_EQUAL; - else - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - else { - if (a->data.v_attach == b->data.v_attach) - return ICAL_XLICCOMPARETYPE_EQUAL; - else - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - } - case ICAL_BINARY_VALUE: - { - if (a->data.v_attach == b->data.v_attach) - return ICAL_XLICCOMPARETYPE_EQUAL; - else - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - - case ICAL_BOOLEAN_VALUE: - { - if (icalvalue_get_boolean(a) == icalvalue_get_boolean(b)){ - return ICAL_XLICCOMPARETYPE_EQUAL; - } else { - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - } - - case ICAL_FLOAT_VALUE: - { - if (a->data.v_float > b->data.v_float){ - return ICAL_XLICCOMPARETYPE_GREATER; - } else if (a->data.v_float < b->data.v_float){ - return ICAL_XLICCOMPARETYPE_LESS; - } else { - return ICAL_XLICCOMPARETYPE_EQUAL; - } - } - - case ICAL_INTEGER_VALUE: - case ICAL_UTCOFFSET_VALUE: - { - if (a->data.v_int > b->data.v_int){ - return ICAL_XLICCOMPARETYPE_GREATER; - } else if (a->data.v_int < b->data.v_int){ - return ICAL_XLICCOMPARETYPE_LESS; - } else { - return ICAL_XLICCOMPARETYPE_EQUAL; - } - } - - case ICAL_DURATION_VALUE: - { - int dur_a = icaldurationtype_as_int(a->data.v_duration); - int dur_b = icaldurationtype_as_int(b->data.v_duration); - - if (dur_a > dur_b){ - return ICAL_XLICCOMPARETYPE_GREATER; - } else if (dur_a < dur_b){ - return ICAL_XLICCOMPARETYPE_LESS; - } else { - return ICAL_XLICCOMPARETYPE_EQUAL; - } - } - - - case ICAL_TEXT_VALUE: - case ICAL_URI_VALUE: - case ICAL_CALADDRESS_VALUE: - case ICAL_TRIGGER_VALUE: - case ICAL_DATE_VALUE: - case ICAL_DATETIME_VALUE: - case ICAL_DATETIMEPERIOD_VALUE: - case ICAL_QUERY_VALUE: - case ICAL_RECUR_VALUE: - { - int r; - char *temp1, *temp2; - temp1 = icalvalue_as_ical_string_r(a); - temp2 = icalvalue_as_ical_string_r(b); - r = strcmp(temp1, temp2); - free(temp1); - free(temp2); - - if (r > 0) { - return ICAL_XLICCOMPARETYPE_GREATER; - } else if (r < 0){ - return ICAL_XLICCOMPARETYPE_LESS; - } else { - return ICAL_XLICCOMPARETYPE_EQUAL; - } - - - } - - case ICAL_METHOD_VALUE: - { - if (icalvalue_get_method(a) == icalvalue_get_method(b)){ - return ICAL_XLICCOMPARETYPE_EQUAL; - } else { - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - - } - - case ICAL_STATUS_VALUE: - { - if (icalvalue_get_status(a) == icalvalue_get_status(b)){ - return ICAL_XLICCOMPARETYPE_EQUAL; - } else { - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - - } - - case ICAL_TRANSP_VALUE: - { - if (icalvalue_get_transp(a) == icalvalue_get_transp(b)){ - return ICAL_XLICCOMPARETYPE_EQUAL; - } else { - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - } - - case ICAL_ACTION_VALUE: - { - if (icalvalue_get_action(a) == icalvalue_get_action(b)){ - return ICAL_XLICCOMPARETYPE_EQUAL; - } else { - return ICAL_XLICCOMPARETYPE_NOTEQUAL; - } - } - - case ICAL_PERIOD_VALUE: - case ICAL_GEO_VALUE: - case ICAL_NO_VALUE: - default: - { - icalerror_warn("Comparison not implemented for value type"); - return 0; - } - } - -} - -/** Examine the value and possibly change the kind to agree with the - * value - */ - -void icalvalue_reset_kind(icalvalue* value) -{ - if( (value->kind==ICAL_DATETIME_VALUE || value->kind==ICAL_DATE_VALUE )&& - !icaltime_is_null_time(value->data.v_time) ) { - - if(icaltime_is_date(value->data.v_time)){ - value->kind = ICAL_DATE_VALUE; - } else { - value->kind = ICAL_DATETIME_VALUE; - } - } - -} - -void icalvalue_set_parent(icalvalue* value, - icalproperty* property) -{ - value->parent = property; -} - -icalproperty* icalvalue_get_parent(icalvalue* value) -{ - return value->parent; -} - - -int icalvalue_encode_ical_string(const char *szText, char *szEncText, int nMaxBufferLen) -{ - char *ptr; - icalvalue *value = 0; - - if ((szText == 0) || (szEncText == 0)) - return 0; - - value = icalvalue_new_from_string(ICAL_STRING_VALUE, szText); - - if (value == 0) - return 0; - - ptr = icalvalue_text_as_ical_string_r(value); - if (ptr == 0) - return 0; - - if ((int)strlen(ptr) >= nMaxBufferLen) - { - icalvalue_free (value); - free(ptr); - return 0; - } - - strcpy(szEncText, ptr); - free(ptr); - - icalvalue_free ((icalvalue*)value); - - return 1; -} - -int icalvalue_decode_ical_string(const char *szText, char *szDecText, int nMaxBufferLen) -{ - char *str, *str_p; - const char *p; - size_t buf_sz; - - if ((szText == 0) || (szDecText == 0)) - return 0; - - buf_sz = strlen(szText); - str_p = str = (char*)icalmemory_new_buffer(buf_sz + 1); - - if (str_p == 0){ - return 0; - } - - for (p=szText; *p!=0; p++) { - if (*p == '\\') { - icalmemory_append_char (&str,&str_p,&buf_sz,*(p+1)); - p++; - } - else - icalmemory_append_char (&str,&str_p,&buf_sz,*p); - } - - icalmemory_append_char(&str,&str_p,&buf_sz,'\0'); - - if ((int)strlen(str) > nMaxBufferLen) { - icalmemory_free_buffer(str); - return 0; - } - - strcpy(szDecText, str); - - icalmemory_free_buffer(str); - return 1; -} - - -/* The remaining interfaces are 'new', 'set' and 'get' for each of the value - types */ diff --git a/calendar/libical/src/libical/icalvalue.h b/calendar/libical/src/libical/icalvalue.h deleted file mode 100644 index 410576203c..0000000000 --- a/calendar/libical/src/libical/icalvalue.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalvalue.h - CREATOR: eric 20 March 1999 - - - $Id: icalvalue.h,v 1.10 2008-01-15 23:17:43 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalvalue.h - - ======================================================================*/ - -#ifndef ICALVALUE_H -#define ICALVALUE_H - -#include -#include "icalenums.h" -#include "icaltypes.h" -#include "icalrecur.h" -#include "icalduration.h" -#include "icalperiod.h" -#include "icalderivedproperty.h" /* For icalproperty_method, etc. */ -#include "icalderivedparameter.h" -#include "icalderivedvalue.h" - -/* Defined in icalderivedvalue.h */ -/*typedef struct icalvalue_impl icalvalue;*/ - -icalvalue* icalvalue_new(icalvalue_kind kind); - -icalvalue* icalvalue_new_clone(const icalvalue* value); - -icalvalue* icalvalue_new_from_string(icalvalue_kind kind, const char* str); - -void icalvalue_free(icalvalue* value); - -int icalvalue_is_valid(const icalvalue* value); - -const char* icalvalue_as_ical_string(const icalvalue* value); -char* icalvalue_as_ical_string_r(const icalvalue* value); - -icalvalue_kind icalvalue_isa(const icalvalue* value); - -int icalvalue_isa_value(void*); - -icalparameter_xliccomparetype icalvalue_compare(const icalvalue* a, const icalvalue *b); - - -/* Special, non autogenerated value accessors */ - -/* Defined in icalderivedvalue.h */ -/* icalvalue* icalvalue_new_recur (struct icalrecurrencetype v); */ -/* void icalvalue_set_recur(icalvalue* value, struct icalrecurrencetype v); */ -/* struct icalrecurrencetype icalvalue_get_recur(const icalvalue* value); */ - -/* icalvalue* icalvalue_new_trigger (struct icaltriggertype v); */ -/* void icalvalue_set_trigger(icalvalue* value, struct icaltriggertype v); */ -/* struct icaltriggertype icalvalue_get_trigger(const icalvalue* value); */ - -/* icalvalue* icalvalue_new_datetimeperiod (struct icaldatetimeperiodtype v); */ -/* void icalvalue_set_datetimeperiod(icalvalue* value, */ -/* struct icaldatetimeperiodtype v); */ -/* struct icaldatetimeperiodtype icalvalue_get_datetimeperiod(const icalvalue* value); */ - -/* Convert enumerations */ - -icalvalue_kind icalvalue_string_to_kind(const char* str); -const char* icalvalue_kind_to_string(const icalvalue_kind kind); - -/** Check validity of a specific icalvalue_kind **/ -int icalvalue_kind_is_valid(const icalvalue_kind kind); - -/** Encode a character string in ical format, esacpe certain characters, etc. */ -int icalvalue_encode_ical_string(const char *szText, char *szEncText, int MaxBufferLen); - -/** Extract the original character string encoded by the above function **/ -int icalvalue_decode_ical_string(const char *szText, char *szDecText, int nMaxBufferLen); - -#endif /*ICALVALUE_H*/ diff --git a/calendar/libical/src/libical/icalvalueimpl.h b/calendar/libical/src/libical/icalvalueimpl.h deleted file mode 100644 index 6674428f10..0000000000 --- a/calendar/libical/src/libical/icalvalueimpl.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C -*- */ -/*====================================================================== - FILE: icalvalue.c - CREATOR: eric 02 May 1999 - - $Id: icalvalueimpl.h,v 1.7 2008-01-15 23:17:43 dothebart Exp $ - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The original code is icalvalue.c - - Contributions from: - Graham Davison (g.m.davison@computer.org) - - -======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifndef ICALVALUEIMPL_H -#define ICALVALUEIMPL_H - -#include "icalenums.h" -#include "icalproperty.h" -#include "icalderivedvalue.h" - - -struct icalvalue_impl { - icalvalue_kind kind; /*this is the kind that is visible from the outside*/ - - char id[5]; - int size; - icalproperty* parent; - char* x_value; - - union data { - icalattach *v_attach; - /* void *v_binary; */ /* use v_attach */ - const char *v_string; - /*char *v_text;*/ - /*char *v_caladdress;*/ - /*char *v_uri;*/ - float v_float; - int v_int; - /*int v_boolean;*/ - /*int v_integer;*/ - struct icaldurationtype v_duration; - /*int v_utcoffset;*/ - - struct icalperiodtype v_period; - /*struct icalperiodtype v_datetimeperiod;*/ - struct icalgeotype v_geo; - /*time_t v_time;*/ - struct icaltimetype v_time; - /*struct icaltimetype v_date;*/ - /*struct icaltimetype v_datetime;*/ - /*struct icaltimetype v_datetimedate;*/ - - struct icalreqstattype v_requeststatus; - - /* struct icalrecurrencetype was once included - directly ( not referenced ) in this union, but it - contributes 2000 bytes to every value, so now it is - a reference*/ - - struct icalrecurrencetype *v_recur; - struct icaltriggertype v_trigger; - - int v_enum; - /* v_enum takes care of several enumerated types including: - icalproperty_method v_method; - icalproperty_status v_status; - icalproperty_action v_action; - icalproperty_class v_class; - icalproperty_transp v_transp; - */ - - } data; -}; - -#endif diff --git a/calendar/libical/src/libical/icalversion.h b/calendar/libical/src/libical/icalversion.h deleted file mode 100644 index c4b1d15ef1..0000000000 --- a/calendar/libical/src/libical/icalversion.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef ICAL_VERSION_H -#define ICAL_VERSION_H - -#define ICAL_PACKAGE "libical" -#define ICAL_VERSION "0.24" - -#endif diff --git a/calendar/libical/src/libical/icalversion.h.cmake b/calendar/libical/src/libical/icalversion.h.cmake deleted file mode 100644 index bcc05c6af3..0000000000 --- a/calendar/libical/src/libical/icalversion.h.cmake +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef ICAL_VERSION_H -#define ICAL_VERSION_H - -#define ICAL_PACKAGE "@CMAKE_PROJECT_NAME@" -#define ICAL_VERSION "@PROJECT_VERSION@" - -#endif diff --git a/calendar/libical/src/libical/icalversion.h.in b/calendar/libical/src/libical/icalversion.h.in deleted file mode 100644 index 5d213693e5..0000000000 --- a/calendar/libical/src/libical/icalversion.h.in +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef ICAL_VERSION_H -#define ICAL_VERSION_H - -#define ICAL_PACKAGE "@PACKAGE@" -#define ICAL_VERSION "@VERSION@" - -#endif diff --git a/calendar/libical/src/libical/icptrholder.h b/calendar/libical/src/libical/icptrholder.h deleted file mode 100644 index 5f697eedce..0000000000 --- a/calendar/libical/src/libical/icptrholder.h +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C++ -*- */ - -/** - * @file icptrholder.h - * @author wyau (08/29/02) - * @brief C++ template classes for managing C++ pointers returned by VComponent::get_..._component, - * VComponent::get_..._property, ICalPropety::get_..._value. - * @remarks VComponent::get... functions returns a C++ oject that wraps the libical implementation. - * It is important to note that the wrapped implementation still belongs to the orginal - * component. To stop memory leak, caller must delete the pointer. However, the destructor - * will call the appropriate free function. eg. ~VComponent calls icalcomponent_free(imp). - * As stated previously, imp stil belongs to the original component. To avoid freeing the - * wrapped "imp", caller must set the "imp" to null before deleting the pointer. - * - * The template class relieves the burden of memory management when used as a stack based - * object. The class holds a pointer to the C++ Wrapper. The destructor set the imp to - * null before deleting the pointer. - * - * Each C++ Wrapper instantiates a template class in it's corresponding .h file. - * - * Usage example: - * VComponentTmpPtr p; // VComponentTmpPtr is an instantiation of this template - * for (p=component.get_first_component; p!= NULL; p=component.get_next_component) { - * - * (C) COPYRIGHT 2001, Critical Path - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - */ - -#ifndef __ICPTRHOLDER_H__ -#define __ICPTRHOLDER_H__ - -template class ICPointerHolder { -public: - ICPointerHolder() { ptr = NULL; } - ICPointerHolder(T* p) { ptr = p; } - - // copy constructor to support assignment - ICPointerHolder(const ICPointerHolder& ip) { - ptr = ip.ptr; - - // We need to transfer ownership of ptr to this object by setting - // ip's ptr to null. Otherwise, ptr will de deleted twice. - // const ugliness requires us to do the const_cast. - ICPointerHolder *ipp = const_cast(&ip); - ipp->ptr = NULL; - }; - - ~ICPointerHolder() { - release(); - } - - ICPointerHolder& operator=(T* p) { - this->release(); - ptr = p; - return *this; - } - - ICPointerHolder& operator=(ICPointerHolder& p) { - this->release(); - ptr = p.ptr; // this transfer ownership of the pointer - p.ptr = NULL; // set it to null so the pointer won't get delete twice. - return *this; - } - - int operator!=(T* p) {return (ptr != p);} - int operator==(T* p) {return (ptr == p);} - - operator T*() const { - return ptr; - } - - T* operator->() const { - assert(ptr); - return ptr; - } - - T& operator*() { - assert(ptr); - return *ptr; - } - -private: - void release() { - if (ptr != NULL) { - ptr->detach(); - delete ptr; - ptr = NULL; - } - } - - T* ptr; -}; - -#endif diff --git a/calendar/libical/src/libical/libical.dsp b/calendar/libical/src/libical/libical.dsp deleted file mode 100644 index c14ba95860..0000000000 --- a/calendar/libical/src/libical/libical.dsp +++ /dev/null @@ -1,594 +0,0 @@ -# Microsoft Developer Studio Project File - Name="libical" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Static Library" 0x0104 - -CFG=libical - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libical.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libical.mak" CFG="libical - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libical - Win32 Release" (based on "Win32 (x86) Static Library") -!MESSAGE "libical - Win32 Debug" (based on "Win32 (x86) Static Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I "./autogenex" /I "./" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I ".." /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /FR /YX /FD /GZ /c -# ADD BASE RSC /l 0x409 /d "_DEBUG" -# ADD RSC /l 0x409 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LIB32=link.exe -lib -# ADD BASE LIB32 /nologo -# ADD LIB32 /nologo - -!ENDIF - -# Begin Target - -# Name "libical - Win32 Release" -# Name "libical - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\caldate.c -# End Source File -# Begin Source File - -SOURCE=.\icalarray.c -# End Source File -# Begin Source File - -SOURCE=.\icalattach.c -# End Source File -# Begin Source File - -SOURCE=icalcomponent.c -# End Source File -# Begin Source File - -SOURCE=.\icalderivedparameter.c -# End Source File -# Begin Source File - -SOURCE=icalderivedparameter.c.in - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICALD="../../scripts/mkderivedparameters.pl" "../../design-data/parameters.csv" -# Begin Custom Build -InputPath=icalderivedparameter.c.in -InputName=icalderivedparameter.c - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedparameters.pl -i $(InputName).in -c ../../design-data/parameters.csv > $(InputName) - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -USERDEP__ICALD="../../scripts/mkderivedparameters.pl" "../../design-data/parameters.csv" -# Begin Custom Build -InputPath=icalderivedparameter.c.in -InputName=icalderivedparameter.c - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedparameters.pl -i $(InputName).in -c ../../design-data/parameters.csv > $(InputName) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\icalderivedproperty.c -# End Source File -# Begin Source File - -SOURCE=icalderivedproperty.c.in - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICALDE="../../scripts/mkderivedproperties.pl" "../../design-data/properties.csv" "../../design-data/value-types.csv" -# Begin Custom Build -InputPath=icalderivedproperty.c.in -InputName=icalderivedproperty.c - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedproperties.pl -i $(InputName).in -c ../../design-data/properties.csv ../../design-data/value-types.csv > $(InputName) - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -USERDEP__ICALDE="../../scripts/mkderivedproperties.pl" "../../design-data/properties.csv" "../../design-data/value-types.csv" -# Begin Custom Build -InputPath=icalderivedproperty.c.in -InputName=icalderivedproperty.c - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedproperties.pl -i $(InputName).in -c ../../design-data/properties.csv ../../design-data/value-types.csv > $(InputName) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\icalderivedvalue.c -# End Source File -# Begin Source File - -SOURCE=icalderivedvalue.c.in - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICALDER="../../scripts/mkderivedvalues.pl" "../../design-data/value-types.csv" -# Begin Custom Build -InputPath=icalderivedvalue.c.in -InputName=icalderivedvalue.c - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedvalues.pl -i $(InputName).in -c ../../design-data/value-types.csv > $(InputName) - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -USERDEP__ICALDER="../../scripts/mkderivedvalues.pl" "../../design-data/value-types.csv" -# Begin Custom Build -InputPath=icalderivedvalue.c.in -InputName=icalderivedvalue.c - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedvalues.pl -i $(InputName).in -c ../../design-data/value-types.csv > $(InputName) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=icalduration.c -# End Source File -# Begin Source File - -SOURCE=icalenums.c -# End Source File -# Begin Source File - -SOURCE=icalerror.c -# End Source File -# Begin Source File - -SOURCE=icallangbind.c -# End Source File -# Begin Source File - -SOURCE=icalmemory.c -# End Source File -# Begin Source File - -SOURCE=icalmime.c -# End Source File -# Begin Source File - -SOURCE=icalparameter.c -# End Source File -# Begin Source File - -SOURCE=icalparser.c -# End Source File -# Begin Source File - -SOURCE=icalperiod.c -# End Source File -# Begin Source File - -SOURCE=icalproperty.c -# End Source File -# Begin Source File - -SOURCE=icalrecur.c -# End Source File -# Begin Source File - -SOURCE=.\icalrestriction.c -# End Source File -# Begin Source File - -SOURCE=icalrestriction.c.in - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICALR="../../scripts/mkrestrictiontable.pl" "../../design-data/restrictions.csv" -# Begin Custom Build -InputPath=icalrestriction.c.in -InputName=icalrestriction.c - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkrestrictiontable.pl -i $(InputName).in ../../design-data/restrictions.csv > $(InputName) - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICALR="../../scripts/mkrestrictiontable.pl" "../../design-data/restrictions.csv" -# Begin Custom Build -InputPath=icalrestriction.c.in -InputName=icalrestriction.c - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkrestrictiontable.pl -i $(InputName).in ../../design-data/restrictions.csv > $(InputName) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=icaltime.c -# End Source File -# Begin Source File - -SOURCE=.\icaltimezone.c -# End Source File -# Begin Source File - -SOURCE=icaltypes.c -# End Source File -# Begin Source File - -SOURCE=icalvalue.c -# End Source File -# Begin Source File - -SOURCE=pvl.c -# End Source File -# Begin Source File - -SOURCE=sspm.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\astime.h -# End Source File -# Begin Source File - -SOURCE=.\ical.h - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICAL_="icalversion.h" "icaltime.h" "icalduration.h" "icalperiod.h" "icalenums.h" "icaltypes.h" "icalrecur.h" "icalattach.h" "icalderivedvalue.h" "icalderivedparameter.h" "icalvalue.h" "icalparameter.h" "icalderivedproperty.h" "icalproperty.h" "pvl.h" "icalarray.h" "icalcomponent.h" "icaltimezone.h" "icalparser.h" "icalmemory.h" "icalerror.h" "icalrestriction.h" "sspm.h" "icalmime.h" "icallangbind.h" -# Begin Custom Build -InputPath=.\ical.h - -"ical.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - sh ../../scripts/mkinclude.sh -o ical.h -e "#include.*\"ical" -e "#include.*\"config" -e "#include.*\"pvl\.h\"" -e '\$$(Id|Locker): .+\$$' icalversion.h icaltime.h icalduration.h icalperiod.h icalenums.h icaltypes.h icalrecur.h icalattach.h icalderivedvalue.h icalderivedparameter.h icalvalue.h icalparameter.h icalderivedproperty.h icalproperty.h pvl.h icalarray.h icalcomponent.h icaltimezone.h icalparser.h icalmemory.h icalerror.h icalrestriction.h sspm.h icalmime.h icallangbind.h - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -USERDEP__ICAL_="icalversion.h" "icaltime.h" "icalduration.h" "icalperiod.h" "icalenums.h" "icaltypes.h" "icalrecur.h" "icalattach.h" "icalderivedvalue.h" "icalderivedparameter.h" "icalvalue.h" "icalparameter.h" "icalderivedproperty.h" "icalproperty.h" "pvl.h" "icalarray.h" "icalcomponent.h" "icaltimezone.h" "icalparser.h" "icalmemory.h" "icalerror.h" "icalrestriction.h" "sspm.h" "icalmime.h" "icallangbind.h" -# Begin Custom Build -InputPath=.\ical.h - -"ical.h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - sh ../../scripts/mkinclude.sh -o ical.h -e "#include.*\"ical" -e "#include.*\"config" -e "#include.*\"pvl\.h\"" -e '\$$(Id|Locker): .+\$$' icalversion.h icaltime.h icalduration.h icalperiod.h icalenums.h icaltypes.h icalrecur.h icalattach.h icalderivedvalue.h icalderivedparameter.h icalvalue.h icalparameter.h icalderivedproperty.h icalproperty.h pvl.h icalarray.h icalcomponent.h icaltimezone.h icalparser.h icalmemory.h icalerror.h icalrestriction.h sspm.h icalmime.h icallangbind.h - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\icalarray.h -# End Source File -# Begin Source File - -SOURCE=.\icalattach.h -# End Source File -# Begin Source File - -SOURCE=.\icalattachimpl.h -# End Source File -# Begin Source File - -SOURCE=icalcomponent.h -# End Source File -# Begin Source File - -SOURCE=.\icalderivedparameter.h -# End Source File -# Begin Source File - -SOURCE=icalderivedparameter.h.in - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICALDERI="../../scripts/mkderivedparameters.pl" "../../design-data/parameters.csv" -# Begin Custom Build -InputPath=icalderivedparameter.h.in -InputName=icalderivedparameter.h - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedparameters.pl -i $(InputName).in -h ../../design-data/parameters.csv > $(InputName) - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -USERDEP__ICALDERI="../../scripts/mkderivedparameters.pl" "../../design-data/parameters.csv" -# Begin Custom Build -InputPath=icalderivedparameter.h.in -InputName=icalderivedparameter.h - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedparameters.pl -i $(InputName).in -h ../../design-data/parameters.csv > $(InputName) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\icalderivedproperty.h -# End Source File -# Begin Source File - -SOURCE=icalderivedproperty.h.in - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICALDERIV="../../scripts/mkderivedproperties.pl" "../../design-data/properties.csv" "../../design-data/value-types.csv" -# Begin Custom Build -InputPath=icalderivedproperty.h.in -InputName=icalderivedproperty.h - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedproperties.pl -i $(InputName).in -h ../../design-data/properties.csv ../../design-data/value-types.csv > $(InputName) - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -USERDEP__ICALDERIV="../../scripts/mkderivedproperties.pl" "../../design-data/properties.csv" "../../design-data/value-types.csv" -# Begin Custom Build -InputPath=icalderivedproperty.h.in -InputName=icalderivedproperty.h - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedproperties.pl -i $(InputName).in -h ../../design-data/properties.csv ../../design-data/value-types.csv > $(InputName) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=.\icalderivedvalue.h -# End Source File -# Begin Source File - -SOURCE=icalderivedvalue.h.in - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -USERDEP__ICALDERIVE="../../scripts/mkderivedvalues.pl" "../../design-data/value-types.csv" -# Begin Custom Build -InputPath=icalderivedvalue.h.in -InputName=icalderivedvalue.h - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedvalues.pl -i $(InputName).in -h ../../design-data/value-types.csv > $(InputName) - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -USERDEP__ICALDERIVE="../../scripts/mkderivedvalues.pl" "../../design-data/value-types.csv" -# Begin Custom Build -InputPath=icalderivedvalue.h.in -InputName=icalderivedvalue.h - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - perl -I ../../scripts ../../scripts/mkderivedvalues.pl -i $(InputName).in -h ../../design-data/value-types.csv > $(InputName) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=icalduration.h -# End Source File -# Begin Source File - -SOURCE=icalenums.h -# End Source File -# Begin Source File - -SOURCE=icalerror.h -# End Source File -# Begin Source File - -SOURCE=icallangbind.h -# End Source File -# Begin Source File - -SOURCE=icalmemory.h -# End Source File -# Begin Source File - -SOURCE=icalmime.h -# End Source File -# Begin Source File - -SOURCE=icalparameter.h -# End Source File -# Begin Source File - -SOURCE=icalparameterimpl.h -# End Source File -# Begin Source File - -SOURCE=icalparser.h -# End Source File -# Begin Source File - -SOURCE=icalperiod.h -# End Source File -# Begin Source File - -SOURCE=icalproperty.h -# End Source File -# Begin Source File - -SOURCE=icalrecur.h -# End Source File -# Begin Source File - -SOURCE=icalrestriction.h -# End Source File -# Begin Source File - -SOURCE=icaltime.h -# End Source File -# Begin Source File - -SOURCE=.\icaltimezone.h -# End Source File -# Begin Source File - -SOURCE=icaltypes.h -# End Source File -# Begin Source File - -SOURCE=icalvalue.h -# End Source File -# Begin Source File - -SOURCE=icalvalueimpl.h -# End Source File -# Begin Source File - -SOURCE=.\icalversion.h -# End Source File -# Begin Source File - -SOURCE=icalversion.h.in - -!IF "$(CFG)" == "libical - Win32 Release" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build -InputPath=icalversion.h.in -InputName=icalversion.h - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - sed -e "s/@VERSION@/0.24/g" -e "s/@PACKAGE@/libical/g" $(InputName).in > $(InputName) - -# End Custom Build - -!ELSEIF "$(CFG)" == "libical - Win32 Debug" - -# PROP Ignore_Default_Tool 1 -# Begin Custom Build -InputPath=icalversion.h.in -InputName=icalversion.h - -"$(InputName)" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)" - sed -e "s/@VERSION@/0.24/g" -e "s/@PACKAGE@/libical/g" $(InputName).in > $(InputName) - -# End Custom Build - -!ENDIF - -# End Source File -# Begin Source File - -SOURCE=pvl.h -# End Source File -# Begin Source File - -SOURCE=sspm.h -# End Source File -# End Group -# End Target -# End Project diff --git a/calendar/libical/src/libical/moz.build b/calendar/libical/src/libical/moz.build deleted file mode 100644 index 6a15ccdc29..0000000000 --- a/calendar/libical/src/libical/moz.build +++ /dev/null @@ -1,66 +0,0 @@ -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -UNIFIED_SOURCES += [ - 'caldate.c', - 'icalarray.c', - 'icalattach.c', - 'icalcomponent.c', - 'icalduration.c', - 'icalenums.c', - 'icalerror.c', - 'icallangbind.c', - 'icalmemory.c', - 'icalmime.c', - 'icalparameter.c', - 'icalparser.c', - 'icalperiod.c', - 'icalproperty.c', - 'icalrecur.c', - 'icaltime.c', - 'icaltimezone.c', - 'icaltypes.c', - 'icalvalue.c', - 'pvl.c', - 'sspm.c', - 'vsnprintf.c', -] - -SOURCES += [ - '!icalderivedparameter.c', - '!icalderivedproperty.c', - '!icalderivedvalue.c', - '!icalrestriction.c', -] - -GENERATED_FILES += [ - 'ical.h', - 'icalderivedparameter.c', - 'icalderivedparameter.h', - 'icalderivedproperty.c', - 'icalderivedproperty.h', - 'icalderivedvalue.c', - 'icalderivedvalue.h', - 'icalrestriction.c', -] - -EXPORTS += [ - '!ical.h' -] - -# We allow warnings for third-party code that can be updated from upstream. -AllowCompilerWarnings() - -FINAL_LIBRARY = 'xul' - -LOCAL_INCLUDES += [ - '../..' -] - -DEFINES['HAVE_CONFIG_H'] = True -DEFINES['HAVE_SNPRINTF'] = True - -if CONFIG['OS_TARGET'] == 'Darwin': - DEFINES['__USE_BSD'] = '1' diff --git a/calendar/libical/src/libical/pvl.c b/calendar/libical/src/libical/pvl.c deleted file mode 100644 index 23c69a8b7f..0000000000 --- a/calendar/libical/src/libical/pvl.c +++ /dev/null @@ -1,597 +0,0 @@ -/*====================================================================== - FILE: pvl.c - CREATOR: eric November, 1995 - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - -======================================================================*/ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "pvl.h" -#include -#include -#include - -/** - struct pvl_list_t - - The list structure. This is the hanlde for the entire list - - This type is also private. Use pvl_list instead - - */ - -typedef struct pvl_list_t -{ - int MAGIC; /**< Magic Identifier */ - struct pvl_elem_t *head; /**< Head of list */ - struct pvl_elem_t *tail; /**< Tail of list */ - int count; /**< Number of items in the list */ - struct pvl_elem_t *p; /**< Pointer used for iterators */ -} pvl_list_t; - - - - -/** - * This global is incremented for each call to pvl_new_element(); it gives each - * list a unique identifer - */ - -int pvl_elem_count = 0; -int pvl_list_count = 0; - - -/** - * @brief Creates a new list, clears the pointers and assigns a magic number - * - * @return Pointer to the new list, 0 if there is no available memory. - */ - -pvl_list -pvl_newlist() -{ - struct pvl_list_t *L; - - if ( ( L = (struct pvl_list_t*)malloc(sizeof(struct pvl_list_t))) == 0) - { - errno = ENOMEM; - return 0; - } - - L->MAGIC = pvl_list_count; - pvl_list_count++; - L->head = 0; - L->tail = 0; - L->count = 0; - L->p = 0; - - return L; -} - -void -pvl_free(pvl_list l) -{ - struct pvl_list_t *L = (struct pvl_list_t *)l; - - pvl_clear(l); - - free(L); -} - -/** - * @brief Creates a new list element, assigns a magic number, and assigns - * the next and previous pointers. - * - * Passing in the next and previous points may seem odd, but it allos the user - * to set them while keeping the internal data hidden. In nearly all cases, - * the user is the pvl library itself. - * - * @param d The data item to be stored in the list - * @param next Pointer value to assign to the member "next" - * @param prior Pointer value to assign to the member "prior" - * - * @return A pointer to the new element, 0 if there is no memory available. - */ - -pvl_elem -pvl_new_element(void *d, pvl_elem next, pvl_elem prior) -{ - struct pvl_elem_t *E; - - if ( ( E = (struct pvl_elem_t*)malloc(sizeof(struct pvl_elem_t))) == 0) - { - errno = ENOMEM; - return 0; - } - - E->MAGIC = pvl_elem_count++; - E->d = d; - E->next = next; - E->prior = prior; - - return (pvl_elem)E; -} - -/** - * @brief Add a new element to the from of the list - * - * @param L The list to add the item to - * @param d Pointer to the item to add - */ - -void -pvl_unshift(pvl_list L,void *d) -{ - struct pvl_elem_t *E = pvl_new_element(d,L->head,0); - - if (E->next != 0) - { - /* Link the head node to it */ - E->next->prior = E; - } - - /* move the head */ - L->head = E; - - /* maybe move the tail */ - - if (L->tail == 0) - { - L->tail = E; - } - - L->count++; -} - -/** - * @brief Remove an element from the front of the list - * - * @param L The list to operate on - * - * @return the entry on the front of the list - */ - -void* -pvl_shift(pvl_list L) -{ - if (L->head == 0) - { - return 0; - } - - return pvl_remove(L,(void*)L->head); - -} - -/** - * @brief Add a new item to the tail of the list - * - * @param L The list to operate on - * @param d Pointer to the item to add - * - */ - -void -pvl_push(pvl_list L,void *d) -{ - struct pvl_elem_t *E = pvl_new_element(d,0,L->tail); - - /* These are done in pvl_new_element - E->next = 0; - E->prior = L->tail; - */ - - if (L->tail != 0) - { - L->tail->next = E; - } - - if (L->head == 0) - { - L->head = E; - } - - L->tail = E; - - L->count++; - -} - -/** - * @brief Remove an element from the tail of the list - * - * @param L The list to operate on - */ - -void* -pvl_pop(pvl_list L) -{ - if ( L->tail == 0) - { - return 0; - } - - return pvl_remove(L,(void*) L->tail);; - -} - - -/** - * Add a new item to a list that is ordered by a comparison function. - * This routine assumes that the list is properly ordered. - * - * @param L The list to operate on - * @param f Pointer to a comparison function - * @param d Pointer to data to pass to the comparison function - */ - -void -pvl_insert_ordered(pvl_list L,pvl_comparef f,void *d) -{ - struct pvl_elem_t *P; - - L->count++; - - /* Empty list, add to head */ - - if(L->head == 0) - { - pvl_unshift(L,d); - return; - } - - /* smaller than head, add to head */ - - if ( ((*f)(d,L->head->d)) <= 0) - { - pvl_unshift(L,d); - return; - } - - /* larger than tail, add to tail */ - if ( (*f)(d,L->tail->d) >= 0) - { - pvl_push(L,d); - return; - } - - - /* Search for the first element that is smaller, and add before it */ - - for (P=L->head; P != 0; P = P->next) - { - if ( (*f)(P->d,d) >= 0) - { - pvl_insert_before(L,P,d); - return; - } - } - - /* badness, choke */ -#ifndef lint - assert(0); -#endif -} - -/** - * @brief Add a new item after the referenced element. - * @param L The list to operate on - * @param P The list element to add the item after - * @param d Pointer to the item to add. - */ - -void -pvl_insert_after(pvl_list L,pvl_elem P,void *d) -{ - struct pvl_elem_t *E = 0; - - L->count++; - - if (P == 0) - { - pvl_unshift(L,d); - return; - } - - if ( P == L->tail) - { - E = pvl_new_element(d,0,P); - L->tail = E; - E->prior->next = E; - } - else - { - E = pvl_new_element(d,P->next,P); - E->next->prior = E; - E->prior->next = E; - } -} - -/** - * @brief Add an item after a referenced item - * - * @param L The list to operate on - * @param P The list element to add the item before - * @param d Pointer to the data to be added. - */ - -void -pvl_insert_before(pvl_list L,pvl_elem P,void *d) -{ - struct pvl_elem_t *E = 0; - - L->count++; - - if (P == 0) - { - pvl_unshift(L,d); - return; - } - - if ( P == L->head) - { - E = pvl_new_element(d,P,0); - E->next->prior = E; - L->head = E; - } - else - { - E = pvl_new_element(d,P,P->prior); - E->prior->next = E; - E->next->prior = E; - } -} - -/** - * @brief Remove the referenced item from the list. - * - * This routine will free the element, but not the data item that the - * element contains. - * - * @param L The list to operate on - * @param E The element to remove. - */ - -void* -pvl_remove(pvl_list L,pvl_elem E) -{ - void* data; - - if (E == L->head) - { - if (E->next != 0) - { - E->next->prior = 0; - L->head = E->next; - } else { - /* E Also points to tail -> only one element in list */ - L->tail = 0; - L->head = 0; - } - } - else if (E == L->tail) - { - if (E->prior != 0) - { - E->prior->next = 0; - L->tail = E->prior; - } else { - /* E points to the head, so it was the last element */ - /* This case should be taken care of in the previous clause */ - L->head = 0; - L->tail = 0; - } - } - else - { - E->prior->next = E->next; - E->next->prior = E->prior; - } - - - L->count--; - - data = E->d; - - E->prior = 0; - E->next = 0; - E->d = 0; - - free(E); - - return data; - -} - -/** - * @brief Return a pointer to data that satisfies a function. - * - * This routine will interate through the entire list and call the - * find function for each item. It will break and return a pointer to the - * data that causes the find function to return 1. - * - * @param l The list to operate on - * @param f Pointer to the find function - * @param v Pointer to constant data to pass into the function - * - * @return Pointer to the element that the find function found. - */ - -pvl_elem -pvl_find(pvl_list l,pvl_findf f,void* v) -{ - pvl_elem e; - - for (e=pvl_head(l); e!= 0; e = pvl_next(e)) - { - if ( (*f)(((struct pvl_elem_t *)e)->d,v) == 1) - { - /* Save this elem for a call to find_next */ - ((struct pvl_list_t *)l)->p = e; - return e; - } - } - - return 0; - -} - -/** - * @brief Like pvl_find(), but continues the search where the last find() or - * find_next() left off. - * - * @param l The list to operate on - * @param f Pointer to the find function - * @param v Pointer to constant data to pass into the function - * - * @return Pointer to the element that the find function found. - */ - -pvl_elem -pvl_find_next(pvl_list l,pvl_findf f,void* v) -{ - - pvl_elem e; - - for (e=pvl_head(l); e!= 0; e = pvl_next(e)) - { - if ( (*f)(((struct pvl_elem_t *)e)->d,v) == 1) - { - /* Save this elem for a call to find_next */ - ((struct pvl_list_t *)l)->p = e; - return e; - } - } - - return 0; - -} - -/** - * @brief Remove the all the elements in the list. The does not free - * the data items the elements hold. - */ - -void -pvl_clear(pvl_list l) -{ - pvl_elem e = pvl_head(l); - pvl_elem next; - - if (e == 0) { - return; - } - - while(e != 0) - { - next = pvl_next(e); - pvl_remove(l,e); - e = next; - } -} - - -/** - * @brief Returns the number of items in the list. - */ - -int -pvl_count(pvl_list L) -{ - return L->count; -} - - -/** - * @brief Returns a pointer to the given element - */ - -pvl_elem -pvl_next(pvl_elem E) -{ - if (E == 0){ - return 0; - } - - return (pvl_elem)E->next; -} - - -/** - * @brief Returns a pointer to the element previous to the element given. - */ - -pvl_elem -pvl_prior(pvl_elem E) -{ - return (pvl_elem)E->prior; -} - - -/** - * @brief Returns a pointer to the first item in the list. - */ - -pvl_elem -pvl_head(pvl_list L ) -{ - return (pvl_elem)L->head; -} - -/** - * @brief Returns a pointer to the last item in the list. - */ -pvl_elem -pvl_tail(pvl_list L) -{ - return (pvl_elem)L->tail; -} - -#ifndef PVL_USE_MACROS -void* -pvl_data(pvl_elem E) -{ - if ( E == 0){ - return 0; - } - - return E->d; -} -#endif - -/** - * @brief Call a function for every item in the list. - * - * @param l The list to operate on - * @param f Pointer to the function to call - * @param v Data to pass to the function on every iteration - */ - -void -pvl_apply(pvl_list l,pvl_applyf f, void *v) -{ - pvl_elem e; - - for (e=pvl_head(l); e!= 0; e = pvl_next(e)) - { - (*f)(((struct pvl_elem_t *)e)->d,v); - } - -} diff --git a/calendar/libical/src/libical/pvl.h b/calendar/libical/src/libical/pvl.h deleted file mode 100644 index 77c0531d35..0000000000 --- a/calendar/libical/src/libical/pvl.h +++ /dev/null @@ -1,110 +0,0 @@ -/*====================================================================== - FILE: pvl.h - CREATOR: eric November, 1995 - - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - -======================================================================*/ - - -#ifndef __PVL_H__ -#define __PVL_H__ - -typedef struct pvl_list_t* pvl_list; -typedef struct pvl_elem_t* pvl_elem; - -/** - * This type is private. Always use pvl_elem instead. The struct would - * not even appear in this header except to make code in the USE_MACROS - * blocks work - */ - -typedef struct pvl_elem_t -{ - int MAGIC; /**< Magic Identifier */ - void *d; /**< Pointer to data user is storing */ - struct pvl_elem_t *next; /**< Next element */ - struct pvl_elem_t *prior; /**< Prior element */ -} pvl_elem_t; - - - -/** - * This global is incremented for each call to pvl_new_element(); it gives each - * list a unique identifer - */ - -extern int pvl_elem_count; -extern int pvl_list_count; - -/* Create new lists or elements */ -pvl_elem pvl_new_element(void* d, pvl_elem next,pvl_elem prior); -pvl_list pvl_newlist(void); -void pvl_free(pvl_list); - -/* Add, remove, or get the head of the list */ -void pvl_unshift(pvl_list l,void *d); -void* pvl_shift(pvl_list l); -pvl_elem pvl_head(pvl_list); - -/* Add, remove or get the tail of the list */ -void pvl_push(pvl_list l,void *d); -void* pvl_pop(pvl_list l); -pvl_elem pvl_tail(pvl_list); - -/* Insert elements in random places */ -typedef int (*pvl_comparef)(void* a, void* b); /* a, b are of the data type*/ -void pvl_insert_ordered(pvl_list l,pvl_comparef f,void *d); -void pvl_insert_after(pvl_list l,pvl_elem e,void *d); -void pvl_insert_before(pvl_list l,pvl_elem e,void *d); - -/* Remove an element, or clear the entire list */ -void* pvl_remove(pvl_list,pvl_elem); /* Remove element, return data */ -void pvl_clear(pvl_list); /* Remove all elements, de-allocate all data */ - -int pvl_count(pvl_list); - -/* Navagate the list */ -pvl_elem pvl_next(pvl_elem e); -pvl_elem pvl_prior(pvl_elem e); - -/* get the data in the list */ -#ifndef PVL_USE_MACROS -void* pvl_data(pvl_elem); -#else -#define pvl_data(x) x==0 ? 0 : ((struct pvl_elem_t *)x)->d; -#endif - - -/* Find an element for which a function returns true */ -typedef int (*pvl_findf)(void* a, void* b); /*a is list elem, b is other data*/ -pvl_elem pvl_find(pvl_list l,pvl_findf f,void* v); -pvl_elem pvl_find_next(pvl_list l,pvl_findf f,void* v); - -/** - * Pass each element in the list to a function - * a is list elem, b is other data - */ -typedef void (*pvl_applyf)(void* a, void* b); -void pvl_apply(pvl_list l,pvl_applyf f, void *v); - - -#endif /* __PVL_H__ */ - - - - - diff --git a/calendar/libical/src/libical/sspm.c b/calendar/libical/src/libical/sspm.c deleted file mode 100644 index ee49eeb499..0000000000 --- a/calendar/libical/src/libical/sspm.c +++ /dev/null @@ -1,1639 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: sspm.c Parse Mime - CREATOR: eric 25 June 2000 - - $Id: sspm.c,v 1.13 2008-01-28 22:34:38 artcancro Exp $ - $Locker: $ - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Initial Developer of the Original Code is Eric Busboom - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - ======================================================================*/ - -#include -#include -#include "sspm.h" -#include -#include /* for tolower */ -#include /* for malloc, free */ -#include /* for strcasecmp */ - -#ifdef DMALLOC -#include "dmalloc.h" -#endif - -#ifdef WIN32 -#if defined(_MSC_VER) && (_MSC_VER < 1900) -#define snprintf _snprintf -#endif -#define strcasecmp stricmp -#endif - -#define TMP_BUF_SIZE 1024 - - -enum mime_state { - UNKNOWN_STATE, - IN_HEADER, - END_OF_HEADER, - IN_BODY, - OPENING_PART, - END_OF_PART, - TERMINAL_END_OF_PART, - END_OF_INPUT -}; - -struct mime_impl{ - struct sspm_part *parts; - size_t max_parts; - int part_no; - int level; - const struct sspm_action_map *actions; - char* (*get_string)(char *s, size_t size, void* data); - void* get_string_data; - char temp[TMP_BUF_SIZE]; - enum mime_state state; -}; - -void sspm_free_header(struct sspm_header *header); -void* sspm_make_multipart_part(struct mime_impl *impl,struct sspm_header *header); -void sspm_read_header(struct mime_impl *impl,struct sspm_header *header); - -char* sspm_strdup(const char* str){ - - char* s; - - s = strdup(str); - - return s; -} - - -static struct major_content_type_map -{ - enum sspm_major_type type; - const char* str; - -} major_content_type_map[] = -{ - {SSPM_MULTIPART_MAJOR_TYPE,"multipart" }, - {SSPM_TEXT_MAJOR_TYPE,"text" }, - {SSPM_TEXT_MAJOR_TYPE,"text" }, - {SSPM_IMAGE_MAJOR_TYPE,"image" }, - {SSPM_AUDIO_MAJOR_TYPE,"audio" }, - {SSPM_VIDEO_MAJOR_TYPE,"video" }, - {SSPM_APPLICATION_MAJOR_TYPE,"application" }, - {SSPM_MULTIPART_MAJOR_TYPE,"multipart" }, - {SSPM_MESSAGE_MAJOR_TYPE,"message" }, - {SSPM_UNKNOWN_MAJOR_TYPE,"" }, -}; - -static struct minor_content_type_map -{ - enum sspm_minor_type type; - const char* str; - -} minor_content_type_map[] = -{ - {SSPM_ANY_MINOR_TYPE,"*" }, - {SSPM_PLAIN_MINOR_TYPE,"plain" }, - {SSPM_RFC822_MINOR_TYPE,"rfc822" }, - {SSPM_DIGEST_MINOR_TYPE,"digest" }, - {SSPM_CALENDAR_MINOR_TYPE,"calendar" }, - {SSPM_MIXED_MINOR_TYPE,"mixed" }, - {SSPM_RELATED_MINOR_TYPE,"related" }, - {SSPM_ALTERNATIVE_MINOR_TYPE,"alternative" }, - {SSPM_PARALLEL_MINOR_TYPE, "parallel" }, - {SSPM_UNKNOWN_MINOR_TYPE,"" } -}; - - - -struct encoding_map { - enum sspm_encoding encoding; - const char* str; -} sspm_encoding_map[] = -{ - {SSPM_NO_ENCODING,""}, - {SSPM_QUOTED_PRINTABLE_ENCODING,"quoted-printable"}, - {SSPM_8BIT_ENCODING,"8bit"}, - {SSPM_7BIT_ENCODING,"7bit"}, - {SSPM_BINARY_ENCODING,"binary"}, - {SSPM_BASE64_ENCODING,"base64"}, - {SSPM_UNKNOWN_ENCODING,""} - -}; - - -char* sspm_get_parameter(const char* line, const char* parameter) -{ - char *p,*s,*q; - static char name[1024]; - - /* Find where the parameter name is in the line */ - p = strstr(line,parameter); - - if( p == 0){ - return 0; - } - - /* skip over the parameter name, the '=' and any blank spaces */ - - p+=strlen(parameter); - - while(*p==' ' || *p == '='){ - p++; - } - - /*now find the next semicolon*/ - - s = strchr(p,';'); - - /* Strip of leading quote */ - q = strchr(p,'\"'); - - if(q !=0){ - p = q+1; - } - - if(s != 0){ - strncpy(name,p,(size_t)s-(size_t)p); - } else { - strncpy(name,p,sizeof(name)-1); - name[sizeof(name)-1]='\0'; - } - - /* Strip off trailing quote, if it exists */ - - q = strrchr(name,'\"'); - - if (q != 0){ - *q='\0'; - } - - return name; -} - -char* sspm_property_name(const char* line) -{ - static char name[1024]; - char *c = strchr(line,':'); - - if(c != 0){ - strncpy(name,line,(size_t)c-(size_t)line); - name[(size_t)c-(size_t)line] = '\0'; - return name; - } else { - return 0; - } -} - -char* sspm_value(char* line) -{ - static char value[1024]; - - char *c,*s, *p; - - /* Find the first colon and the next semicolon */ - - value[0] = 0; - c = strchr(line,':'); - if (!c) - return value; - s = strchr(c,';'); - - /* Skip the colon */ - c++; - - if (s == 0){ - s = c+strlen(line); - } - - for(p=value; c != s; c++){ - if(*c!=' ' && *c!='\n'){ - *(p++) = *c; - } - } - - *p='\0'; - - return value; - -} - -static const char *mime_headers[] = { - "Content-Type", - "Content-Transfer-Encoding", - "Content-Disposition", - "Content-Id", - "Mime-Version", - 0 -}; - - -void* sspm_default_new_part(void) -{ - return 0; -} -void sspm_default_add_line(void *part, struct sspm_header *header, - const char* line, size_t size) -{ - (void)part; - (void)header; - (void)line; - (void)size; -} - -void* sspm_default_end_part(void* part) -{ - (void)part; - return 0; -} - -void sspm_default_free_part(void *part) -{ - (void)part; -} - - - -struct sspm_action_map sspm_action_map[] = -{ - {SSPM_UNKNOWN_MAJOR_TYPE,SSPM_UNKNOWN_MINOR_TYPE,sspm_default_new_part,sspm_default_add_line,sspm_default_end_part,sspm_default_free_part}, -}; - -int sspm_is_mime_header(char *line) -{ - char *name = sspm_property_name(line); - int i; - - if(name == 0){ - return 0; - } - - for(i = 0; mime_headers[i] != 0; i++){ - if(strcasecmp(name, mime_headers[i]) == 0) - return 1; - } - - return 0; -} - -int sspm_is_mail_header(char* line) -{ - char *name = sspm_property_name(line); - - if (name != 0){ - return 1; - } - - return 0; - -} - -int sspm_is_blank(char* line) -{ - char *p; - char c =0; - - for(p=line; *p!=0; p++){ - if( ! (*p == ' '|| *p == '\t' || *p=='\n') ){ - c++; - } - } - - if (c==0){ - return 1; - } - - return 0; - -} - -int sspm_is_continuation_line(char* line) -{ - if (line[0] == ' '|| line[0] == '\t' ) { - return 1; - } - - return 0; -} - -int sspm_is_mime_boundary(char *line) -{ - if( line[0] == '-' && line[1] == '-') { - return 1; - } - - return 0; -} - -int sspm_is_mime_terminating_boundary(char *line) -{ - - - if (sspm_is_mime_boundary(line) && - strstr(line,"--\n")){ - return 1; - } - - return 0; -} - -enum line_type { - EMPTY, - BLANK, - MIME_HEADER, - MAIL_HEADER, - HEADER_CONTINUATION, - BOUNDARY, - TERMINATING_BOUNDARY, - UNKNOWN_TYPE -}; - - -static enum line_type get_line_type(char* line){ - - if (line == 0){ - return EMPTY; - } else if(sspm_is_blank(line)){ - return BLANK; - } else if (sspm_is_mime_header(line)){ - return MIME_HEADER; - } else if (sspm_is_mail_header(line)){ - return MAIL_HEADER; - } else if (sspm_is_continuation_line(line)){ - return HEADER_CONTINUATION; - } else if (sspm_is_mime_terminating_boundary(line)){ - return TERMINATING_BOUNDARY; - } else if (sspm_is_mime_boundary(line)) { - return BOUNDARY; - } else { - return UNKNOWN_TYPE; - } - - -} - - -static struct sspm_action_map get_action(struct mime_impl *impl, - enum sspm_major_type major, - enum sspm_minor_type minor) -{ - int i; - - /* Read caller suppled action map */ - - if (impl->actions != 0){ - for(i=0; impl->actions[i].major != SSPM_UNKNOWN_MAJOR_TYPE; i++){ - if((major == impl->actions[i].major && - minor == impl->actions[i].minor) || - (major == impl->actions[i].major && - minor == SSPM_ANY_MINOR_TYPE)){ - return impl->actions[i]; - } - } - } - - /* Else, read default action map */ - - for(i=0; sspm_action_map[i].major != SSPM_UNKNOWN_MAJOR_TYPE; i++){ - if((major == sspm_action_map[i].major && - minor == sspm_action_map[i].minor) || - (major == sspm_action_map[i].major && - minor == SSPM_ANY_MINOR_TYPE)){ - break; - } - } - - return sspm_action_map[i]; -} - - -char* sspm_lowercase(char* str) -{ - char* p = 0; - char* new; - - if(str ==0){ - return 0; - } - new = sspm_strdup(str); - for(p = new; *p!=0; p++){ - *p = tolower(*p); - } - - return new; -} - -enum sspm_major_type sspm_find_major_content_type(char* type) -{ - int i; - - char* ltype = sspm_lowercase(type); - - for (i=0; major_content_type_map[i].type != SSPM_UNKNOWN_MAJOR_TYPE; i++){ - if(strncmp(ltype, major_content_type_map[i].str, - strlen(major_content_type_map[i].str))==0){ - free(ltype); - return major_content_type_map[i].type; - } - } - free(ltype); - return major_content_type_map[i].type; /* Should return SSPM_UNKNOWN_MINOR_TYPE */ -} - -enum sspm_minor_type sspm_find_minor_content_type(char* type) -{ - int i; - char* ltype = sspm_lowercase(type); - - char *p = strchr(ltype,'/'); - - if (p==0){ - free(ltype); - return SSPM_UNKNOWN_MINOR_TYPE; - } - - p++; /* Skip the '/' */ - - for (i=0; minor_content_type_map[i].type != SSPM_UNKNOWN_MINOR_TYPE; i++){ - if(strncmp(p, minor_content_type_map[i].str, - strlen(minor_content_type_map[i].str))==0){ - free(ltype); - return minor_content_type_map[i].type; - } - } - - free(ltype); - return minor_content_type_map[i].type; /* Should return SSPM_UNKNOWN_MINOR_TYPE */ -} - -const char* sspm_major_type_string(enum sspm_major_type type) -{ - int i; - - for (i=0; major_content_type_map[i].type != SSPM_UNKNOWN_MAJOR_TYPE; - i++){ - - if(type == major_content_type_map[i].type){ - return major_content_type_map[i].str; - } - } - - return major_content_type_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */ -} - -const char* sspm_minor_type_string(enum sspm_minor_type type) -{ - int i; - for (i=0; minor_content_type_map[i].type != SSPM_UNKNOWN_MINOR_TYPE; - i++){ - if(type == minor_content_type_map[i].type){ - return minor_content_type_map[i].str; - } - } - - return minor_content_type_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */ -} - - -const char* sspm_encoding_string(enum sspm_encoding type) -{ - int i; - for (i=0; sspm_encoding_map[i].encoding != SSPM_UNKNOWN_ENCODING; - i++){ - if(type == sspm_encoding_map[i].encoding){ - return sspm_encoding_map[i].str; - } - } - - return sspm_encoding_map[i].str; /* Should return SSPM_UNKNOWN_MINOR_TYPE */ -} - -/* Interpret a header line and add its data to the header - structure. */ -void sspm_build_header(struct sspm_header *header, char* line) -{ - char *prop; - char *val; - - val = sspm_strdup(sspm_value(line)); - prop = sspm_strdup(sspm_property_name(line)); - - if(strcasecmp(prop,"Content-Type") == 0){ - - /* Create a new mime_header, fill in content-type - and possibly boundary */ - - char* boundary= sspm_get_parameter(line,"boundary"); - - header->def = 0; - header->major = sspm_find_major_content_type(val); - header->minor = sspm_find_minor_content_type(val); - - if(header->minor == SSPM_UNKNOWN_MINOR_TYPE){ - char *p = strchr(val,'/'); - - if (p != 0){ - p++; /* Skip the '/' */ - - header->minor_text = sspm_strdup(p); - } else { - /* Error, malformed content type */ - header->minor_text = sspm_strdup("unknown"); - } - } - if (boundary != 0){ - header->boundary = sspm_strdup(boundary); - } - - } else if(strcasecmp(prop,"Content-Transfer-Encoding")==0){ - char* encoding = sspm_value(line); - char* lencoding = sspm_lowercase(encoding); - - if(strcasecmp(lencoding,"base64")==0){ - header->encoding = SSPM_BASE64_ENCODING; - } else if(strcasecmp(lencoding,"quoted-printable")==0){ - header->encoding = SSPM_QUOTED_PRINTABLE_ENCODING; - } else if(strcasecmp(lencoding,"binary")==0){ - header->encoding = SSPM_BINARY_ENCODING; - } else if(strcasecmp(lencoding,"7bit")==0){ - header->encoding = SSPM_7BIT_ENCODING; - } else if(strcasecmp(lencoding,"8bit")==0){ - header->encoding = SSPM_8BIT_ENCODING; - } else { - header->encoding = SSPM_UNKNOWN_ENCODING; - } - - - free(lencoding); - - header->def = 0; - - } else if(strcasecmp(prop,"Content-Id")==0){ - char* cid = sspm_value(line); - header->content_id = sspm_strdup(cid); - header->def = 0; - - } - free(val); - free(prop); -} - -char* sspm_get_next_line(struct mime_impl *impl) -{ - char* s; - s = impl->get_string(impl->temp,TMP_BUF_SIZE,impl->get_string_data); - - if(s == 0){ - impl->state = END_OF_INPUT; - } - return s; -} - - -void sspm_store_part(struct mime_impl *impl, struct sspm_header header, - int level, void *part, size_t size) -{ - - impl->parts[impl->part_no].header = header; - impl->parts[impl->part_no].level = level; - impl->parts[impl->part_no].data = part; - impl->parts[impl->part_no].data_size = size; - impl->part_no++; -} - -void sspm_set_error(struct sspm_header* header, enum sspm_error error, - char* message) -{ - header->error = error; - - if(header->error_text!=0){ - free(header->error_text); - } - - header->def = 0; - - if(message != 0){ - header->error_text = sspm_strdup(message); - } else { - header->error_text = 0; - } - -} - -void* sspm_make_part(struct mime_impl *impl, - struct sspm_header *header, - struct sspm_header *parent_header, - void **end_part, - size_t *size) -{ - - /* For a single part type, read to the boundary, if there is a - boundary. Otherwise, read until the end of input. This routine - assumes that the caller has read the header and has left the input - at the first blank line */ - - char *line; - void *part; - int end = 0; - - struct sspm_action_map action = get_action( - impl, - header->major, - header->minor); - - *size = 0; - part =action.new_part(); - - impl->state = IN_BODY; - - while(end == 0 && (line = sspm_get_next_line(impl)) != 0){ - - if(sspm_is_mime_boundary(line)){ - - /* If there is a boundary, then this must be a multipart - part, so there must be a parent_header. */ - if(parent_header == 0){ - char* boundary; - end = 1; - *end_part = 0; - - sspm_set_error(header,SSPM_UNEXPECTED_BOUNDARY_ERROR,line); - - /* Read until the paired terminating boundary */ - if((boundary = (char*)malloc(strlen(line)+5)) == 0){ - fprintf(stderr,"Out of memory"); - abort(); - } - strcpy(boundary,line); - strcat(boundary,"--"); - while((line = sspm_get_next_line(impl)) != 0){ - /*printf("Error: %s\n",line);*/ - if(strcmp(boundary,line)==0){ - break; - } - } - free(boundary); - - break; - } - - if(strcmp((line+2),parent_header->boundary) == 0) { - *end_part = action.end_part(part); - - if(sspm_is_mime_boundary(line)){ - impl->state = END_OF_PART; - } else if ( sspm_is_mime_terminating_boundary(line)){ - impl->state = TERMINAL_END_OF_PART; - } - end = 1; - } else { - /* Error, this is not the correct terminating boundary*/ - - /* read and discard until we get the right boundary. */ - char* boundary; - char msg[256]; - - snprintf(msg,256, - "Expected: %s--. Got: %s", - parent_header->boundary,line); - - sspm_set_error(parent_header, - SSPM_WRONG_BOUNDARY_ERROR,msg); - - /* Read until the paired terminating boundary */ - if((boundary = (char*)malloc(strlen(line)+5)) == 0){ - fprintf(stderr,"Out of memory"); - abort(); - } - strcpy(boundary,line); - strcat(boundary,"--"); - while((line = sspm_get_next_line(impl)) != 0){ - if(strcmp(boundary,line)==0){ - break; - } - } - free(boundary); - - } - } else { - char* data=0; - char* rtrn=0; - *size = strlen(line); - - data = (char*)malloc(*size+2); - assert(data != 0); - if (header->encoding == SSPM_BASE64_ENCODING){ - rtrn = decode_base64(data,line,size); - } else if(header->encoding == SSPM_QUOTED_PRINTABLE_ENCODING){ - rtrn = decode_quoted_printable(data,line,size); - } - - if(rtrn == 0){ - strcpy(data,line); - } - - /* add a end-of-string after the data, just in case binary - data from decode64 gets passed to a tring handling - routine in add_line */ - data[*size+1]='\0'; - - action.add_line(part,header,data,*size); - - free(data); - } - } - - if (end == 0){ - /* End the part if the input is exhausted */ - *end_part = action.end_part(part); - } - - return end_part; -} - - -void* sspm_make_multipart_subpart(struct mime_impl *impl, - struct sspm_header *parent_header) -{ - struct sspm_header header; - char *line; - void* part; - size_t size; - - if(parent_header->boundary == 0){ - /* Error. Multipart headers must have a boundary*/ - - sspm_set_error(parent_header,SSPM_NO_BOUNDARY_ERROR,0); - /* read all of the reamining lines */ - while((line = sspm_get_next_line(impl)) != 0){ - } - - return 0; - } - - - /* Step 1: Read the opening boundary */ - - if(get_line_type(impl->temp) != BOUNDARY){ - while((line=sspm_get_next_line(impl)) != 0 ){ - if(sspm_is_mime_boundary(line)){ - - assert(parent_header != 0); - - /* Check if it is the right boundary */ - if(!sspm_is_mime_terminating_boundary(line) && - strcmp((line+2),parent_header->boundary) - == 0){ - /* The +2 in strncmp skips over the leading "--" */ - - break; - } else { - /* Got the wrong boundary, so read and discard - until we get the right boundary. */ - char* boundary; - char msg[256]; - - snprintf(msg,256, - "Expected: %s. Got: %s", - parent_header->boundary,line); - - sspm_set_error(parent_header, - SSPM_WRONG_BOUNDARY_ERROR,msg); - - /* Read until the paired terminating boundary */ - if((boundary = (char*)malloc(strlen(line)+5)) == 0){ - fprintf(stderr,"Out of memory"); - abort(); - } - strcpy(boundary,line); - strcat(boundary,"--"); - while((line = sspm_get_next_line(impl)) != 0){ - if(strcmp(boundary,line)==0){ - break; - } - } - free(boundary); - - return 0; - } - } - } - } - - /* Step 2: Get the part header */ - sspm_read_header(impl,&header); - - /* If the header is still listed as default, there was probably an - error */ - if(header.def == 1 && header.error != SSPM_NO_ERROR){ - sspm_set_error(&header,SSPM_NO_HEADER_ERROR,0); - return 0; - } - - if(header.error!= SSPM_NO_ERROR){ - sspm_store_part(impl,header,impl->level,0,0); - return 0; - } - - /* Step 3: read the body */ - - if(header.major == SSPM_MULTIPART_MAJOR_TYPE){ - struct sspm_header *child_header; - child_header = &(impl->parts[impl->part_no].header); - - /* Store the multipart part */ - sspm_store_part(impl,header,impl->level,0,0); - - /* now get all of the sub-parts */ - part = sspm_make_multipart_part(impl,child_header); - - if(get_line_type(impl->temp) != TERMINATING_BOUNDARY){ - - sspm_set_error(child_header,SSPM_NO_BOUNDARY_ERROR,impl->temp); - return 0; - } - - sspm_get_next_line(impl); /* Step past the terminating boundary */ - - } else { - sspm_make_part(impl, &header,parent_header,&part,&size); - - memset(&(impl->parts[impl->part_no]), 0, sizeof(struct sspm_part)); - - sspm_store_part(impl,header,impl->level,part,size); - - } - - return part; -} - -void* sspm_make_multipart_part(struct mime_impl *impl,struct sspm_header *header) -{ - void *part=0; - - /* Now descend a level into each of the children of this part */ - impl->level++; - - /* Now we are working on the CHILD */ - memset(&(impl->parts[impl->part_no]), 0, sizeof(struct sspm_part)); - - do{ - part = sspm_make_multipart_subpart(impl,header); - - if (part==0){ - /* Clean up the part in progress */ - impl->parts[impl->part_no].header.major - = SSPM_NO_MAJOR_TYPE; - impl->parts[impl->part_no].header.minor - = SSPM_NO_MINOR_TYPE; - - } - - - } while (get_line_type(impl->temp) != TERMINATING_BOUNDARY && - impl->state != END_OF_INPUT); - - impl->level--; - - return 0; -} - - -void sspm_read_header(struct mime_impl *impl,struct sspm_header *header) -{ -#define BUF_SIZE 1024 -#define MAX_HEADER_LINES 25 - - char *buf; - char header_lines[MAX_HEADER_LINES][BUF_SIZE]; /* HACK, hard limits TODO*/ - int current_line = -1; - int end = 0; - - memset(header_lines,0,sizeof(header_lines)); - memset(header,0,sizeof(struct sspm_header)); - - /* Set up default header */ - header->def = 1; - header->major = SSPM_TEXT_MAJOR_TYPE; - header->minor = SSPM_PLAIN_MINOR_TYPE; - header->error = SSPM_NO_ERROR; - header->error_text = 0; - - /* Read all of the lines into memory */ - while(current_line<(MAX_HEADER_LINES-2) && - (end==0) && - ((buf=sspm_get_next_line(impl)) != 0)){ - - enum line_type line_type = get_line_type(buf); - - switch(line_type){ - case BLANK: { - end = 1; - impl->state = END_OF_HEADER; - break; - } - - case MAIL_HEADER: - case MIME_HEADER: { - impl->state = IN_HEADER; - current_line++; - - assert(strlen(buf) < BUF_SIZE); - - strncpy(header_lines[current_line],buf,BUF_SIZE); - header_lines[current_line][BUF_SIZE-1] = '\0'; - - break; - } - - case HEADER_CONTINUATION: { - char* last_line, *end; - char *buf_start; - - if(current_line < 0){ - /* This is not really a continuation line, since - we have not see any header line yet */ - sspm_set_error(header,SSPM_MALFORMED_HEADER_ERROR,buf); - return; - } - - last_line = header_lines[current_line]; - end = (char*) ( (size_t)strlen(last_line)+ - (size_t)last_line); - - impl->state = IN_HEADER; - - - /* skip over the spaces in buf start, and remove the new - line at the end of the lat line */ - if (last_line[strlen(last_line)-1] == '\n'){ - last_line[strlen(last_line)-1] = '\0'; - } - buf_start = buf; - while(*buf_start == ' ' ||*buf_start == '\t' ){ - buf_start++; - } - - assert( strlen(buf_start) + strlen(last_line) < BUF_SIZE); - - strncat(last_line,buf_start, BUF_SIZE-strlen(last_line)-1); - - break; - } - - default: { - sspm_set_error(header,SSPM_MALFORMED_HEADER_ERROR,buf); - return; - } - } - } - - - for(current_line = 0; - current_line < MAX_HEADER_LINES && header_lines[current_line][0] != 0; - current_line++){ - - sspm_build_header(header,header_lines[current_line]); - } - - -} - -/* Root routine for parsing mime entries*/ -int sspm_parse_mime(struct sspm_part *parts, - size_t max_parts, - const struct sspm_action_map *actions, - char* (*get_string)(char *s, size_t size, void* data), - void *get_string_data, - struct sspm_header *first_header - ) -{ - struct mime_impl impl; - struct sspm_header header; - void *part; - int i; - (void)first_header; - - /* Initialize all of the data */ - memset(&impl,0,sizeof(struct mime_impl)); - memset(&header,0,sizeof(struct sspm_header)); - - for(i = 0; i<(int)max_parts; i++){ - parts[i].header.major = SSPM_NO_MAJOR_TYPE; - parts[i].header.minor = SSPM_NO_MINOR_TYPE; - } - - impl.parts = parts; - impl.max_parts = max_parts; - impl.part_no = 0; - impl.actions = actions; - impl.get_string = get_string; - impl.get_string_data = get_string_data; - - /* Read the header of the message. This will be the email header, - unless first_header is specified. But ( HACK) that var is not - currently being used */ - sspm_read_header(&impl,&header); - - if(header.major == SSPM_MULTIPART_MAJOR_TYPE){ - struct sspm_header *child_header; - child_header = &(impl.parts[impl.part_no].header); - - sspm_store_part(&impl,header,impl.level,0,0); - - part = sspm_make_multipart_part(&impl,child_header); - - } else { - void *part; - size_t size; - sspm_make_part(&impl, &header, 0,&part,&size); - - memset(&(impl.parts[impl.part_no]), 0, sizeof(struct sspm_part)); - - sspm_store_part(&impl,header,impl.level,part,size); - } - - return 0; -} - -void sspm_free_parts(struct sspm_part *parts, size_t max_parts) -{ - int i; - - for(i = 0; i<(int)max_parts && parts[i].header.major != SSPM_NO_MAJOR_TYPE; - i++){ - sspm_free_header(&(parts[i].header)); - } -} - -void sspm_free_header(struct sspm_header *header) -{ - if(header->boundary!=0){ - free(header->boundary); - } - if(header->minor_text!=0){ - free(header->minor_text); - } - if(header->charset!=0){ - free(header->charset); - } - if(header->filename!=0){ - free(header->filename); - } - if(header->content_id!=0){ - free(header->content_id); - } - if(header->error_text!=0){ - free(header->error_text); - } -} - -/*********************************************************************** -The remaining code is beased on code from the mimelite distribution, -which has the following notice: - -| Authorship: -| Copyright (c) 1994 Gisle Hannemyr. -| Permission is granted to hack, make and distribute copies of this -| program as long as this copyright notice is not removed. -| Flames, bug reports, comments and improvements to: -| snail: Gisle Hannemyr, Brageveien 3A, 0452 Oslo, Norway -| email: Inet: gisle@oslonett.no - -The code is heavily modified by Eric Busboom. - -***********************************************************************/ - -char *decode_quoted_printable(char *dest, - char *src, - size_t *size) -{ - int cc; - size_t i=0; - - while (*src != 0 && i < *size) { - if (*src == '=') { - - src++; - if (!*src) { - break; - } - - /* remove soft line breaks*/ - if ((*src == '\n') || (*src == '\r')){ - src++; - if ((*src == '\n') || (*src == '\r')){ - src++; - } - continue; - } - - cc = isdigit(*src) ? (*src - '0') : (*src - 55); - cc *= 0x10; - src++; - if (!*src) { - break; - } - cc += isdigit(*src) ? (*src - '0') : (*src - 55); - - *dest = cc; - - } else { - *dest = *src; - } - - dest++; - src++; - i++; - } - - *dest = '\0'; - - *size = i; - return(dest); -} - -char *decode_base64(char *dest, - char *src, - size_t *size) -{ - int cc = 0; - char buf[4] = {0,0,0,0}; - int p = 0; - int valid_data = 0; - size_t size_out=0; - - while (*src && p<(int)*size && (cc!= -1)) { - - /* convert a character into the Base64 alphabet */ - cc = *src++; - - if ((cc >= 'A') && (cc <= 'Z')) cc = cc - 'A'; - else if ((cc >= 'a') && (cc <= 'z')) cc = cc - 'a' + 26; - else if ((cc >= '0') && (cc <= '9')) cc = cc - '0' + 52; - else if (cc == '/') cc = 63; - else if (cc == '+') cc = 62; - else cc = -1; - - assert(cc<64); - - /* If we've reached the end, fill the remaining slots in - the bucket and do a final conversion */ - if(cc== -1){ - if(valid_data == 0){ - return 0; - } - - while(p%4!=3){ - p++; - buf[p%4] = 0; - } - } else { - buf[p%4] = cc; - size_out++; - valid_data = 1; - } - - - /* When we have 4 base64 letters, convert them into three - bytes */ - if (p%4 == 3) { - *dest++ =(buf[0]<< 2)|((buf[1] & 0x30) >> 4); - *dest++ =((buf[1] & 0x0F) << 4)|((buf[2] & 0x3C) >> 2); - *dest++ =((buf[2] & 0x03) << 6)|(buf[3] & 0x3F); - - memset(buf,0,4); - } - - p++; - - } - /* Calculate the size of the converted data*/ - *size = ((int)(size_out/4))*3; - if(size_out%4 == 2) *size+=1; - if(size_out%4 == 3) *size+=2; - - return(dest); -} - - -/*********************************************************************** - - Routines to output MIME - -**********************************************************************/ - - -struct sspm_buffer { - char* buffer; - char* pos; - size_t buf_size; - int line_pos; -}; - -void sspm_append_string(struct sspm_buffer* buf, const char* string); -void sspm_write_part(struct sspm_buffer *buf,struct sspm_part *part, int *part_num); - -void sspm_append_hex(struct sspm_buffer* buf, char ch) -{ - char tmp[4]; - - snprintf(tmp,sizeof(tmp),"=%02X",ch); - - sspm_append_string(buf,tmp); -} - -/* a copy of icalmemory_append_char */ -void sspm_append_char(struct sspm_buffer* buf, char ch) -{ - char *new_buf; - char *new_pos; - - size_t data_length, final_length; - - data_length = (size_t)buf->pos - (size_t)buf->buffer; - - final_length = data_length + 2; - - if ( final_length > (size_t) buf->buf_size ) { - - buf->buf_size = (buf->buf_size) * 2 + final_length +1; - - new_buf = realloc(buf->buffer,buf->buf_size); - - new_pos = (void*)((size_t)new_buf + data_length); - - buf->pos = new_pos; - buf->buffer = new_buf; - } - - *(buf->pos) = ch; - buf->pos += 1; - *(buf->pos) = 0; -} -/* A copy of icalmemory_append_string */ -void sspm_append_string(struct sspm_buffer* buf, const char* string) -{ - char *new_buf; - char *new_pos; - - size_t data_length, final_length, string_length; - - string_length = strlen(string); - data_length = (size_t)buf->pos - (size_t)buf->buffer; - final_length = data_length + string_length; - - if ( final_length >= (size_t) buf->buf_size) { - - - buf->buf_size = (buf->buf_size) * 2 + final_length; - - new_buf = realloc(buf->buffer,buf->buf_size); - - new_pos = (void*)((size_t)new_buf + data_length); - - buf->pos = new_pos; - buf->buffer = new_buf; - } - - strcpy(buf->pos, string); - - buf->pos += string_length; -} - - - -static int sspm_is_printable(char c) -{ - return (c >= 33) && (c <= 126) && (c != '='); - -} - - -void sspm_encode_quoted_printable(struct sspm_buffer *buf, char* data) -{ - char *p; - int lpos = 0; - - for(p = data; *p != 0; p++){ - - if(sspm_is_printable(*p)){ - /* plain characters can represent themselves */ - /* RFC2045 Rule #2 */ - sspm_append_char(buf,*p); - lpos++; - } else if ( *p == '\t' || *p == ' ' ) { - - /* For tabs and spaces, only encode if they appear at the - end of the line */ - /* RFC2045 Rule #3 */ - - char n = *(p+1); - - if( n == '\n' || n == '\r'){ - sspm_append_hex(buf,*p); - lpos += 3; - } else { - sspm_append_char(buf,*p); - lpos++; - } - - } else if( *p == '\n' || *p == '\r'){ - sspm_append_char(buf,*p); - - lpos=0; - - } else { - /* All others need to be encoded */ - sspm_append_hex(buf,*p); - lpos+=3; - } - - - /* Add line breaks */ - if (lpos > 72){ - lpos = 0; - sspm_append_string(buf,"=\n"); - } - } -} - -static char BaseTable[64] = { - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', - 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', - 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' -}; - -void sspm_write_base64(struct sspm_buffer *buf, char* inbuf,int size ) -{ - - char outbuf[4]; - int i; - - outbuf[0] = outbuf[1] = outbuf[2] = outbuf[3] = 65; - - switch(size){ - - case 4: - outbuf[3] = inbuf[2] & 0x3F; - - case 3: - outbuf[2] = ((inbuf[1] & 0x0F) << 2) | ((inbuf[2] & 0xC0) >> 6); - - case 2: - outbuf[0] = (inbuf[0] & 0xFC) >> 2; - outbuf[1] = ((inbuf[0] & 0x03) << 4) | ((inbuf[1] & 0xF0) >> 4); - break; - - default: - assert(0); - } - - for(i = 0; i < 4; i++){ - - if(outbuf[i] == 65){ - sspm_append_char(buf,'='); - } else { - sspm_append_char(buf,BaseTable[(int)outbuf[i]]); - } - } -} - -void sspm_encode_base64(struct sspm_buffer *buf, char* data, size_t size) -{ - char *p; - char inbuf[3]; - int i = 0; - int first = 1; - int lpos = 0; - (void)size; - - inbuf[0] = inbuf[1] = inbuf[2] = 0; - - for (p = data; *p !=0; p++){ - - if (i%3 == 0 && first == 0){ - - sspm_write_base64(buf, inbuf, 4); - lpos+=4; - - inbuf[0] = inbuf[1] = inbuf[2] = 0; - } - - assert(lpos%4 == 0); - - if (lpos == 72){ - sspm_append_string(buf,"\n"); - lpos = 0; - } - - inbuf[i%3] = *p; - - i++; - first = 0; - - } - - - /* If the inbuf was not exactly filled on the last byte, we need - to spit out the odd bytes that did get in -- either one or - two. This will result in an output of two bytes and '==' or - three bytes and '=', respectively */ - - if (i%3 == 1 && first == 0){ - sspm_write_base64(buf, inbuf, 2); - } else if (i%3 == 2 && first == 0){ - sspm_write_base64(buf, inbuf, 3); - } - -} - -void sspm_write_header(struct sspm_buffer *buf,struct sspm_header *header) -{ - - int i; - char temp[TMP_BUF_SIZE]; - const char* major; - const char* minor; - - /* Content-type */ - - major = sspm_major_type_string(header->major); - minor = sspm_minor_type_string(header->minor); - - if(header->minor == SSPM_UNKNOWN_MINOR_TYPE ){ - assert(header->minor_text !=0); - minor = header->minor_text; - } - - snprintf(temp,sizeof(temp),"Content-Type: %s/%s",major,minor); - - sspm_append_string(buf,temp); - - if(header->boundary != 0){ - snprintf(temp,sizeof(temp),";boundary=\"%s\"",header->boundary); - sspm_append_string(buf,temp); - } - - /* Append any content type parameters */ - if(header->content_type_params != 0){ - for(i=0; *(header->content_type_params[i])!= 0;i++){ - snprintf(temp, sizeof(temp),"%s", header->content_type_params[i]); - sspm_append_char(buf, ';'); - sspm_append_string(buf, temp); - } - } - - sspm_append_char(buf,'\n'); - - /*Content-Transfer-Encoding */ - - if(header->encoding != SSPM_UNKNOWN_ENCODING && - header->encoding != SSPM_NO_ENCODING){ - snprintf(temp,sizeof(temp),"Content-Transfer-Encoding: %s\n", - sspm_encoding_string(header->encoding)); - } - - sspm_append_char(buf,'\n'); - -} - -void sspm_write_multipart_part(struct sspm_buffer *buf, - struct sspm_part *parts, - int* part_num) -{ - - int parent_level, level; - struct sspm_header *header = &(parts[*part_num].header); - /* Write the header for the multipart part */ - sspm_write_header(buf,header); - - parent_level = parts[*part_num].level; - - (*part_num)++; - - level = parts[*part_num].level; - - while(parts[*part_num].header.major != SSPM_NO_MAJOR_TYPE && - level == parent_level+1){ - - assert(header->boundary); - sspm_append_string(buf,header->boundary); - sspm_append_char(buf,'\n'); - - if (parts[*part_num].header.major == SSPM_MULTIPART_MAJOR_TYPE){ - sspm_write_multipart_part(buf,parts,part_num); - } else { - sspm_write_part(buf, &(parts[*part_num]), part_num); - } - - (*part_num)++; - level = parts[*part_num].level; - } - - sspm_append_string(buf,"\n\n--"); - sspm_append_string(buf,header->boundary); - sspm_append_string(buf,"\n"); - - (*part_num)--; /* undo last, spurious, increment */ -} - -void sspm_write_part(struct sspm_buffer *buf,struct sspm_part *part,int *part_num) -{ - (void)part_num; - - /* Write header */ - sspm_write_header(buf,&(part->header)); - - /* Write part data */ - - if(part->data == 0){ - return; - } - - if(part->header.encoding == SSPM_BASE64_ENCODING) { - assert(part->data_size != 0); - sspm_encode_base64(buf,part->data,part->data_size); - } else if(part->header.encoding == SSPM_QUOTED_PRINTABLE_ENCODING) { - sspm_encode_quoted_printable(buf,part->data); - } else { - sspm_append_string(buf,part->data); - } - - sspm_append_string(buf,"\n\n"); -} - -int sspm_write_mime(struct sspm_part *parts,size_t num_parts, - char **output_string, const char* header) -{ - struct sspm_buffer buf; - int part_num =0; - int slen; - (void)num_parts; - - buf.buffer = malloc(4096); - buf.buffer[0] = '\0'; - buf.pos = buf.buffer; - buf.buf_size = 10; - buf.line_pos = 0; - - /* write caller's header */ - if(header != 0){ - sspm_append_string(&buf,header); - } - - slen = strlen(buf.buffer); - if(slen > 0 && buf.buffer[slen-1] != '\n'){ - sspm_append_char(&buf,'\n'); - } - - /* write mime-version header */ - sspm_append_string(&buf,"Mime-Version: 1.0\n"); - - /* End of header */ - - /* Write body parts */ - while(parts[part_num].header.major != SSPM_NO_MAJOR_TYPE){ - if (parts[part_num].header.major == SSPM_MULTIPART_MAJOR_TYPE){ - sspm_write_multipart_part(&buf,parts,&part_num); - } else { - sspm_write_part(&buf, &(parts[part_num]), &part_num); - } - - part_num++; - } - - - *output_string = buf.buffer; - - return 0; -} - diff --git a/calendar/libical/src/libical/sspm.h b/calendar/libical/src/libical/sspm.h deleted file mode 100644 index fad0bb6538..0000000000 --- a/calendar/libical/src/libical/sspm.h +++ /dev/null @@ -1,146 +0,0 @@ -/* -*- Mode: C -*- - ====================================================================== - FILE: sspm.h Mime Parser - CREATOR: eric 25 June 2000 - - $Id: sspm.h,v 1.5 2008-01-15 23:17:43 dothebart Exp $ - $Locker: $ - - (C) COPYRIGHT 2000, Eric Busboom - http://www.softwarestudio.org - - The contents of this file are subject to the Mozilla Public License - Version 1.0 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - the License for the specific language governing rights and - limitations under the License. - - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - - The Initial Developer of the Original Code is Eric Busboom - - (C) COPYRIGHT 2000, Eric Busboom, http://www.softwarestudio.org - ======================================================================*/ - -#ifndef SSPM_H -#define SSPM_H - -enum sspm_major_type { - SSPM_NO_MAJOR_TYPE, - SSPM_TEXT_MAJOR_TYPE, - SSPM_IMAGE_MAJOR_TYPE, - SSPM_AUDIO_MAJOR_TYPE, - SSPM_VIDEO_MAJOR_TYPE, - SSPM_APPLICATION_MAJOR_TYPE, - SSPM_MULTIPART_MAJOR_TYPE, - SSPM_MESSAGE_MAJOR_TYPE, - SSPM_UNKNOWN_MAJOR_TYPE -}; - -enum sspm_minor_type { - SSPM_NO_MINOR_TYPE, - SSPM_ANY_MINOR_TYPE, - SSPM_PLAIN_MINOR_TYPE, - SSPM_RFC822_MINOR_TYPE, - SSPM_DIGEST_MINOR_TYPE, - SSPM_CALENDAR_MINOR_TYPE, - SSPM_MIXED_MINOR_TYPE, - SSPM_RELATED_MINOR_TYPE, - SSPM_ALTERNATIVE_MINOR_TYPE, - SSPM_PARALLEL_MINOR_TYPE, - SSPM_UNKNOWN_MINOR_TYPE -}; - -enum sspm_encoding { - SSPM_NO_ENCODING, - SSPM_QUOTED_PRINTABLE_ENCODING, - SSPM_8BIT_ENCODING, - SSPM_7BIT_ENCODING, - SSPM_BINARY_ENCODING, - SSPM_BASE64_ENCODING, - SSPM_UNKNOWN_ENCODING -}; - -enum sspm_error{ - SSPM_NO_ERROR, - SSPM_UNEXPECTED_BOUNDARY_ERROR, - SSPM_WRONG_BOUNDARY_ERROR, - SSPM_NO_BOUNDARY_ERROR, - SSPM_NO_HEADER_ERROR, - SSPM_MALFORMED_HEADER_ERROR -}; - - -struct sspm_header -{ - int def; - char* boundary; - enum sspm_major_type major; - enum sspm_minor_type minor; - char *minor_text; - char ** content_type_params; - char* charset; - enum sspm_encoding encoding; - char* filename; - char* content_id; - enum sspm_error error; - char* error_text; -}; - -struct sspm_part { - struct sspm_header header; - int level; - size_t data_size; - void *data; -}; - -struct sspm_action_map { - enum sspm_major_type major; - enum sspm_minor_type minor; - void* (*new_part)(void); - void (*add_line)(void *part, struct sspm_header *header, - const char* line, size_t size); - void* (*end_part)(void* part); - void (*free_part)(void *part); -}; - -const char* sspm_major_type_string(enum sspm_major_type type); -const char* sspm_minor_type_string(enum sspm_minor_type type); -const char* sspm_encoding_string(enum sspm_encoding type); - -int sspm_parse_mime(struct sspm_part *parts, - size_t max_parts, - const struct sspm_action_map *actions, - char* (*get_string)(char *s, size_t size, void* data), - void *get_string_data, - struct sspm_header *first_header - ); - -void sspm_free_parts(struct sspm_part *parts, size_t max_parts); - -char *decode_quoted_printable(char *dest, - char *src, - size_t *size); -char *decode_base64(char *dest, - char *src, - size_t *size); - - -int sspm_write_mime(struct sspm_part *parts,size_t num_parts, - char **output_string, const char* header); - -#endif /*SSPM_H*/ diff --git a/calendar/libical/src/libical/vcomponent.h b/calendar/libical/src/libical/vcomponent.h deleted file mode 100644 index ec9652362c..0000000000 --- a/calendar/libical/src/libical/vcomponent.h +++ /dev/null @@ -1,351 +0,0 @@ -/* -*- Mode: C++ -*- */ - -/** - * @file vcomponent.h - * @author fnguyen (12/10/01) - * @brief C++ classes for the icalcomponent wrapper (VToDo VEvent, etc..). - * - * (C) COPYRIGHT 2001, Critical Path - - This program is free software; you can redistribute it and/or modify - it under the terms of either: - - The LGPL as published by the Free Software Foundation, version - 2.1, available at: http://www.fsf.org/copyleft/lesser.html - - Or: - - The Mozilla Public License Version 1.0. You may obtain a copy of - the License at http://www.mozilla.org/MPL/ - */ - -#ifndef VCOMPONENT_H -#define VCOMPONENT_H - -#include "ical.h" -#include "icptrholder.h" - -typedef char* string; // Will use the string library from STL - -class ICalProperty; - -/** - * @class VComponent - * @brief A class wrapping the libical icalcomponent functions - * - * @exception icalerrorenum Any errors generated in libical are - * propogated via this exception type. - */ - -class VComponent { -public: - VComponent() throw (icalerrorenum); - VComponent(const VComponent&) throw (icalerrorenum); - VComponent& operator=(const VComponent&) throw (icalerrorenum); - virtual ~VComponent(); - - VComponent(icalcomponent* v) throw (icalerrorenum); - VComponent(string str) throw (icalerrorenum); - VComponent(icalcomponent_kind kind) throw (icalerrorenum);; - - operator icalcomponent* () { return imp; } - - void new_from_string(string str); - - // detach imp to this object. use with caution. it would cause - // memory leak if you are not careful. - void detach() { - imp = NULL; - } - -public: - string as_ical_string() throw (icalerrorenum); - bool is_valid(); - icalcomponent_kind isa(); - int isa_component(void* component); - - /// Working with properties - void add_property(ICalProperty* property); - void remove_property(ICalProperty* property); - int count_properties(icalproperty_kind kind); - - // Iterate through the properties - ICalProperty* get_current_property(); - ICalProperty* get_first_property(icalproperty_kind kind); - ICalProperty* get_next_property(icalproperty_kind kind); - - // Working with components - - /** - * Return the first VEVENT, VTODO or VJOURNAL sub-component if - * it is one of those types - */ - - VComponent* get_inner(); - - void add_component(VComponent* child); - void remove_component(VComponent* child); - int count_components(icalcomponent_kind kind); - - /** - * Iteration Routines. There are two forms of iterators, - * internal and external. The internal ones came first, and - * are almost completely sufficient, but they fail badly when - * you want to construct a loop that removes components from - * the container. - */ - - /// Iterate through components - VComponent* get_current_component(); - VComponent* get_first_component(icalcomponent_kind kind); - VComponent* get_next_component(icalcomponent_kind kind); - - /// Using external iterators - icalcompiter begin_component(icalcomponent_kind kind); - icalcompiter end_component(icalcomponent_kind kind); - VComponent* next(icalcompiter* i); - VComponent* prev(icalcompiter* i); - VComponent* current(icalcompiter* i); - - /// Working with embedded error properties - int count_errors(); - - /// Remove all X-LIC-ERROR properties - void strip_errors(); - - /// Convert some X-LIC-ERROR properties into RETURN-STATUS properties - void convert_errors(); - - /// Kind conversion routines - static icalcomponent_kind string_to_kind(string str); - static string kind_to_string(icalcomponent_kind kind); - -public: - struct icaltimetype get_dtstart(); - void set_dtstart(struct icaltimetype v); - - /** For the icalcomponent routines only, dtend and duration - * are tied together. If you call the set routine for one and - * the other exists, the routine will calculate the change to - * the other. That is, if there is a DTEND and you call - * set_duration, the routine will modify DTEND to be the sum - * of DTSTART and the duration. If you call a get routine for - * one and the other exists, the routine will calculate the - * return value. If you call a set routine and neither - * exists, the routine will create the apropriate property - */ - - struct icaltimetype get_dtend(); - void set_dtend(struct icaltimetype v); - - struct icaltimetype get_due(); - void set_due(struct icaltimetype v); - - struct icaldurationtype get_duration(); - void set_duration(struct icaldurationtype v); - - icalproperty_method get_method(); - void set_method(icalproperty_method method); - - struct icaltimetype get_dtstamp(); - void set_dtstamp(struct icaltimetype v); - - string get_summary(); - void set_summary(string v); - - string get_location(); - void set_location(string v); - - string get_description(); - void set_description(string v); - - string get_comment(); - void set_comment(string v); - - string get_uid(); - void set_uid(string v); - - string get_relcalid(); - void set_relcalid(string v); - - struct icaltimetype get_recurrenceid(); - void set_recurrenceid(struct icaltimetype v); - - int get_sequence(); - void set_sequence(int v); - - int get_status(); - void set_status(enum icalproperty_status v); - - -public: - /** - * For VCOMPONENT: Return a reference to the first VEVENT, - * VTODO, or VJOURNAL - */ - VComponent* get_first_real_component(); - - /** - * For VEVENT, VTODO, VJOURNAL and VTIMEZONE: report the - * start and end times of an event in UTC - */ - virtual struct icaltime_span get_span(); - - int recurrence_is_excluded(struct icaltimetype *dtstart, - struct icaltimetype *recurtime); - - -public: - /** - helper functions for adding/removing/updating property and - sub-components */ - - /// Note: the VComponent kind have to be the same - - bool remove(VComponent&, bool ignoreValue); - bool update(VComponent&, bool removeMissing); - bool add(VComponent&); - -private: - /* Internal operations. They are private, and you should not be using them. */ - VComponent* get_parent(); - void set_parent(VComponent *parent); - - char* quote_ical_string(char* str); - -private: - icalcomponent* imp; -}; - -class VCalendar : public VComponent { -public: - VCalendar(); - VCalendar(const VCalendar&); - VCalendar& operator=(const VCalendar&); - ~VCalendar(); - - VCalendar(icalcomponent* v); - VCalendar(string str); -}; - - -class VEvent : public VComponent { -public: - VEvent(); - VEvent(const VEvent&); - VEvent& operator=(const VEvent&); - ~VEvent(); - - VEvent(icalcomponent* v); - VEvent(string str); -}; - -class VToDo : public VComponent { -public: - VToDo(); - VToDo(const VToDo&); - VToDo& operator=(const VToDo&); - ~VToDo(); - - VToDo(icalcomponent* v); - VToDo(string str); -}; - -class VAgenda : public VComponent { -public: - VAgenda(); - VAgenda(const VAgenda&); - VAgenda& operator=(const VAgenda&); - ~VAgenda(); - - VAgenda(icalcomponent* v); - VAgenda(string str); -}; - -class VQuery : public VComponent { -public: - VQuery(); - VQuery(const VQuery&); - VQuery& operator=(const VQuery&); - ~VQuery(); - - VQuery(icalcomponent* v); - VQuery(string str); -}; - -class VJournal : public VComponent { -public: - VJournal(); - VJournal(const VJournal&); - VJournal& operator=(const VJournal&); - ~VJournal(); - - VJournal(icalcomponent* v); - VJournal(string str); -}; - -class VAlarm : public VComponent { -public: - VAlarm(); - VAlarm(const VAlarm&); - VAlarm& operator=(const VAlarm&); - ~VAlarm(); - - VAlarm(icalcomponent* v); - VAlarm(string str); - - /** - * compute the absolute trigger time for this alarm. trigger - * may be related to the containing component c. the result - * is populated in tr->time - */ - icalrequeststatus getTriggerTime(VComponent &c, struct icaltriggertype *tr); -}; - -class VFreeBusy : public VComponent { -public: - VFreeBusy(); - VFreeBusy(const VFreeBusy&); - VFreeBusy& operator=(const VFreeBusy&); - ~VFreeBusy(); - - VFreeBusy(icalcomponent* v); - VFreeBusy(string str); -}; - -class VTimezone : public VComponent { -public: - VTimezone(); - VTimezone(const VTimezone&); - VTimezone& operator=(const VTimezone&); - ~VTimezone(); - - VTimezone(icalcomponent* v); - VTimezone(string str); -}; - -class XStandard : public VComponent { -public: - XStandard(); - XStandard(const XStandard&); - XStandard& operator=(const XStandard&); - ~XStandard(); - - XStandard(icalcomponent* v); - XStandard(string str); -}; - -class XDaylight : public VComponent { -public: - XDaylight(); - XDaylight(const XDaylight&); - XDaylight& operator=(const XDaylight&); - ~XDaylight(); - - XDaylight(icalcomponent* v); - XDaylight(string str); -}; - -typedef ICPointerHolder VComponentTmpPtr; /* see icptrholder.h for comments */ - -#endif /* VComponent_H */ diff --git a/calendar/libical/src/libical/vsnprintf.c b/calendar/libical/src/libical/vsnprintf.c deleted file mode 100644 index cb416bcd79..0000000000 --- a/calendar/libical/src/libical/vsnprintf.c +++ /dev/null @@ -1,173 +0,0 @@ -#ifndef WIN32 -#include "config.h" -#endif -#ifndef HAVE_SNPRINTF -#error DO NOT USE libical version of vsnprintf. -/* - * Revision 12: http://theos.com/~deraadt/snprintf.c - * - * Copyright (c) 1997 Theo de Raadt - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WIN32 -#include -#include -#include -#endif -#include -#include -#include -#include -#if __STDC__ -#include -#include -#else -#include -#endif -#include - -#ifndef roundup -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) -#endif - -static int pgsize; -static char *curobj; -static sigjmp_buf bail; - -#define EXTRABYTES 2 /* XXX: why 2? you don't want to know */ - -static char * -msetup(str, n) - char *str; - size_t n; -{ - char *e; - - if (n == 0) - return NULL; - if (pgsize == 0) - pgsize = getpagesize(); - curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2); - if (curobj == NULL) - return NULL; - e = curobj + n + EXTRABYTES; - e = (char *)roundup((unsigned long)e, pgsize); - if (mprotect(e, pgsize, PROT_NONE) == -1) { - free(curobj); - curobj = NULL; - return NULL; - } - e = e - n - EXTRABYTES; - *e = '\0'; - return (e); -} - -static void -mcatch(int i) -{ - siglongjmp(bail, 1); -} - -static void -mcleanup(str, n, p) - char *str; - size_t n; - char *p; -{ - strncpy(str, p, n-1); - str[n-1] = '\0'; - if (mprotect((caddr_t)(p + n + EXTRABYTES), pgsize, - PROT_READ|PROT_WRITE|PROT_EXEC) == -1) - mprotect((caddr_t)(p + n + EXTRABYTES), pgsize, - PROT_READ|PROT_WRITE); - free(curobj); -} - -int -#if __STDC__ -vsnprintf(char *str, size_t n, char const *fmt, va_list ap) -#else -vsnprintf(str, n, fmt, ap) - char *str; - size_t n; - char *fmt; - char *ap; -#endif -{ - struct sigaction osa, nsa; - char *p; - int ret = n + 1; /* if we bail, indicated we overflowed */ - - memset(&nsa, 0, sizeof nsa); - nsa.sa_handler = mcatch; - sigemptyset(&nsa.sa_mask); - - p = msetup(str, n); - if (p == NULL) { - *str = '\0'; - return 0; - } - if (sigsetjmp(bail, 1) == 0) { - if (sigaction(SIGSEGV, &nsa, &osa) == -1) { - mcleanup(str, n, p); - return (0); - } - ret = vsprintf(p, fmt, ap); - } - mcleanup(str, n, p); - (void) sigaction(SIGSEGV, &osa, NULL); - return (ret); -} - -int -#if __STDC__ -snprintf(char *str, size_t n, char const *fmt, ...) -#else -snprintf(str, n, fmt, va_alist) - char *str; - size_t n; - char *fmt; - va_dcl -#endif -{ - va_list ap; -#if __STDC__ - va_start(ap, fmt); -#else - va_start(ap); -#endif - - return (vsnprintf(str, n, fmt, ap)); - va_end(ap); -} - - -#else - -/* ANSI C forbids an empty source file... */ - -static void vsnprintf_dummy_func() { - vsnprintf_dummy_func(); -} - -#endif diff --git a/calendar/libical/src/libical/vsnprintf.h b/calendar/libical/src/libical/vsnprintf.h deleted file mode 100644 index 104a53a939..0000000000 --- a/calendar/libical/src/libical/vsnprintf.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifdef WIN32 - -#ifndef roundup -#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) -#endif - -#include -#include - -int -#if __STDC__ -vsnprintf(char *str, size_t n, char const *fmt, va_list ap); -#else -vsnprintf(str, n, fmt, ap); - char *str; - size_t n; - char *fmt; - char *ap; -#endif - - -int -#if __STDC__ -snprintf(char *str, size_t n, char const *fmt, ...); -#else -snprintf(str, n, fmt, va_alist); - char *str; - size_t n; - char *fmt; - va_dcl -#endif - -#endif diff --git a/calendar/moz.build b/calendar/moz.build index 9fec872f43..8324779713 100644 --- a/calendar/moz.build +++ b/calendar/moz.build @@ -8,7 +8,6 @@ DIRS += [ "extract", "import-export", "itip", - "libical", "locales", "providers", ] diff --git a/calendar/test/moz.build b/calendar/test/moz.build index fa6ae4de44..8c6dc6b9db 100644 --- a/calendar/test/moz.build +++ b/calendar/test/moz.build @@ -26,6 +26,5 @@ TESTING_JS_MODULES.calendar += [ XPCSHELL_TESTS_MANIFESTS += [ "unit/providers/xpcshell.ini", - "unit/xpcshell-icaljs.ini", - "unit/xpcshell-libical.ini", + "unit/xpcshell.ini", ] diff --git a/calendar/test/unit/head_consts.js b/calendar/test/unit/head.js similarity index 100% rename from calendar/test/unit/head_consts.js rename to calendar/test/unit/head.js diff --git a/calendar/test/unit/head_icaljs.js b/calendar/test/unit/head_icaljs.js deleted file mode 100644 index 80d66818fd..0000000000 --- a/calendar/test/unit/head_icaljs.js +++ /dev/null @@ -1,5 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -Services.prefs.setBoolPref("calendar.icaljs", true); diff --git a/calendar/test/unit/head_libical.js b/calendar/test/unit/head_libical.js deleted file mode 100644 index a1317a817c..0000000000 --- a/calendar/test/unit/head_libical.js +++ /dev/null @@ -1,5 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -Services.prefs.setBoolPref("calendar.icaljs", false); diff --git a/calendar/test/unit/test_freebusy.js b/calendar/test/unit/test_freebusy.js index e00fbd8508..7485eea265 100644 --- a/calendar/test/unit/test_freebusy.js +++ b/calendar/test/unit/test_freebusy.js @@ -58,23 +58,21 @@ function test_period() { equal(period.duration.icalString, "PT1S"); period.makeImmutable(); - if (!Services.prefs.getBoolPref("calendar.icaljs", false)) { - // ical.js doesn't support immutability yet - throws( - () => { - period.start = cal.createDateTime("20120202T020202"); - }, - /0x80460002/, - "Object is Immutable" - ); - throws( - () => { - period.end = cal.createDateTime("20120202T020202"); - }, - /0x80460002/, - "Object is Immutable" - ); - } + // ical.js doesn't support immutability yet + // throws( + // () => { + // period.start = cal.createDateTime("20120202T020202"); + // }, + // /0x80460002/, + // "Object is Immutable" + // ); + // throws( + // () => { + // period.end = cal.createDateTime("20120202T020202"); + // }, + // /0x80460002/, + // "Object is Immutable" + // ); let copy = period.clone(); equal(copy.start.icalString, "20120101T010105"); diff --git a/calendar/test/unit/test_ics_parser.js b/calendar/test/unit/test_ics_parser.js index 69a2f7ba43..7df927c497 100644 --- a/calendar/test/unit/test_ics_parser.js +++ b/calendar/test/unit/test_ics_parser.js @@ -9,9 +9,7 @@ function run_test() { function really_run_test() { test_roundtrip(); test_async(); - if (Services.prefs.getBoolPref("calendar.icaljs", false)) { - test_failures(); - } + test_failures(); test_fake_parent(); test_props_comps(); test_timezone(); diff --git a/calendar/test/unit/test_ics_service.js b/calendar/test/unit/test_ics_service.js index 19ea772694..464b82b130 100644 --- a/calendar/test/unit/test_ics_service.js +++ b/calendar/test/unit/test_ics_service.js @@ -20,11 +20,7 @@ function really_run_test() { test_icsservice(); test_icalstring(); test_param(); - - // Only supported with ical.js - if (Services.prefs.getBoolPref("calendar.icaljs", false)) { - test_icalproperty(); - } + test_icalproperty(); } function test_icalstring() { @@ -87,19 +83,10 @@ function test_icalstring() { ); equal(rrule.getComponent("BYDAY").toString(), [2].toString()); - if (Services.prefs.getBoolPref("calendar.icaljs", false)) { - let rdate = checkComp(cal.createRecurrenceDate.bind(cal), "RDATE:20120101T000000", { - isNegative: false, - }); - equal(rdate.date.compare(cal.createDateTime("20120101T000000")), 0); - } else { - let rdate = checkComp( - cal.createRecurrenceDate.bind(cal), - "RDATE;VALUE=DATE-TIME:20120101T000000", - { isNegative: false } - ); - equal(rdate.date.compare(cal.createDateTime("20120101T000000")), 0); - } + let rdate = checkComp(cal.createRecurrenceDate.bind(cal), "RDATE:20120101T000000", { + isNegative: false, + }); + equal(rdate.date.compare(cal.createDateTime("20120101T000000")), 0); /* TODO consider removing period support, ics throws badarg let rdateperiod = checkComp(cal.createRecurrenceDate.bind(cal), diff --git a/calendar/test/unit/xpcshell-icaljs.ini b/calendar/test/unit/xpcshell-icaljs.ini deleted file mode 100644 index 5223d53c8c..0000000000 --- a/calendar/test/unit/xpcshell-icaljs.ini +++ /dev/null @@ -1,8 +0,0 @@ -[DEFAULT] -tags = calendar icaljs -head = head_icaljs.js head_consts.js -tail = -dupe-manifest = -support-files = data/** - -[include:xpcshell-shared.ini] diff --git a/calendar/test/unit/xpcshell-libical.ini b/calendar/test/unit/xpcshell-libical.ini deleted file mode 100644 index 92ce681faf..0000000000 --- a/calendar/test/unit/xpcshell-libical.ini +++ /dev/null @@ -1,8 +0,0 @@ -[DEFAULT] -tags = calendar libical -head = head_libical.js head_consts.js -tail = -dupe-manifest = -support-files = data/** - -[include:xpcshell-shared.ini] diff --git a/calendar/test/unit/xpcshell-shared.ini b/calendar/test/unit/xpcshell.ini similarity index 96% rename from calendar/test/unit/xpcshell-shared.ini rename to calendar/test/unit/xpcshell.ini index d2eca4099c..95ea06f9a1 100644 --- a/calendar/test/unit/xpcshell-shared.ini +++ b/calendar/test/unit/xpcshell.ini @@ -1,7 +1,10 @@ [DEFAULT] +head = head.js prefs = calendar.timezone.local=UTC calendar.timezone.use-system-timezone=false +support-files = data/** +tags = calendar [test_alarm.js] [test_alarmservice.js] diff --git a/mail/installer/package-manifest.in b/mail/installer/package-manifest.in index 1ff1630a65..791fdf004e 100644 --- a/mail/installer/package-manifest.in +++ b/mail/installer/package-manifest.in @@ -330,19 +330,10 @@ @RESPATH@/res/zones.json @RESPATH@/@PREF_DIR@/calendar.js -# Files added to components directory via `EXTRA_COMPONENTS`. -@RESPATH@/components/calICALJSComponents.js - # Files added to components directory via `FINAL_TARGET_FILES.components`. @RESPATH@/components/calCachedCalendar.js -@RESPATH@/components/calDateTime.js -@RESPATH@/components/calDuration.js -@RESPATH@/components/calICSService.js @RESPATH@/components/calICSService-worker.js @RESPATH@/components/calItemBase.js -@RESPATH@/components/calPeriod.js -@RESPATH@/components/calRecurrenceRule.js -@RESPATH@/components/calTimezone.js @RESPATH@/components/SyncComponents.manifest @RESPATH@/components/servicesComponents.manifest