/* This module provides some helper APIs for creating a VCalendar object. Note on APIs: 1. The APIs does not attempt to verify if the arguments passed are correct. 2. Where the argument to an API is not applicable, pass the value 0. 3. See the test program at the bottom of this file as an example of usage. 4. This code calls APIs in vobject.c. */ /*************************************************************************** (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. For purposes of this license notice, the term Licensors shall mean, collectively, Apple Computer, Inc., AT&T Corp., International Business Machines Corporation and Siemens Rolm Communications Inc. The term Licensor shall mean any of the Licensors. Subject to acceptance of the following conditions, permission is hereby granted by Licensors without the need for written agreement and without license or royalty fees, to use, copy, modify and distribute this software for any purpose. The above copyright notice and the following four paragraphs must be reproduced in all copies of this software and any software including this software. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS. IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. The software is provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the government are subject to restrictions set forth in DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. ***************************************************************************/ #include #include #include "vcaltmp.h" DLLEXPORT(VObject*) vcsCreateVCal( char *date_created, char *location, char *product_id, char *time_zone, char *version ) { VObject *vcal = newVObject(VCCalProp); #define Z(p,v) if (v) addPropValue(vcal,p,v); Z(VCDCreatedProp, date_created); Z(VCLocationProp, location) Z(VCProdIdProp, product_id) Z(VCTimeZoneProp, time_zone) Z(VCVersionProp, version) #undef Z return vcal; } DLLEXPORT(VObject*) vcsAddEvent( VObject *vcal, char *start_date_time, char *end_date_time, char *description, char *summary, char *categories, char *classification, char *status, char *transparency, char *uid, char *url ) { VObject *vevent = addProp(vcal,VCEventProp); #define Z(p,v) if (v) addPropValue(vevent,p,v); Z(VCDTstartProp,start_date_time); Z(VCDTendProp,end_date_time); if (description) { VObject *p = addPropValue(vevent,VCDescriptionProp,description); if (strchr(description,'\n')) addProp(p,VCQuotedPrintableProp); } Z(VCSummaryProp,summary); Z(VCCategoriesProp,categories); Z(VCClassProp,classification); Z(VCStatusProp,status); Z(VCTranspProp,transparency); Z(VCUniqueStringProp,uid); Z(VCURLProp,url); #undef Z return vevent; } DLLEXPORT(VObject*) vcsAddTodo( VObject *vcal, char *start_date_time, char *due_date_time, char *date_time_complete, char *description, char *summary, char *priority, char *classification, char *status, char *uid, char *url ) { VObject *vtodo = addProp(vcal,VCTodoProp); #define Z(p,v) if (v) addPropValue(vtodo,p,v); Z(VCDTstartProp,start_date_time); Z(VCDueProp,due_date_time); Z(VCCompletedProp,date_time_complete); if (description) { VObject *p = addPropValue(vtodo,VCDescriptionProp,description); if (strchr(description,'\n')) addProp(p,VCQuotedPrintableProp); } Z(VCSummaryProp,summary); Z(VCPriorityProp,priority); Z(VCClassProp,classification); Z(VCStatusProp,status); Z(VCUniqueStringProp,uid); Z(VCURLProp,url); #undef Z return vtodo; } DLLEXPORT(VObject*) vcsAddAAlarm( VObject *vevent, char *run_time, char *snooze_time, char *repeat_count, char *audio_content ) { VObject *aalarm= addProp(vevent,VCAAlarmProp); #define Z(p,v) if (v) addPropValue(aalarm,p,v); Z(VCRunTimeProp,run_time); Z(VCSnoozeTimeProp,snooze_time); Z(VCRepeatCountProp,repeat_count); Z(VCAudioContentProp,audio_content); #undef Z return aalarm; } DLLEXPORT(VObject*) vcsAddMAlarm( VObject *vevent, char *run_time, char *snooze_time, char *repeat_count, char *email_address, char *note ) { VObject *malarm= addProp(vevent,VCMAlarmProp); #define Z(p,v) if (v) addPropValue(malarm,p,v); Z(VCRunTimeProp,run_time); Z(VCSnoozeTimeProp,snooze_time); Z(VCRepeatCountProp,repeat_count); Z(VCEmailAddressProp,email_address); Z(VCNoteProp,note); #undef Z return malarm; } DLLEXPORT(VObject*) vcsAddDAlarm( VObject *vevent, char *run_time, char *snooze_time, char *repeat_count, char *display_string ) { VObject *dalarm= addProp(vevent,VCDAlarmProp); #define Z(p,v) if (v) addPropValue(dalarm,p,v); Z(VCRunTimeProp,run_time); Z(VCSnoozeTimeProp,snooze_time); Z(VCRepeatCountProp,repeat_count); Z(VCDisplayStringProp,display_string); #undef Z return dalarm; } DLLEXPORT(VObject*) vcsAddPAlarm( VObject *vevent, char *run_time, char *snooze_time, char *repeat_count, char *procedure_name ) { VObject *palarm= addProp(vevent,VCPAlarmProp); #define Z(p,v) if (v) addPropValue(palarm,p,v); Z(VCRunTimeProp,run_time); Z(VCSnoozeTimeProp,snooze_time); Z(VCRepeatCountProp,repeat_count); Z(VCProcedureNameProp,procedure_name); #undef Z return palarm; } #ifdef _TEST #if 0 This testcase would generate a file call "frankcal.vcf" with the following content: BEGIN:VCALENDAR DCREATED:19960523T100522 GEO:37.24,-17.87 PRODID:-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN VERSION:0.3 BEGIN:VEVENT DTSTART:19960523T120000 DTEND:19960523T130000 DESCRIPTION;QUOTED-PRINTABLE:VERSIT PDI PR Teleconference/Interview =0A= With Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar=0A= activities with European Press representatives. SUMMARY:VERSIT PDI PR Teleconference/Interview CATEGORIES:PHONE CALL STATUS:CONFIRMED TRANSP:19960523T100522-4000F100582713-009251 UID:http://www.ibm.com/raleigh/fdawson/~c:\or2\orgfiles\versit.or2 DALARM:19960523T114500;5;3;Your Telecon Starts At Noon!!!; MALARM:19960522T120000;;;fdawson@raleigh.ibm.com;Remember 05/23 Noon Telecon!!!; PALARM:19960523T115500;;;c:\or2\organize.exe c:\or2\orgfiles\versit.or2; X-LDC-OR2-OLE:c:\temp\agenda.doc END:VEVENT BEGIN:VTODO DUE:19960614T0173000 DESCRIPTION:Review VCalendar helper API. END:VTODO END:VCALENDAR #endif void testVcalAPIs() { FILE *fp; VObject *vcal = vcsCreateVCal( "19960523T100522", "37.24,-17.87", "-//Frank Dawson/Hand Crafted In North Carolina//NONSGML Made By Hand//EN", 0, "0.3" ); VObject *vevent = vcsAddEvent( vcal, "19960523T120000", "19960523T130000", "VERSIT PDI PR Teleconference/Interview \nWith Tom Streeter and Frank Dawson - Discuss VERSIT PDI project and vCard and vCalendar\nactivities with European Press representatives.", "VERSIT PDI PR Teleconference/Interview", "PHONE CALL", 0, "CONFIRMED", "19960523T100522-4000F100582713-009251", "http://www.ibm.com/raleigh/fdawson/~c:\\or2\\orgfiles\\versit.or2", 0 ); vcsAddDAlarm(vevent, "19960523T114500", "5", "3", "Your Telecon Starts At Noon!!!"); vcsAddMAlarm(vevent, "19960522T120000", 0, 0, "fdawson@raleigh.ibm.com", "Remember 05/23 Noon Telecon!!!"); vcsAddPAlarm(vevent, "19960523T115500", 0 ,0, "c:\\or2\\organize.exe c:\\or2\\orgfiles\\versit.or2"); addPropValue(vevent, "X-LDC-OR2-OLE", "c:\\temp\\agenda.doc"); vcsAddTodo( vcal, 0, "19960614T0173000", 0, "Review VCalendar helper API.", 0, 0, 0, 0, 0, 0 ); /* now do something to the resulting VObject */ /* pretty print on stdout for fun */ printVObject(vcal); /* open the output text file */ #define OUTFILE "frankcal.vcf" fp = fopen(OUTFILE, "w"); if (fp) { /* write it in text form */ writeVObject(fp,vcal); fclose(fp); } else { printf("open output file '%s' failed\n", OUTFILE); } } void main() { testVcalAPIs(); } #endif /* end of source file vcaltmp.c */ -0/+47 * - update to 1.4.1dinoex2010-03-281-2/+2 * Make work with -current's utmpx changes.cracauer2010-02-171-0/+34 * - update to jpeg-8dinoex2010-02-051-2/+2 * Assign LATEST_LINK to apropriate directory names for ports:bsam2009-12-231-0/+2 * . backout previous commit (revert editors/emacs to version 22.3)bsam2009-09-0813-1132/+351 * Updat GNU Emacs to v. 23.1.bsam2009-09-0813-350/+1132 * - update to jpeg7dinoex2009-07-181-1/+2 * - Do not explicitly set LATEST_LINK to the default value. Slave ports need topav2008-11-141-2/+0 * . update to version 22.3 (includes a security fix in the way Emacsbsam2008-11-117-35/+45 * Update CONFIGURE_ARGS for how we pass CONFIGURE_TARGET to configure script.rafan2008-08-211-1/+0 * Bump portrevision due to upgrade of devel/gettext.edwin2008-06-061-1/+1 * - Update editors/emacs to 22.2.bsam2008-06-035-623/+25 * As pointed out by mjl @ #bsdports: The patch I commited was a patchedwin2008-05-153-15/+11 * [patch] editors/emacs build on armedwin2008-05-122-1/+15 * - Remove unneeded dependency from gtk12/gtk20 [1]miwi2008-04-201-3/+3 * Port the gmalloc.c allocator from the CVS trunk of Emacs.keramida2007-10-092-1/+607 * - Kill packaged info files, they are splitted. We need to generate our own,pav2007-09-271-0/+4 * - Remove --mandir and --infodir from CONFIGURE_ARGS. They are now defaultrafan2007-07-241-2/+0 * Update to 22.1.nobutaka2007-07-1726-2358/+2769 * - Welcome X.org 7.2 \o/.flz2007-05-201-1/+1 * Add emacs-22.* to CONFLICTS.nobutaka2007-05-041-1/+1 * Change PATCH_SITES.nobutaka2006-11-121-1/+1 * SHA256ify (manually updated and checked)edwin2006-01-221-0/+3 * Remove emacs20 from CONFLICTS.nobutaka2005-12-181-1/+1 * - Add .info suffix to filename of info files.nobutaka2005-12-093-81/+27 * Mass-conversion to the USE_AUTOTOOLS New World Order. The code presentade2005-11-151-1/+1 * Fix build error.nobutaka2005-09-052-1/+43 * Add powerpc support.nobutaka2005-07-161-3/+4 * Disable optimization on ia64 to avoid elisp processing errors.nobutaka2005-05-151-2/+2 * Bump PORTREVISION to reflect changes in rev. 1.59 in package building.nobutaka2005-05-071-1/+1 * Add CONFLICTS variable, since this port conflicts with otherjylefort2005-05-061-0/+4 * Replace -O(2|3|s) CFLAGS with -O on ia64 for a workaround to fix elisp proces...nobutaka2005-05-061-1/+8 * At Kris's request, back out the MACHINE_ARCH spelling correction untilobrien2005-04-121-1/+1 * Assist getting more ports working on AMD64 by obeying theobrien2005-04-111-1/+1 * Fix problems with AltGr-Modifier on several keyboards.nobutaka2005-03-022-1/+12 * Fix format string vulnerability in the movemail utility.nobutaka2005-02-142-1/+12 * farewell to libxpg4.sf2004-11-151-8/+0 * Fix runtime breakage on ia64, which was introduced with binutils 2.15.marcel2004-09-061-1/+9 * Enable interruption with C-g key while opening network connection.nobutaka2004-05-242-33/+14 * Add SIZE to distinfo.nobutaka2004-03-251-0/+3 * Move the ancient emacs 19.x port from editors/emacs tokris2004-03-2131-2275/+2391 * BROKEN on !i386 5.x: Does not compilekris2004-02-251-1/+7 * Bump PORTREVISION on all ports that depend on gettext to aid with upgrading.marcus2004-02-041-0/+1 * SIZEify.trevor2004-01-291-0/+1