Index: src/python/LibicalWrap.i =================================================================== --- src/python/LibicalWrap.i (revision 999) +++ src/python/LibicalWrap.i (working copy) @@ -34,420 +34,81 @@ %} +typedef int time_t; -#include "fcntl.h" /* For Open flags */ +// This is declared as an extern, but never used in the library. +%ignore icalfileset_safe_saves; -typedef void icalcomponent; -typedef void icalproperty; +// Ignore these declarations because there does not exist a definition for them +%ignore _icalerror_set_errno(icalerrorenum); +%ignore icalattachtype_add_reference(struct icalattachtype* v); +%ignore icalattachtype_get_binary(struct icalattachtype* v); +%ignore icalattachtype_set_binary(struct icalattachtype* v, char* binary, + int owns); +%ignore icalattachtype_get_url(struct icalattachtype* v); +%ignore icalattachtype_set_url(struct icalattachtype* v, char* url); +%ignore icalattachtype_free(struct icalattachtype* v); +%ignore icalattachtype_get_base64(struct icalattachtype* v); +%ignore icalattachtype_new(void); +%ignore icalattachtype_set_base64(struct icalattachtype* v, char* base64, + int owns); +%ignore icalclassify_class_to_string(icalproperty_xlicclass c); +%ignore icalfileset_new_from_cluster(const char* path, icalcluster *cluster); +%ignore icalgauge_as_sql(icalcomponent* gauge); +%ignore icalgauge_new_clone(icalgauge* g, icalcomponent* comp); +%ignore icallangbind_get_component(icalcomponent *c, const char* comp); +%ignore icallangbind_get_parameter(icalproperty *p, const char* parameter); +%ignore icallangbind_get_property(icalcomponent *c, int n, const char* prop); +%ignore icallangbind_get_property_val(icalproperty* p); +%ignore icalmessage_new_cancel_all(icalcomponent* c, + const char* user, + const char* msg); +%ignore icalmessage_new_cancel_event(icalcomponent* c, + const char* user, + const char* msg); +%ignore icalmessage_new_cancel_instance(icalcomponent* c, + const char* user, + const char* msg); +%ignore icalmime_as_mime_string(char* icalcomponent); +%ignore icalparameter_is_valid(icalparameter* parameter); +%ignore icalparser_parse_value(icalvalue_kind kind, + const char* str, icalcomponent** errors); +%ignore icalrecur_iterator_decrement_count(icalrecur_iterator*); +%ignore icalrestriction_is_parameter_allowed(icalproperty_kind property, + icalparameter_kind parameter); +%ignore icalset_clear_select(icalset* set); +%ignore icalspanlist_make_free_list(icalspanlist* sl); +%ignore icalspanlist_make_busy_list(icalspanlist* sl); +%ignore icalspanlist_next_busy_time(icalspanlist* sl, + struct icaltimetype t); +%ignore icaltime_compare_with_zone(const struct icaltimetype a, + const struct icaltimetype b); +%ignore icaltime_days_in_year (const int year); +%ignore icaltime_from_string_with_zone(const char* str, + const icaltimezone *zone); +%ignore icaltime_from_week_number(const int week_number, + const int year); +%ignore icaltime_is_floating(const struct icaltimetype t); +%ignore icaltimezonetype_free(struct icaltimezonetype tzt); -icalcomponent* icalparser_parse_string(char* str); +#ifndef _DLOPEN_TEST +%ignore icalset_register_class(icalset *set); +#endif +#include "fcntl.h" /* For Open flags */ +%include "libical/ical.h" +%include "libicalss/icalss.h" -/* actually takes icalcomponent_kind */ -icalcomponent* icalcomponent_new(int kind); -icalcomponent* icalcomponent_new_clone(icalcomponent* component); -icalcomponent* icalcomponent_new_from_string(char* str); +// declare some internal functions which are not in the header file. +void icalproperty_set_parent(icalproperty* property, + icalcomponent* component); +icalcomponent* icalproperty_get_parent(const icalproperty* property); -const char* icalcomponent_kind_to_string(int kind); -int icalcomponent_string_to_kind(const char* string); +void icalvalue_set_parent(icalvalue* value, + icalproperty* property); +icalproperty* icalvalue_get_parent(icalvalue* value); +void icalparameter_set_parent(icalparameter* param, + icalproperty* property); +icalproperty* icalparameter_get_parent(icalparameter* value); -char* icalcomponent_as_ical_string(icalcomponent* component); - -void icalcomponent_free(icalcomponent* component); -int icalcomponent_count_errors(icalcomponent* component); -void icalcomponent_strip_errors(icalcomponent* component); -void icalcomponent_convert_errors(icalcomponent* component); - -icalproperty* icalcomponent_get_current_property(icalcomponent* component); - -icalproperty* icalcomponent_get_first_property(icalcomponent* component, - int kind); -icalproperty* icalcomponent_get_next_property(icalcomponent* component, - int kind); - -icalcomponent* icalcomponent_get_current_component (icalcomponent* component); - -icalcomponent* icalcomponent_get_first_component(icalcomponent* component, - int kind); -icalcomponent* icalcomponent_get_next_component(icalcomponent* component, - int kind); - -void icalcomponent_add_property(icalcomponent* component, - icalproperty* property); - -void icalcomponent_remove_property(icalcomponent* component, - icalproperty* property); - - -void icalcomponent_add_component(icalcomponent* parent, - icalcomponent* child); - -void icalcomponent_remove_component(icalcomponent* parent, - icalcomponent* child); - -icalcomponent* icalcomponent_get_inner(icalcomponent* comp); - -icalcomponent* icalcomponent_get_parent(icalcomponent* component); -int icalcomponent_isa(icalcomponent* component); - -int icalrestriction_check(icalcomponent* comp); - -/* actually takes icalproperty_kind */ -icalproperty* icalproperty_new(int kind); - -icalproperty* icalproperty_new_from_string(char* str); - -char* icalproperty_as_ical_string(icalproperty *prop); - -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); -void icalproperty_remove_parameter_by_name(icalproperty* prop, - const char *name); - -void icalproperty_set_value_from_string(icalproperty* prop,const char* value, const char * kind); - -const char* icalproperty_get_value_as_string(icalproperty* prop); -icalcomponent* icalproperty_get_parent(icalproperty* property); - -const char* icalproperty_kind_to_string(int kind); -int icalproperty_string_to_kind(const char* string); -int icalproperty_string_to_enum(const char* str); -int icalproperty_enum_belongs_to_property(int kind, int e); -int icalproperty_kind_to_value_kind(int kind); - -/* 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_name (const icalproperty* prop); - - -int icalerror_supress(const char* error); -void icalerror_restore(const char* error, int es); -char* icalerror_perror(); -void icalerror_clear_errno(void); - - -const char* icalvalue_kind_to_string(int kind); -int icalvalue_string_to_kind(const char* str); - -char* icalparameter_as_ical_string(icalparameter* parameter); - -const char* icalparameter_kind_to_string(int kind); -int icalparameter_string_to_kind(const char* string); - -int* icallangbind_new_array(int size); -void icallangbind_free_array(int* array); -int icallangbind_access_array(int* array, int index); - - - -/* int icalrecur_expand_recurrence(char* rule, int start, - int count, int* array);*/ -int icalrecur_expand_recurrence(char* rule, int start, - int count, time_t* array); - - -/* Iterate through properties, components and parameters using strings for the kind */ -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); - - -/* Return a string that can be evaluated in perl or python to - generated a hash that holds the property's name, value and - parameters. Sep is the hash seperation string, "=>" for perl and - ":" for python */ -const char* icallangbind_property_eval_string(icalproperty* prop, char* sep); - -int icallangbind_string_to_open_flag(const char* str); - -const char* icallangbind_quote_as_ical(const char* str); - -/*********************************************************************** - Time routines -***********************************************************************/ - - -struct icaltimetype -{ - int year; - int month; - int day; - int hour; - int minute; - int second; -}; - - -/* Convert seconds past UNIX epoch to a timetype*/ -struct icaltimetype icaltime_from_timet(int v, int is_date); - -/** Convert seconds past UNIX epoch to a timetype, using timezones. */ -struct icaltimetype icaltime_from_timet_with_zone(int tm, - int is_date, icaltimezone *zone); - -/* Return the time as seconds past the UNIX epoch */ -/* Normally, this returns a time_t, but SWIG tries to turn that type - into a pointer */ -int icaltime_as_timet(struct icaltimetype tt); - -/* Return a string represention of the time, in RFC2445 format. The - string is owned by libical */ -char* icaltime_as_ical_string(struct icaltimetype tt); - -/* create a time from an ISO format string */ -struct icaltimetype icaltime_from_string(const char* str); - -/* Routines for handling timezones */ -/* Return a null time, which indicates no time has been set. This time represent the beginning of the epoch */ -struct icaltimetype icaltime_null_time(void); - -/* Return true of the time is null. */ -int icaltime_is_null_time(struct icaltimetype t); - -/* Returns false if the time is clearly invalid, but is not null. This - is usually the result of creating a new time type buy not clearing - it, or setting one of the flags to an illegal value. */ -int icaltime_is_valid_time(struct icaltimetype t); - -/** @brief Return the timezone */ -const icaltimezone *icaltime_get_timezone(const struct icaltimetype t); - -/** @brief Return the tzid, or NULL for a floating time */ -char *icaltime_get_tzid(const struct icaltimetype t); - -/** @brief Set the timezone */ -struct icaltimetype icaltime_set_timezone(struct icaltimetype *t, - const icaltimezone *zone); - -/* Returns true if time is of DATE type, false if DATE-TIME */ -int icaltime_is_date(struct icaltimetype t); - -/* Returns true if time is relative to UTC zone */ -int icaltime_is_utc(struct icaltimetype t); - -/* Reset all of the time components to be in their normal ranges. For - instance, given a time with minutes=70, the minutes will be reduces - to 10, and the hour incremented. This allows the caller to do - arithmetic on times without worrying about overflow or - underflow. */ -struct icaltimetype icaltime_normalize(struct icaltimetype t); - -/* Return the day of the year of the given time */ -short icaltime_day_of_year(struct icaltimetype t); - -/* Create a new time, given a day of year and a year. */ -struct icaltimetype icaltime_from_day_of_year(short doy, short year); - -/* Return the day of the week of the given time. Sunday is 0 */ -short icaltime_day_of_week(struct icaltimetype t); - -/* Return the day of the year for the Sunday of the week that the - given time is within. */ -short icaltime_start_doy_of_week(struct icaltimetype t); - -/* Return the week number for the week the given time is within */ -short icaltime_week_number(struct icaltimetype t); - -/* Return -1, 0, or 1 to indicate that ab */ -int icaltime_compare(struct icaltimetype a,struct icaltimetype b); - -/* like icaltime_compare, but only use the date parts. */ -int icaltime_compare_date_only(struct icaltimetype a, struct icaltimetype b); - -/* Return the number of days in the given month */ -short icaltime_days_in_month(short month,short year); - -/** convert tt, of timezone tzid, into a utc time. Does nothing if the - time is already UTC. */ -struct icaltimetype icaltime_convert_to_zone(struct icaltimetype tt, - icaltimezone *zone); - - - -/*********************************************************************** - Duration Routines -***********************************************************************/ - - -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); -struct icaldurationtype icaldurationtype_null_duration(); -int icaldurationtype_is_null_duration(struct icaldurationtype d); - -struct icaltimetype icaltime_add(struct icaltimetype t, - struct icaldurationtype d); - -struct icaldurationtype icaltime_subtract(struct icaltimetype t1, - struct icaltimetype t2); - - -/*********************************************************************** - Period Routines -***********************************************************************/ - - -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); -struct icalperiodtype icalperiodtype_null_period(); -int icalperiodtype_is_null_period(struct icalperiodtype p); -int icalperiodtype_is_valid_period(struct icalperiodtype p); - -/*********************************************************************** - * timezone handling routines -***********************************************************************/ - -/** Returns a single builtin timezone, given its Olson city name. */ -icaltimezone* icaltimezone_get_builtin_timezone (const char *location); - -/** Returns the UTC timezone. */ -icaltimezone* icaltimezone_get_utc_timezone (void); - -/*********************************************************************** - Storage Routines -***********************************************************************/ - -/** - * @brief options for opening an icalfileset. - * - * These options should be passed to the icalset_new() function - */ - -struct icalfileset_options { - int flags; /**< flags for open() O_RDONLY, etc */ - mode_t mode; /**< file mode */ - icalcluster *cluster; /**< use this cluster to initialize data */ -}; - -icalset* icalfileset_new(const char* path); -icalset* icalfileset_new_reader(const char* path); -icalset* icalfileset_new_writer(const char* path); - -icalset* icalfileset_init(icalset *set, const char *dsn, void* options); - -/* icalfileset* icalfileset_new_from_cluster(const char* path, icalcluster *cluster); */ - -icalcluster* icalfileset_produce_icalcluster(const char *path); - -void icalfileset_free(icalset* cluster); - -const char* icalfileset_path(icalset* cluster); - -/* Mark the cluster as changed, so it will be written to disk when it - is freed. Commit writes to disk immediately. */ -void icalfileset_mark(icalset* set); -icalerrorenum icalfileset_commit(icalset* set); - -icalerrorenum icalfileset_add_component(icalset* set, - icalcomponent* child); - -icalerrorenum icalfileset_remove_component(icalset* set, - icalcomponent* child); - -int icalfileset_count_components(icalset* set, - int kind); - -/** - * Restrict the component returned by icalfileset_first, _next to those - * that pass the gauge. _clear removes the gauge - */ -icalerrorenum icalfileset_select(icalset* set, icalgauge* gauge); - -/** clear the gauge **/ -void icalfileset_clear(icalset* set); - -/** Get and search for a component by uid **/ -icalcomponent* icalfileset_fetch(icalset* set, const char* uid); -int icalfileset_has_uid(icalset* set, const char* uid); -icalcomponent* icalfileset_fetch_match(icalset* set, icalcomponent *c); - - -/** - * Modify components according to the MODIFY method of CAP. Works on the - * currently selected components. - */ -icalerrorenum icalfileset_modify(icalset* set, - icalcomponent *oldcomp, - icalcomponent *newcomp); - -/* Iterate through components. If a gauge has been defined, these - will skip over components that do not pass the gauge */ - -icalcomponent* icalfileset_get_current_component (icalset* cluster); -icalcomponent* icalfileset_get_first_component(icalset* cluster); -icalcomponent* icalfileset_get_next_component(icalset* cluster); - -/* External iterator for thread safety */ -icalsetiter icalfileset_begin_component(icalset* set, int kind, icalgauge* gauge); -icalcomponent * icalfilesetiter_to_next(icalset* set, icalsetiter *iter); -icalcomponent* icalfileset_form_a_matched_recurrence_component(icalsetiter* itr); - -/*********************************************************************** - Gauge Routines -***********************************************************************/ - -icalgauge* icalgauge_new_from_sql(char* sql, int expand); - -int icalgauge_get_expand(icalgauge* gauge); - -void icalgauge_free(icalgauge* gauge); - -/* Pending Implementation */ -/* char* icalgauge_as_sql(icalcomponent* gauge); */ - -void icalgauge_dump(icalgauge* gauge); - - -/** @brief Return true if comp matches the gauge. - * - * The component must be in - * cannonical form -- a VCALENDAR with one VEVENT, VTODO or VJOURNAL - * sub component - */ -int icalgauge_compare(icalgauge* g, icalcomponent* comp); - -/* Pending Implementation */ -/** Clone the component, but only return the properties - * specified in the gauge */ -/* icalcomponent* icalgauge_new_clone(icalgauge* g, icalcomponent* comp); */ - - Index: src/python/Time.py =================================================================== --- src/python/Time.py (revision 999) +++ src/python/Time.py (working copy) @@ -79,7 +79,7 @@ raise Property.ConstructorFailedError("Failed to construct a Time") def _update_value(self): - self.tt = icaltime_normalize(self.tt) + self.normalize() self.value(icaltime_as_ical_string(self.tt),"DATE-TIME") def valid(self): @@ -88,12 +88,12 @@ def utc_seconds(self,v=None): """ Return or set time in seconds past POSIX epoch""" + tz = icaltimezone_get_builtin_timezone(self.timezone()) if (v!=None): - tz = icaltimezone_get_builtin_timezone(self.timezone()) self.tt = icaltime_from_timet_with_zone(v,0,tz) self._update_value() - return icaltime_as_timet(self.tt) + return icaltime_as_timet_with_zone(self.tt, tz) def is_utc(self): """ Return a boolean indicating if time is in UTC """ @@ -127,50 +127,58 @@ self._update_value() return icaltime_get_tzid(self.tt) - def second(self,v=None): + def normalize(self): + self.tt = icaltime_normalize(self.tt) + + def __second_property(self,v=None): """ Get or set the seconds component of this time """ if(v != None): - icaltimetype_second_set(self.tt,v) + self.tt.second = v self._update_value() - return icaltimetype_second_get(self.tt) + return self.tt.second + second = property(__second_property, __second_property) - def minute(self,v=None): + def __minute_property(self,v=None): """ Get or set the minute component of this time """ if(v != None): - icaltimetype_minute_set(self.tt,v) + self.tt.minute = v self._update_value() - return icaltimetype_minute_get(self.tt) + return self.tt.minute + minute = property(__minute_property, __minute_property) - def hour(self,v=None): + def __hour_property(self,v=None): """ Get or set the hour component of this time """ if(v != None): - icaltimetype_hour_set(self.tt,v) + self.tt.hour = v self._update_value() - return icaltimetype_hour_get(self.tt) + return self.tt.hour + hour = property(__hour_property, __hour_property) - def day(self,v=None): + def __day_property(self,v=None): """ Get or set the month day component of this time """ if(v != None): - icaltimetype_day_set(self.tt,v) + self.tt.day = v self._update_value() - return icaltimetype_day_get(self.tt) + return self.tt.day + day = property(__day_property, __day_property) - def month(self,v=None): + def __month_property(self,v=None): """ Get or set the month component of this time. January is month 1 """ if(v != None): - icaltimetype_month_set(self.tt,v) + self.tt.month = v self._update_value() - return icaltimetype_month_get(self.tt) + return self.tt.month + month = property(__month_property, __month_property) - def year(self,v=None): + def __year_property(self,v=None): """ Get or set the year component of this time """ if(v != None): - icaltimetype_year_set(self.tt,v) + self.tt.year = v self._update_value() + return self.tt.year + year = property(__year_property, __year_property) - return icaltimetype_year_get(self.tt) - def __cmp__(self,other): if other == None: @@ -185,9 +193,10 @@ if not other.valid(): return Duration(0,"DURATION") - + + print self.utc_seconds(), other.seconds() seconds = self.utc_seconds() + other.seconds() - + new = Time(seconds,self.name(),self.timezone()) return new Index: src/python/Component.py =================================================================== --- src/python/Component.py (revision 999) +++ src/python/Component.py (working copy) @@ -37,8 +37,22 @@ WrapperNULL = None -class Component: +# Swig objects are natively unhashable, so we hash on the pointer val. +class SwigRefHash(dict): + def __getitem__(self, k): + return dict.__getitem__(self, int(k)) + + def __setitem__(self, k, v): + return dict.__setitem__(self, int(k), v) + + def __delitem__(self, k): + dict.__delitem__(self, int(k)) + + def has_key(self, k): + return dict.has_key(self, int(k)) +class Component(object): + def __init__(self,ref=None,kind=None): if ref != None: @@ -54,8 +68,8 @@ else: raise "Could not construct component of kind" + kind - self.cached_props = {} - self.cached_comps = {} + self.cached_props = SwigRefHash() + self.cached_comps = SwigRefHash() def __del__(self): if self._ref != None and icalcomponent_get_parent(self._ref) != WrapperNULL: @@ -73,7 +87,7 @@ d = {} d['value'] = icalproperty_get_value_as_string(p) - d['name'] = icalproperty_get_name(p) + d['name'] = icalproperty_get_property_name(p) propkind = icalproperty_string_to_kind(d['name']) kind = icalproperty_kind_to_value_kind(propkind) @@ -81,6 +95,7 @@ d['ref'] = p + #~ print p, Property(ref=p).name() if not self.cached_props.has_key(p): if d['value_type'] == 'DATE-TIME' or d['value_type'] == 'DATE': Index: src/python/test.py =================================================================== --- src/python/test.py (revision 999) +++ src/python/test.py (working copy) @@ -133,12 +133,12 @@ t = Time("19970325T123010Z",'DTSTART') - assert(t.year() == 1997) - assert(t.month() == 3) - assert(t.day() == 25) - assert(t.hour() == 12) - assert(t.minute() == 30) - assert(t.second() == 10) + assert(t.year == 1997) + assert(t.month == 3) + assert(t.day == 25) + assert(t.hour == 12) + assert(t.minute == 30) + assert(t.second == 10) assert(t.is_utc()) assert(not t.is_date()) @@ -148,25 +148,26 @@ print str(t) print t.timezone() #assert(str(t)=='DTSTART;TZID=America/Los_Angeles:19970325T123010') - assert(str(t)=='DTSTART;TZID=/softwarestudio.org/Olson_20010626_2/America/Los_Angeles:19970325T043010') + assert(str(t)=='DTSTART;TZID=/freeassociation.sourceforge.net/Tzfile/America/Los_Angeles:19970325T053010') - t.second(t.second()+80) + t.second = t.second+80 t.timezone("UTC") - assert(t.minute() == 31) - assert(t.second() == 30) + print t.minute, t.second + assert(t.minute == 31) + assert(t.second == 30) d = Duration(3600,"DURATION") t2 = t + d print t2 - assert(t2.hour() == 13) + assert(t2.hour == 13) t2 = t - d print t2 assert(isinstance(t2,Time)) - assert(t2.hour() == 11) + assert(t2.hour == 11) # test int args t = Time(2) @@ -297,13 +298,13 @@ print dtstart - print "\n Orig hour: ", dtstart.hour() - assert(dtstart.hour() == 12) + print "\n Orig hour: ", dtstart.hour + assert(dtstart.hour == 12) - dtstart.hour(dtstart.hour() + 5) + dtstart.hour = dtstart.hour + 5 - print "\n New hour: ", dtstart.hour() - assert(dtstart.hour() == 17) + print "\n New hour: ", dtstart.hour + assert(dtstart.hour == 17) attendee = inner.properties('ATTENDEE')[0] @@ -496,7 +497,7 @@ for i in range(1,11): newevent = event.clone() newevent.uid("%d@localhost" % (i,)) - newevent.dtstart().month( newevent.dtstart().month() + i ) + newevent.dtstart().month = newevent.dtstart().month + i #print ne store.add_component(newevent) Index: src/python/Makefile.am =================================================================== --- src/python/Makefile.am (revision 999) +++ src/python/Makefile.am (working copy) @@ -30,7 +30,8 @@ # http://sources.redhat.com/automake/automake.html#Libtool-Modules _LibicalWrap_la_SOURCES = _LibicalWrap.c _LibicalWrap_la_LDFLAGS = -avoid-version -module -lc -_LibicalWrap_la_LTLIBADD = ../libical/libical.la ../libicalss/libicalss.la +_LibicalWrap_la_LIBADD = $(top_srcdir)/src/libical/libical.la \ + $(top_srcdir)/src/libicalss/libicalss.la AM_CPPFLAGS = \ -I$(top_builddir) \ @@ -41,8 +42,8 @@ -I$(top_srcdir)/src/libicalss \ $(PY_CFLAGS) -_LibicalWrap.c: LibicalWrap.i - swig -python -o _LibicalWrap.c LibicalWrap.i +_LibicalWrap.c: LibicalWrap.i $(top_srcdir)/src/libical/ical.h $(top_srcdir)/src/libicalss/icalss.h + swig -python -Wall $(AM_CPPFLAGS) -o _LibicalWrap.c LibicalWrap.i CLEANFILES = _LibicalWrap.c _LibicalWrap_wrap.doc Libical.pyc _LibicalWrap.so Index: src/python/Period.py =================================================================== --- src/python/Period.py (revision 999) +++ src/python/Period.py (working copy) @@ -76,13 +76,13 @@ raise Property.ConstructorFailedError("Failed to construct Period") def _end_is_duration(self): - dur = icalperiodtype_duration_get(self.pt) + dur = self.pt.duration if not icaldurationtype_is_null_duration(dur): return 1 return 0 def _end_is_time(self): - end = icalperiodtype_end_get(self.pt) + end = self.pt.end if not icaltime_is_null_time(end): return 1 return 0 @@ -112,12 +112,12 @@ else: raise TypeError - icalperiodtype_start_set(self.pt,t.tt) + self.pt.start = t.tt self._update_value() - return Time(icaltime_as_timet(icalperiodtype_start_get(self.pt)), + return Time(icaltime_as_timet(self.pt.start), "DTSTART") def end(self,v=None): @@ -139,23 +139,22 @@ raise TypeError if(self._end_is_duration()): - start = icaltime_as_timet(icalperiodtype_start_get(self.pt)) + start = icaltime_as_timet(self.pt.start) dur = t.utc_seconds()-start; - icalperiodtype_duration_set(self.pt, - icaldurationtype_from_int(dur)) + self.pt.duration = icaldurationtype_from_int(dur) else: - icalperiodtype_end_set(self.pt,t.tt) + self.pt.end = t.tt self._update_value() if(self._end_is_time()): - rt = Time(icaltime_as_timet(icalperiodtype_end_get(self.pt)), + rt = Time(icaltime_as_timet(self.pt.end), 'DTEND') rt.timezone(self.timezone()) return rt elif(self._end_is_duration()): - start = icaltime_as_timet(icalperiodtype_start_get(self.pt)) - dur = icaldurationtype_as_int(icalperiodtype_duration_get(self.pt)) + start = icaltime_as_timet(self.pt.start) + dur = icaldurationtype_as_int(self.pt.duration) rt = Time(start+dur,'DTEND') rt.timezone(self.timezone()) return rt @@ -183,24 +182,23 @@ raise TypeError if(self._end_is_time()): - start = icaltime_as_timet(icalperiodtype_start_get(self.pt)) + start = icaltime_as_timet(self.pt.start) end = start + d.seconds() - icalperiodtype_end_set(self.pt,icaltime_from_timet(end,0)) + self.pt.end = icaltime_from_timet(end,0) else: - icalperiodtype_duration_set(self.pt,d.dur) + self.pt.duration = d.dur if(self._end_is_time()): - start =icaltime_as_timet(icalperiodtype_start_get(self.pt)) - end = icaltime_as_timet(icalperiodtype_end_get(self.pt)) + start =icaltime_as_timet(self.pt.start) + end = icaltime_as_timet(self.pt.end) print "End is time " + str(end-start) return Duration(end-start,"DURATION") elif(self._end_is_duration()): - dur = icaldurationtype_as_int( - icalperiodtype_duration_get(self.pt)) + dur = icaldurationtype_as_int(self.pt.duration) return Duration(dur,"DURATION") else: Index: src/python/Property.py =================================================================== --- src/python/Property.py (revision 999) +++ src/python/Property.py (working copy) @@ -54,7 +54,7 @@ return None -class Property: +class Property(object): """ Represent any iCalendar Property. Usage: @@ -75,8 +75,8 @@ def __init__(self, type = None, ref = None): - assert(ref == None or isinstance(ref,StringType)) - assert(type == None or isinstance(type,StringType)) + #~ assert(ref == None or isinstance(ref,StringType)) + #~ assert(type == None or isinstance(type,StringType)) self._ref = None @@ -87,14 +87,13 @@ self._ref = icalproperty_new(kind) if type.find("X-") == 0: - icalproperty_set_x_name(self._ref, type) + icalproperty_set_x_name(self._ref, type) if self._ref == None or self._ref == 'NULL': raise Property.ConstructorFailedError("Failed to construct Property") self._deleted = 0; - # Initialize all of the required keys @@ -110,7 +109,7 @@ def name(self,v=None): """ Return the name of the property """ - return icalproperty_get_name(self._ref) + return icalproperty_get_property_name(self._ref) def ref(self,v=None): """ Return the internal reference to the libical icalproperty """ @@ -133,7 +132,9 @@ if kind != None: # Get the default kind of value for this property - default_kind = icalvalue_kind_to_string(icalproperty_kind_to_value_kind(icalproperty_string_to_kind(self.name()))) + default_kind = icalvalue_kind_to_string( + icalproperty_kind_to_value_kind( + icalproperty_string_to_kind(self.name()))) if(kind != default_kind): self.__setitem__('VALUE',kind) @@ -148,9 +149,8 @@ icalerror_clear_errno() #e1=icalerror_supress("MALFORMEDDATA") - if (self.name().find("X-") == 0) and type(v) is StringType: - v = icallangbind_quote_as_ical(v) - v = icallangbind_quote_as_ical(v) + if (self.name() == None or self.name().find("X-") == 0) and type(v) is StringType: + v = icallangbind_quote_as_ical(v) icalproperty_set_value_from_string(self._ref,str(v),vt) #icalerror_restore("MALFORMEDDATA",e1) Index: src/libicalss/icalfileset.h =================================================================== --- src/libicalss/icalfileset.h (revision 999) +++ src/libicalss/icalfileset.h (working copy) @@ -41,8 +41,6 @@ #define mode_t int #endif -extern int icalfileset_safe_saves; - typedef struct icalfileset_impl icalfileset; icalset* icalfileset_new(const char* path); Index: doc/UsingLibical.txt =================================================================== --- doc/UsingLibical.txt (revision 999) +++ doc/UsingLibical.txt (working copy) @@ -151,7 +151,7 @@ 3.1.4 Parameters -Parameters are represetned in a similar way to properties, except that +Parameters are represented in a similar way to properties, except that they contain only one value 3.2 Other elements of libical @@ -161,7 +161,7 @@ 3.2.1 Enumerations and types -Libical is strongly typed, soo every component, property, parameter, +Libical is strongly typed, so every component, property, parameter, and value type has an enumeration, and some have an associated structure or union. @@ -180,7 +180,7 @@ Since many of libicals interfaces return strings, the library has its own memory management system to elimiate the need to free every string -returned from the libraru. +returned from the library. 3.2.5 Storage classes @@ -290,7 +290,7 @@ icalcomponent_add_property(event, prop); -prop = icalproperty_new_uid(''guid-1.host1.com'') ); +prop = icalproperty_new_uid(''guid-1.host1.com''); icalcomponent_add_property(event,prop);