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
This commit is contained in:
Geoff Lankow 2022-08-25 15:54:49 +12:00
Родитель 81be03390e
Коммит fc256b5150
138 изменённых файлов: 161 добавлений и 31996 удалений

Просмотреть файл

@ -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/.*

Просмотреть файл

@ -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);
},
};
}

Просмотреть файл

@ -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"],
},
]

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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")

Просмотреть файл

@ -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

Просмотреть файл

@ -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<icaltimezone*>(icalt.zone),
&icalt, &dst);
return NS_OK;
}
NS_IMETHODIMP
calDateTime::SetNativeTime(PRTime aNativeTime) {
icaltimetype icalt;
PRTimeToIcaltime(aNativeTime, false, icaltimezone_get_utc_timezone(), &icalt);
nsCOMPtr<calITimezone> 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<calIDurationLibical> 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<int>((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<int16_t>(mIsDate), mNativeTime);
if (length != static_cast<uint32_t>(-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<icaltimezone*>(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<nsresult>(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<int16_t>(t.year);
mMonth = static_cast<int16_t>(t.month - 1);
mDay = static_cast<int16_t>(t.day);
mHour = static_cast<int16_t>(t.hour);
mMinute = static_cast<int16_t>(t.minute);
mSecond = static_cast<int16_t>(t.second);
if (tz) {
mTimezone = tz;
} else {
mTimezone = cal::detectTimezone(t, nullptr);
}
#if defined(DEBUG)
if (mTimezone) {
if (t.is_utc) {
nsCOMPtr<calITimezone> ctz = cal::UTC();
NS_ASSERTION(SameCOMIdentity(mTimezone, ctz), "UTC mismatch!");
} else if (!t.zone) {
nsAutoCString tzid;
mTimezone->GetTzid(tzid);
if (tzid.EqualsLiteral("floating")) {
nsCOMPtr<calITimezone> 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<icaltimezone*>(t.zone))),
"tzid mismatch!");
}
}
#endif
mWeekday = static_cast<int16_t>(icaltime_day_of_week(t) - 1);
mYearday = static_cast<int16_t>(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<icaltimezone*>(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<int16_t>(tt.day);
et.tm_month = static_cast<int16_t>(tt.month - 1);
et.tm_year = static_cast<int16_t>(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<calIDateTimeLibical> 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;
}

Просмотреть файл

@ -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<calITimezone> 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

Просмотреть файл

@ -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<JS::Value>) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
calDuration::SetIcalDuration(JS::Handle<JS::Value>) {
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<calIDurationLibical> 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;
}

Просмотреть файл

@ -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_ */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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<calIIcsComponentParsingListener>(
"calICSService::mListener", listener);
}
NS_DECL_NSIRUNNABLE
protected:
nsCString mString;
nsCOMPtr<calITimezoneProvider> mProvider;
nsMainThreadPtrHandle<calIIcsComponentParsingListener> mListener;
nsCOMPtr<nsIThread> mMainThread;
nsCOMPtr<nsIThread> mWorkerThread;
class ParserWorkerCompleter : public mozilla::Runnable {
public:
ParserWorkerCompleter(
nsIThread* workerThread, nsresult status,
calIIcalComponent* component,
const nsMainThreadPtrHandle<calIIcsComponentParsingListener>&
listener)
: mozilla::Runnable("ParserWorkerCompleter"),
mWorkerThread(workerThread),
mListener(listener),
mComp(component),
mStatus(status) {}
NS_DECL_NSIRUNNABLE
protected:
nsCOMPtr<nsIThread> mWorkerThread;
nsMainThreadPtrHandle<calIIcsComponentParsingListener> mListener;
nsCOMPtr<calIIcalComponent> 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<calIIcalComponentLibical> 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<calIcalComponent const*>(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<calIcalComponent*>(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<nsCStringHashKey, calITimezone> mReferencedTimezones;
icalcomponent* mComponent;
icaltimezone* mTimezone; // set iff VTIMEZONE
nsCOMPtr<calITimezoneProvider> const mTzProvider;
nsCOMPtr<calIIcalComponentLibical> mParent;
};
inline calIcalProperty* toIcalProperty(calIIcalPropertyLibical* p) {
return static_cast<calIcalProperty*>(p);
}
inline calIcalComponent* toIcalComponent(calIIcalComponentLibical* p) {
return static_cast<calIcalComponent*>(p);
}
#endif // INCLUDED_CALICSSERVICE_H

Просмотреть файл

@ -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<calIDateTime> start;
cpt.mStart->Clone(getter_AddRefs(start));
mStart = do_QueryInterface(start);
}
if (cpt.mEnd) {
nsCOMPtr<calIDateTime> 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<JS::Value>) {
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
calPeriod::SetIcalPeriod(JS::Handle<JS::Value>) {
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;
}

Просмотреть файл

@ -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<calIDateTimeLibical> mStart;
nsCOMPtr<calIDateTimeLibical> mEnd;
void FromIcalPeriod(struct icalperiodtype const* icalp);
};
#endif /* CALPERIOD_H_ */

Просмотреть файл

@ -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 <climits>
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<int>(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<calIDateTimeLibical> icaldt;
nsCOMPtr<calITimezone> tz;
aRecurEnd->GetTimezone(getter_AddRefs(tz));
if (NS_SUCCEEDED(tz->GetIsUTC(&b)) && !b &&
NS_SUCCEEDED(tz->GetIsFloating(&b)) && !b) {
// convert to UTC:
nsCOMPtr<calIDateTime> dt;
nsCOMPtr<calITimezone> 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<short>(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<int16_t>& 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<int16_t> 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<calIDateTimeLibical> icaldtstart =
do_QueryInterface(aStartTime, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<calIDateTimeLibical> 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<calITimezone> 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<RefPtr<calIDateTime>>& 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<calIDateTime> 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<calIDateTimeLibical> icalrangestart =
do_QueryInterface(aRangeStart, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<calIDateTimeLibical> 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<calITimezone> tz;
aStartTime->GetTimezone(getter_AddRefs(tz));
if (aRangeEnd) {
nsCOMPtr<calIDateTimeLibical> 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<calIIcalPropertyLibical> 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<calIICSService> icsSvc = cal::getICSService();
nsCOMPtr<calIIcalProperty> 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<calIIcalProperty> 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; }

Просмотреть файл

@ -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

Просмотреть файл

@ -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);
}
}

Просмотреть файл

@ -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<calIIcalComponent> const mIcalComponent;
};
#endif // INCLUDED_CAL_TIMEZONE_H

Просмотреть файл

@ -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<nsIScriptError> 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<nsIScriptError> 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<calITimezone> detectTimezone(icaltimetype const& icalt,
calITimezoneProvider* tzProvider) {
if (icalt.is_utc) {
return UTC();
}
if (icalt.zone) {
char const* const tzid =
icaltimezone_get_tzid(const_cast<icaltimezone*>(icalt.zone));
if (tzid) {
nsCOMPtr<calITimezone> 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<calIIcalComponent> tzComp;
tz->GetIcalComponent(getter_AddRefs(tzComp));
if (tzComp) {
nsCOMPtr<calIIcalComponentLibical> tzCompLibical =
do_QueryInterface(tzComp);
icaltz = tzCompLibical->GetLibicalTimezone();
} // else floating or phantom timezone
}
return icaltz;
}
XpcomBase::~XpcomBase() {}
} // namespace cal

Просмотреть файл

@ -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<nsIConsoleService> getConsoleService() {
return do_GetService("@mozilla.org/consoleservice;1");
}
/**
* Gets the global ICS service.
*/
inline nsCOMPtr<calIICSService> getICSService() {
return do_GetService(CAL_ICSSERVICE_CONTRACTID);
}
/**
* Gets the global timezone service.
*/
inline nsCOMPtr<calITimezoneService> getTimezoneService() {
nsresult rv;
nsCOMPtr<calITimezoneService> 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<calITimezone> UTC() {
nsresult rv;
nsCOMPtr<calITimezone> 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<calITimezone> floating() {
nsresult rv;
nsCOMPtr<calITimezone> 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<calITimezone> 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)

Просмотреть файл

@ -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"

Просмотреть файл

@ -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")

Просмотреть файл

@ -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);

Просмотреть файл

@ -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",

Просмотреть файл

@ -5,7 +5,6 @@
DIRS = [
"public",
"backend",
"src",
"modules",
"themes",

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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();
};

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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));
},
};

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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

Просмотреть файл

@ -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;
},

Просмотреть файл

@ -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;
},
};

Просмотреть файл

@ -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;

Просмотреть файл

@ -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;

Просмотреть файл

@ -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"],

Просмотреть файл

@ -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("**"):

Просмотреть файл

@ -1,6 +0,0 @@
Eric Busboom <eric@softwarestudio.org>
Andrea Campi <a.campi@inet.it>
Art Cancro [http://www.citadel.org]
Wilfried Goesgens [http://www.citadel.org]
John Gray <gray@agora-net.com>
Omar Kilani [http://www.rememberthemilk.com]

Просмотреть файл

@ -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."

Просмотреть файл

@ -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

Просмотреть файл

@ -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

Просмотреть файл

@ -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"
Не удается отобразить этот файл, потому что он имеет неправильное количество полей в строке 26.

Просмотреть файл

@ -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

Просмотреть файл

@ -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"
1
2 #Property Name libical Value type iCalendar default value
3 ACTION ACTION ACTION
4 ALLOW-CONFLICT TEXT TEXT
5 ATTACH ATTACH URI
6 ATTENDEE CAL-ADDRESS CAL-ADDRESS
7 CALSCALE TEXT TEXT
8 CATEGORIES TEXT TEXT
9 CALID TEXT TEXT
10 CARID TEXT TEXT
11 CLASS CLASS CLASS
12 COMMENT TEXT TEXT
13 COMPLETED DATE-TIME DATE-TIME
14 CONTACT TEXT TEXT
15 CREATED DATE-TIME DATE-TIME
16 DECREED TEXT TEXT
17 DEFAULT-CHARSET TEXT TEXT
18 DEFAULT-LOCALE TEXT TEXT
19 DEFAULT-TZID TEXT TEXT
20 DESCRIPTION TEXT TEXT
21 DTEND DATE-TIME DATE-TIME
22 DTSTAMP DATE-TIME DATE-TIME
23 DTSTART DATE-TIME DATE-TIME
24 DUE DATE-TIME DATE-TIME
25 DURATION DURATION DURATION
26 EXDATE DATE-TIME DATE-TIME
27 EXRULE RECUR RECUR
28 FREEBUSY PERIOD PERIOD
29 GEO GEO GEO
30 LAST-MODIFIED DATE-TIME DATE-TIME
31 LOCATION TEXT TEXT
32 METHOD METHOD METHOD
33 ORGANIZER CAL-ADDRESS CAL-ADDRESS
34 OWNER TEXT TEXT
35 PERCENT-COMPLETE INTEGER INTEGER
36 PRIORITY INTEGER INTEGER
37 PRODID TEXT TEXT
38 RDATE DATE-TIME-PERIOD DATE-TIME
39 RECURRENCE-ID DATE-TIME DATE-TIME
40 RELATED-TO TEXT TEXT
41 RELCALID TEXT TEXT
42 REPEAT INTEGER INTEGER
43 REQUEST-STATUS REQUEST-STATUS REQUEST-STATUS
44 RESOURCES TEXT TEXT
45 RRULE RECUR RECUR
46 SEQUENCE INTEGER INTEGER
47 STATUS STATUS STATUS
48 SUMMARY TEXT TEXT
49 TRANSP TRANSP TRANSP
50 TRIGGER TRIGGER DURATION
51 TZID TEXT TEXT
52 TZNAME TEXT TEXT
53 TZOFFSETFROM UTC-OFFSET UTC-OFFSET
54 TZOFFSETTO UTC-OFFSET UTC-OFFSET
55 TZURL URI URI
56 UID TEXT TEXT
57 URL URI URI
58 VERSION TEXT TEXT
59 X X X
60 SCOPE TEXT TEXT
61 MAXRESULTS INTEGER INTEGER
62 MAXRESULTSSIZE INTEGER INTEGER
63 QUERY QUERY QUERY
64 QUERYNAME TEXT TEXT
65 EXPAND INTEGER INTEGER
66 TARGET CAL-ADDRESS CAL-ADDRESS
67 X-LIC-ERROR TEXT TEXT
68 X-LIC-CLUSTERCOUNT STRING STRING
69 X-LIC-MIMECONTENTTYPE STRING STRING
70 X-LIC-MIMECHARSET STRING STRING
71 X-LIC-MIMEENCODING STRING STRING
72 X-LIC-MIMEOPTINFO STRING STRING
73 X-LIC-MIMECID STRING STRING
74 X-LIC-MIMEFILENAME STRING STRING
75 CALMASTER TEXT TEXT
76 X-LIC-CLASS X-LIC-CLASS X-LIC-CLASS
77 ANY NO NO
78 NO NO NO
79 #CAP Properties
80 FIXME Should be BOOLEAN
81 ALLOW-CONFLICT TEXT TEXT
82 CALID TEXT TEXT
83 CALMASTER TEXT TEXT
84 CARID TEXT TEXT
85 CMD CMD CMD
86 CSID URI URI
87 DECREED TEXT TEXT
88 DEFAULT-CHARSET TEXT TEXT
89 DEFAULT-LOCALE TEXT TEXT
90 DEFAULT-TZID TEXT TEXT
91 DEFAULT-VCARS TEXT TEXT
92 FIXME Should be UPN-FILTER
93 DENY TEXT TEXT
94 FIXME Should be BOOLEAN
95 EXPAND INTEGER INTEGER
96 FIXME Should be UPN-FILTER
97 GRANT TEXT TEXT
98 MAXDATE DATE-TIME DATE-TIME
99 MINDATE DATE-TIME DATE-TIME
100 NAME TEXT TEXT
101 OWNER TEXT TEXT
102 PERMISSION TEXT TEXT
103 QUERY QUERY QUERY
104 QUERYID TEXT TEXT
105 RELCALID TEXT TEXT
106 RESTRICTION QUERY QUERY
107 SCOPE TEXT TEXT
108 TARGET CAL-ADDRESS CAL-ADDRESS
109 #CAP Properties These are only allowed in VREPLY
110 CAP-VERSION TEXT TEXT
111 CAR-LEVEL CAR-LEVEL CAR-LEVEL
112 COMPONENTS TEXT TEXT
113 STORES-EXPANDED TEXT TEXT
114 DATE-MAX DATE-TIME DATE-TIME
115 DATE-MIN DATE-TIME DATE-TIME
116 ITIP-VERSION TEXT TEXT
117 MAX-COMPONENT-SIZE INTEGER INTEGER
118 MULTIPART TEXT TEXT
119 QUERY-LEVEL QUERY-LEVEL QUERY-LEVEL
120 RECUR-ACCEPTED TEXT TEXT
121 RECUR-EXPAND TEXT TEXT
122 RECUR-LIMIT TEXT TEXT

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,56 +0,0 @@
2.0 STATOK Operation was successfully performed.
2.0.1 STARTSENDATA Start ICAL input; end with <CRLF>.<CRLF>
2.0.11 OKDATAFOLLOWS The request was processed successfully. Reply data follows on the next line and terminates with <CRLF>.<CRLF>
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.

Просмотреть файл

@ -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"
Не удается отобразить этот файл, потому что он имеет неправильное количество полей в строке 28.

Просмотреть файл

@ -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")

Просмотреть файл

@ -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 (<PV>){
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(<IN>){
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 <<EOM;
/* -*- Mode: C -*-
======================================================================
FILE: icalderivedproperties.{c,h}
CREATOR: eric 09 May 1999
\044Id:\044
(C) COPYRIGHT 1999 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 FILE IS MACHINE GENERATED DO NOT EDIT
*/
#include <stdarg.h> /* for va_arg functions */
EOM
}
if ($opt_p and !$opt_i){
print <<EOM;
EOM
}
foreach $comp (@components) {
next if !$comp;
my $ucf = join("",map {ucfirst(lc($_));} split(/-/,$comp));
my $lc = lc($ucf);
my $uc = uc($lc);
if($opt_c) { # Make C source
print<<EOM;
/* $comp */
icalcomponent* icalcomponent_new_${lc}()
{
return (icalcomponent*)icalcomponent_new_impl(ICAL_${uc}_COMPONENT);
}
icalcomponent* icalcomponent_vanew_${lc}(...)
{
va_list args;
struct icalcomponent_impl *impl = icalcomponent_new_impl(ICAL_${uc}_component);
va_start(args,v);
icalcomponent_add_properties(impl, args);
va_end(args);
return (icalcomponent*)impl;
}
EOM
} elsif ($opt_h) { # Make a C header
print<<EOM;
/* $comp */
icalcomponent* icalcomponent_new_${lc}();
icalcomponent* icalcomponent_vanew_${lc}(...);
EOM
} elsif ($opt_s) { # Make something for a switch statement
print <<EOM;
case ICAL_${uc}_PROPERTY:
EOM
} elsif ($opt_p) { # make perl source
print <<EOM;
# $comp
package Net::ICal::Component::${ucf};
\@ISA=qw(Net::ICal::Component);
sub new
{
my \$package = shift;
my \$c = Net::ICal::icalcomponent_new(\$Net::ICal::ICAL_${uc}_COMPONENT);
my \$self = Net::ICal::Component::new_from_ref(\$c);
Net::ICal::Component::_add_elements(\$self,\\\@_);
# Self is blessed in new_from_ref
return \$self;
}
EOM
}
}

Просмотреть файл

@ -1,390 +0,0 @@
#!/usr/bin/env perl
### START ###
# Copied from readvaluesfile.pl as a temporary fix due to perl problems (Bug 1259090).
###
sub read_parameters_file {
my $path = shift;
my %h;
open(F,$path) || die "Can't open parameters file $path";
while(<F>){
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(<IN>){
if (/<insert_code_here>/){
$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 <<EOM;
/* $param */
icalparameter* icalparameter_new_${lc}($type v)
{
struct icalparameter_impl *impl;
icalerror_clear_errno();
$pointer_check
impl = icalparameter_new_impl(ICAL_${uc}_PARAMETER);
if (impl == 0) {
return 0;
}
icalparameter_set_${lc}((icalparameter*) impl,v);
if (icalerrno != ICAL_NO_ERROR) {
icalparameter_free((icalparameter*) impl);
return 0;
}
return (icalparameter*) impl;
}
${type} icalparameter_get_${lc}(const icalparameter* param)
{
icalerror_clear_errno();
$charorenum
}
void icalparameter_set_${lc}(icalparameter* param, ${type} v)
{
$pointer_check_v
icalerror_check_arg_rv( (param!=0), "param");
icalerror_clear_errno();
if (param->string != NULL)
free ((void*)param->string);
$set_code
}
EOM
} elsif( $opt_h) {
print <<EOM;
/* $param */
icalparameter* icalparameter_new_${lc}($type v);
${type} icalparameter_get_${lc}(const icalparameter* value);
void icalparameter_set_${lc}(icalparameter* value, ${type} v);
EOM
}
if ($opt_p) {
print <<EOM;
# $param
package Net::ICal::Parameter::${ucf};
\@ISA=qw(Net::ICal::Parameter);
sub new
{
my \$self = [];
my \$package = shift;
my \$value = shift;
bless \$self, \$package;
my \$p;
if (\$value) {
\$p = Net::ICal::icalparameter_new_from_string(\$Net::ICal::ICAL_${uc}_PARAMETER,\$value);
} else {
\$p = Net::ICal::icalparameter_new(\$Net::ICal::ICAL_${uc}_PARAMETER);
}
\$self->[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 <<EOM;
#endif /*ICALPARAMETER_H*/
EOM
}
}

Просмотреть файл

@ -1,384 +0,0 @@
#!/usr/bin/env perl
### START ###
# Copied from readvaluesfile.pl as a temporary fix due to perl problems (Bug 1259090).
###
sub read_values_file {
my $path = shift;
my %h;
open(F,$path) || die "Can't open values file $path";
while(<F>){
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(<F>){
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(<IN>){
if (/<insert_code_here>/){
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<<EOM;
icalproperty* icalproperty_vanew_${lc}($type v, ...){
va_list args;
struct icalproperty_impl *impl;
$pointer_check
impl= icalproperty_new_impl(ICAL_${uc}_PROPERTY);
icalproperty_set_${lc}((icalproperty*)impl,v);
va_start(args,v);
icalproperty_add_parameters(impl, args);
va_end(args);
return (icalproperty*)impl;
}
EOM
}
print<<EOM;
/* $prop */
icalproperty* icalproperty_new_${lc}($type v) {
struct icalproperty_impl *impl;
$pointer_check
impl = icalproperty_new_impl(ICAL_${uc}_PROPERTY);
icalproperty_set_${lc}((icalproperty*)impl,v);
return (icalproperty*)impl;
}
EOM
# Allow DTSTART, DTEND, DUE, EXDATE and RECURRENCE-ID to take DATE values.
if ($lc eq "dtstart" || $lc eq "dtend" || $lc eq "due" || $lc eq "exdate"
|| $lc eq "recurrenceid") {
print<<EOM;
void icalproperty_set_${lc}(icalproperty* prop, $type v){
icalvalue *value;
$set_pointer_check
icalerror_check_arg_rv( (prop!=0),"prop");
if (v.is_date)
value = icalvalue_new_date(v);
else
value = icalvalue_new_datetime(v);
icalproperty_set_value(prop,value);
}
EOM
} else {
print<<EOM;
void icalproperty_set_${lc}(icalproperty* prop, $type v){
$set_pointer_check
icalerror_check_arg_rv( (prop!=0),"prop");
icalproperty_set_value(prop,icalvalue_new_${lcvalue}(v));
}
EOM
}
# Dirk Theisen pointed out, exdate needs to match TZID parameters in EXDATE
if ($lc eq "exdate") {
print<<EOM;
$type icalproperty_get_${lc}(const icalproperty* prop){
icalerror_check_arg( (prop!=0),"prop");
#ifndef _MSC_VER
/*
* Code by dirk\@objectpark.net:
* Set the time zone manually. I am really puzzled that
* it doesnot work automatically like in the other functions
* like icalproperty_get_dtstart().
*/
struct icaltimetype itt =
icalvalue_get_datetime(icalproperty_get_value(prop));
icalparameter* param = icalproperty_get_first_parameter(prop,
ICAL_TZID_PARAMETER);
if (param) {
const icaltimezone *zone =
icaltimezone_get_builtin_timezone(icalparameter_get_tzid(param));
icaltime_set_timezone(&itt, zone);
}
return itt;
#else
return icalvalue_get_datetime(icalproperty_get_value(prop));
#endif
}
EOM
} else {
print<<EOM;
$type icalproperty_get_${lc}(const icalproperty* prop){
icalerror_check_arg( (prop!=0),"prop");
return icalvalue_get_${lcvalue}(icalproperty_get_value(prop));
}
EOM
}
} elsif ($opt_h) { # Generate C Header file
print "\
/* $prop */\
icalproperty* icalproperty_new_${lc}($type v);\
void icalproperty_set_${lc}(icalproperty* prop, $type v);\
$type icalproperty_get_${lc}(const icalproperty* prop);";
if ($include_vanew){
print "icalproperty* icalproperty_vanew_${lc}($type v, ...);\n";
}
}
} # This brace terminates the main loop
if ($opt_h){
print "\n\n#endif /*ICALPROPERTY_H*/\n"
}
}

Просмотреть файл

@ -1,297 +0,0 @@
#!/usr/bin/perl
### START ###
# Copied from readvaluesfile.pl as a temporary fix due to perl problems (Bug 1259090).
###
sub read_values_file {
my $path = shift;
my %h;
open(F,$path) || die "Can't open values file $path";
while(<F>){
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(<IN>){
if (/<insert_code_here>/){
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";
}
}

Просмотреть файл

@ -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

Просмотреть файл

@ -1,99 +0,0 @@
#!/usr/local/bin/perl
$pr = 1;
$ignore = 0;
print<<EOM;
/* -*- Mode: C -*-*/
/*======================================================================
FILE: ical.i
(C) COPYRIGHT 1999 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.
The original author is Eric Busboom
Contributions from:
Graham Davison (g.m.davison\@computer.org)
======================================================================*/
%module Net__ICal
%{
#include "ical.h"
#include <sys/types.h> /* for size_t */
#include <time.h>
%}
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(<F>){
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; }
}
}

Просмотреть файл

@ -1,85 +0,0 @@
#!/usr/bin/perl
# Version: 1.0
# Script last updated: 30May1999 GMD
# Change log:
# <none>
# usually open params-in-prop.txt
open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!";
print <<EOM;
/*
======================================================================
File: parameterrestrictions.c
(C) COPYRIGHT 1999 Graham Davison
mailto:g.m.davison\@computer.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 FILE IS MACHINE GENERATED DO NOT EDIT
*/
int icalrestriction_is_parameter_allowed(icalproperty_kind prop,icalparameter_kind param)
{
switch (prop)
{
EOM
while(<F>)
{
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 <<EOM;
/* ${prop_name} */
case ICAL_${prop}_PROPERTY:
switch (param)
{
EOM
foreach $param (@v)
{
$param = join("",split(/-/,$param));
print "\t\t\t\tcase ICAL_${param}_PARAMETER:\n";
}
print <<EOM;
return 1;
default:
return 0;
}
EOM
}
print <<EOM;
}
return 0;
}
EOM

Просмотреть файл

@ -1,109 +0,0 @@
#!/usr/bin/env perl
# Version: 1.0
# Script last updated: 30May1999 GMD
# Change log:
# <none>
# usually open restrictions.csv
open(F,"$ARGV[0]") || die "Can't open restriction file $ARGV[0]:$!";
print <<EOM;
/*
======================================================================
File: restrictionrecords.c
(C) COPYRIGHT 1999 Graham Davison
mailto:g.m.davison\@computer.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 FILE IS MACHINE GENERATED DO NOT EDIT
*/
typedef struct icalrestriction_record {
icalproperty_method method;
icalcomponent_kind component;
icalproperty_kind property;
icalcomponent_kind subcomponent;
icalrestriction_kind restriction;
} icalrestriction_record;
icalrestriction_record icalrestriction_records[] =
{
EOM
my $last_method = "";
my $last_component = "";
my $last_property = "";
my $need_header = 0;
while(<F>)
{
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 <<EOM;
/* END */
{ICAL_METHOD_NONE,ICAL_NO_COMPONENT,ICAL_NO_PROPERTY,ICAL_NO_COMPONENT,ICAL_RESTRICTION_NONE}
};
EOM

Просмотреть файл

@ -1,102 +0,0 @@
#!/usr/bin/env perl
use Getopt::Std;
getopts('i:');
# the argument should be the path to the restriction datafile, usually
# design-data/restrictions.csv
open(F,"$ARGV[0]") || die "Can't open restriction data 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(<IN>){
if (/<insert_code_here>/){
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(<F>)
{
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(<F>)
{
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";
}

Просмотреть файл

@ -1,135 +0,0 @@
sub read_values_file {
my $path = shift;
my %h;
open(F,$path) || die "Can't open values file $path";
while(<F>){
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(<F>){
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(<F>){
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;

Просмотреть файл

@ -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 <mvl@exedo.nl>
#
# 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

Просмотреть файл

@ -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_ */

Просмотреть файл

@ -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 ) */

Просмотреть файл

@ -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 <stdlib.h>
#include <string.h>
#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);
}
}

Просмотреть файл

@ -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 */

Просмотреть файл

@ -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 <stdlib.h> /* for malloc and abs() */
#include <errno.h> /* for errno */
#include <string.h> /* for icalmemory_strdup */
#include <assert.h>
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;
}

Просмотреть файл

@ -1,60 +0,0 @@
/* -*- Mode: C -*- */
/*======================================================================
FILE: icalattach.h
CREATOR: acampi 28 May 02
(C) COPYRIGHT 2002, Andrea Campi <a.campi@inet.it>
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 */

Просмотреть файл

@ -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 <a.campi@inet.it>
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 <config.h>
#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

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,285 +0,0 @@
/* -*- Mode: C -*- */
/*======================================================================
FILE: icalcomponent.h
CREATOR: eric 20 March 1999
(C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
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 */

Просмотреть файл

@ -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 <config.h>
#endif
#include "icalparameter.h"
#include "icalparameterimpl.h"
#include "icalproperty.h"
#include "icalerror.h"
#include "icalmemory.h"
#include "icaltypes.h"
#include <stdlib.h> /* for malloc() */
#include <errno.h>
#include <string.h> /* 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;
};
<insert_code_here>
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;
}

Просмотреть файл

@ -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);
<insert_code_here>

Просмотреть файл

@ -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 <config.h>
#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 <string.h> /* For icalmemory_strdup, rindex */
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h> /* for printf */
#include <stdarg.h> /* 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;
};
<insert_code_here>
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;
}

Просмотреть файл

@ -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 <time.h>
#include "icalparameter.h"
#include "icalderivedvalue.h"
#include "icalrecur.h"
typedef struct icalproperty_impl icalproperty;
<insert_code_here>

Просмотреть файл

@ -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 <config.h>
#endif
#include "icalerror.h"
#include "icalmemory.h"
#include "icalparser.h"
#include "icalenums.h"
#include "icalvalueimpl.h"
#include <stdlib.h> /* for malloc */
#include <stdio.h> /* for snprintf */
#include <string.h> /* For memset, others */
#include <stddef.h> /* For offsetof() macro */
#include <errno.h>
#include <time.h> /* for mktime */
#include <stdlib.h> /* for atoi and atof */
#include <limits.h> /* 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];
};
<insert_code_here>
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. */

Просмотреть файл

@ -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);
<insert_code_here>
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);

Просмотреть файл

@ -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 <config.h>
#endif
#include "icalduration.h"
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#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, <alves@hungry.com> */
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));
}

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 */

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 <stdio.h> /* For fprintf */
#include <stdio.h> /* For stderr */
#include <string.h> /* For strncmp */
#include <assert.h>
#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;
}

Просмотреть файл

@ -1,168 +0,0 @@
/* -*- Mode: C -*-*/
/*======================================================================
FILE: icalenums.h
(C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
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 <g.m.davison@computer.org>
======================================================================*/
#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 */

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 <execinfo.h>
#endif
#include <stdlib.h> /* for malloc() */
#include <string.h> /* for strcmp */
#include "icalerror.h"
#ifdef HAVE_PTHREAD
#include <pthread.h>
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
}

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 <assert.h>
#include <stdio.h> /* 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 */

Просмотреть файл

@ -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 <stdlib.h>
#include <string.h>
#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);
}

Просмотреть файл

@ -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__*/

Просмотреть файл

@ -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 <stdio.h> /* for printf (debugging) */
#include <stdlib.h> /* for malloc, realloc */
#include <string.h> /* for memset(), strdup */
#ifdef WIN32
#include <windows.h>
#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 <pthread.h>
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; i<BUFFER_RING_SIZE; i++){
br->ring[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; i<BUFFER_RING_SIZE; i++){
if ( br->ring[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;
}

Просмотреть файл

@ -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 <eric@softwarestudio.org>
http://www.softwarestudio.org
======================================================================*/
#ifndef ICALMEMORY_H
#define ICALMEMORY_H
#ifndef WIN32
#include <sys/types.h> /* for size_t */
#else
#include <stddef.h>
#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 */

Просмотреть файл

@ -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 <string.h> /* For strdup */
#include <stdio.h> /* 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 <NUM_PARTS && parts[i].header.major != SSPM_NO_MAJOR_TYPE ; i++){
#define TMPSZ 1024
char mimetype[TMPSZ];
const char* major = sspm_major_type_string(parts[i].header.major);
const char* minor = sspm_minor_type_string(parts[i].header.minor);
if(parts[i].header.minor == SSPM_UNKNOWN_MINOR_TYPE ){
assert(parts[i].header.minor_text !=0);
minor = parts[i].header.minor_text;
}
snprintf(mimetype,sizeof(mimetype),"%s/%s",major,minor);
comp = icalcomponent_new(ICAL_XLICMIMEPART_COMPONENT);
if(comp == 0){
/* HACK Handle Error */
assert(0);
}
if(parts[i].header.error!=SSPM_NO_ERROR){
const char *str="Unknown error";
char temp[256];
if(parts[i].header.error==SSPM_MALFORMED_HEADER_ERROR){
str = "Malformed header, possibly due to input not in MIME format";
}
if(parts[i].header.error==SSPM_UNEXPECTED_BOUNDARY_ERROR){
str = "Got an unexpected boundary, possibly due to a MIME header for a MULTIPART part that is missing the Content-Type line";
}
if(parts[i].header.error==SSPM_WRONG_BOUNDARY_ERROR){
str = "Got the wrong boundary for the opening of a MULTIPART part.";
}
if(parts[i].header.error==SSPM_NO_BOUNDARY_ERROR){
str = "Got a multipart header that did not specify a boundary";
}
if(parts[i].header.error==SSPM_NO_HEADER_ERROR){
str = "Did not get a header for the part. Is there a blank\
line between the header and the previous boundary\?";
}
if(parts[i].header.error_text != 0){
snprintf(temp,256,
"%s: %s",str,parts[i].header.error_text);
} else {
strcpy(temp,str);
}
icalcomponent_add_property
(comp,
icalproperty_vanew_xlicerror(
temp,
icalparameter_new_xlicerrortype(
ICAL_XLICERRORTYPE_MIMEPARSEERROR),
0));
}
if(parts[i].header.major != SSPM_NO_MAJOR_TYPE &&
parts[i].header.major != SSPM_UNKNOWN_MAJOR_TYPE){
icalcomponent_add_property(comp,
icalproperty_new_xlicmimecontenttype((char*)
icalmemory_strdup(mimetype)));
}
if (parts[i].header.encoding != SSPM_NO_ENCODING){
icalcomponent_add_property(comp,
icalproperty_new_xlicmimeencoding(
sspm_encoding_string(parts[i].header.encoding)));
}
if (parts[i].header.filename != 0){
icalcomponent_add_property(comp,
icalproperty_new_xlicmimefilename(parts[i].header.filename));
}
if (parts[i].header.content_id != 0){
icalcomponent_add_property(comp,
icalproperty_new_xlicmimecid(parts[i].header.content_id));
}
if (parts[i].header.charset != 0){
icalcomponent_add_property(comp,
icalproperty_new_xlicmimecharset(parts[i].header.charset));
}
/* Add iCal components as children of the component */
if(parts[i].header.major == SSPM_TEXT_MAJOR_TYPE &&
parts[i].header.minor == SSPM_CALENDAR_MINOR_TYPE &&
parts[i].data != 0){
icalcomponent_add_component(comp,
(icalcomponent*)parts[i].data);
parts[i].data = 0;
} else if(parts[i].header.major == SSPM_TEXT_MAJOR_TYPE &&
parts[i].header.minor != SSPM_CALENDAR_MINOR_TYPE &&
parts[i].data != 0){
/* Add other text components as "DESCRIPTION" properties */
icalcomponent_add_property(comp,
icalproperty_new_description(
(char*)icalmemory_strdup((char*)parts[i].data)));
parts[i].data = 0;
}
if(root!= 0 && parts[i].level == 0){
/* We've already assigned the root, but there is another
part at the root level. This is probably a parse
error*/
icalcomponent_free(comp);
continue;
}
if(parts[i].level == last_level && last_level != 0){
icalerror_assert(parent!=0,"No parent for adding component");
icalcomponent_add_component(parent,comp);
} else if (parts[i].level == last_level && last_level == 0 &&
root == 0) {
root = comp;
parent = comp;
} else if (parts[i].level > 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 <NUM_PARTS && parts[i].header.major != SSPM_NO_MAJOR_TYPE ;
i++){
if(parts[i].header.minor == SSPM_CALENDAR_MINOR_TYPE){
parts[i].data =
icalcomponent_as_ical_string_r((icalcomponent*)parts[i].data);
}
}
sspm_write_mime(parts,NUM_PARTS,&out,"To: bob@bob.org");
printf("%s\n",out);
free(out);
return 0;
}

Просмотреть файл

@ -1,44 +0,0 @@
/* -*- Mode: C -*- */
/*======================================================================
FILE: icalmime.h
CREATOR: eric 26 July 2000
$Id: icalmime.h,v 1.3 2008-01-15 23:17:40 dothebart Exp $
$Locker: $
(C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org>
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 */

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 <config.h>
#endif
#include "icalparameter.h"
#include "icalproperty.h"
#include "icalerror.h"
#include "icalmemory.h"
#include "icalparameterimpl.h"
#include <stdlib.h> /* for malloc() */
#include <errno.h>
#include <string.h> /* 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 */

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 <config.h>
#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*/

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 <stdio.h> /* 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 */

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#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;
}

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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 <eric@softwarestudio.org>
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 <time.h>
#include <stdarg.h> /* 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*/

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше