diff options
author | Hans Petter <hansp@src.gnome.org> | 2003-09-12 06:04:44 +0800 |
---|---|---|
committer | Hans Petter <hansp@src.gnome.org> | 2003-09-12 06:04:44 +0800 |
commit | 697761cc337aa77a47140c8df50ed84bc25e23f6 (patch) | |
tree | b785830f72e9938cceaa016a419c7b6d9892bada /libical/examples | |
parent | 733d77e657516f9a59b5c1a7b62acb87b03ec86f (diff) | |
download | gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.gz gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.bz2 gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.lz gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.xz gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.tar.zst gsoc2013-evolution-697761cc337aa77a47140c8df50ed84bc25e23f6.zip |
Import new libical from mainline HEAD and make appropriate changes to
Evolution.
svn path=/trunk/; revision=22538
Diffstat (limited to 'libical/examples')
-rw-r--r-- | libical/examples/.cvsignore | 7 | ||||
-rw-r--r-- | libical/examples/Makefile.am | 11 | ||||
-rw-r--r-- | libical/examples/access-usecases.txt | 60 | ||||
-rw-r--r-- | libical/examples/access_components.c | 5 | ||||
-rw-r--r-- | libical/examples/access_store.c | 210 | ||||
-rw-r--r-- | libical/examples/changenames.pl | 4 | ||||
-rw-r--r-- | libical/examples/usecases.c | 89 |
7 files changed, 377 insertions, 9 deletions
diff --git a/libical/examples/.cvsignore b/libical/examples/.cvsignore index 29ef3ef4c8..14459733c2 100644 --- a/libical/examples/.cvsignore +++ b/libical/examples/.cvsignore @@ -1,5 +1,6 @@ -.libs -.deps Makefile -Makefile.in +.deps +.libs +*.lo +*.la doesnothing diff --git a/libical/examples/Makefile.am b/libical/examples/Makefile.am index 99e33d3400..ea8dc02c3d 100644 --- a/libical/examples/Makefile.am +++ b/libical/examples/Makefile.am @@ -1,10 +1,15 @@ noinst_PROGRAMS = doesnothing -LDADD = ../src/libical/libical.a ../src/libicalss/libicalss.la ../src/libicalvcal/libicalvcal.la -INCLUDES = -I . -I../src/libical -I$(srcdir)/../src/libical -I../src/libicalss -I../src/libicalvcal +if WITH_BDB4 +doesnothing_LDADD = ../src/libical/libical.la ../src/libicalss/libicalss.la ../src/libicalvcal/libicalvcal.la @BDB_DIR_LIB@/@BDB_LIB@ +else +doesnothing_LDADD = ../src/libical/libical.la ../src/libicalss/libicalss.la ../src/libicalvcal/libicalvcal.la +endif -INCLUDES = -I. -I../src/libical -I$(srcdir)/../src/libical -I../src/libicalss -I../src/libicalvcal +LIBS = @PTHREAD_LIBS@ + +INCLUDES = -I. -I../src/libical -I$(srcdir)/../src/libical -I../src/libicalss -I../src/libicalvcal doesnothing_SOURCES = \ access_components.c \ diff --git a/libical/examples/access-usecases.txt b/libical/examples/access-usecases.txt new file mode 100644 index 0000000000..9bcb7544c3 --- /dev/null +++ b/libical/examples/access-usecases.txt @@ -0,0 +1,60 @@ + + +Usecases +--------- + +1) iMIP based CUA uses a local, file-based store + +2) CAP based CUA uses one or more remote CAP servers + +3) CAP based CUA uses a local cache that synchronizes with one or more +CAP servers. + +4) CUA imports and exports from a file + +Scenarios. +--------- + +1 Open a connection to a store. + +2 Create a new calendar for which user Bob can read and user Alice can +read an write. + +3 Create several new calendars + +4 Delete a calendar + +5 Change the calid of a calendar + +6 Delete all calendars belonging to user bob + +7 Get three new UIDs from the store + +8 Store a new VEVENT in the store. + +9 Find all components for which the LOCATION is "West Conference Room" +and change them to "East Conference Room" + +10 Find the component with UID X and add a GEO property to it. + +11 Delete all VEVENTS which have a METHOD that is not CREATED + +12 Retrieve all VEVENTS which have a METHOD that is not CREATED + +13 Retrieve the capabilities of the store + +14 Retrieve/Modify/Add/Delete properties of a store + +15 Retrieve/Modify/Add/Delete VCARs of a store + +16 Retrieve/Modify/Add/Delete VTIMEZONEs of a store + +17 Retrieve/Modify/Add/Delete properties of a calendar + +18 Retrieve/Modify/Add/Delete VCARs of a calendar + +19 Retrieve/Modify/Add/Delete VTIMEZONEs of a calendar + +20 Translate a CALID into one or more UPNs + +21 Expand a group UPN into all of the members of the group
\ No newline at end of file diff --git a/libical/examples/access_components.c b/libical/examples/access_components.c index cc5a33d6d2..dc92b64a7c 100644 --- a/libical/examples/access_components.c +++ b/libical/examples/access_components.c @@ -7,7 +7,6 @@ #include <stdlib.h> /* for malloc */ #include <stdio.h> /* for printf */ #include <time.h> /* for time() */ -#include "icalmemory.h" void do_something(icalcomponent *c); @@ -154,7 +153,7 @@ icalcomponent* create_new_component() icalcomponent_add_property( event, - icalproperty_new_class("PUBLIC") + icalproperty_new_class(ICAL_CLASS_PUBLIC) ); icalcomponent_add_property( @@ -242,7 +241,7 @@ icalcomponent* create_new_component_with_va_args() icalproperty_new_description("Project XYZ Review Meeting"), icalproperty_new_categories("MEETING"), - icalproperty_new_class("PUBLIC"), + icalproperty_new_class(ICAL_CLASS_PUBLIC), icalproperty_new_created(atime), icalproperty_new_summary("XYZ Project Review"), icalproperty_vanew_dtstart( diff --git a/libical/examples/access_store.c b/libical/examples/access_store.c new file mode 100644 index 0000000000..fc2f5b01e2 --- /dev/null +++ b/libical/examples/access_store.c @@ -0,0 +1,210 @@ + + +void acess_cap(void) { + + /* Note, all routines that are prefixed with "caller_" are + implemented by the caller of libical */ + +/* 1 Open a connection to a store. */ + + /* The caller is responsible for getting a socket to the server + and negotiating the first stages of the CAP exchange. These can + be fairly complex and varied for different operating systems, + local vs remote usage, and for different authentication + schemes, so the API does not try to simplify them. */ + + int sock = caller_create_socket_to_server(); + icalcstp *cstp = icalcstp_new(0,sock,sock); + + caller_authenticate(cstp); + + icalcsdb *csdb = icalcsdb_new(cstp); + +/* 2 Create a new calendar for which user Bill can read and user Mary can +read and write. See CAP draft 7.2.1.1.1. for the text of this example*/ + + /* This case requires setting up a TARGET, multiple OWNERs and + multiple VCARs, so it creates a component and uses CSTP that + than the CSDB interface. + + icalcomponent *create = icalcaputil_new_create(); + + icalcomponent_add_property(create, + icalproperty_new_target( + strdup("cap://cal.example.com/relcal8") + )); + + icalcomponent *cal = + icalcomponent_vanew_vcalendar( + icalproperty_new_relcalid(strdup("relcalid")), + icalproperty_new_name(strdup("Bill & Mary's cal")), + icalproperty_new_owner(strdup("bill")), + icalproperty_new_owner(strdup("mary")), + icalproperty_new_calmaster(strdup("mailto:bill@example.com")), + icalcomponent_vanew_vcar( + icalproperty_new_grant(strdup("UPN=bill;ACTION=*;OBJECT=*")), + icalproperty_new_grant(strdup("UPN=bill;ACTION=*;OBJECT=*")) + 0) + 0); + + error = icalcomponent_add_component(create,cal); + + /* Send the data */ + error = icalcstp_senddata(cstp,10,create); + + + /* Get the response */ + icalcstp_response response = icalcstp_get_first_response(cstp); + + /* Do something with the response*/ + + if(icalenum_reqstat_major(response.code) != 2){ + /* do something with the error */ + } + + icalcomponent_free(create); + + +/* 3 Create several new calendars */ + + /* Same as #2, but insert more TARGET properties and read more responses*/ + +/* 4 Delete a calendar */ + + error = icalcsdb_delete(csdb,"uid12345-example.com"); + +/* 5 Change the calid of a calendar */ + + erorr = icalcsdb_move(csdb,"uid12345-old-example.com", + "uid12345-new-example.com"); + + +/* 6 Delete all calendars belonging to user bob */ + + icalproperty *p; + /* First expand bob's UPN into a set of CALIDs */ + icalcomponent *calids = icalcsdb_expand_upn("bob@example.com"); + + /* Then, create a message to delete all of them */ + icalcomponent *delete = icalcaputil_new_create(); + + + for(p = icalcomponent_get_first_property(calids,ICAL_CALID_PROPERTY); + p != 0; + p = icalcomponent_get_next_property(calids,ICAL_CALID_PROPERTY)){ + + char* = icalproperty_get_calid(p); + + icalcomponent_add_target(delete,p); + + } + + /* Send the message */ + + error = icalcstp_senddata(cstp,10,delete); + + /* Finally, read the responses */ + + for(response = icalcstp_get_first_response(cstp); + response.code != ICAL_UNKNOWN_STATUS; + response = icalcstp_get_next_response(cstp)){ + + if(icalenum_reqstat_major(response.code) != 2){ + /* do something with the error */ + } + } + + +/* 7 Get three new UIDs from the store */ + + /* libical owns the returned memory. Copy before using */ + char* uid1 = icalcsdb_generateuid(csdb); + char* uid2 = icalcsdb_generateuid(csdb); + char* uid3 = icalcsdb_generateuid(csdb); + +/* 8 Store a new VEVENT in the store. */ + + /* Very similar to case #2 */ + +/* 9 Find all components for which the LOCATION is "West Conference +Room" and change them to "East Conference Room" */ + + icalcomponent *modify = icalcaputil_new_modify(); + + icalcaputil_modify_add_old_prop(modify, + icalproperty_new_location( + strdup("West Conference Room"))); + + icalcaputil_modify_add_new_prop(modify, + icalproperty_new_location( + strdup("East Conference Room"))); + + icalcaputil_add_target(modify,"relcal2"); + + /* Send the component */ + error = icalcstp_senddata(cstp,10,delete); + + /* Get the response */ + icalcstp_response response = icalcstp_get_first_response(cstp); + + /* Do something with the response*/ + + if(icalenum_reqstat_major(response.code) != 2){ + /* do something with the error */ + } + + icalcomponent_free(modify); + +/* 10 Find the component with UID X and add a GEO property to it. */ + + + icalcomponent *modify = icalcaputil_new_modify(); + + icalcaputil_modify_add_query(modify, + "SELECT UID FROM VEVENT WHERE UID = 'X'"); + + icalcaputil_modify_add_new_prop(modify, + icalproperty_new_geo( + strdup("-117;32"))); + + icalcaputil_add_target(modify,"relcal2"); + + /* Send the component */ + error = icalcstp_senddata(cstp,10,delete); + + /* Get the response */ + icalcstp_response response = icalcstp_get_first_response(cstp); + + /* Do something with the response*/ + + if(icalenum_reqstat_major(response.code) != 2){ + /* do something with the error */ + } + + icalcomponent_free(modify); + + +/* 11 Delete all VEVENTS which have a METHOD that is not CREATED */ + + +/* 12 Retrieve all VEVENTS which have a METHOD that is not CREATED */ + + /* Nearly the same at #11 */ + +/* 13 Retrieve the capabilities of the store */ + +/* 14 Retrieve/Modify/Add/Delete properties of a store */ + +/* 15 Retrieve/Modify/Add/Delete VCARs of a store */ + +/* 16 Retrieve/Modify/Add/Delete VTIMEZONEs of a store */ + +/* 17 Retrieve/Modify/Add/Delete properties of a calendar */ + +/* 18 Retrieve/Modify/Add/Delete VCARs of a calendar */ + +/* 19 Retrieve/Modify/Add/Delete VTIMEZONEs of a calendar */ + +/* 20 Translate a CALID into one or more UPNs */ + +/* 21 Expand a group UPN into all of the members of the group */ diff --git a/libical/examples/changenames.pl b/libical/examples/changenames.pl new file mode 100644 index 0000000000..4adf84b9c0 --- /dev/null +++ b/libical/examples/changenames.pl @@ -0,0 +1,4 @@ +s/icalcluster/icalfileset/g; +s/ICALCLUSTER/ICALFILESET/g; +s/icalstore/icaldirset/g; +s/ICALSTORE/ICALDIRSET/g; diff --git a/libical/examples/usecases.c b/libical/examples/usecases.c new file mode 100644 index 0000000000..116be30a59 --- /dev/null +++ b/libical/examples/usecases.c @@ -0,0 +1,89 @@ +/* -*- Mode: C -*- + ====================================================================== + FILE: usecases.c + CREATOR: eric 03 April 1999 + + DESCRIPTION: + + $Id$ + $Locker$ + + (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 + The original code is usecases.c + + + ======================================================================*/ + +#include "ical.h" +#include <assert.h> +#include <string.h> /* for strdup */ +#include <stdlib.h> /* for malloc */ +#include <stdio.h> /* for printf */ +#include <time.h> /* for time() */ + +char str[] = "BEGIN:VCALENDAR\ +PRODID:\"-//RDU Software//NONSGML HandCal//EN\"\ +VERSION:2.0\ +BEGIN:VEVENT\ +DTSTAMP:19980309T231000Z\ +UID:guid-1.host1.com\ +ORGANIZER;ROLE=CHAIR:MAILTO:mrbig@host.com\ +ATTENDEE;RSVP=TRUE;ROLE=REQ-PARTICIPANT;CUTYPE=GROUP:MAILTO:employee-A@host.com\ +DESCRIPTION:Project XYZ Review Meeting\ +CATEGORIES:MEETING\ +CREATED:19980309T130000Z\ +SUMMARY:XYZ Project Review\ +DTSTART;TZID=US-Eastern:19980312T083000\ +DTEND;TZID=US-Eastern:19980312T093000\ +END:VEVENT\ +END:VCALENDAR"; + + + + +/* Here are some ways to work with values. */ +void test_values() +{ + icalvalue *v; + icalvalue *copy; + + v = icalvalue_new_caladdress("cap://value/1"); + printf("caladdress 1: %s\n",icalvalue_get_caladdress(v)); + + icalvalue_set_caladdress(v,"cap://value/2"); + printf("caladdress 2: %s\n",icalvalue_get_caladdress(v)); + printf("String: %s\n",icalvalue_as_ical_string(v)); + + copy = icalvalue_new_clone(v); + printf("Clone: %s\n",icalvalue_as_ical_string(v)); + icalvalue_free(v); + icalvalue_free(copy); + + +} + +void test_parameters() +{ + icalparameter *p; + + p = icalparameter_new_cn("A Common Name"); + + printf("Common Name: %s\n",icalparameter_get_cn(p)); + + printf("As String: %s\n",icalparameter_as_ical_string(p)); +} + + |